1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.tests.services.remoting.rmi;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.fail;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.junit.Test;
25 import org.springframework.beans.factory.BeanFactory;
26 import org.springframework.context.ApplicationContext;
27
28 import ch.elca.el4j.core.context.ModuleApplicationContext;
29 import ch.elca.el4j.tests.services.remoting.loadbalancing.common.BusinessObject;
30
31
32
33
34
35
36
37
38
39 public class ClientTestCaseNoContextPassing {
40
41 public ClientTestCaseNoContextPassing() {
42 super();
43 m_applicationContext = new ModuleApplicationContext(
44 getInclusiveConfigLocations(),
45 (String[]) null,
46 false,
47 null);
48 }
49
50
51
52
53
54
55
56 @Test
57 public void testNextProtocol() {
58 getLog().debug("Starting test 'testIdempotence'....");
59 try {
60 s_logger.debug("-- Calling with hello 1") ;
61 String result = getTestObj().call("hello1") ;
62 assertEquals("Server 1 should have executed this code.",
63 "localhost:8089",
64 result);
65 s_logger.debug("-- Calling with hello 2") ;
66 result = getTestObj().call("hello2") ;
67 assertEquals("Server 1 should have executed this code.",
68 "localhost:8089",
69 result);
70 s_logger.debug("-- Calling with hello 3") ;
71 result = getTestObj().call("hello3") ;
72 assertEquals("Server 1 should have executed this code.",
73 "localhost:8089",
74 result);
75 s_logger.debug("-- Calling with hello 4") ;
76 result = getTestObj().call("hello4") ;
77 assertEquals("Server 1 should have executed this code.",
78 "localhost:8089",
79 result);
80 s_logger.debug("-- Calling with hello 5") ;
81 result = getTestObj().call("hello5") ;
82 assertEquals("Server 1 should have executed this code.",
83 "localhost:8089",
84 result);
85
86 } catch (Exception e) {
87 e.printStackTrace();
88 fail("Exception occurred: " + e.getMessage());
89 }
90 }
91
92
93 protected void runTest() {
94 testNextProtocol();
95 }
96
97
98 protected String[] getInclusiveConfigLocations() {
99 return new String[] {
100 "classpath*:mandatory/*.xml",
101 "classpath:rmi/rmi-nocontext-protocol-config.xml",
102 "classpath:rmi/startup-client.xml"};
103 }
104
105 protected Logger getLog() {
106 return s_logger;
107 }
108
109 protected BusinessObject getTestObj() {
110 if (m_obj == null) {
111 BeanFactory factory = (BeanFactory) m_applicationContext;
112
113 m_obj = (BusinessObject) factory.getBean("rmiBusinessObj");
114
115 }
116 return m_obj;
117 }
118
119
120
121
122 private static Logger s_logger = LoggerFactory
123 .getLogger(ClientTestCaseNoContextPassing.class);
124
125 private ApplicationContext m_applicationContext ;
126
127 private BusinessObject m_obj ;
128
129 }