1 57 58 package soapinterop; 59 60 import java.math.BigDecimal ; 61 import java.text.DateFormat ; 62 import java.util.Date ; 63 import java.util.Locale ; 64 65 import junit.framework.Test; 66 import junit.framework.TestCase; 67 import junit.framework.TestSuite; 68 69 import org.apache.wsif.providers.soap.apachesoap.WSIFDynamicProvider_ApacheSOAP; 70 import org.apache.wsif.util.WSIFPluggableProviders; 71 72 public class InteropTest extends TestCase { 73 74 public static void main(String [] args) { 75 junit.textui.TestRunner.run(suite()); 76 } 77 78 public static Test suite() { 79 return new TestSuite(InteropTest.class); 80 } 81 82 public InteropTest(String name) { 83 super(name); 84 } 85 86 89 90 public void testInterop() { 91 try 92 { 93 WSIFPluggableProviders.overrideDefaultProvider( 95 "http://schemas.xmlsoap.org/wsdl/soap/", 96 new WSIFDynamicProvider_ApacheSOAP() ); 97 98 InteropTestServiceProxy proxy = new InteropTestServiceProxy(); 99 100 System.out.println("echoString"); 102 assertTrue("echoString", proxy.echoString("String").equals("String")); 103 104 System.out.println("echoInteger"); 106 assertTrue("echoInteger", proxy.echoInteger(3) == 3); 107 108 System.out.println("echoFloat"); 110 assertTrue("echoInteger", proxy.echoFloat((float) 5) == 5.0); 111 112 System.out.println("echoVoid"); 114 proxy.echoVoid(); 115 116 System.out.println("echoDate"); 118 Date dateIn = new Date (); 119 DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); 120 dateIn = fmt.parse("Thursday, January 10, 2002 "); 121 assertTrue("echoDate", proxy.echoDate(dateIn).equals(dateIn)); 122 123 134 135 System.out.println("echoBase64"); 137 byte[] base64In = { -1, 0, 1 }; 138 byte[] base64Out = proxy.echoBase64(base64In); 139 140 for (int i = 0; i < base64Out.length; i++) { 141 assertTrue("echoBase64 [" + i + "]", base64In[i] == base64Out[i]); 142 } 143 144 153 154 System.out.println("echoBigDecimal"); 156 BigDecimal bigDecimalIn = new BigDecimal ("7"); 157 assertTrue("echoDecimal", proxy.echoDecimal(bigDecimalIn).equals(bigDecimalIn)); 158 159 System.out.println("echoBoolean"); 161 boolean booleanIn = false; 162 assertTrue("echoBoolean", proxy.echoBoolean(booleanIn) == booleanIn); 163 164 174 193 194 205 216 } 217 catch (Exception e) 218 { 219 System.out.println("InteropTest caught exception "+e); 220 e.printStackTrace(); 221 assertTrue(false); 222 } 223 224 } 225 } 226
| Popular Tags
|