You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/08/21 07:51:31 UTC

svn commit: r433157 - in /geronimo/trunk/modules/connector: ./ src/test/org/apache/geronimo/connector/outbound/ src/test/org/apache/geronimo/connector/work/

Author: jdillon
Date: Sun Aug 20 22:51:29 2006
New Revision: 433157

URL: http://svn.apache.org/viewvc?rev=433157&view=rev
Log:
Use testsupport and log exceptions so that this module runs tests quietly now

Modified:
    geronimo/trunk/modules/connector/pom.xml
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/work/PooledWorkManagerTest.java

Modified: geronimo/trunk/modules/connector/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/connector/pom.xml?rev=433157&r1=433156&r2=433157&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/pom.xml (original)
+++ geronimo/trunk/modules/connector/pom.xml Sun Aug 20 22:51:29 2006
@@ -130,7 +130,14 @@
             <groupId>regexp</groupId>
             <artifactId>regexp</artifactId>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-testsupport</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
     
     <!--

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java?rev=433157&r1=433156&r2=433157&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java Sun Aug 20 22:51:29 2006
@@ -20,19 +20,14 @@
 import java.util.HashSet;
 
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContextImpl;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
 
 /**
- *
+ * ???
  *
  * @version $Rev$ $Date$
- *
- * */
+ */
 public class ConnectionManagerStressTest extends ConnectionManagerTestUtils {
 
-    private static final Log log = LogFactory.getLog(ConnectionManagerStressTest.class);
-
     protected int repeatCount = 200;
     protected int threadCount = 10;
     private Object startBarrier = new Object();
@@ -78,11 +73,11 @@
                                     log.debug("got a cx: " + i + ", time: " + (duration));
                                 }
                             } catch (Throwable throwable) {
-                                throwable.printStackTrace();
+                                log.debug(throwable.getMessage(), throwable);
                             }
                         }
                     } catch (Exception e) {
-                        log.info(e);
+                        log.info(e.getMessage(), e);
                         ConnectionManagerStressTest.this.e = e;
                     } finally {
                         synchronized (stopBarrier) {

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java?rev=433157&r1=433156&r2=433157&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java Sun Aug 20 22:51:29 2006
@@ -1,6 +1,5 @@
 /**
- *
- * Copyright 2004 The Apache Software Foundation
+ *  Copyright 2004 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -23,7 +22,6 @@
 import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
 
-import junit.framework.TestCase;
 import org.apache.geronimo.connector.mock.MockConnection;
 import org.apache.geronimo.connector.mock.MockConnectionFactory;
 import org.apache.geronimo.connector.mock.MockManagedConnection;
@@ -40,14 +38,14 @@
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
 import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.apache.geronimo.testsupport.TestSupport;
 
 /**
- *
+ * ???
  *
  * @version $Rev$ $Date$
- *
- * */
-public class ConnectionManagerTestUtils extends TestCase implements DefaultInterceptor {
+ */
+public class ConnectionManagerTestUtils extends TestSupport implements DefaultInterceptor {
     protected boolean useTransactionCaching = true;
     protected boolean useLocalTransactions = false;
     protected boolean useThreadCaching = false;
@@ -95,7 +93,7 @@
 
         connectionTrackingCoordinator = new ConnectionTrackingCoordinator();
         transactionManager.addTransactionAssociationListener(new GeronimoTransactionListener(connectionTrackingCoordinator));
-        
+
         mockManagedConnectionFactory = new MockManagedConnectionFactory();
         subject = new Subject();
         ContextManager.setCallers(subject, subject);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/work/PooledWorkManagerTest.java?rev=433157&r1=433156&r2=433157&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/work/PooledWorkManagerTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/work/PooledWorkManagerTest.java Sun Aug 20 22:51:29 2006
@@ -1,6 +1,5 @@
 /**
- *
- * Copyright 2003-2004 The Apache Software Foundation
+ *  Copyright 2003-2004 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,10 +23,10 @@
 import javax.resource.spi.work.WorkException;
 import javax.resource.spi.work.WorkListener;
 
-import junit.framework.TestCase;
 import org.apache.geronimo.pool.ThreadPool;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.apache.geronimo.transaction.manager.XAWork;
+import org.apache.geronimo.testsupport.TestSupport;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -37,9 +36,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class PooledWorkManagerTest extends TestCase {
-
-    private static final Log log = LogFactory.getLog(PooledWorkManagerTest.class);
+public class PooledWorkManagerTest extends TestSupport {
 
     private GeronimoWorkManager workManager;
 
@@ -54,8 +51,7 @@
 
     public void testDoWork() throws Exception {
         int nbThreads = 2;
-        AbstractDummyWork threads[] =
-            helperTest(DummyDoWork.class, nbThreads, 500, 600);
+        AbstractDummyWork threads[] = helperTest(DummyDoWork.class, nbThreads, 500, 600);
         int nbStopped = 0;
         int nbTimeout = 0;
         for (int i = 0; i < threads.length; i++) {
@@ -70,15 +66,12 @@
                 fail("WORK_COMPLETED or WORK_REJECTED expected");
             }
         }
-        assertEquals("Wrong number of works in the WORK_COMPLETED state",
-            1, nbStopped);
-        assertEquals("Wrong number of works in the START_TIMED_OUT state",
-            1, nbTimeout);
+        assertEquals("Wrong number of works in the WORK_COMPLETED state", 1, nbStopped);
+        assertEquals("Wrong number of works in the START_TIMED_OUT state", 1, nbTimeout);
     }
 
     public void testStartWork() throws Exception {
-        AbstractDummyWork threads[] =
-            helperTest(DummyStartWork.class, 2, 10000, 100);
+        AbstractDummyWork threads[] = helperTest(DummyStartWork.class, 2, 10000, 100);
         int nbStopped = 0;
         int nbStarted = 0;
         for (int i = 0; i < threads.length; i++) {
@@ -90,10 +83,8 @@
                 fail("WORK_COMPLETED or WORK_STARTED expected");
             }
         }
-        assertEquals("At least one work should be in the WORK_COMPLETED state.",
-            1, nbStopped);
-        assertEquals("At least one work should be in the WORK_STARTED state.",
-            1, nbStarted);
+        assertEquals("At least one work should be in the WORK_COMPLETED state.", 1, nbStopped);
+        assertEquals("At least one work should be in the WORK_STARTED state.", 1, nbStarted);
     }
 
     public void testScheduleWork() throws Exception {
@@ -101,6 +92,7 @@
             helperTest(DummyScheduleWork.class, 3, 10000, 100);
         int nbAccepted = 0;
         int nbStarted = 0;
+
         for (int i = 0; i < threads.length; i++) {
             if ( null != threads[i].listener.acceptedEvent ) {
                 nbAccepted++;
@@ -110,8 +102,8 @@
                 fail("WORK_ACCEPTED or WORK_STARTED expected");
             }
         }
-        assertTrue("At least one work should be in the WORK_ACCEPTED state.",
-            nbAccepted > 0);
+
+        assertTrue("At least one work should be in the WORK_ACCEPTED state.", nbAccepted > 0);
     }
 
     public void testLifecycle() throws Exception {
@@ -158,7 +150,7 @@
             try {
                 perform(new DummyWork(name, tempo), timeout, null, listener);
             } catch (Exception e) {
-                e.printStackTrace();
+                log.debug(e.getMessage(), e);
             }
         }
 
@@ -208,6 +200,8 @@
     }
 
     public static class DummyWork implements Work {
+        private Log log = LogFactory.getLog(getClass());
+
         private final String name;
         private final int tempo;
 
@@ -223,7 +217,7 @@
             try {
                 Thread.sleep(tempo);
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                log.debug(e.getMessage(), e);
             }
         }
 
@@ -233,6 +227,8 @@
     }
 
     public static class DummyWorkListener implements WorkListener {
+        private Log log = LogFactory.getLog(getClass());
+
         public WorkEvent acceptedEvent;
         public WorkEvent rejectedEvent;
         public WorkEvent startedEvent;