View Javadoc

1   /**
2    * 
3    */
4   package test.crispy.impl;
5   
6   import java.io.PrintWriter;
7   import java.math.BigDecimal;
8   import java.util.Date;
9   import java.util.List;
10  import java.util.Properties;
11  import java.util.Vector;
12  
13  import javax.xml.namespace.QName;
14  
15  import junit.framework.TestCase;
16  import net.sf.crispy.Property;
17  import net.sf.crispy.impl.JaxRpcExecutor;
18  import net.sf.crispy.impl.MiniServer;
19  import net.sf.crispy.impl.ServiceManager;
20  import net.sf.crispy.impl.jaxrpc.ArrayTypeMappingFactory;
21  import net.sf.crispy.impl.jaxrpc.BeanTypeMappingFactory;
22  import net.sf.crispy.impl.jaxrpc.CharacterTypeMappingFactory;
23  import net.sf.crispy.impl.jaxrpc.MiniAxisServer;
24  import net.sf.crispy.impl.jaxrpc.TypeMappingFactory;
25  import net.sf.crispy.impl.jaxrpc.VectorTypeMappingFactory;
26  import net.sf.crispy.impl.jaxrpc.serializer.CharacterDeserializer;
27  import net.sf.crispy.impl.jaxrpc.serializer.CharacterSerializer;
28  import net.sf.crispy.util.Util;
29  
30  import org.apache.axis.Constants;
31  import org.apache.axis.encoding.SerializationContext;
32  import org.xml.sax.Attributes;
33  import org.xml.sax.helpers.AttributesImpl;
34  
35  import test.crispy.JUnitTestException2;
36  import test.crispy.compatibility.CompatibilityKit;
37  import test.crispy.concurrent.AsynchronousCallbackForTests;
38  import test.crispy.example.model.Adresse;
39  import test.crispy.example.model.Kunde;
40  import test.crispy.example.model.Node;
41  import test.crispy.example.model.Primitive;
42  import test.crispy.example.model.ValidationError;
43  import test.crispy.example.service.Calculator;
44  import test.crispy.example.service.Echo;
45  import test.crispy.example.service.EchoImpl;
46  
47  /**
48   * @author Linke
49   *
50   */
51  public class JaxRpcServiceTest extends TestCase {
52  
53  	private static MiniServer miniServer = null;
54  	private CompatibilityKit compatibilityKit = new CompatibilityKit();
55  	
56  	public JaxRpcServiceTest() {
57  		if (miniServer == null) {
58  			miniServer = new MiniAxisServer();
59  			miniServer.start();
60  		}
61  		
62  		
63  		compatibilityKit.addProperty(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
64  		compatibilityKit.addProperty(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
65  		compatibilityKit.addProperty(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
66  										BeanTypeMappingFactory.class.getName() + "," + Kunde.class.getName());
67  		compatibilityKit.addProperty(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_2, 
68  										BeanTypeMappingFactory.class.getName() + "," + Adresse.class.getName());
69  		
70  	}
71  
72  	protected void setUp() throws Exception {
73  		compatibilityKit.removeProperty(Property.DYNAMIC_PROXY_CLASS);
74  	}
75  	
76      public void testEchoPrimitive() throws Exception {
77      	Properties prop = new Properties();
78      	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
79      	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
80      	prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY + "__101", 
81  										BeanTypeMappingFactory.class.getName() + "," + Primitive.class.getName());
82      	prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY + "__102", 
83  				CharacterTypeMappingFactory.class.getName()+ "," + Character.class.getName());
84      	prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY + "__103", 
85  				BeanTypeMappingFactory.class.getName() + "," + Kunde.class.getName());
86      	
87          ServiceManager lvServiceManager = new ServiceManager(prop);
88          Echo lvEcho = (Echo) lvServiceManager.createService(Echo.class);
89          Primitive lvPrimitive = Primitive.createPrimitiveExample();
90          
91          Primitive lvPrimitiveAfter = lvEcho.echoPrimitive(lvPrimitive);
92          assertEquals(lvPrimitive, lvPrimitiveAfter);
93          assertNotSame(lvPrimitive, lvPrimitiveAfter);
94  	}
95  
96      public void testTransferCharacter() throws Exception {
97      	Properties prop = new Properties();
98      	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
99      	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
100     	prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY + "__102", 
101 				CharacterTypeMappingFactory.class.getName()+ "," + Character.class.getName());
102     	prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY + "__103", 
103 				BeanTypeMappingFactory.class.getName() + "," + Kunde.class.getName());
104     	
105         ServiceManager lvServiceManager = new ServiceManager(prop);
106         Echo lvEcho = (Echo) lvServiceManager.createService(Echo.class);
107 
108 		Kunde k = new Kunde ("Bla");
109 		k.setCharacter(new Character('Z'));
110 		Kunde k2 = lvEcho.renameKunde(k, "NEW");
111 
112         assertNotNull(k2);
113         assertNotNull(k2.getCharacter());
114         assertEquals(k2.getCharacter(), new Character('Z'));
115 	}
116 
117 	public void testSimpleRemotePing() throws Exception {
118 		Properties prop = new Properties();
119     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
120     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
121     			
122 		ServiceManager manager = new ServiceManager(prop);
123 		Echo echo =  (Echo) manager.createService(Echo.class);
124 		String lvPing = echo.ping();
125 		assertEquals(lvPing, Echo.PING_STRING);
126 	}
127 	
128 	public void testSimpleRemoteInvocation() throws Exception {
129     	compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
130 	}
131 	
132     public void testSimpleDoubleRemoteInvocation() throws Exception {
133     	compatibilityKit.makeMultipleServiceTest();
134     }
135 
136     public void testComplexRemoteInvocation() throws Exception {
137     	compatibilityKit.makeComplexEchoTest(compatibilityKit.createServiceManager());
138     }
139 
140     public void testProxyInterceptor() throws Exception {
141     	compatibilityKit.makeSimpleProxyInterceptorTest();
142     }
143 
144     public void testMultiProxyInterceptor() throws Exception {
145     	compatibilityKit.makeMultiProxyInterceptorTest();
146     }
147 
148     public void testSimpleRemoteInvocationWithDynamicCglibProxy() throws Exception {
149     	compatibilityKit.addProperty(Property.DYNAMIC_PROXY_CLASS, Property.VALUE_FOR_CGLIB_DYNAMIC_PROXY);
150     	compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
151 	}
152 
153     public void testSimpleRemoteInvocationWithDynamicJdkProxy() throws Exception {
154     	compatibilityKit.addProperty(Property.DYNAMIC_PROXY_CLASS, Property.VALUE_FOR_JDK_DYNAMIC_PROXY);
155     	compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
156 	}
157    
158     public void testCycleDetectionTest() throws Exception {
159 		compatibilityKit.makeCycleDetectionTest(compatibilityKit.createServiceManager());
160 	}
161     
162     public void testAddNode() throws Exception {
163     	compatibilityKit.addProperty(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
164 				BeanTypeMappingFactory.class.getName()+ "," + Node.class.getName());
165     	compatibilityKit.addProperty(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_2, 
166 				VectorTypeMappingFactory.class.getName()+ "," + Vector.class.getName());
167     	
168     	compatibilityKit.makeAddNodeTest(compatibilityKit.createServiceManager());
169 	}
170     
171     public void testModifyService() throws Exception {
172 		compatibilityKit.makeModifyServiceTest(compatibilityKit.createServiceManager());
173 	}
174 	
175     public void testAddLongs() throws Exception {
176     	Properties prop = new Properties();
177     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
178     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
179     	
180 		ServiceManager manager = new ServiceManager(prop);
181 		Calculator calc =  (Calculator) manager.createService(Calculator.class);
182 		assertEquals(calc.addLong(new Long(123l), new Long(124l)), new Long(247));
183 	}
184 
185     public void testOverloading() throws Exception {
186 		Properties prop = new Properties();
187     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
188     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
189 		
190 		
191 		ServiceManager manager = new ServiceManager(prop);
192 		Calculator lvCalculator = (Calculator) manager.createService(Calculator.class);
193 		int lvIntResult = lvCalculator.add(2, 3);
194 		assertEquals(lvIntResult, 5);
195 		long lvLongResult = lvCalculator.add(21, 32);
196 		assertEquals(lvLongResult, 53);
197 		double lvDoubleResult = lvCalculator.add(2.3, 3.2);
198 		assertEquals(lvDoubleResult, 5.5, 0);
199     }
200     
201     public void testOverloadingInteger() throws Exception {
202 		Properties prop = new Properties();
203     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
204     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
205 		prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
206 				ArrayTypeMappingFactory.class.getName()+ "," + Integer[].class.getName());
207 	
208 		ServiceManager manager = new ServiceManager(prop);
209 		Echo echo =  (Echo) manager.createService(Echo.class);
210 		Integer i[] = echo.echoArray(new Integer[] {new Integer(1), new Integer(3), new Integer(5)});
211 		assertTrue(i.length == 3);
212 		assertEquals(i[0], new Integer(1));
213 		assertEquals(i[1], new Integer(3));
214 		assertEquals(i[2], new Integer(5));
215 	}
216     
217     public void testOverloadingLong() throws Exception {
218 		Properties prop = new Properties();
219     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
220     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
221 		prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
222 				ArrayTypeMappingFactory.class.getName()+ "," + Long[].class.getName());
223 
224 		
225 		ServiceManager manager = new ServiceManager(prop);
226 		Echo echo =  (Echo) manager.createService(Echo.class);
227 		Long l[] = echo.echoArray(new Long[] {new Long(1), new Long(5)});
228 		assertTrue(l.length == 2);
229 		assertEquals(l[0], new Long(1));
230 		assertEquals(l[1], new Long(5));
231 	}
232 
233     public void testOverloadingObject() throws Exception {
234 		Properties prop = new Properties();
235     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
236     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
237 		prop.put(Echo.class.getName(), EchoImpl.class.getName());
238 		prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
239 				ArrayTypeMappingFactory.class.getName()+ "," + String[].class.getName());
240 
241 		
242 		ServiceManager manager = new ServiceManager(prop);
243 		Echo echo =  (Echo) manager.createService(Echo.class);
244 		Object o[] = echo.echoArray(new String[] {"a", "b", "c"}); 
245 		assertTrue(o.length == 3);
246 		assertEquals(o[0], "a");
247 		assertEquals(o[1], "b");
248 		assertEquals(o[2], "c");
249 	}
250     
251     public void testUserPasswd() throws Exception {
252 		Properties prop = new Properties();
253     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
254     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
255 		prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
256 				BeanTypeMappingFactory.class.getName()+ "," + Kunde.class.getName());
257 		prop.put(Property.SECURITY_USER, "user");
258 		prop.put(Property.SECURITY_PASSWD, "passWd");
259 		
260 		ServiceManager manager = new ServiceManager(prop);
261 		Echo echo =  (Echo) manager.createService(Echo.class);
262 		Kunde k = new Kunde();
263 		k.setName("before");
264 		Kunde k2 = echo.renameKunde(k, "after");
265 		assertEquals(k2.getName(), "after");
266 	}
267     
268     public void testXMLTypeByClass() throws Exception {
269 		QName lvName = JaxRpcExecutor.getXMLTypeByClass(Kunde.class);
270 		assertEquals(lvName.getPrefix(), "");
271 		assertEquals(lvName.getNamespaceURI(), "model.example.crispy.test");
272 	}
273 
274     public void testCreateService() throws Exception {
275         Properties prop = new Properties();
276     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
277     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
278 
279     	
280         ServiceManager lvManager = new ServiceManager(prop);
281         Calculator lvCalculator1 = (Calculator) lvManager.createService(Calculator.class);
282         Calculator lvCalculator2 = (Calculator) lvManager.createService(Calculator.class);
283         
284         assertNotNull(lvCalculator1);
285         assertNotNull(lvCalculator2);
286         assertNotSame(lvCalculator1, lvCalculator2);
287 	}
288 
289     public void testThrowException() throws Exception {
290         Properties prop = new Properties();
291     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
292     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
293 
294     	ServiceManager lvManager = new ServiceManager(prop);
295 
296 		Echo lvEcho = (Echo) lvManager.createService(Echo.class);
297 		boolean throwException = false;
298 		try {
299 			lvEcho.throwException("A Test-Excption.");
300 		} catch (Exception e) {
301 			throwException = true;
302 		}
303 		assertTrue("No Exception thrown: " + throwException, throwException);
304 	}
305 
306     
307     public void testNullValueParamsWithException() throws Exception {
308         Properties prop = new Properties();
309     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
310     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
311         
312 		ServiceManager lvManager = new ServiceManager(prop);
313 
314 		Echo lvEcho = (Echo) lvManager.createService(Echo.class);
315 		String s = lvEcho.echo(null);
316 		assertNull(s);
317 	}
318 
319     public void testNullLongValueParams() throws Exception {
320         Properties prop = new Properties();
321     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
322     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
323         
324 		ServiceManager lvManager = new ServiceManager(prop);
325 
326 		Calculator lvCalculator = (Calculator) lvManager.createService(Calculator.class);
327 		Long lvLong = lvCalculator.addLong(null, null);
328 		assertNull(lvLong);
329 	}
330 
331     public void testNullComplexValueParams() throws Exception {
332         Properties prop = new Properties();
333     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
334     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
335 		
336 		ServiceManager lvManager = new ServiceManager(prop);
337 
338 		Echo lvEcho = (Echo) lvManager.createService(Echo.class);
339 		Kunde k = lvEcho.renameKunde(null, null);
340 		assertNull(k);
341 	}
342     
343     public void testKundeWithObjectValue() throws Exception {
344         Properties prop = new Properties();
345     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
346     	prop.put(Property.REMOTE_URL_AND_PORT, "http://localhost:9080/axis/services");
347 		
348 		ServiceManager lvManager = new ServiceManager(prop);
349 
350 		Echo lvEcho = (Echo) lvManager.createService(Echo.class);
351 		Kunde k1 = new Kunde("JUnit-Test-Kunden-Name");
352 		Double d = new Double(47.11);
353 		Long l = new Long (-12345);
354 		BigDecimal bd = new BigDecimal("0.07");
355 		k1.setDouble(d);
356 		k1.setLongValue(l);
357 		k1.setGehalt(bd);
358 		Kunde k2 = lvEcho.renameKunde(k1, "NewName");
359 		assertNotNull(k2);
360 		assertEquals(d, k2.getDouble());
361 		assertEquals(l, k2.getLongValue());
362 		assertEquals(bd, k2.getGehalt());
363 		assertEquals("NewName", k2.getName());
364 	}
365     
366 	public void testTransferDate() throws Exception {
367 		Properties prop = new Properties();
368     	prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
369 		
370 		ServiceManager manager = new ServiceManager(prop);
371 		Echo lvEcho =  (Echo) manager.createService(Echo.class);
372 		
373 		Kunde k = new Kunde("JUnit-Test-Name");
374 		Date d = new Date();
375 		k.setDate(d);
376 		Kunde k2 = lvEcho.renameKunde(k, "Rename-Test");
377 		assertNotNull(k2.getDate());
378 		assertEquals(k.getDate(), k2.getDate());
379 	}
380 
381 
382     
383 	public void testAsynchronousInvocation() throws Exception {
384 		Properties prop = new Properties();
385 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
386 		prop.put(Property.ASYNCHRONOUS_CALLBACK_CLASS, AsynchronousCallbackForTests.class.getName());
387 		
388 		ServiceManager manager = new ServiceManager(prop);
389 		Echo echo =  (Echo) manager.createService(Echo.class);
390 		String lvPing = echo.ping();
391 		assertNull(lvPing);
392 		
393         assertTrue(manager.isInvocationAsynchronous(Echo.class));
394         
395         Thread.sleep(500);
396         AsynchronousCallbackForTests lvAsynchronousCallbackForTests = (AsynchronousCallbackForTests) manager.getAsynchronousCallback(Echo.class);
397         assertNotNull(lvAsynchronousCallbackForTests);
398         
399         assertEquals("ping", lvAsynchronousCallbackForTests.getMethodName());
400         assertEquals(Echo.PING_STRING, lvAsynchronousCallbackForTests.getResult());
401         assertNull(lvAsynchronousCallbackForTests.getThrowable());
402 	}
403 	
404 	public void testAsynchronousInvocationWithMultyThreaded() throws Exception {
405 		Properties prop = new Properties();
406 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
407 		prop.put(Property.ASYNCHRONOUS_CALLBACK_CLASS, AsynchronousCallbackForTests.class.getName());
408 		prop.put(Property.ASYNCHRONOUS_MAX_SIZE_OF_THREADS, "3");
409 		
410 		ServiceManager manager = new ServiceManager(prop);
411 		Echo echo =  (Echo) manager.createService(Echo.class);
412 		String lvPing = echo.ping();
413 		assertNull(lvPing);
414 		
415         assertTrue(manager.isInvocationAsynchronous(Echo.class));
416         
417         Thread.sleep(500);
418         AsynchronousCallbackForTests lvAsynchronousCallbackForTests = (AsynchronousCallbackForTests) manager.getAsynchronousCallback(Echo.class);
419         assertNotNull(lvAsynchronousCallbackForTests);
420         
421         assertEquals("ping", lvAsynchronousCallbackForTests.getMethodName());
422         assertEquals(Echo.PING_STRING, lvAsynchronousCallbackForTests.getResult());
423         assertNull(lvAsynchronousCallbackForTests.getThrowable());
424 	}
425 
426 	public void testIndivualAsynchronousInvocationWithMultyThreaded() throws Exception {
427 		Properties prop = new Properties();
428 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
429 
430 		ServiceManager manager = new ServiceManager(prop);
431 		AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
432 		Echo e = (Echo) manager.createService(Echo.class, lvCallback, null, 8);
433 		
434 		String lvEchoStr = null;
435 		String lvLongExecution = null;
436 		for (int i=0;i<3;i++) {
437 			lvLongExecution = e.doLongExecution("Hello");
438 			assertNull(lvLongExecution);
439 			lvEchoStr = e.echo("Hello");
440 			assertNull(lvEchoStr);
441 		}
442 	}
443 	
444 	public void testIndivualAsynchronousInvocationWithMultyThreadedWith2Services() throws Exception {
445 		Properties prop = new Properties();
446 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
447 
448 		ServiceManager manager = new ServiceManager(prop);
449 		AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
450 		Echo e = (Echo) manager.createService(Echo.class, lvCallback, null, 8);
451 		Calculator c =  (Calculator) manager.createService(Calculator.class, lvCallback, null, 8);
452 		
453 		String lvLongExecution = null;
454 		Long lvAddResult = null;
455 		for (int i=0;i<3;i++) {
456 			lvLongExecution = e.doLongExecution("Hello");
457 			assertNull(lvLongExecution);
458 			lvAddResult = c.addLong(new Long(123), new Long(456));
459 			assertNull(lvAddResult);
460 		}
461 	}
462 
463 	public void testIndivualAsynchronousInvocationWithMethodFilter() throws Exception {
464 		Properties prop = new Properties();
465 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
466 
467 		ServiceManager manager = new ServiceManager(prop);
468 		AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
469 		Echo e = (Echo) manager.createService(Echo.class, lvCallback, new String[] { "doLongExecution" }, 4);
470 		
471 		String lvEchoStr = null;
472 		String lvLongExecution = null;
473 		for (int i=0;i<3;i++) {
474 			lvLongExecution = e.doLongExecution("Hello");
475 			assertNotNull(lvLongExecution);
476 			assertEquals("Hello", lvLongExecution);
477 			lvEchoStr = e.echo("Hello");
478 			assertNull(lvEchoStr);
479 		}
480 	}
481 
482 	public void testAddAndRemoveAsynchronousCallback() throws Exception {
483 		Properties prop = new Properties();
484 		prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
485 
486 		ServiceManager manager = new ServiceManager(prop);
487 		AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
488 		Echo e = (Echo) manager.createService(Echo.class, lvCallback, new String[] { "doLongExecution" }, 4);
489 		Calculator c =  (Calculator) manager.createService(Calculator.class, lvCallback, null, 4);
490 				
491 		String lvEchoStr = e.echo("Hello");
492 		assertNull(lvEchoStr);
493 		
494 		Long lvAddResult = c.addLong(new Long(1), new Long(3));
495 		assertNull(lvAddResult);
496 		
497 		assertTrue(manager.isInvocationAsynchronous(Calculator.class));
498 		manager.removeAsynchronousCallback(Calculator.class);
499 		assertFalse(manager.isInvocationAsynchronous(Calculator.class));
500 		
501 		lvEchoStr = e.echo("Hello2");
502 		assertNull(lvEchoStr);
503 		
504 		Object lvAddResultSynch = c.addLong(new Long(1), new Long(3));
505 		assertEquals(new Long(4), lvAddResultSynch);
506 		
507 		
508 		manager.removeAsynchronousCallback(Echo.class);
509 		
510 		String lvEchoStr3 = e.echo("Hello_3");
511 		assertNotNull(lvEchoStr3);
512 		assertEquals("Hello_3", lvEchoStr3);
513 	}
514 
515 
516 	public void testCharacterDeserializer() throws Exception {
517 		QName lvName = new CharacterTypeMappingFactory ().getXmlType();
518 		CharacterDeserializer lvCharacterDeserializer = new CharacterDeserializer (Character.class, lvName);
519 		assertNull(lvCharacterDeserializer.makeValue(null));
520 	}
521 	
522 	public void testCharacterSerializer() throws Exception {
523 		CharacterSerializer lvCharacterSerializer = new CharacterSerializer();
524 		assertNull(lvCharacterSerializer.writeSchema(Character.class, null));
525 		assertEquals(Constants.AXIS_SAX, lvCharacterSerializer.getMechanismType());
526 		assertNull(lvCharacterSerializer.getValueAsString(null, null));
527 
528 		Attributes lvAttributes = new AttributesImpl();
529 		QName lvName = new CharacterTypeMappingFactory ().getXmlType();
530 		lvCharacterSerializer.serialize(lvName, lvAttributes, null, new SerializationContext(new PrintWriter(System.out)));
531 	}
532 	
533 	public void testVectorTypeMappingFactory() throws Exception {
534 		VectorTypeMappingFactory lvMappingFactory = new VectorTypeMappingFactory();
535 		lvMappingFactory.setParameter(null);
536 		assertEquals(Vector.class, lvMappingFactory.getJavaType());
537 		assertEquals(Constants.SOAP_VECTOR, lvMappingFactory.getXmlType());
538 		
539 		lvMappingFactory.setParameter(new String[0]);
540 		assertEquals(Vector.class, lvMappingFactory.getJavaType());
541 		assertEquals(Constants.SOAP_VECTOR, lvMappingFactory.getXmlType());
542 		
543 		lvMappingFactory.setParameter(new String[] {"Dummy" });
544 		assertEquals(Vector.class, lvMappingFactory.getJavaType());
545 		assertEquals(Constants.SOAP_VECTOR, lvMappingFactory.getXmlType());
546 		
547 		lvMappingFactory.setParameter(new String[] {"Dummy", List.class.getName() });
548 		assertEquals(Vector.class, lvMappingFactory.getJavaType());
549 		assertEquals(Util.createQNameByClass(List.class), lvMappingFactory.getXmlType());
550 	}
551 	
552 	public void testTransportParamVector() throws Exception {
553         Properties prop = new Properties();
554         prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
555         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
556 				BeanTypeMappingFactory.class.getName()+ "," + Node.class.getName());
557         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_2, 
558 				VectorTypeMappingFactory.class.getName() + "," + Vector.class.getName());
559 
560 		ServiceManager manager = new ServiceManager(prop);
561 		Echo lvEcho = (Echo) manager.createService(Echo.class);
562 
563 		List v = new Vector();
564 		Object o = lvEcho.echoObject(v);
565 		assertTrue(o instanceof List);
566 		assertEquals(0, ((List) o).size());
567 		
568 		v.add("TEST");
569 		o = lvEcho.echoObject(v);
570 		assertTrue(o instanceof List);
571 		assertEquals(1, ((List) o).size());
572 		assertEquals("TEST", ((List) o).get(0));
573 	}
574 	
575 	public void testTransferExceptionWithValidationErrors() throws Exception {
576         Properties prop = new Properties();
577         prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
578         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
579 				BeanTypeMappingFactory.class.getName()+ "," + JUnitTestException2.class.getName());
580         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_2, 
581 				BeanTypeMappingFactory.class.getName()+ "," + ValidationError.class.getName());
582 //        prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_3, 
583 //				BeanTypeMappingFactory.class.getName()+ "," + Object.class.getName());
584 
585 		ServiceManager manager = new ServiceManager(prop);
586 		Echo lvEcho = (Echo) manager.createService(Echo.class);
587 
588 		Vector lvValidationErrors = new Vector();
589 		ValidationError lvError1 = new ValidationError(1, "Error 1");
590 		ValidationError lvError2 = new ValidationError(2, "Error 2");
591 		lvValidationErrors.add(lvError1);
592 		lvValidationErrors.add(lvError2);
593 		JUnitTestException2 e = new JUnitTestException2();
594 		e.setValidationErrors(lvValidationErrors);
595 		
596 		Object lvResult = lvEcho.echoObject(e);
597 		assertTrue(lvResult instanceof JUnitTestException2);
598 		JUnitTestException2 lvExceptionAfter = (JUnitTestException2) lvResult;
599 		assertEquals(2, lvExceptionAfter.getValidationErrors().size());
600 		assertEquals(1, ((ValidationError) lvExceptionAfter.getValidationErrors().get(0)).getCode());
601 		assertEquals(2, ((ValidationError) lvExceptionAfter.getValidationErrors().get(1)).getCode());
602 	}
603 	
604 	
605 	public void testRemoteMethodWithThrownExceptionWithValidationErrors() throws Exception {
606         Properties prop = new Properties();
607         prop.put(Property.EXECUTOR_CLASS, JaxRpcExecutor.class.getName());
608         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY, 
609 				BeanTypeMappingFactory.class.getName()+ "," + JUnitTestException2.class.getName());
610         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_2, 
611 				BeanTypeMappingFactory.class.getName()+ "," + ValidationError.class.getName());
612         prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_3, 
613 				VectorTypeMappingFactory.class.getName()+ "," + List.class.getName());
614         
615 //        prop.put(TypeMappingFactory.PROPERTY_TYPE_MAPPING_FACTORY_3, 
616 //				BeanTypeMappingFactory.class.getName()+ "," + Object.class.getName());
617     	
618 		ServiceManager manager = new ServiceManager(prop);
619 		Echo lvEcho = (Echo) manager.createService(Echo.class);
620 		
621 		Vector lvValidationErrors = new Vector();
622 		ValidationError lvError1 = new ValidationError(1, "Error 1");
623 		ValidationError lvError2 = new ValidationError(2, "Error 2");
624 		lvValidationErrors.add(lvError1);
625 		lvValidationErrors.add(lvError2);
626 
627 		try {
628 			lvEcho.throwComplexException("JUnit-Test", lvValidationErrors);
629 			fail("The method throwComplexEception must be thrown a Exception");
630 		} catch (Exception e) {
631 			assertTrue(e instanceof JUnitTestException2);
632 			JUnitTestException2 lvExceptionAfter = (JUnitTestException2) e;
633 			assertEquals(lvValidationErrors.size(), lvExceptionAfter.getValidationErrors().size());
634 			assertEquals(1, ((ValidationError) lvExceptionAfter.getValidationErrors().get(0)).getCode());
635 			assertEquals(2, ((ValidationError) lvExceptionAfter.getValidationErrors().get(1)).getCode());			
636 		}
637 	}
638 
639 }