1 package test.crispy.impl;
2
3 import java.util.ArrayList;
4 import java.util.Date;
5 import java.util.Hashtable;
6 import java.util.List;
7 import java.util.Map;
8 import java.util.Properties;
9
10 import junit.framework.TestCase;
11 import net.sf.crispy.InterceptorHandler;
12 import net.sf.crispy.Property;
13 import net.sf.crispy.impl.RmiExecutor;
14 import net.sf.crispy.impl.ServiceManager;
15 import net.sf.crispy.impl.rmi.MiniRmiServer;
16 import net.sf.crispy.impl.rmi.RmiInvocationHandler;
17 import net.sf.crispy.interceptor.StopWatchInterceptor;
18 import test.crispy.JUnitTestException;
19 import test.crispy.JUnitTestException2;
20 import test.crispy.compatibility.CompatibilityKit;
21 import test.crispy.concurrent.AsynchronousCallbackForTests;
22 import test.crispy.example.InterceptorHandlerCreatorExample;
23 import test.crispy.example.interceptor.AddSecurityTokenModifier;
24 import test.crispy.example.interceptor.RemoveSecurityTokenModifier;
25 import test.crispy.example.interceptor.WaitInterceptor;
26 import test.crispy.example.model.Adresse;
27 import test.crispy.example.model.Kunde;
28 import test.crispy.example.model.Primitive;
29 import test.crispy.example.model.SubSubProblemNode;
30 import test.crispy.example.model.ValidationError;
31 import test.crispy.example.service.Calculator;
32 import test.crispy.example.service.CalculatorImpl;
33 import test.crispy.example.service.Echo;
34 import test.crispy.example.service.EchoImpl;
35 import test.crispy.example.service.MyService;
36 import test.crispy.example.service.MyServiceImpl;
37
38 public class RmiServiceTest extends TestCase {
39
40
41 private static MiniRmiServer miniRmiServer = null;
42 private CompatibilityKit compatibilityKit = new CompatibilityKit();
43 private RmiInvocationHandler rmiInvocationHandler = null;
44
45 public RmiServiceTest() {
46 compatibilityKit.addProperty(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
47 compatibilityKit.addProperty(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
48 }
49
50 protected void setUp() throws Exception {
51 super.setUp();
52 if (MiniRmiServer.isStarted() == false) {
53 miniRmiServer = new MiniRmiServer();
54 rmiInvocationHandler = miniRmiServer.getDefaultRmiInvocationHandler();
55 miniRmiServer = new MiniRmiServer(1098, rmiInvocationHandler);
56
57 miniRmiServer.addService(Echo.class.getName(), EchoImpl.class.getName());
58 miniRmiServer.addService(Calculator.class.getName(), CalculatorImpl.class.getName());
59
60 miniRmiServer.addService(MyService.class.getName(), new MyService() {
61
62 MyServiceImpl myServiceImpl = new MyServiceImpl();
63
64 public SubSubProblemNode transferSubSubProblemNode(SubSubProblemNode pvNode) {
65 return myServiceImpl.transferSubSubProblemNode(pvNode);
66 }
67
68 }
69
70 );
71
72 miniRmiServer.start();
73 }
74
75 compatibilityKit.removeProperty(Property.DYNAMIC_PROXY_CLASS);
76 }
77
78 protected void tearDown() throws Exception {
79 super.tearDown();
80 miniRmiServer.stop();
81 }
82
83 public void testEchoPrimitive() throws Exception {
84 Properties prop = new Properties();
85 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.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 testInnerClassServiceImpl() throws Exception {
97 Properties prop = new Properties();
98 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
99
100 ServiceManager manager = new ServiceManager(prop);
101 MyService lvService = (MyService) manager.createService(MyService.class);
102
103 SubSubProblemNode lvNode = new SubSubProblemNode();
104 Date d = new Date();
105 lvNode.setDate(d);
106
107 SubSubProblemNode lvNodeAfter = lvService.transferSubSubProblemNode(lvNode);
108 assertEquals(lvNodeAfter.getDate(), lvNode.getDate());
109 }
110
111 public void testSimpleRemotePing() throws Exception {
112 Properties prop = new Properties();
113 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
114 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
115
116 ServiceManager manager = new ServiceManager(prop);
117 Echo echo = (Echo) manager.createService(Echo.class);
118 String lvPing = echo.ping();
119 assertEquals(lvPing, Echo.PING_STRING);
120 }
121
122
123 public void testSimpleRemoteInvocation() throws Exception {
124 compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
125 }
126
127 public void testSimpleDoubleRemoteInvocation() throws Exception {
128 compatibilityKit.makeMultipleServiceTest();
129 }
130
131 public void testComplexRemoteInvocation() throws Exception {
132 compatibilityKit.makeComplexEchoTest(compatibilityKit.createServiceManager());
133 }
134
135 public void testCycleDetectionTest() throws Exception {
136 compatibilityKit.makeCycleDetectionTest(compatibilityKit.createServiceManager());
137 }
138
139 public void testAddNode() throws Exception {
140 compatibilityKit.makeAddNodeTest(compatibilityKit.createServiceManager());
141 }
142
143 public void testProxyInterceptor() throws Exception {
144 compatibilityKit.makeSimpleProxyInterceptorTest();
145 }
146
147 public void testMultiProxyInterceptor() throws Exception {
148 compatibilityKit.makeMultiProxyInterceptorTest();
149 }
150
151 public void testSimpleRemoteInvocationWithDynamicCglibProxy() throws Exception {
152 compatibilityKit.addProperty(Property.DYNAMIC_PROXY_CLASS, Property.VALUE_FOR_CGLIB_DYNAMIC_PROXY);
153 compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
154 }
155
156 public void testSimpleRemoteInvocationWithDynamicJdkProxy() throws Exception {
157 compatibilityKit.addProperty(Property.DYNAMIC_PROXY_CLASS, Property.VALUE_FOR_JDK_DYNAMIC_PROXY);
158 compatibilityKit.makeSimpleEchoTest(compatibilityKit.createServiceManager());
159 }
160
161 public void testModifyService() throws Exception {
162 compatibilityKit.makeModifyServiceTest(compatibilityKit.createServiceManager());
163 }
164
165 public void testAddLongs() throws Exception {
166 Properties prop = new Properties();
167 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
168 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
169
170 ServiceManager manager = new ServiceManager(prop);
171 Calculator calc = (Calculator) manager.createService(Calculator.class);
172 assertEquals(calc.addLong(new Long(123l), new Long(124l)), new Long(247));
173 }
174
175 public void testOverloadingInteger() throws Exception {
176 Properties prop = new Properties();
177 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
178 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
179
180 ServiceManager manager = new ServiceManager(prop);
181 Echo echo = (Echo) manager.createService(Echo.class);
182 Integer i[] = echo.echoArray(new Integer[] {new Integer(1), new Integer(3), new Integer(5)});
183 assertTrue(i.length == 3);
184 assertEquals(i[0], new Integer(1));
185 assertEquals(i[1], new Integer(3));
186 assertEquals(i[2], new Integer(5));
187 }
188
189 public void testOverloadingLong() throws Exception {
190 Properties prop = new Properties();
191 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
192 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
193
194 ServiceManager manager = new ServiceManager(prop);
195 Echo echo = (Echo) manager.createService(Echo.class);
196 Long l[] = echo.echoArray(new Long[] {new Long(1), new Long(5)});
197 assertTrue(l.length == 2);
198 assertEquals(l[0], new Long(1));
199 assertEquals(l[1], new Long(5));
200 }
201
202 public void testOverloadingObject() throws Exception {
203 Properties prop = new Properties();
204 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
205 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
206
207 ServiceManager manager = new ServiceManager(prop);
208 Echo echo = (Echo) manager.createService(Echo.class);
209 Object o[] = echo.echoArray(new Object[] {"a", new Integer(3), new Long(5)});
210 assertTrue(o.length == 3);
211 assertEquals(o[0], "a");
212 assertEquals(o[1], new Integer(3));
213
214 }
215
216 public void testCreateService() throws Exception {
217 Properties prop = new Properties();
218 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
219 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
220
221 ServiceManager lvManager = new ServiceManager(prop);
222 Calculator lvCalculator1 = (Calculator) lvManager.createService(Calculator.class);
223 Calculator lvCalculator2 = (Calculator) lvManager.createService(Calculator.class);
224
225 assertNotNull(lvCalculator1);
226 assertNotNull(lvCalculator2);
227 assertNotSame(lvCalculator1, lvCalculator2);
228 }
229
230 public void testThrowException() throws Exception {
231 Properties prop = new Properties();
232 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
233 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
234
235 ServiceManager lvManager = new ServiceManager(prop);
236
237 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
238 boolean throwException = false;
239 try {
240 lvEcho.throwException("A Test-Excption.");
241 } catch (JUnitTestException e) {
242 throwException = true;
243 }
244 assertTrue("No Exception thrown: " + throwException, throwException);
245 }
246
247 public void testNullValueParamsWithException() throws Exception {
248 Properties prop = new Properties();
249 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
250 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
251
252 ServiceManager lvManager = new ServiceManager(prop);
253
254 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
255 String s = lvEcho.echo(null);
256 assertNull(s);
257 }
258
259 public void testNullLongValueParams() throws Exception {
260 Properties prop = new Properties();
261 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
262 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
263
264 ServiceManager lvManager = new ServiceManager(prop);
265
266 Calculator lvCalculator = (Calculator) lvManager.createService(Calculator.class);
267 Long lvLong = lvCalculator.addLong(null, null);
268 assertNull(lvLong);
269 }
270
271 public void testNullComplexValueParams() throws Exception {
272 Properties prop = new Properties();
273 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
274 prop.put(Property.REMOTE_URL_AND_PORT, "rmi://localhost:1098");
275
276 ServiceManager lvManager = new ServiceManager(prop);
277
278 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
279 Kunde k = lvEcho.renameKunde(null, null);
280 assertNull(k);
281 }
282
283 public void testTransferDate() throws Exception {
284 Properties prop = new Properties();
285 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
286
287 ServiceManager manager = new ServiceManager(prop);
288 Echo lvEcho = (Echo) manager.createService(Echo.class);
289
290 Kunde k = new Kunde("JUnit-Test-Name");
291 Date d = new Date();
292 k.setDate(d);
293 Kunde k2 = lvEcho.renameKunde(k, "Rename-Test");
294 assertNotNull(k2.getDate());
295 assertEquals(k.getDate(), k2.getDate());
296 }
297
298
299 public void testAsynchronousInvocation() throws Exception {
300 Properties prop = new Properties();
301 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
302 prop.put(Property.ASYNCHRONOUS_CALLBACK_CLASS, AsynchronousCallbackForTests.class.getName());
303
304 ServiceManager manager = new ServiceManager(prop);
305 Echo echo = (Echo) manager.createService(Echo.class);
306 String lvPing = echo.ping();
307 assertNull(lvPing);
308
309 assertTrue(manager.isInvocationAsynchronous(Echo.class));
310
311 Thread.sleep(300);
312 AsynchronousCallbackForTests lvAsynchronousCallbackForTests = (AsynchronousCallbackForTests) manager.getAsynchronousCallback(Echo.class);
313 assertNotNull(lvAsynchronousCallbackForTests);
314
315 assertEquals("ping", lvAsynchronousCallbackForTests.getMethodName());
316 assertEquals(Echo.PING_STRING, lvAsynchronousCallbackForTests.getResult());
317 assertNull(lvAsynchronousCallbackForTests.getThrowable());
318 }
319
320 public void testAsynchronousInvocationWithMultyThreaded() throws Exception {
321 Properties prop = new Properties();
322 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
323 prop.put(Property.ASYNCHRONOUS_CALLBACK_CLASS, AsynchronousCallbackForTests.class.getName());
324 prop.put(Property.ASYNCHRONOUS_MAX_SIZE_OF_THREADS, "3");
325
326 ServiceManager manager = new ServiceManager(prop);
327 Echo echo = (Echo) manager.createService(Echo.class);
328 String lvPing = echo.ping();
329 assertNull(lvPing);
330
331 assertTrue(manager.isInvocationAsynchronous(Echo.class));
332
333 Thread.sleep(300);
334 AsynchronousCallbackForTests lvAsynchronousCallbackForTests = (AsynchronousCallbackForTests) manager.getAsynchronousCallback(Echo.class);
335 assertNotNull(lvAsynchronousCallbackForTests);
336
337 assertEquals("ping", lvAsynchronousCallbackForTests.getMethodName());
338 assertEquals(Echo.PING_STRING, lvAsynchronousCallbackForTests.getResult());
339 assertNull(lvAsynchronousCallbackForTests.getThrowable());
340 }
341
342 public void testIndivualAsynchronousInvocationWithMultyThreaded() throws Exception {
343 Properties prop = new Properties();
344 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
345
346 ServiceManager manager = new ServiceManager(prop);
347 AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
348 Echo e = (Echo) manager.createService(Echo.class, lvCallback, null, 8);
349
350 String lvEchoStr = null;
351 String lvLongExecution = null;
352 for (int i=0;i<3;i++) {
353 lvLongExecution = e.doLongExecution("Hello");
354 assertNull(lvLongExecution);
355 lvEchoStr = e.echo("Hello");
356 assertNull(lvEchoStr);
357 }
358 }
359
360 public void testIndivualAsynchronousInvocationWithMultyThreadedWith2Services() throws Exception {
361 Properties prop = new Properties();
362 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
363
364 ServiceManager manager = new ServiceManager(prop);
365 AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
366 Echo e = (Echo) manager.createService(Echo.class, lvCallback, null, 8);
367 Calculator c = (Calculator) manager.createService(Calculator.class, lvCallback, null, 8);
368
369 String lvLongExecution = null;
370 Long lvAddResult = null;
371 for (int i=0;i<3;i++) {
372 lvLongExecution = e.doLongExecution("Hello");
373 assertNull(lvLongExecution);
374 lvAddResult = c.addLong(new Long(123), new Long(456));
375 assertNull(lvAddResult);
376 }
377 }
378
379 public void testIndivualAsynchronousInvocationWithMethodFilter() throws Exception {
380 Properties prop = new Properties();
381 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
382
383 ServiceManager manager = new ServiceManager(prop);
384 AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
385 Echo e = (Echo) manager.createService(Echo.class, lvCallback, new String[] { "doLongExecution" }, 4);
386
387 String lvEchoStr = null;
388 String lvLongExecution = null;
389 for (int i=0;i<3;i++) {
390 lvLongExecution = e.doLongExecution("Hello");
391 assertNotNull(lvLongExecution);
392 assertEquals("Hello", lvLongExecution);
393 lvEchoStr = e.echo("Hello");
394 assertNull(lvEchoStr);
395 }
396 }
397
398 public void testAddAndRemoveAsynchronousCallback() throws Exception {
399 Properties prop = new Properties();
400 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
401
402 ServiceManager manager = new ServiceManager(prop);
403 AsynchronousCallbackForTests lvCallback = new AsynchronousCallbackForTests();
404 Echo e = (Echo) manager.createService(Echo.class, lvCallback, new String[] { "doLongExecution" }, 4);
405 Calculator c = (Calculator) manager.createService(Calculator.class, lvCallback, null, 4);
406
407 String lvEchoStr = e.echo("Hello");
408 assertNull(lvEchoStr);
409
410 Long lvAddResult = c.addLong(new Long(1), new Long(3));
411 assertNull(lvAddResult);
412
413 assertTrue(manager.isInvocationAsynchronous(Calculator.class));
414 manager.removeAsynchronousCallback(Calculator.class);
415 assertFalse(manager.isInvocationAsynchronous(Calculator.class));
416
417 lvEchoStr = e.echo("Hello2");
418 assertNull(lvEchoStr);
419
420 lvAddResult = c.addLong(new Long(2), new Long(3));
421 assertNotNull(lvAddResult);
422 assertEquals(new Long(5), lvAddResult);
423
424
425 manager.removeAsynchronousCallback(Echo.class);
426
427 lvEchoStr = e.echo("Hello3");
428 assertNotNull(lvEchoStr);
429 assertEquals("Hello3", lvEchoStr);
430 }
431
432 public void testServiceEndpoint() throws Exception {
433 assertNull(miniRmiServer.getInterceptorHandlerCreator());
434
435 InterceptorHandler ih = new InterceptorHandler();
436 ih.addInterceptor(new WaitInterceptor());
437 StopWatchInterceptor lvStopWatch = new StopWatchInterceptor();
438 ih.addInterceptor(lvStopWatch);
439 InterceptorHandlerCreatorExample lvCreatorExample = new InterceptorHandlerCreatorExample();
440 lvCreatorExample.setInterceptorHandler(ih);
441 miniRmiServer.setInterceptorHandlerCreator(lvCreatorExample);
442
443 assertTrue(lvStopWatch.getStopTimeInvokeMethod() < 0);
444 Properties prop = new Properties();
445 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
446
447 ServiceManager lvManager = new ServiceManager(prop);
448
449 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
450 String lvEchoString = "ECHO-TEST";
451 assertEquals(lvEchoString, lvEcho.echo(lvEchoString));
452 assertTrue(lvStopWatch.getStopTimeInvokeMethod() > 0);
453
454 miniRmiServer.setInterceptorHandlerCreator(null);
455 assertNull(miniRmiServer.getInterceptorHandlerCreator());
456 }
457
458 public void testServiceEndpointAndServersideModifier() throws Exception {
459 Properties prop = new Properties();
460 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
461
462 ServiceManager lvManager = new ServiceManager(prop);
463 lvManager.setModifier(new AddSecurityTokenModifier());
464
465 assertNull(miniRmiServer.getInterceptorHandlerCreator());
466 InterceptorHandler ih = new InterceptorHandler();
467 ih.setModifier(new RemoveSecurityTokenModifier());
468 InterceptorHandlerCreatorExample lvCreatorExample = new InterceptorHandlerCreatorExample();
469 lvCreatorExample.setInterceptorHandler(ih);
470 miniRmiServer.setInterceptorHandlerCreator(lvCreatorExample);
471 assertNotNull(miniRmiServer.getInterceptorHandlerCreator());
472
473 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
474 String lvEchoString = "ECHO-TEST";
475 assertEquals(lvEchoString, lvEcho.echo(lvEchoString));
476 miniRmiServer.setInterceptorHandlerCreator(null);
477 assertNull(miniRmiServer.getInterceptorHandlerCreator());
478 }
479
480 public void testRmiInvocationHandler() throws Exception {
481 assertNotNull(rmiInvocationHandler);
482 assertEquals(rmiInvocationHandler, miniRmiServer.getRmiInvocationHandler());
483 }
484
485 public void testInterceptorHandlerCreator() throws Exception {
486 assertNull(miniRmiServer.getInterceptorHandlerCreator());
487
488 StopWatchInterceptor lvStopWatch = new StopWatchInterceptor();
489 InterceptorHandlerCreatorExample lvInterceptorHandlerCreator = new InterceptorHandlerCreatorExample(lvStopWatch);
490 miniRmiServer.setInterceptorHandlerCreator(lvInterceptorHandlerCreator);
491 assertNotNull(miniRmiServer.getInterceptorHandlerCreator());
492 assertEquals(lvInterceptorHandlerCreator, miniRmiServer.getInterceptorHandlerCreator());
493
494 Properties prop = new Properties();
495 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
496
497 ServiceManager lvManager = new ServiceManager(prop);
498 Echo lvEcho = (Echo) lvManager.createService(Echo.class);
499 String lvParamStr = "Test-JUnit-String - LongExecution ...";
500 String lvResult = lvEcho.doLongExecution(lvParamStr);
501 assertTrue((EchoImpl.WAIT_BY_LONG_EXECUTION - 20) < lvInterceptorHandlerCreator.getStopWatch().getStopTimeInvokeMethod());
502 assertEquals(lvParamStr, lvResult);
503 }
504
505 public void testEchoObjectWithComplexMap() throws Exception {
506 Properties prop = new Properties();
507 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
508
509 ServiceManager manager = new ServiceManager(prop);
510
511 Kunde k = new Kunde("Test-Kunde");
512 Adresse a = new Adresse();
513 a.setOrt("Hier");
514 k.getAdressen().add(a);
515 Map lvMap = new Hashtable();
516 lvMap.put("ADRESSE_KEY", a);
517 lvMap.put("KUNDE_KEY", k);
518
519 Echo lvEcho = (Echo) manager.createService(Echo.class);
520
521 assertNotNull(lvEcho.echo("Test"));
522
523 Object lvResult = lvEcho.echoObject(lvMap);
524 assertNotNull(lvResult);
525 assertTrue(lvResult instanceof Map);
526 Map lvMapAfter = (Map) lvResult;
527 Adresse a2 = (Adresse) lvMapAfter.get("ADRESSE_KEY");
528 assertEquals(a.getOrt(), a2.getOrt());
529 Kunde k2 = (Kunde) lvMapAfter.get("KUNDE_KEY");
530 assertEquals(k.getName(), k2.getName());
531 assertEquals(k.getAdressen().size(), k2.getAdressen().size());
532 assertEquals(a2, k2.getAdressen().get(0));
533 }
534
535 public void testRemoteMethodWithThrownExceptionWithValidationErrors() throws Exception {
536 Properties prop = new Properties();
537 prop.put(Property.EXECUTOR_CLASS, RmiExecutor.class.getName());
538
539 ServiceManager manager = new ServiceManager(prop);
540 Echo lvEcho = (Echo) manager.createService(Echo.class);
541
542 List lvValidationErrors = new ArrayList();
543 ValidationError lvError1 = new ValidationError(1, "Error 1");
544 ValidationError lvError2 = new ValidationError(2, "Error 2");
545 lvValidationErrors.add(lvError1);
546 lvValidationErrors.add(lvError2);
547 try {
548 lvEcho.throwComplexException("JUnit-Test", lvValidationErrors);
549 fail("The method throwComplexEception must be thrown a Exception");
550 } catch (Exception e) {
551 assertTrue(e instanceof JUnitTestException2);
552 assertEquals(lvValidationErrors.size(), ((JUnitTestException2) e).getValidationErrors().size());
553 }
554 }
555
556
557 }