tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r618789 - in /incubator/tuscany/java/sca: itest/pom.xml tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java
Date Tue, 05 Feb 2008 21:51:50 GMT
Author: rfeng
Date: Tue Feb  5 13:51:47 2008
New Revision: 618789

URL: http://svn.apache.org/viewvc?rev=618789&view=rev
Log:
Enable Jetty web unit test

Modified:
    incubator/tuscany/java/sca/itest/pom.xml
    incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java

Modified: incubator/tuscany/java/sca/itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/pom.xml?rev=618789&r1=618788&r2=618789&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/pom.xml Tue Feb  5 13:51:47 2008
@@ -212,6 +212,30 @@
             <build>
                 <plugins>
                     <plugin>
+                        <groupId>org.apache.tuscany.sca</groupId>
+                        <artifactId>tuscany-maven-web-junit</artifactId>
+                        <version>1.2-incubating-SNAPSHOT</version>
+                        <executions>
+                            <execution>
+                                <id>generate-web-xml</id>
+                                <phase>process-resources</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>web-junit-test</id>
+                                <configuration>
+                                    <url>${http.base}/${project.build.finalName}/junit</url>
+                                </configuration>
+                                <phase>integration-test</phase>
+                                <goals>
+                                    <goal>test</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
                         <groupId>org.codehaus.cargo</groupId>
                         <artifactId>cargo-maven2-plugin</artifactId>
                         <executions>

Modified: incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java?rev=618789&r1=618788&r2=618789&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java
(original)
+++ incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java
Tue Feb  5 13:51:47 2008
@@ -26,6 +26,7 @@
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.DefaultHttpClient;
@@ -66,13 +67,7 @@
      * Timeout for the http connection
      * @parameter
      */
-    private int timeout = 60000; // 1 minute
-
-    /**
-     * Maximum number of retries
-     * @parameter
-     */
-    private int maxRetries = 3;
+    private int timeout = 300000; // 5 minutes
 
     public void execute() throws MojoExecutionException {
         if (project.getPackaging().equals("pom")) {
@@ -85,6 +80,20 @@
             url = "http://localhost:8080/" + project.getBuild().getFinalName() + "/junit";
         }
 
+        if (testCases != null) {
+            StringBuffer buf = new StringBuffer(url);
+            for (int i = 0; i < testCases.length; i++) {
+                if (i == 0) {
+                    buf.append('?');
+                }
+                buf.append(testCases[i]);
+                if (i != testCases.length - 1) {
+                    buf.append(',');
+                }
+            }
+            url = buf.toString();
+        }
+
         getLog().info("Connecting to " + url);
 
         int runs = 0, errors = 0, failures = 0;
@@ -93,9 +102,14 @@
         try {
             HttpClient client = new DefaultHttpClient();
             HttpGet httpget = new HttpGet(url);
+            httpget.getParams().setParameter("http.socket.timeout", new Integer(timeout));
 
             // Execute HTTP request
             HttpResponse response = client.execute(httpget);
+
+            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
+                throw new MojoExecutionException(response.getStatusLine().getReasonPhrase());
+            }
             Header header = response.getFirstHeader("junit.errors");
             errors = header == null ? 0 : Integer.parseInt(header.getValue());
             header = response.getFirstHeader("junit.failures");



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message