This project has retired. For details please refer to its
Attic page.
UDDI_090_HttpMavenIntegrationTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.v3.tck;
17
18 import java.util.Iterator;
19 import java.util.Random;
20 import javax.xml.ws.Endpoint;
21 import org.apache.commons.configuration.ConfigurationException;
22 import org.junit.AfterClass;
23 import org.junit.Assert;
24 import org.junit.BeforeClass;
25
26
27
28
29
30 public class UDDI_090_HttpMavenIntegrationTest extends UDDI_090_SubscriptionListenerIntegrationBase {
31
32 private static Endpoint endPoint;
33 private static String hostname;
34 private static int port = 0;
35
36 @AfterClass
37 public static void stop() throws ConfigurationException {
38 if (!TckPublisher.isEnabled()) {
39 return;
40 }
41 stopManager();
42 endPoint.stop();
43 endPoint = null;
44
45 }
46
47 @BeforeClass
48 public static void startup() throws Exception {
49
50 if (!TckPublisher.isEnabled()) {
51 return;
52 }
53 startManager();
54 hostname = "localhost";
55
56 port = 9600;
57 String httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
58 logger.info("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
59 endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
60 int count = 0;
61 while (!endPoint.isPublished()) {
62 port = 9600 + new Random().nextInt(99);
63 httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
64 logger.info("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
65 endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
66 count++;
67 if (count > 10) {
68 Assert.fail("unable to bring up endpoint");
69 }
70 }
71 }
72
73 @Override
74 public boolean verifyDelivery(String findMe) {
75 for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
76 try {
77 Thread.sleep(1000);
78 } catch (InterruptedException ex) {
79 }
80 logger.info(".");
81
82 }
83 logger.info("RX " + UDDISubscriptionListenerImpl.notificationCount + " notifications");
84 Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
85 boolean found = false;
86
87 while (it.hasNext()) {
88 String test = it.next();
89 if (TckCommon.isDebug()) {
90 logger.info("Notification: " + test);
91 }
92 if (test.toLowerCase().contains(findMe.toLowerCase())) {
93 found = true;
94 }
95 }
96 if (!found) {
97 logger.error("_________________________________________________the test failed!!!");
98 it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
99 Thread.dumpStack();
100 while (it.hasNext()) {
101 logger.info("Notification: " + it.next());
102 }
103 }
104 return found;
105 }
106
107 @Override
108 public void reset() {
109 UDDISubscriptionListenerImpl.notifcationMap.clear();
110 UDDISubscriptionListenerImpl.notificationCount = 0;
111 }
112
113 @Override
114 public String getXMLLocationOfServiceForDelivery() {
115 return TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML;
116 }
117
118 @Override
119 public String getTransport() {
120 return "HTTP_MAVEN";
121 }
122
123 @Override
124 public int getPort() {
125 return port;
126 }
127
128 @Override
129 public String getHostame() {
130 return hostname;
131 }
132
133 @Override
134 public String getSubscription1XML() {
135 return TckSubscriptionListener.SUBSCRIPTION_XML;
136 }
137
138 @Override
139 public String getSubscription2XML() {
140 return TckSubscriptionListener.SUBSCRIPTION2_XML;
141 }
142
143 @Override
144 public String getSubscription3XML() {
145 return TckSubscriptionListener.SUBSCRIPTION3_XML;
146 }
147
148 @Override
149 public String getSubscriptionKey1() {
150 return TckSubscriptionListener.SUBSCRIPTION_KEY;
151 }
152
153 @Override
154 public String getSubscriptionKey2() {
155 return TckSubscriptionListener.SUBSCRIPTION_KEY;
156 }
157
158 @Override
159 public String getSubscriptionKey3() {
160 return TckSubscriptionListener.SUBSCRIPTION_KEY;
161 }
162
163 @Override
164 public boolean IsEnabled() {
165 return true;
166 }
167
168 }