This project has retired. For details please refer to its
Attic page.
ServiceLocatorTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.v3.client.mapping;
16
17 import java.net.URL;
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Properties;
21 import java.util.UUID;
22 import org.apache.commons.configuration.ConfigurationException;
23 import org.apache.juddi.v3.client.config.UDDIClient;
24
25 import org.junit.Assert;
26 import org.junit.Ignore;
27 import org.junit.Test;
28
29
30
31
32 public class ServiceLocatorTest {
33
34 @Test @Ignore
35 public void testRoundRobin() {
36 try {
37 List<String> eprs = new ArrayList<String>();
38 eprs.add("epr1");
39 eprs.add("epr2");
40 eprs.add("epr3");
41
42
43 Properties properties = new Properties();
44 ServiceLocator locator = new ServiceLocator(null, new URLLocalizerDefaultImpl(), properties);
45 System.out.println(locator);
46 locator.shutdown();
47 } catch (Exception e) {
48 e.printStackTrace();
49 Assert.fail(e.getMessage());
50
51 }
52
53 }
54
55 @Test
56 public void testJUDDI_939() throws Exception {
57 UDDIClient uddiClient = new UDDIClient();
58 ServiceLocator serviceLocator = uddiClient.getServiceLocator("default");
59 Assert.assertNotNull(serviceLocator);
60 serviceLocator.setPolicy(PolicyRoundRobin.class.getName());
61
62 }
63
64 @Test(expected = ConfigurationException.class)
65 public void testJUDDI_939_1() throws Exception {
66 UDDIClient uddiClient = new UDDIClient();
67 ServiceLocator serviceLocator = uddiClient.getServiceLocator(UUID.randomUUID().toString());
68 Assert.fail();
69 }
70
71
72
73
74
75
76 @Ignore
77 @Test
78 public void testJUDDI_939_2() throws Exception {
79 String uddiServiceId = "uddi:juddi.apache.org:services-inquiry";
80 try {
81 UDDIClient uddiClient = new UDDIClient();
82 ServiceLocator serviceLocator = uddiClient.getServiceLocator("default8080");
83 serviceLocator.setPolicy(PolicyRoundRobin.class.getName());
84
85 String endpoint = serviceLocator.lookupEndpoint(uddiServiceId);
86 Assert.assertNotNull(endpoint);
87
88 String endpoint2 = serviceLocator.lookupEndpoint(uddiServiceId);
89 Assert.assertNotNull(endpoint2);
90 Assert.assertNotEquals(endpoint2, endpoint);
91
92 } catch (Exception e) {
93 throw new Exception("Could not resolve endpoint '" + uddiServiceId + "'.", e);
94 }
95
96 }
97
98
99
100 }