abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r429892 - in /incubator/abdera/java/trunk: build/build.xml client/src/test/java/org/apache/abdera/test/client/TestSuite.java client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java
Date Tue, 08 Aug 2006 23:59:00 GMT
Author: rooneg
Date: Tue Aug  8 16:59:00 2006
New Revision: 429892

URL: http://svn.apache.org/viewvc?rev=429892&view=rev
Log:
Add the client tests to the "test" target in our ant build.  This is a
pretty ugly hack, so if someone more adept with JUnit has a better way to
shut Jetty down when it's done it'd be great.  This is also slower than
I'd like it to be, mainly because Jetty appears to have this irritating
"hey, lets sleep for a while while the threads stop" behavior that isn't
avoidable as far as I can tell.  Alternate solutions ot this problem are
also welcome ;-)

* build/build.xml: Add the client test suite to the tests.

* client/src/test/java/org/apache/abdera/test/client/TestSuite.java: New file.

* client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java
  (NUM_TESTS, testsRun): New static fields.
  (static): Put server initialization here.
  (setUp): Removed.
  (tearDown): If we're the last test run, shut down the server so we don't
   hang at shutdown.

Added:
    incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/TestSuite.java
Modified:
    incubator/abdera/java/trunk/build/build.xml
    incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=429892&r1=429891&r2=429892&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Tue Aug  8 16:59:00 2006
@@ -314,6 +314,12 @@
           classname="org.apache.abdera.test.parser.stax.TestSuite"
           fork="yes" />
 
+    <echo>Running Client Tests...</echo>
+    <java classpathref="jar.dependencies"
+          classpath="${core.work}:${parser.work}:${server.work}:${client.work}:${test}"
+          classname="org.apache.abdera.test.client.TestSuite"
+          fork="yes" />
+
     <echo>Running Extension Tests...</echo>
     <java classpathref="jar.dependencies"
           classpath="${core.work}:${parser.work}:${server.work}:${extensions.work}:${test}"

Added: incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/TestSuite.java?rev=429892&view=auto
==============================================================================
--- incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/TestSuite.java
(added)
+++ incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/TestSuite.java
Tue Aug  8 16:59:00 2006
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.client;
+
+import org.apache.abdera.test.client.cache.*;
+
+public class TestSuite extends junit.framework.TestSuite {
+  public static void main(String[] args)
+  {
+    junit.textui.TestRunner.run(new TestSuite());
+  }
+
+  public TestSuite()
+  {
+    addTestSuite(CacheTests.class);
+  }
+}

Modified: incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java?rev=429892&r1=429891&r2=429892&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java
(original)
+++ incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTests.java
Tue Aug  8 16:59:00 2006
@@ -55,6 +55,11 @@
   private static String CHECK_CACHE_INVALIDATE;
   private static int PORT;
   
+  private static Server server;
+
+  private static int NUM_TESTS = 3;
+  private static int testsRun  = 0;
+
   static {
     if (System.getProperty(PORT_PROP) != null) {
       PORT = Integer.parseInt(System.getProperty(PORT_PROP));  
@@ -63,31 +68,34 @@
     }
     
     CHECK_CACHE_INVALIDATE = "http://localhost:" + PORT + "/";
-  }
 
-  private static Server server;
-
-  protected void setUp() throws Exception {
-    if (server == null) {
-      server = new Server();
+    server = new Server();
 
-      Connector connector = new SocketConnector();
+    Connector connector = new SocketConnector();
 
-      connector.setPort(PORT);
+    connector.setPort(PORT);
 
-      server.setConnectors(new Connector[]{connector});
+    server.setConnectors(new Connector[]{connector});
 
-      ServletHandler handler = new ServletHandler();
+    ServletHandler handler = new ServletHandler();
 
-      server.setHandler(handler);
+    server.setHandler(handler);
 
-      handler.addServletWithMapping(
-        "org.apache.abdera.test.client.cache.CacheTests$Servlet",
-        "/"
-      );
+    handler.addServletWithMapping(
+      "org.apache.abdera.test.client.cache.CacheTests$Servlet",
+      "/"
+    );
 
+    try {
       server.start();
+    } catch (Exception e) {
+      // Nothing...
     }
+  }
+
+  public void tearDown() throws Exception {
+    if (++testsRun == NUM_TESTS)
+      server.stop();
   }
 
   public static class Servlet extends HttpServlet {



Mime
View raw message