[embjopr-commits] EMBJOPR SVN: r492 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war.
embjopr-commits at lists.jboss.org
embjopr-commits at lists.jboss.org
Wed Jun 3 10:24:43 EDT 2009
Author: ozizka at redhat.com
Date: 2009-06-03 10:24:43 -0400 (Wed, 03 Jun 2009)
New Revision: 492
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
Log:
WAR tests updated.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-06-02 17:27:52 UTC (rev 491)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-06-03 14:24:43 UTC (rev 492)
@@ -26,15 +26,25 @@
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebRequestSettings;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
import org.jboss.jopr.jsfunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import java.io.*;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.URL;
import java.util.Properties;
import javax.faces.application.FacesMessage;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.SimpleHttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
@@ -127,6 +137,10 @@
final String DEPLOYABLE_NAME = WAR_VIRTUAL_HOSTS;
+ final String VHOST_1 = "snert.home.pilhuhn.de";
+ final String VHOST_2 = "snert.home.bsd.de";
+
+
String filePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
try {
@@ -139,13 +153,53 @@
ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES);
+
+
+ /*
// Use HtmlUnit to test the newly deployed war in a new WebClient session.
-
+ // Commented out - localhost is not in the list of virtual hosts, thus the web app is not accessible there.
int port = ejtt.getEmbJoprPort();
WebClient webClient = new WebClient();
+ //webClient.addRequestHeader("Host", VHOST_1);
HtmlPage page = (HtmlPage)webClient.getPage("http://localhost:" + port + "/test/index.jsp");
assertTrue(page.asText().contains("HELLO WORLD"));
+ /**/
+
+ /*
+ // Get IP Address
+ InetAddress addr = InetAddress.getLocalHost();
+ byte[] ip = addr.getAddress();
+ String host = String.format("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ //HttpConnection hc = new HttpConnection( host, ejtt.getEmbJoprPort() );
+ HttpConnection hc = new HttpConnection( host, VHOST_1, ejtt.getEmbJoprPort(), Protocol.getProtocol("http") );
+ hc.open();
+ // Lack of Commons HttpClient documentation.
+ /**/
+
+ Socket socket = new Socket(InetAddress.getLocalHost(), ejtt.getEmbJoprPort());
+ socket.getOutputStream().write( ("GET /test/index.jsp HTTP/1.1\nHost: "+VHOST_1+"\n\n").getBytes() );
+
+ BufferedInputStream inputStream = new BufferedInputStream(socket.getInputStream());
+ StringBuilder sb = new StringBuilder(4096);
+
+ int read;
+ byte data[] = new byte[4096];
+ do {
+ read = inputStream.read(data);
+ if( -1 == read )
+ break;
+ sb.append( new String(data) );
+ }while( true );
+
+ String responseText = sb.toString();
+ log.debug("Vhost test web app response:\n"+responseText);
+ assertTrue( responseText.contains("HELLO WORLD") );
+
+
+
+
+
// Check that the virtual hosts are listed in EmbJopr.
// Expand the VHosts node and click it.
@@ -154,9 +208,6 @@
ejtt.navTree.getNodeByLabel(NAV_VIRTUAL_HOSTS).getLabelLink().click();
- final String VHOST_1 = "snert.home.pilhuhn.de";
- final String VHOST_2 = "snert.home.bsd.de";
-
// Check that vhosts from the WARare listed.
ContentTableRow row = ejtt.tabMenu.getTabContentBox().
getDefaultTable().getFirstRowContainingLink(VHOST_1);
More information about the embjopr-commits
mailing list