This project has retired. For details please refer to its
Attic page.
API_160_ReplicationTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.api.impl;
17
18 import java.rmi.RemoteException;
19 import java.util.List;
20 import java.util.UUID;
21 import javax.xml.bind.JAXB;
22 import org.apache.commons.configuration.ConfigurationException;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.juddi.Registry;
26 import org.apache.juddi.api_v3.Clerk;
27 import org.apache.juddi.api_v3.ClerkList;
28 import org.apache.juddi.api_v3.DeleteClerk;
29 import org.apache.juddi.api_v3.DeleteNode;
30 import org.apache.juddi.api_v3.Node;
31 import org.apache.juddi.api_v3.NodeList;
32 import org.apache.juddi.api_v3.SaveClerk;
33 import org.apache.juddi.api_v3.SaveNode;
34 import org.apache.juddi.replication.ReplicationNotifier;
35 import org.apache.juddi.v3.tck.TckPublisher;
36 import org.apache.juddi.v3.tck.TckSecurity;
37 import org.junit.AfterClass;
38 import org.junit.Assert;
39 import org.junit.BeforeClass;
40 import org.junit.Test;
41 import org.uddi.api_v3.Contact;
42 import org.uddi.api_v3.DispositionReport;
43 import org.uddi.api_v3.PersonName;
44 import org.uddi.repl_v3.ChangeRecordIDType;
45 import org.uddi.repl_v3.ChangeRecords;
46 import org.uddi.repl_v3.CommunicationGraph;
47 import org.uddi.repl_v3.DoPing;
48 import org.uddi.repl_v3.GetChangeRecords;
49 import org.uddi.repl_v3.HighWaterMarkVectorType;
50 import org.uddi.repl_v3.Operator;
51 import org.uddi.repl_v3.OperatorStatusType;
52 import org.uddi.repl_v3.ReplicationConfiguration;
53 import org.uddi.v3_service.DispositionReportFaultMessage;
54 import org.uddi.v3_service.UDDIReplicationPortType;
55 import org.uddi.v3_service.UDDISecurityPortType;
56
57
58
59
60
61 public class API_160_ReplicationTest {
62
63 private static Log logger = LogFactory.getLog(API_141_JIRATest.class);
64 static UDDIReplicationPortType repl = new UDDIReplicationImpl();
65 static JUDDIApiImpl juddi = new JUDDIApiImpl();
66 static ReplicationNotifier notifier = null;
67 protected static String authInfoJoe = null;
68 protected static String authInfoMary = null;
69 protected static String authInfoSam = null;
70 protected static String authInfoRoot = null;
71 protected static String authInfoUDDI = null;
72
73 @AfterClass
74 public static void stopManager() throws ConfigurationException {
75 Registry.stop();
76 }
77
78 @BeforeClass
79 public static void startManager() throws ConfigurationException {
80 Registry.start();
81
82 try {
83
84 UDDISecurityPortType security = new UDDISecurityImpl();
85 authInfoRoot = TckSecurity.getAuthToken(security, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
86
87 } catch (RemoteException e) {
88 logger.error(e.getMessage(), e);
89 Assert.fail("Could not obtain authInfo token.");
90 }
91
92 }
93
94 @Test
95 public void getPing() throws Exception {
96 String node = repl.doPing(new DoPing());
97 Assert.assertNotNull(node);
98 }
99
100 @Test
101 public void getGetHighWaterMarks() throws Exception {
102 List<ChangeRecordIDType> highWaterMarks = repl.getHighWaterMarks();
103
104 Assert.assertNotNull(highWaterMarks);
105 Assert.assertFalse(highWaterMarks.isEmpty());
106 for (int i = 0; i < highWaterMarks.size(); i++) {
107 Assert.assertNotNull(highWaterMarks.get(i).getNodeID());
108
109 Assert.assertNotNull(highWaterMarks.get(i).getOriginatingUSN());
110 Assert.assertTrue(highWaterMarks.get(i).getOriginatingUSN() >= 0);
111
112
113
114
115
116
117
118 }
119 }
120
121
122 public void getChangeRecordsValid() throws DispositionReportFaultMessage, RemoteException {
123 List<ChangeRecordIDType> highWaterMarks = repl.getHighWaterMarks();
124
125 HighWaterMarkVectorType highWaterMarkVectorType = new HighWaterMarkVectorType();
126 highWaterMarkVectorType.getHighWaterMark().add(highWaterMarks.get(0));
127 GetChangeRecords req = new GetChangeRecords();
128 req.setRequestingNode("test");
129 req.setChangesAlreadySeen(null);
130
131 req.setResponseLimitVector(highWaterMarkVectorType);
132 ChangeRecords changeRecords = repl.getChangeRecords(req);
133
134 }
135
136
137
138
139
140
141
142 @Test
143 public void testAddClerkNodeThenDelete() throws Exception {
144 SaveClerk sc = new SaveClerk();
145 sc.setAuthInfo(authInfoRoot);
146 Clerk c = new Clerk();
147 c.setName("clerk1");
148
149 c.setPassword("pass");
150 c.setPublisher("username");
151 c.setNode(new Node());
152 c.getNode().setName("test_node");
153 c.getNode().setClientName("test_client");
154 c.getNode().setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName());
155 c.getNode().setCustodyTransferUrl("http://localhost");
156 c.getNode().setDescription("http://localhost");
157 c.getNode().setInquiryUrl("http://localhost");
158 c.getNode().setPublishUrl("http://localhost");
159 c.getNode().setReplicationUrl("http://localhost");
160 c.getNode().setSecurityUrl("http://localhost");
161 c.getNode().setSubscriptionListenerUrl("http://localhost");
162 c.getNode().setSubscriptionUrl("http://localhost");
163
164 sc.getClerk().add(c);
165 juddi.saveClerk(sc);
166
167 juddi.deleteClerk(new DeleteClerk(authInfoRoot, "clerk1"));
168
169 ClerkList allNodes = juddi.getAllClerks(authInfoRoot);
170 boolean found = false;
171 for (int i = 0; i < allNodes.getClerk().size(); i++) {
172 if (allNodes.getClerk().get(i).getName().equals("clerk1")) {
173 found = true;
174 }
175
176 }
177 Assert.assertFalse(found);
178
179 NodeList allNodes1 = juddi.getAllNodes(authInfoRoot);
180 for (int i = 0; i < allNodes1.getNode().size(); i++) {
181 if (allNodes1.getNode().get(i).getName().equals("test_node")) {
182 return;
183 }
184 }
185
186 Assert.fail("node unexpectedly deleted");
187 }
188
189
190
191
192
193
194 @Test
195 public void testAddClerkNodeThenDelete2() throws Exception {
196 SaveClerk sc = new SaveClerk();
197 sc.setAuthInfo(authInfoRoot);
198 Clerk c = new Clerk();
199 c.setName("clerk1" + UUID.randomUUID().toString());
200
201 c.setPassword("pass");
202 c.setPublisher("username");
203 c.setNode(new Node());
204 c.getNode().setName("test_node" + UUID.randomUUID().toString());
205 c.getNode().setClientName("test_client");
206 c.getNode().setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName());
207 c.getNode().setCustodyTransferUrl("http://localhost");
208 c.getNode().setDescription("http://localhost");
209 c.getNode().setInquiryUrl("http://localhost");
210 c.getNode().setPublishUrl("http://localhost");
211 c.getNode().setReplicationUrl("http://localhost");
212 c.getNode().setSecurityUrl("http://localhost");
213 c.getNode().setSubscriptionListenerUrl("http://localhost");
214 c.getNode().setSubscriptionUrl("http://localhost");
215
216 sc.getClerk().add(c);
217 juddi.saveClerk(sc);
218
219 juddi.deleteNode(new DeleteNode(authInfoRoot, c.getNode().getName()));
220
221
222
223 ClerkList allNodes = juddi.getAllClerks(authInfoRoot);
224 boolean found = false;
225 for (int i = 0; i < allNodes.getClerk().size(); i++) {
226 if (allNodes.getClerk().get(i).getName().equals(c.getName())) {
227 found = true;
228 }
229
230 }
231 Assert.assertFalse(found);
232
233
234 NodeList allNodes1 = juddi.getAllNodes(authInfoRoot);
235 for (int i = 0; i < allNodes1.getNode().size(); i++) {
236 if (allNodes1.getNode().get(i).getName().equals(c.getNode().getName())) {
237 Assert.fail("node is still there!");
238 }
239 }
240
241 }
242
243 @Test
244 public void testAddClerkExistingNode() throws Exception {
245
246 SaveClerk sc = new SaveClerk();
247 sc.setAuthInfo(authInfoRoot);
248 Clerk c = new Clerk();
249 c.setName("clerk1" + UUID.randomUUID().toString());
250
251 c.setPassword("pass");
252 c.setPublisher("username");
253 c.setNode(new Node());
254 c.getNode().setName("test_node" + UUID.randomUUID().toString());
255 c.getNode().setClientName("test_client");
256 c.getNode().setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName());
257 c.getNode().setCustodyTransferUrl("http://localhost");
258 c.getNode().setDescription("http://localhost");
259 c.getNode().setInquiryUrl("http://localhost");
260 c.getNode().setPublishUrl("http://localhost");
261 c.getNode().setReplicationUrl("http://localhost");
262 c.getNode().setSecurityUrl("http://localhost");
263 c.getNode().setSubscriptionListenerUrl("http://localhost");
264 c.getNode().setSubscriptionUrl("http://localhost");
265 sc.getClerk().add(c);
266
267 SaveNode saveNode = new SaveNode();
268 saveNode.setAuthInfo(authInfoRoot);
269 saveNode.getNode().add(c.getNode());
270
271 juddi.saveNode(saveNode);
272
273 juddi.saveClerk(sc);
274
275
276
277 juddi.deleteClerk(new DeleteClerk(authInfoRoot, c.getName()));
278 System.out.println(c.getName() + " deleted");
279
280 juddi.deleteNode(new DeleteNode(authInfoRoot, c.getNode().getName()));
281
282 NodeList allNodes = juddi.getAllNodes(authInfoRoot);
283 boolean found = false;
284 for (int i = 0; i < allNodes.getNode().size(); i++) {
285 if (allNodes.getNode().get(i).getName().equals(c.getNode().getName())) {
286 found = true;
287 }
288
289 }
290 Assert.assertFalse(found);
291 }
292
293 @Test
294 public void setReplicationConfig() throws Exception {
295
296
297
298 ReplicationConfiguration r = new ReplicationConfiguration();
299 Operator op = new Operator();
300 op.setOperatorNodeID("test_node");
301 op.setSoapReplicationURL("http://localhost");
302 op.setOperatorStatus(OperatorStatusType.NORMAL);
303
304 r.getOperator().add(op);
305 r.setCommunicationGraph(new CommunicationGraph());
306 r.setRegistryContact(new ReplicationConfiguration.RegistryContact());
307 r.getRegistryContact().setContact(new Contact());
308 r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null));
309
310 r.getCommunicationGraph().getNode().add("test_node");
311
312 JAXB.marshal(r, System.out);
313 DispositionReport setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r);
314
315 ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot);
316 Assert.assertNotNull(replicationNodes.getCommunicationGraph());
317 Assert.assertNotNull(replicationNodes.getCommunicationGraph().getNode());
318 Assert.assertEquals("test_node", replicationNodes.getCommunicationGraph().getNode().get(0));
319 Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges());
320 Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry());
321 Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate());
322 Assert.assertNotNull(replicationNodes.getSerialNumber());
323 long firstcommit = replicationNodes.getSerialNumber();
324
325 r = new ReplicationConfiguration();
326 r.getOperator().add(op);
327 r.setCommunicationGraph(new CommunicationGraph());
328 r.setRegistryContact(new ReplicationConfiguration.RegistryContact());
329 r.getRegistryContact().setContact(new Contact());
330 r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null));
331
332 r.getCommunicationGraph().getNode().add("test_node");
333
334 JAXB.marshal(r, System.out);
335 Thread.sleep(50);
336 setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r);
337
338 replicationNodes = juddi.getReplicationNodes(authInfoRoot);
339 Assert.assertNotNull(replicationNodes.getCommunicationGraph());
340 Assert.assertNotNull(replicationNodes.getCommunicationGraph().getNode());
341 Assert.assertEquals("test_node", replicationNodes.getCommunicationGraph().getNode().get(0));
342 Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges());
343 Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry());
344 Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate());
345 Assert.assertNotNull(replicationNodes.getSerialNumber());
346 Assert.assertTrue(firstcommit < replicationNodes.getSerialNumber());
347
348 }
349
350 @Test
351 public void setReplicationConfig2() throws Exception {
352
353
354
355 ReplicationConfiguration r = new ReplicationConfiguration();
356 Operator op = new Operator();
357 op.setOperatorNodeID("test_node");
358 op.setSoapReplicationURL("http://localhost");
359 op.setOperatorStatus(OperatorStatusType.NORMAL);
360
361 r.getOperator().add(op);
362 op = new Operator();
363 op.setOperatorNodeID("test_node2");
364 op.setSoapReplicationURL("http://localhost");
365 op.setOperatorStatus(OperatorStatusType.NORMAL);
366
367 r.getOperator().add(op);
368
369
370 r.setCommunicationGraph(new CommunicationGraph());
371 r.setRegistryContact(new ReplicationConfiguration.RegistryContact());
372 r.getRegistryContact().setContact(new Contact());
373 r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null));
374
375 r.getCommunicationGraph().getNode().add("test_node");
376 r.getCommunicationGraph().getNode().add("test_node2");
377 r.getCommunicationGraph().getControlledMessage().add("doPing");
378 r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge());
379 r.getCommunicationGraph().getEdge().get(0).setMessageReceiver("test_node");
380 r.getCommunicationGraph().getEdge().get(0).setMessageSender("test_node2");
381 r.getCommunicationGraph().getEdge().get(0).getMessage().add("doPing");
382 r.getCommunicationGraph().getEdge().get(0).getMessageReceiverAlternate().add("test_node2");
383
384 DispositionReport setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r);
385
386 ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot);
387 Assert.assertNotNull(replicationNodes.getCommunicationGraph());
388 Assert.assertNotNull(replicationNodes.getCommunicationGraph().getNode());
389 Assert.assertEquals("test_node", replicationNodes.getCommunicationGraph().getNode().get(0));
390 Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges());
391 Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry());
392 Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate());
393 Assert.assertNotNull(replicationNodes.getSerialNumber());
394
395 }
396
397
398
399
400 @Test
401 public void getReplicationConfigMandatoryItems() throws Exception {
402
403 ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot);
404 Assert.assertNotNull(replicationNodes);
405 Assert.assertNotNull(replicationNodes.getCommunicationGraph());
406 Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate());
407 Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges());
408 Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry());
409 Assert.assertNotNull(replicationNodes.getRegistryContact());
410 Assert.assertNotNull(replicationNodes.getRegistryContact().getContact());
411 Assert.assertNotNull(replicationNodes.getRegistryContact().getContact().getPersonName().get(0));
412
413 }
414
415
416 }