geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r580964 - in /geronimo/server/trunk/testsuite/web-testsuite/test-tomcat: pom.xml src/main/webapp/WEB-INF/geronimo-web.xml src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java
Date Mon, 01 Oct 2007 14:08:12 GMT
Author: gawor
Date: Mon Oct  1 07:08:11 2007
New Revision: 580964

URL: http://svn.apache.org/viewvc?rev=580964&view=rev
Log:
fix tomcat tests

Modified:
    geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/pom.xml
    geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/main/webapp/WEB-INF/geronimo-web.xml
    geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java

Modified: geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/pom.xml?rev=580964&r1=580963&r2=580964&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/pom.xml (original)
+++ geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/pom.xml Mon Oct  1 07:08:11
2007
@@ -56,11 +56,6 @@
             <id>child</id>
             <build>
                 <plugins>
-                   <plugin>
-                      <groupId>org.codehaus.mojo</groupId>
-                      <artifactId>selenium-maven-plugin</artifactId>
-                   </plugin>
-
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-surefire-plugin</artifactId>

Modified: geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/main/webapp/WEB-INF/geronimo-web.xml?rev=580964&r1=580963&r2=580964&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/main/webapp/WEB-INF/geronimo-web.xml
(original)
+++ geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/main/webapp/WEB-INF/geronimo-web.xml
Mon Oct  1 07:08:11 2007
@@ -17,6 +17,8 @@
 -->
 
 <!-- $Rev$ $Date$ -->
+
+
 <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2"
     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
     <sys:environment>
@@ -32,7 +34,7 @@
         <gbean-link>TomcatWebContainer</gbean-link>
     </web-container>
     <container-config>
-        <tomcat>
+        <tomcat xmlns="http://geronimo.apache.org/xml/ns/web/tomcat/config-1.0">
             <host>testhost.com</host>
             <valve-chain>FirstValve</valve-chain>
             <tomcat-realm>TomcatRealm</tomcat-realm>

Modified: geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java?rev=580964&r1=580963&r2=580964&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java
(original)
+++ geronimo/server/trunk/testsuite/web-testsuite/test-tomcat/src/test/java/org/apache/geronimo/testsuite/tomcat/TestTomcat.java
Mon Oct  1 07:08:11 2007
@@ -19,18 +19,74 @@
 
 package org.apache.geronimo.testsuite.tomcat;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
 
-import org.apache.geronimo.testsupport.SeleniumTestSupport;
+import org.apache.geronimo.testsupport.TestSupport;
 import org.testng.annotations.Test;
 
-public class TestTomcat extends SeleniumTestSupport
+public class TestTomcat extends TestSupport
 {
     @Test
-    public void testTomcat() throws Exception {
-        selenium.open("/testhost.com:8080/TomcatWeb/");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Testing Tomcat.", selenium.getText("xpath=/html/body"));
+    public void testTomcatHost() throws Exception {
+        URL url = new URL("http://localhost:8080/TomcatWeb/");
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+        try {
+            String reply = doGET(conn, "testhost.com");
+
+            assertEquals("responseCode", 200, conn.getResponseCode());
+
+            assertTrue( reply.indexOf("Testing Tomcat.") != -1 );
+        } finally {
+            conn.disconnect();
+        }
+    }
+
+    @Test
+    public void testTomcatNoHost() throws Exception {
+        URL url = new URL("http://localhost:8080/TomcatWeb/");
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+        try {
+            String reply = doGET(conn, null);
+
+            assertEquals("responseCode", 404, conn.getResponseCode());
+        } finally {
+            conn.disconnect();
+        }
     }
 
+    private String doGET(HttpURLConnection conn, String host) throws IOException { 
+        conn.setConnectTimeout(1000 * 30);
+        conn.setReadTimeout(1000 * 30);
+        conn.setDoOutput(true);
+        conn.setUseCaches(false);
+        if (host != null) {
+            conn.setRequestProperty("Host", host);
+        }
+
+        InputStream is = null;
+        
+        try {
+            is = conn.getInputStream();
+        } catch (IOException e) {
+            is = conn.getErrorStream();
+        }
+        
+        StringBuffer buf = new StringBuffer();
+        BufferedReader in = new BufferedReader(new InputStreamReader(is));
+        String inputLine;
+        while ((inputLine = in.readLine()) != null) {
+            System.out.println(inputLine);
+            buf.append(inputLine);
+        }
+        in.close();
+        
+        return buf.toString();
+    }
 
-}
\ No newline at end of file
+}



Mime
View raw message