antelder 2002/06/21 04:12:10 Modified: java/test/stockquote StockquoteTest.java java/test/inout InoutTest.java java/test/util TestUtilities.java WSIFTestRunner.java java/test/async AsyncTests.java java/test/addressbook AddressBookTest.java java/test/jms JmsTest.java java/test/invocation DynamicInvokerTest.java java/test/jrom JROMTests.java Log: Change testcase setup to allow each test to be run individually or with TestRunner without needing to manually start any JMS/Async listeners Revision Changes Path 1.4 +4 -2 xml-axis-wsif/java/test/stockquote/StockquoteTest.java Index: StockquoteTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/stockquote/StockquoteTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- StockquoteTest.java 20 Jun 2002 11:37:06 -0000 1.3 +++ StockquoteTest.java 21 Jun 2002 11:12:09 -0000 1.4 @@ -81,8 +81,10 @@ super(name); } - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + public static void main(String[] args) { + TestUtilities.startListeners(); + junit.textui.TestRunner.run (suite()); + TestUtilities.stopListeners(); } public static Test suite() { 1.5 +4 -2 xml-axis-wsif/java/test/inout/InoutTest.java Index: InoutTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/inout/InoutTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- InoutTest.java 20 Jun 2002 11:14:05 -0000 1.4 +++ InoutTest.java 21 Jun 2002 11:12:09 -0000 1.5 @@ -131,8 +131,10 @@ super(name); } - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + public static void main(String[] args) { + TestUtilities.startListeners(); + junit.textui.TestRunner.run (suite()); + TestUtilities.stopListeners(); } public static Test suite() { 1.3 +86 -0 xml-axis-wsif/java/test/util/TestUtilities.java Index: TestUtilities.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/util/TestUtilities.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestUtilities.java 6 Jun 2002 12:28:32 -0000 1.2 +++ TestUtilities.java 21 Jun 2002 11:12:10 -0000 1.3 @@ -66,11 +66,24 @@ import java.util.Properties; import java.util.StringTokenizer; +import org.apache.wsif.WSIFException; +import org.apache.wsif.base.WSIFDefaultCorrelationService; +import org.apache.wsif.util.WSIFCorrelationServiceLocator; +import org.apache.wsif.util.jms.JMS2HTTPBridge; +import org.apache.wsif.util.jms.JMS2HTTPBridgeDestination; +import org.apache.wsif.util.jms.JMSAsyncListener; +import org.apache.wsif.util.jms.NativeJMSRequestListener; + public class TestUtilities { private static final String WSIF_TEST_PROPERTIES = "wsif.test.properties"; private static final String WSIF_PATH = "wsif.path"; private static final String WSIF_TEST_COMPONENTS = "wsif.test.components"; + private static BridgeThread jmsAb = null; + private static BridgeThread jmsSq = null; + private static JMSAsyncListener asyncListener = null; + private static NativeJMSRequestListener nativeReqListener = null; + public static String getWsdlPath(String relativePath) { String wsdlPath = getWsifProperty(WSIF_PATH); if (wsdlPath == null) @@ -142,4 +155,77 @@ //WSIFServiceImpl.addExtensionRegistry(new JmsExtensionRegistry()) ; //WSIFServiceImpl.addExtensionRegistry(new EJBExtensionRegistry()); } + /** + * This starts what listeners are required to run the testcases. + * What listeners are needed depends on settings in the + * wsif.test.properties file. + * Possible listeners are: + * JMS2HTTPBridge - for SOAP/JMS tests + * NativeJMSRequestListener - for the native JMS provider + * JMSAsynListener - for asynchronous operation tests + */ + public static void startListeners() + { + if (TestUtilities.areWeTesting("jms")) + { + jmsAb = new BridgeThread("AddressBook"); + jmsSq = new BridgeThread("Stockquote"); + jmsAb.start(); + jmsSq.start(); + try { + nativeReqListener = + new NativeJMSRequestListener( + TestUtilities.getWsifProperty("wsif.nativejms.requestq") ); + } catch (WSIFException ex) { + ex.printStackTrace(); + } + } + if (TestUtilities.areWeTesting("async")) { + try { + asyncListener = + new JMSAsyncListener( TestUtilities.getWsifProperty("wsif.async.replytoq") ); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + /** + * This starts whatever listeners have been started. + * Possible listeners are: + * JMS2HTTPBridge - for SOAP/JMS tests + * NativeJMSRequestListener - for the native JMS provider + * JMSAsynListener - for asynchronous operation tests + */ + public static void stopListeners() + { + if ( jmsAb != null ) jmsAb.stop(); + if ( jmsSq != null ) jmsSq.stop(); + if ( asyncListener != null ) asyncListener.stop(); + if ( nativeReqListener != null ) nativeReqListener.stop(); + ((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator. + getCorrelationService()).shutdown(); + } + } + +class BridgeThread extends Thread { + private String name; + public BridgeThread(String name) { this.name=name; } + public void run() { + try { + System.out.println("Starting "+name+" JMS2HTTPBridge"); + JMS2HTTPBridge j2h = new JMS2HTTPBridge( + "com.sun.jndi.fscontext.RefFSContextFactory", + "file://C:/JNDI-Directory", + "WSIFSampleQCF", + "SoapJms"+name+"Queue", + "http://localhost:8080/soap/servlet/rpcrouter", + JMS2HTTPBridgeDestination.COLDSTART); + j2h.listen(); + } catch (Exception e) { + System.out.println("Caught JMS2HTTPBridge exception " + e); + } + } +} + 1.10 +7 -79 xml-axis-wsif/java/test/util/WSIFTestRunner.java Index: WSIFTestRunner.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/util/WSIFTestRunner.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WSIFTestRunner.java 20 Jun 2002 14:52:10 -0000 1.9 +++ WSIFTestRunner.java 21 Jun 2002 11:12:10 -0000 1.10 @@ -57,6 +57,8 @@ package util; +import faults.FaultMsgTest; +import headers.HeadersTest; import inout.InoutTest; import invocation.DynamicInvokerTest; @@ -64,26 +66,15 @@ import jndi.JNDIAddressBookTest; import junit.framework.Test; import junit.framework.TestSuite; -import junit.textui.TestRunner; -import org.apache.wsif.WSIFException; -import org.apache.wsif.util.jms.JMS2HTTPBridge; -import org.apache.wsif.util.jms.JMS2HTTPBridgeDestination; -import org.apache.wsif.util.jms.JMSAsyncListener; -import org.apache.wsif.util.jms.NativeJMSRequestListener; -import org.apache.wsif.base.WSIFDefaultCorrelationService; -import org.apache.wsif.util.WSIFCorrelationServiceLocator; + import providers.ProvidersInitialisationTest; import shop.ShoppingCartTest; -import soapinterop.InteropTest; import stockquote.StockquoteTest; import wsdl.WsdlLoadingTest; -import zipcode.ZIPCodeTest; -import jrom.JROMTests; import addressbook.AddressBookTest; import async.AsyncTests; -import headers.HeadersTest; -import faults.FaultMsgTest; +import jrom.JROMTests; /** * Run JUnit tests on WSIF code. @@ -95,74 +86,10 @@ public class WSIFTestRunner { - private class BridgeThread extends Thread { - private String name; - public BridgeThread(String name) { - this.name = name; - } - public void run() { - try { - System.out.println("Starting " + name + " JMS2HTTPBridge"); - JMS2HTTPBridge j2h = - new JMS2HTTPBridge( - "com.sun.jndi.fscontext.RefFSContextFactory", - "file:///JNDI-Directory", - "WSIFSampleQCF", - "SoapJms" + name + "Queue", - "http://localhost:8080/soap/servlet/rpcrouter", - JMS2HTTPBridgeDestination.COLDSTART); - j2h.listen(); - } catch (Exception e) { - System.out.println("Caught JMS2HTTPBridge exception " + e); - } - } - }; - public static void main(String[] args) { - WSIFTestRunner wtr = null; - BridgeThread jmsAb = null; - BridgeThread jmsSq = null; - JMSAsyncListener asyncListener = null; - NativeJMSRequestListener nativeReqListener = null; - - if (TestUtilities.areWeTesting("jms")) { - wtr = new WSIFTestRunner(); - jmsAb = wtr.new BridgeThread("AddressBook"); - jmsSq = wtr.new BridgeThread("Stockquote"); - try { - nativeReqListener = - new NativeJMSRequestListener( - TestUtilities.getWsifProperty("wsif.nativejms.requestq") ); - } catch (WSIFException ex) { - ex.printStackTrace(); - } - jmsAb.start(); - jmsSq.start(); - } - if (TestUtilities.areWeTesting("async")) { - try { - asyncListener = - new JMSAsyncListener( TestUtilities.getWsifProperty("wsif.async.replytoq") ); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - + TestUtilities.startListeners(); junit.textui.TestRunner.run(suite()); - - if (jmsAb != null) - jmsAb.interrupt(); - if (jmsSq != null) - jmsSq.interrupt(); - if (TestUtilities.areWeTesting("async")) { - asyncListener.stop(); - if ( nativeReqListener != null ) { - nativeReqListener.stop(); - } - ((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator. - getCorrelationService()).shutdown(); - } - + TestUtilities.stopListeners(); } public static Test suite() { @@ -190,6 +117,7 @@ suite.addTest(new TestSuite(ZIPCodeTest.class)); suite.addTest(new TestSuite(InteropTest.class)); suite.addTest(new TestSuite(JNDIAddressBookTest.class)); + suite.addTest(new TestSuite(JROMTests.class)); if (TestUtilities.areWeTesting("jms")) suite.addTest(new TestSuite(JmsTest.class)); 1.2 +3 -1 xml-axis-wsif/java/test/async/AsyncTests.java Index: AsyncTests.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AsyncTests.java 20 Jun 2002 14:52:10 -0000 1.1 +++ AsyncTests.java 21 Jun 2002 11:12:10 -0000 1.2 @@ -105,7 +105,9 @@ } public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + TestUtilities.startListeners(); + junit.textui.TestRunner.run(suite()); + TestUtilities.stopListeners(); } public static Test suite() { 1.6 +5 -3 xml-axis-wsif/java/test/addressbook/AddressBookTest.java Index: AddressBookTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/addressbook/AddressBookTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AddressBookTest.java 20 Jun 2002 11:14:05 -0000 1.5 +++ AddressBookTest.java 21 Jun 2002 11:12:10 -0000 1.6 @@ -112,9 +112,11 @@ super(name); } - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } + public static void main(String[] args) { + TestUtilities.startListeners(); + junit.textui.TestRunner.run (suite()); + TestUtilities.stopListeners(); + } public static Test suite() { return new TestSuite(AddressBookTest.class); 1.5 +4 -2 xml-axis-wsif/java/test/jms/JmsTest.java Index: JmsTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/jms/JmsTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JmsTest.java 12 Jun 2002 10:27:23 -0000 1.4 +++ JmsTest.java 21 Jun 2002 11:12:10 -0000 1.5 @@ -143,8 +143,10 @@ super(name); } - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + public static void main(String[] args) { + TestUtilities.startListeners(); + junit.textui.TestRunner.run (suite()); + TestUtilities.stopListeners(); } public static Test suite() { 1.2 +7 -1 xml-axis-wsif/java/test/invocation/DynamicInvokerTest.java Index: DynamicInvokerTest.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/invocation/DynamicInvokerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DynamicInvokerTest.java 6 Jun 2002 08:28:57 -0000 1.1 +++ DynamicInvokerTest.java 21 Jun 2002 11:12:10 -0000 1.2 @@ -81,7 +81,9 @@ } public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + TestUtilities.startListeners(); + junit.textui.TestRunner.run(suite()); + TestUtilities.stopListeners(); } public static Test suite() { @@ -111,6 +113,10 @@ public void testAxisJms() { if (TestUtilities.areWeTesting("jms")) doit("SOAPJMSPort", "axis"); + } + public void testNativeJms() { + if (TestUtilities.areWeTesting("jms")) + doit("NativeJmsPort", ""); } private void doit(String portName, String protocol) { 1.6 +4 -2 xml-axis-wsif/java/test/jrom/JROMTests.java Index: JROMTests.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/test/jrom/JROMTests.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JROMTests.java 19 Jun 2002 09:47:40 -0000 1.5 +++ JROMTests.java 21 Jun 2002 11:12:10 -0000 1.6 @@ -98,8 +98,10 @@ super(name); } - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + public static void main(String[] args) { + TestUtilities.startListeners(); + junit.textui.TestRunner.run (suite()); + TestUtilities.stopListeners(); } public static Test suite() {