1 57 58 package invocation; 59 60 import java.util.HashMap ; 61 62 import junit.framework.Test; 63 import junit.framework.TestCase; 64 import junit.framework.TestSuite; 65 66 import util.TestUtilities; 67 68 import clients.DynamicInvoker; 69 70 74 public class DynamicInvokerTest extends TestCase { 75 String wsdlLocation = 76 TestUtilities.getWsdlPath("java\\test\\stockquote\\wsifservice") 77 + "Stockquote.wsdl"; 78 static String server = TestUtilities.getSoapServer().toUpperCase(); 79 80 public DynamicInvokerTest(String name) { 81 super(name); 82 } 83 84 public static void main(String [] args) 85 { 86 TestUtilities.startListeners( 87 TestUtilities.STOCKQUOTE_LISTENER 88 | TestUtilities.NATIVEJMS_LISTENER); 89 90 junit.textui.TestRunner.run(suite()); 91 TestUtilities.stopListeners(); 92 } 93 94 public static Test suite() { 95 return new TestSuite(DynamicInvokerTest.class); 96 } 97 98 public void setUp() { 99 TestUtilities.setUpExtensionsAndProviders(); 100 } 101 102 public void testDefault() { 103 doit(null, null); 104 } 105 public void testAxis() { 106 doit(server+"Port", "axis"); 107 } 108 public void testSoap() { 109 doit(server+"Port", "soap"); 110 } 111 public void testJava() { 112 doit("JavaPort", "java"); 113 } 114 public void testSoapJms() { 115 doit("SOAPJMSPort", "soap"); 116 } 117 public void testAxisJms() { 118 doit("SOAPJMSPort", "axis"); 119 } 120 public void testNativeJms() { 121 doit("NativeJmsPort", ""); 122 } 123 124 private void doit(String portName, String protocol) { 125 if (portName != null 126 && portName.toUpperCase().indexOf("JMS") != -1 127 && !TestUtilities.areWeTesting("jms")) { 128 return; 129 } 130 131 try { 132 HashMap map = 133 DynamicInvoker.invokeMethod( 134 wsdlLocation, 135 "getQuote", 136 null, 137 null, 138 portName, 139 protocol, 140 new String [] { "" }, 141 0); 142 143 float quote = ((Float ) (map.get("quote"))).floatValue(); 144 assertTrue(quote == -1.0F); 145 } catch (Exception e) { 146 if (portName != null) { 147 System.err.println("DynamicInvokerTest(" + portName + ") caught exception " + e); 148 e.printStackTrace(); 149 assertTrue(false); 150 } else { 151 System.out.println("null port name caused exception as expected"); 152 assertTrue(true); 153 } 154 } 155 } 156 157 } 158
| Popular Tags
|