This project has retired. For details please refer to its
Attic page.
CLIServerTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.api.runtime;
17
18 import java.util.Random;
19 import javax.xml.ws.BindingProvider;
20 import javax.xml.ws.Endpoint;
21 import junit.framework.Assert;
22 import org.apache.commons.configuration.ConfigurationException;
23 import org.apache.juddi.v3.client.JUDDIApiService;
24 import org.apache.juddi.v3_service.JUDDIApiPortType;
25 import org.junit.AfterClass;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.uddi.repl_v3.ReplicationConfiguration;
29 import org.uddi.v3_service.UDDIReplicationPortType;
30 import org.apache.juddi.v3.client.UDDIService;
31 import org.uddi.api_v3.Contact;
32 import org.uddi.api_v3.PersonName;
33 import org.uddi.repl_v3.CommunicationGraph;
34 import org.uddi.repl_v3.DoPing;
35 import org.uddi.repl_v3.GetChangeRecords;
36
37
38
39
40
41 public class CLIServerTest {
42
43 @AfterClass
44 public static void stopManager() throws ConfigurationException {
45 replication.stop();
46 replication = null;
47 juddiapi.stop();
48 juddiapi = null;
49 }
50
51 static Endpoint replication = null;
52 static Endpoint juddiapi = null;
53 static String replUrl = null;
54 static String juddiUrl = null;
55 static boolean sink = false;
56 static ReplicantImpl repl= new ReplicantImpl();
57 static JuddiTestimpl jude= new JuddiTestimpl();
58
59 @BeforeClass
60 public static void startManager() throws Exception {
61
62 Random r = new Random(System.currentTimeMillis());
63 replUrl = "http://localhost:" + (7000 + r.nextInt(1000)) + "/repl";
64 replication = Endpoint.publish(replUrl, repl);
65
66 juddiUrl = "http://localhost:" + (7000 + r.nextInt(1000)) + "/juddi";
67 juddiapi = Endpoint.publish(juddiUrl, jude);
68 System.out.println("Endpoint up at " + replUrl);
69 System.out.println("Endpoint up at " + juddiUrl);
70 }
71
72 @Test
73 public void testGetReplicationConfig() throws Exception {
74
75 JUDDIApiPortType juddiApiService = new JUDDIApiService().getJUDDIApiImplPort();
76 ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, juddiUrl);
77 juddiApiService.getReplicationNodes(null);
78 Assert.assertTrue(sink);
79 sink = false;
80 }
81
82 @Test
83 public void testSetReplicationConfig() throws Exception {
84
85 JUDDIApiPortType juddiApiService = new JUDDIApiService().getJUDDIApiImplPort();
86 ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, juddiUrl);
87 ReplicationConfiguration replicationConfiguration = new ReplicationConfiguration();
88 replicationConfiguration.setCommunicationGraph(new CommunicationGraph());
89 replicationConfiguration.setRegistryContact(new ReplicationConfiguration.RegistryContact());
90 replicationConfiguration.getRegistryContact().setContact(new Contact());
91 replicationConfiguration.getRegistryContact().getContact().getPersonName().add(new PersonName("name", null));
92
93 juddiApiService.setReplicationNodes(null, replicationConfiguration);
94 Assert.assertTrue(sink);
95 sink = false;
96 }
97
98 @Test
99 public void testReplicationGetChanges() throws Exception {
100
101 UDDIReplicationPortType juddiApiService = new UDDIService().getUDDIReplicationPort();
102 ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replUrl);
103 juddiApiService.getChangeRecords(new GetChangeRecords());
104 Assert.assertTrue(sink);
105 sink = false;
106 }
107 @Test
108 public void testReplicationPing() throws Exception {
109
110 UDDIReplicationPortType juddiApiService = new UDDIService().getUDDIReplicationPort();
111 ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replUrl);
112 juddiApiService.doPing(new DoPing());
113 Assert.assertTrue(sink);
114 sink = false;
115 }
116
117
118 }