1 57 58 package soap; 59 60 import junit.framework.Test; 61 import junit.framework.TestCase; 62 import junit.framework.TestSuite; 63 64 import org.apache.wsif.WSIFMessage; 65 import org.apache.wsif.WSIFOperation; 66 import org.apache.wsif.WSIFPort; 67 import org.apache.wsif.WSIFService; 68 import org.apache.wsif.WSIFServiceFactory; 69 import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis; 70 import org.apache.wsif.util.WSIFPluggableProviders; 71 import util.TestUtilities; 72 73 import addressbook.wsiftypes.Address; 74 import addressbook.wsiftypes.Phone; 75 76 81 public class MissingInputPartTest extends TestCase { 82 String wsdlLocation = 83 TestUtilities.getWsdlPath("java\\test\\addressbook\\wsifservice") 84 + "AddressBook.wsdl"; 85 static String server = TestUtilities.getSoapServer().toUpperCase(); 86 87 public MissingInputPartTest(String name) { 88 super(name); 89 } 90 91 public static void main(String [] args) { 92 TestUtilities.startListeners( 93 TestUtilities.ADDRESSBOOK_LISTENER 94 | TestUtilities.NATIVEJMS_LISTENER); 95 96 junit.textui.TestRunner.run (suite()); 97 TestUtilities.stopListeners(); 98 } 99 100 public static Test suite() { 101 return new TestSuite(MissingInputPartTest.class); 102 } 103 104 public void setUp() { 105 TestUtilities.setUpExtensionsAndProviders(); 106 } 107 108 public void testDynamicSOAP() { 109 doitDyn(server+"Port", "soap"); 110 } 111 public void testDynamicJava() { 112 doitDyn("JavaPort", "java"); 113 } 114 public void testDynamicSoapJms() { 115 doitDyn("SOAPJMSPort", "soap"); 116 } 117 public void testDynamicNativeJms() { 126 doitDyn("NativeJmsPort", "" ); 127 } 128 129 private void doitDyn(String portName, String protocol) { 130 131 if (portName.toUpperCase().indexOf("JMS") != -1 132 && !TestUtilities.areWeTesting("jms")) 133 return; 134 135 TestUtilities.setProviderForProtocol( protocol ); 136 137 try { 138 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 139 WSIFService service = factory.getService(wsdlLocation, null, null, "http://wsifservice.addressbook/", "AddressBook"); 144 service.mapType( 145 new javax.xml.namespace.QName ( 146 "http://wsiftypes.addressbook/", 147 "address"), 148 Class.forName("addressbook.wsiftypes.Address")); 149 150 service.mapType( 151 new javax.xml.namespace.QName ( 152 "http://wsiftypes.addressbook/", 153 "phone"), 154 Class.forName("addressbook.wsiftypes.Phone")); 155 156 WSIFPort port = null; 157 158 port = service.getPort(portName); 159 160 WSIFOperation operation = 161 port.createOperation("addEntry", "AddEntryWholeNameRequest", null); 162 163 WSIFMessage inputMessage = operation.createInputMessage(); 164 WSIFMessage outputMessage = operation.createOutputMessage(); 165 WSIFMessage faultMessage = operation.createFaultMessage(); 166 167 String nameToAdd = "Chris P. Bacon"; 169 170 inputMessage.setObjectPart("name", nameToAdd); 172 174 boolean ok = 176 operation.executeRequestResponseOperation( 177 inputMessage, 178 outputMessage, 179 faultMessage); 180 181 assertTrue( "Failed to add name and address to addressbook", ok ); 182 183 operation = null; 185 inputMessage = null; 186 outputMessage = null; 187 faultMessage = null; 188 189 operation = port.createOperation("getAddressFromName"); 190 191 inputMessage = operation.createInputMessage(); 193 outputMessage = operation.createOutputMessage(); 194 faultMessage = operation.createFaultMessage(); 195 196 String nameToLookup = "Chris P. Bacon"; 198 inputMessage.setObjectPart("name", nameToLookup); 199 200 ok = operation.executeRequestResponseOperation( 202 inputMessage, 203 outputMessage, 204 faultMessage); 205 206 assertTrue( "Failed to lookup name from addressbook", ok ); 207 208 Address addressFound = (Address) outputMessage.getObjectPart("address"); 210 if ( addressFound != null ) { 211 assertTrue( "city not null!!", addressFound.getCity() == null ); 212 assertTrue( "PhoneNumber not null!!", addressFound.getPhoneNumber() == null ); 213 assertTrue( "State not null!!", addressFound.getState() == null ); 214 assertTrue( "StreetName not null!!", addressFound.getStreetName() == null ); 215 } 216 217 } catch (Exception ex) { 218 ex.printStackTrace(); 219 assertTrue("AddressBookTest(" + portName + ") caught exception " + ex, false); 220 } finally { 221 if (protocol.equals("axis")) { 222 WSIFPluggableProviders.overrideDefaultProvider( 223 "http://schemas.xmlsoap.org/wsdl/soap/", 224 null); 225 } 226 } 227 } 228 229 } 230
| Popular Tags
|