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