This project has retired. For details please refer to its
Attic page.
API_141_JIRATest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.api.impl;
16
17 import java.security.cert.CertificateException;
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.UUID;
21 import java.util.concurrent.atomic.AtomicReference;
22
23 import javax.xml.soap.SOAPFault;
24
25 import org.apache.commons.configuration.ConfigurationException;
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.juddi.Registry;
29 import org.apache.juddi.api_v3.GetEntityHistoryMessageRequest;
30 import org.apache.juddi.api_v3.GetEntityHistoryMessageResponse;
31 import org.apache.juddi.api_v3.SubscriptionWrapper;
32 import org.apache.juddi.jaxb.PrintUDDI;
33 import org.apache.juddi.v3.client.UDDIConstants;
34 import org.apache.juddi.v3.client.config.UDDIClient;
35 import org.apache.juddi.v3.client.cryptor.DigSigUtil;
36 import org.apache.juddi.v3.error.ValueNotAllowedException;
37 import org.apache.juddi.v3.tck.TckBusiness;
38 import org.apache.juddi.v3.tck.TckBusinessService;
39 import org.apache.juddi.v3.tck.TckPublisher;
40 import org.apache.juddi.v3.tck.TckSecurity;
41 import org.apache.juddi.v3.tck.TckTModel;
42 import org.junit.AfterClass;
43 import org.junit.Assert;
44 import org.junit.BeforeClass;
45 import org.junit.Test;
46 import org.uddi.api_v3.AccessPoint;
47 import org.uddi.api_v3.BindingTemplate;
48 import org.uddi.api_v3.BindingTemplates;
49 import org.uddi.api_v3.BusinessDetail;
50 import org.uddi.api_v3.BusinessEntity;
51 import org.uddi.api_v3.BusinessInfos;
52 import org.uddi.api_v3.BusinessList;
53 import org.uddi.api_v3.BusinessService;
54 import org.uddi.api_v3.BusinessServices;
55 import org.uddi.api_v3.CategoryBag;
56 import org.uddi.api_v3.Contacts;
57 import org.uddi.api_v3.DeleteBusiness;
58 import org.uddi.api_v3.DeleteTModel;
59 import org.uddi.api_v3.Description;
60 import org.uddi.api_v3.FindBusiness;
61 import org.uddi.api_v3.FindQualifiers;
62 import org.uddi.api_v3.FindService;
63 import org.uddi.api_v3.FindTModel;
64 import org.uddi.api_v3.GetBusinessDetail;
65 import org.uddi.api_v3.KeyedReference;
66 import org.uddi.api_v3.Name;
67 import org.uddi.api_v3.SaveBinding;
68 import org.uddi.api_v3.SaveBusiness;
69 import org.uddi.api_v3.SaveService;
70 import org.uddi.api_v3.SaveTModel;
71 import org.uddi.api_v3.ServiceDetail;
72 import org.uddi.api_v3.ServiceInfos;
73 import org.uddi.api_v3.ServiceList;
74 import org.uddi.api_v3.TModel;
75 import org.uddi.api_v3.TModelDetail;
76 import org.uddi.api_v3.TModelList;
77 import org.uddi.v3_service.DispositionReportFaultMessage;
78 import org.uddi.v3_service.UDDIInquiryPortType;
79 import org.uddi.v3_service.UDDIPublicationPortType;
80 import org.uddi.v3_service.UDDISecurityPortType;
81
82
83
84
85
86
87
88
89
90 public class API_141_JIRATest {
91
92 private static Log logger = LogFactory.getLog(API_141_JIRATest.class);
93 static UDDISecurityPortType security = new UDDISecurityImpl();
94 static UDDIInquiryPortType inquiry = new UDDIInquiryImpl();
95 static UDDIPublicationPortType publication = new UDDIPublicationImpl();
96 static TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
97 protected static String authInfoJoe = null;
98 protected static String authInfoSam = null;
99 private static UDDIClient manager;
100 static final String str256 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
101 static final String str255 = "uddi:tmodelkey:categories:1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
102 static final String strkey256 = "uddi:tmodelkey:categories:11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
103 static final String strkey256_1 = "uddi:org.apache:omething.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.something.somethi.com";
104 static final String str26 = "11111111111111111111111111";
105 static final String str27 = "111111111111111111111111110";
106 static final String str10 = "0123456789";
107 static final String str11 = "01234567890";
108 static final String str80 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
109 static final String str81 = "012345678901234567890123456789012345678901234567890123456789012345678901234567891";
110 static final String TRANS = "The transaction has been rolled back";
111 static final String str4096 = "12345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000XXXXXXXX";
112 static final String str4097 = "12345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012345670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234567000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000XXXXXXXXZ";
113 static final String str51 = "111111111111111111111111111111111111111111111111111";
114 static final String str50 = "11111111111111111111111111111111111111111111111111";
115 static final String MISSING_RESOURCE = "Can't find resource for bundle";
116
117 @AfterClass
118 public static void stopManager() throws ConfigurationException {
119 Registry.stop();
120 }
121
122 @BeforeClass
123 public static void startManager() throws ConfigurationException {
124 Registry.start();
125
126 logger.debug("Getting auth tokens..");
127 try {
128 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
129 authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
130 Assert.assertNotNull(authInfoJoe);
131 Assert.assertNotNull(authInfoSam);
132 String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
133 tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
134 tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
135 tckTModel.saveJoePublisherTmodel(authInfoJoe);
136 } catch (Exception e) {
137 logger.error(e.getMessage(), e);
138 Assert.fail("Could not obtain authInfo token.");
139 }
140 }
141
142 static void HandleException(Exception ex) {
143 System.err.println("Error caught of type " + ex.getClass().getCanonicalName());
144 ex.printStackTrace();
145 if (ex.getMessage() != null) {
146 Assert.assertFalse(ex.getMessage().contains(TRANS));
147 Assert.assertFalse(ex.getMessage().contains(MISSING_RESOURCE));
148 }
149 if (ex instanceof SOAPFault) {
150 SOAPFault sf = (SOAPFault) ex;
151 if (!sf.getTextContent().contains("org.apache.juddi.v3.error.ValueNotAllowedException")) {
152 Assert.fail();
153 }
154 }
155 }
156
157 @Test
158 public void JUDDI_JIRA_571_Part1_Test() {
159
160
161
162
163 List<String> businesskeysToDelete = new ArrayList<String>();
164 String failuremsg = "";
165 System.out.println("JUDDI_JIRA_571_Part1_Test");
166 SaveBusiness sb = new SaveBusiness();
167 sb.setAuthInfo(authInfoJoe);
168 BusinessEntity be = new BusinessEntity();
169 be.setBusinessKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
170 Name n = new Name();
171 n.setValue("JUDDI_JIRA_571_Part1_Test no lang");
172 be.getName().add(n);
173 sb.getBusinessEntity().add(be);
174
175 be = new BusinessEntity();
176 be.setBusinessKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
177 n = new Name();
178 n.setValue("JUDDI_JIRA_571_Part1_Test with lang");
179 n.setLang("en");
180 be.getName().add(n);
181 sb.getBusinessEntity().add(be);
182 try {
183 BusinessDetail saveBusiness = publication.saveBusiness(sb);
184 businesskeysToDelete.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
185 businesskeysToDelete.add(saveBusiness.getBusinessEntity().get(1).getBusinessKey());
186
187 } catch (Exception ex) {
188 HandleException(ex);
189 Assert.fail("unexpected failure");
190 }
191
192 int found1 = 0;
193 FindBusiness fb = new FindBusiness();
194 fb.setAuthInfo(authInfoJoe);
195 n = new Name();
196 n.setValue("%");
197 fb.getName().add(n);
198 fb.setFindQualifiers(new FindQualifiers());
199 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
200 try {
201 BusinessList findBusiness = inquiry.findBusiness(fb);
202 if (findBusiness.getBusinessInfos() != null) {
203 for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
204 if (businesskeysToDelete.contains(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey())) {
205 found1++;
206 }
207 }
208 }
209 } catch (Exception ex) {
210 HandleException(ex);
211 Assert.fail("unexpected failure");
212 }
213 if (found1 != 2) {
214 failuremsg += "No lang defined, " + found1 + " records found instead of 2";
215 }
216
217
218
219 found1 = 0;
220 fb = new FindBusiness();
221 fb.setAuthInfo(authInfoJoe);
222 n = new Name();
223 n.setLang("en");
224 n.setValue("%");
225 fb.getName().add(n);
226 fb.setFindQualifiers(new FindQualifiers());
227 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
228 try {
229 BusinessList findBusiness = inquiry.findBusiness(fb);
230 if (findBusiness.getBusinessInfos() != null) {
231 for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
232 if (businesskeysToDelete.contains(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey())) {
233 found1++;
234 }
235 }
236 }
237 } catch (Exception ex) {
238 HandleException(ex);
239 Assert.fail("unexpected failure");
240 }
241 if (found1 != 1) {
242 failuremsg += "Lang defined, " + found1 + " records found instead of 1";
243 }
244
245
246 DeleteBusinesses(businesskeysToDelete);
247 if (failuremsg.length() > 0) {
248 Assert.fail(failuremsg);
249 }
250 System.out.println("Pass");
251
252 }
253
254 @Test
255 public void JUDDI_JIRA_571_Part2_Test() {
256
257
258
259
260
261
262
263 List<String> businesskeysToDelete = new ArrayList<String>();
264 List<String> targetServiceKeys = new ArrayList<String>();
265 String failuremsg = "";
266 System.out.println("JUDDI_JIRA_571_Part2_Test");
267 SaveBusiness sb = new SaveBusiness();
268 sb.setAuthInfo(authInfoJoe);
269 BusinessEntity be = new BusinessEntity();
270 be.setBusinessKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
271 Name n = new Name();
272 n.setValue("JUDDI_JIRA_571_Part2_Test no lang");
273 be.getName().add(n);
274 sb.getBusinessEntity().add(be);
275
276 BusinessService bs = new BusinessService();
277 n = new Name();
278 bs.setServiceKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
279 bs.setBusinessKey(be.getBusinessKey());
280 n.setValue("Service1 No Lang");
281 bs.getName().add(n);
282 be.setBusinessServices(new BusinessServices());
283 be.getBusinessServices().getBusinessService().add(bs);
284
285 bs = new BusinessService();
286 bs.setServiceKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
287 bs.setBusinessKey(be.getBusinessKey());
288 n = new Name();
289 n.setValue("Service2 Lang");
290 n.setLang("en");
291 bs.getName().add(n);
292 be.getBusinessServices().getBusinessService().add(bs);
293 try {
294 BusinessDetail saveBusiness = publication.saveBusiness(sb);
295 businesskeysToDelete.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
296 targetServiceKeys.add(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey());
297 targetServiceKeys.add(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(1).getServiceKey());
298
299 } catch (Exception ex) {
300 HandleException(ex);
301 Assert.fail("unexpected failure");
302 }
303
304 int found1 = 0;
305 FindService fb = new FindService();
306 fb.setAuthInfo(authInfoJoe);
307 n = new Name();
308 n.setValue("%");
309 fb.getName().add(n);
310 fb.setFindQualifiers(new FindQualifiers());
311 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
312 try {
313 ServiceList findBusiness = inquiry.findService(fb);
314 if (findBusiness.getServiceInfos() != null) {
315 for (int i = 0; i < findBusiness.getServiceInfos().getServiceInfo().size(); i++) {
316 if (targetServiceKeys.contains(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey())) {
317 found1++;
318 }
319 }
320 }
321 } catch (Exception ex) {
322 HandleException(ex);
323 Assert.fail("unexpected failure");
324 }
325 if (found1 != 2) {
326 failuremsg += "No lang defined, " + found1 + " records found instead of 2";
327 }
328
329
330
331 found1 = 0;
332 fb = new FindService();
333 fb.setAuthInfo(authInfoJoe);
334 n = new Name();
335 n.setLang("en");
336 n.setValue("%");
337 fb.getName().add(n);
338 fb.setFindQualifiers(new FindQualifiers());
339 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
340 try {
341 ServiceList findBusiness = inquiry.findService(fb);
342 if (findBusiness.getServiceInfos() != null) {
343 for (int i = 0; i < findBusiness.getServiceInfos().getServiceInfo().size(); i++) {
344 if (businesskeysToDelete.contains(findBusiness.getServiceInfos().getServiceInfo().get(i).getBusinessKey())) {
345 found1++;
346 }
347 }
348 }
349 } catch (Exception ex) {
350 HandleException(ex);
351 Assert.fail("unexpected failure");
352 }
353 if (found1 != 1) {
354 failuremsg += "Lang defined, " + found1 + " records found instead of 1";
355 }
356
357
358 DeleteBusinesses(businesskeysToDelete);
359 if (failuremsg.length() > 0) {
360 Assert.fail(failuremsg);
361 }
362 System.out.println("Pass");
363
364 }
365
366 @Test
367 public void JUDDI_571_Part3_Test() {
368
369
370
371
372
373
374 List<String> businesskeysToDelete = new ArrayList<String>();
375
376 String failuremsg = "";
377 System.out.println("JUDDI_571_Part3_Test");
378 SaveTModel sb = new SaveTModel();
379 sb.setAuthInfo(authInfoJoe);
380 TModel be = new TModel();
381 be.setTModelKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
382 Name n = new Name();
383 n.setValue("JUDDI_571_Part3_Test no lang");
384 be.setName(n);
385 sb.getTModel().add(be);
386
387 be = new TModel();
388 be.setTModelKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
389 n = new Name();
390 n.setValue("JUDDI_571_Part3_Test lang");
391 n.setLang("en");
392 be.setName(n);
393 sb.getTModel().add(be);
394
395 try {
396 TModelDetail saveTModel = publication.saveTModel(sb);
397 businesskeysToDelete.add(saveTModel.getTModel().get(0).getTModelKey());
398 businesskeysToDelete.add(saveTModel.getTModel().get(1).getTModelKey());
399 } catch (Exception ex) {
400 HandleException(ex);
401 Assert.fail("unexpected failure");
402 }
403
404 int found1 = 0;
405 FindTModel fb = new FindTModel();
406 fb.setAuthInfo(authInfoJoe);
407 n = new Name();
408 n.setValue("%JUDDI_571_Part3_Test%");
409 fb.setName(n);
410 fb.setFindQualifiers(new FindQualifiers());
411 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
412 try {
413 TModelList findTModel = inquiry.findTModel(fb);
414 if (findTModel.getTModelInfos() != null) {
415 for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
416 if (businesskeysToDelete.contains(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey())) {
417 found1++;
418 }
419 }
420 }
421 } catch (Exception ex) {
422 HandleException(ex);
423 Assert.fail("unexpected failure");
424 }
425 if (found1 != 2) {
426 failuremsg += "No lang defined, " + found1 + " records found instead of 2";
427 }
428
429
430
431 found1 = 0;
432 fb = new FindTModel();
433 fb.setAuthInfo(authInfoJoe);
434 n = new Name();
435 n.setLang("en");
436 n.setValue("%JUDDI_571_Part3_Test%");
437 fb.setName(n);
438 fb.setFindQualifiers(new FindQualifiers());
439 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
440 try {
441 TModelList findTModel = inquiry.findTModel(fb);
442 if (findTModel.getTModelInfos() != null) {
443 for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
444 if (businesskeysToDelete.contains(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey())) {
445 found1++;
446 }
447 }
448 }
449 } catch (Exception ex) {
450 HandleException(ex);
451 Assert.fail("unexpected failure");
452 }
453 if (found1 != 1) {
454 failuremsg += "Lang defined, " + found1 + " records found instead of 1";
455 }
456
457
458 DeleteTModels(businesskeysToDelete);
459 if (failuremsg.length() > 0) {
460 Assert.fail(failuremsg);
461 }
462 System.out.println("Pass");
463
464 }
465
466 @Test
467 public void JUDDI_574() {
468
469
470
471
472
473
474 List<String> businesskeysToDelete = new ArrayList<String>();
475
476 String failuremsg = "";
477 System.out.println("JUDDI_574");
478 SaveTModel sb = new SaveTModel();
479 sb.setAuthInfo(authInfoJoe);
480 TModel be = new TModel();
481 be.setTModelKey(TckTModel.JOE_PUBLISHER_KEY_PREFIX + UUID.randomUUID().toString());
482 Name n = new Name();
483 n.setValue("JUDDI_574");
484 n.setLang("en");
485 be.setName(n);
486 sb.getTModel().add(be);
487
488 try {
489 TModelDetail saveTModel = publication.saveTModel(sb);
490 businesskeysToDelete.add(saveTModel.getTModel().get(0).getTModelKey());
491 System.out.println("tmodel created with key " + saveTModel.getTModel().get(0).getTModelKey());
492 } catch (Exception ex) {
493 HandleException(ex);
494 Assert.fail("unexpected failure");
495 }
496 int found1 = 0;
497 FindTModel fb = new FindTModel();
498 fb.setAuthInfo(authInfoJoe);
499 n = new Name();
500 n.setValue("JUDDI_574");
501 fb.setName(n);
502 fb.setFindQualifiers(new FindQualifiers());
503 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
504 try {
505 TModelList findTModel = inquiry.findTModel(fb);
506 if (findTModel.getTModelInfos() != null) {
507 for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
508 if (businesskeysToDelete.contains(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey())) {
509 found1++;
510 if (findTModel.getTModelInfos().getTModelInfo().get(i).getName() == null
511 || findTModel.getTModelInfos().getTModelInfo().get(i).getName().getLang() == null
512 || findTModel.getTModelInfos().getTModelInfo().get(i).getName().getLang().length() == 0) {
513 failuremsg += "Tmodel key " + findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey()
514 + " has a null or empty lang";
515 }
516 }
517
518 }
519 }
520 } catch (Exception ex) {
521 HandleException(ex);
522 Assert.fail("unexpected failure");
523 }
524 if (found1 != 1) {
525 failuremsg += "found " + found1 + " records found instead of 1";
526 }
527
528 DeleteTModels(businesskeysToDelete);
529 if (failuremsg.length() > 0) {
530 Assert.fail(failuremsg);
531 }
532 System.out.println("Pass");
533
534 }
535
536
537
538
539
540
541
542
543
544
545
546 public static String CatBagToString(CategoryBag categoryBag) {
547 StringBuilder sb = new StringBuilder();
548 if (categoryBag == null) {
549 return "no data";
550 }
551 for (int i = 0; i < categoryBag.getKeyedReference().size(); i++) {
552 sb.append(KeyedReferenceToString(categoryBag.getKeyedReference().get(i)));
553 }
554 for (int i = 0; i < categoryBag.getKeyedReferenceGroup().size(); i++) {
555 sb.append("Key Ref Grp: TModelKey=");
556 for (int k = 0; k < categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().size(); k++) {
557 sb.append(KeyedReferenceToString(categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().get(k)));
558 }
559 }
560 return sb.toString();
561 }
562
563 public static String KeyedReferenceToString(KeyedReference item) {
564 StringBuilder sb = new StringBuilder();
565 sb.append("Key Ref: Name=").
566 append(item.getKeyName()).
567 append(" Value=").
568 append(item.getKeyValue()).
569 append(" tModel=").
570 append(item.getTModelKey()).
571 append(System.getProperty("line.separator"));
572 return sb.toString();
573 }
574
575 public static void PrintContacts(Contacts contacts) {
576 if (contacts == null) {
577 return;
578 }
579 for (int i = 0; i < contacts.getContact().size(); i++) {
580 System.out.println("Contact " + i + " type:" + contacts.getContact().get(i).getUseType());
581 for (int k = 0; k < contacts.getContact().get(i).getPersonName().size(); k++) {
582 System.out.println("Name: " + contacts.getContact().get(i).getPersonName().get(k).getValue());
583 }
584 for (int k = 0; k < contacts.getContact().get(i).getEmail().size(); k++) {
585 System.out.println("Email: " + contacts.getContact().get(i).getEmail().get(k).getValue());
586 }
587 for (int k = 0; k < contacts.getContact().get(i).getAddress().size(); k++) {
588 System.out.println("Address sort code " + contacts.getContact().get(i).getAddress().get(k).getSortCode());
589 System.out.println("Address use type " + contacts.getContact().get(i).getAddress().get(k).getUseType());
590 System.out.println("Address tmodel key " + contacts.getContact().get(i).getAddress().get(k).getTModelKey());
591 for (int x = 0; x < contacts.getContact().get(i).getAddress().get(k).getAddressLine().size(); x++) {
592 System.out.println("Address line value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getValue());
593 System.out.println("Address line key name " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyName());
594 System.out.println("Address line key value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyValue());
595 }
596 }
597 for (int k = 0; k < contacts.getContact().get(i).getDescription().size(); k++) {
598 System.out.println("Desc: " + contacts.getContact().get(i).getDescription().get(k).getValue());
599 }
600 for (int k = 0; k < contacts.getContact().get(i).getPhone().size(); k++) {
601 System.out.println("Phone: " + contacts.getContact().get(i).getPhone().get(k).getValue());
602 }
603 }
604
605 }
606
607
608
609
610
611
612
613 public static void PrintBindingTemplates(BindingTemplates bindingTemplates) {
614 if (bindingTemplates == null) {
615 return;
616 }
617 for (int i = 0; i < bindingTemplates.getBindingTemplate().size(); i++) {
618 System.out.println("Binding Key: " + bindingTemplates.getBindingTemplate().get(i).getBindingKey());
619
620 if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint() != null) {
621 System.out.println("Access Point: " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getValue() + " type " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType());
622 }
623
624 if (bindingTemplates.getBindingTemplate().get(i).getHostingRedirector() != null) {
625 System.out.println("Hosting Redirection: " + bindingTemplates.getBindingTemplate().get(i).getHostingRedirector().getBindingKey());
626 }
627 }
628 }
629
630 public static void PrintBusinessInfo(BusinessInfos businessInfos) {
631 if (businessInfos == null) {
632 System.out.println("No data returned");
633 } else {
634 for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) {
635 System.out.println("===============================================");
636 System.out.println("Business Key: " + businessInfos.getBusinessInfo().get(i).getBusinessKey());
637 System.out.println("Name: " + ListToString(businessInfos.getBusinessInfo().get(i).getName()));
638
639 System.out.println("Name: " + ListToDescString(businessInfos.getBusinessInfo().get(i).getDescription()));
640 System.out.println("Services:");
641 PrintServiceInfo(businessInfos.getBusinessInfo().get(i).getServiceInfos());
642 }
643 }
644 }
645
646 public static String ListToString(List<Name> name) {
647 StringBuilder sb = new StringBuilder();
648 for (int i = 0; i < name.size(); i++) {
649 sb.append(name.get(i).getValue()).append(" ");
650 }
651 return sb.toString();
652 }
653
654 public static String ListToDescString(List<Description> name) {
655 StringBuilder sb = new StringBuilder();
656 for (int i = 0; i < name.size(); i++) {
657 sb.append(name.get(i).getValue()).append(" ");
658 }
659 return sb.toString();
660 }
661
662 public static void PrintServiceInfo(ServiceInfos serviceInfos) {
663 for (int i = 0; i < serviceInfos.getServiceInfo().size(); i++) {
664 System.out.println("-------------------------------------------");
665 System.out.println("Service Key: " + serviceInfos.getServiceInfo().get(i).getServiceKey());
666 System.out.println("Owning Business Key: " + serviceInfos.getServiceInfo().get(i).getBusinessKey());
667 System.out.println("Name: " + ListToString(serviceInfos.getServiceInfo().get(i).getName()));
668 }
669 }
670
671 public static void PrintBusinessDetails(List<BusinessEntity> businessDetail) throws Exception {
672
673
674 for (int i = 0; i < businessDetail.size(); i++) {
675 System.out.println("Business Detail - key: " + businessDetail.get(i).getBusinessKey());
676 System.out.println("Name: " + ListToString(businessDetail.get(i).getName()));
677 System.out.println("CategoryBag: " + CatBagToString(businessDetail.get(i).getCategoryBag()));
678 PrintContacts(businessDetail.get(i).getContacts());
679 }
680 }
681
682
683 private void DeleteBusinesses(List<String> businesskeysToDelete) {
684
685
686
687 try {
688 DeleteBusiness db = new DeleteBusiness();
689 db.setAuthInfo(authInfoJoe);
690 db.getBusinessKey().addAll(businesskeysToDelete);
691 publication.deleteBusiness(db);
692 } catch (Exception ex) {
693 ex.printStackTrace();
694 }
695 }
696
697 private void DeleteTModels(List<String> businesskeysToDelete) {
698
699
700 try {
701 DeleteTModel db = new DeleteTModel();
702 db.setAuthInfo(authInfoJoe);
703 db.getTModelKey().addAll(businesskeysToDelete);
704 publication.deleteTModel(db);
705 } catch (Exception ex) {
706 ex.printStackTrace();
707 }
708 }
709
710 org.apache.juddi.v3.client.cryptor.DigSigUtil GetDigSig() throws CertificateException {
711 org.apache.juddi.v3.client.cryptor.DigSigUtil ds = new DigSigUtil();
712 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE, "./src/test/resources/keystore.jks");
713 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE, "JKS");
714 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, "Test");
715 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "Test");
716 ds.put(DigSigUtil.TRUSTSTORE_FILE, "./src/test/resources/truststore.jks");
717 ds.put(DigSigUtil.TRUSTSTORE_FILETYPE, "JKS");
718 ds.put(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, "Test");
719 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
720 return ds;
721 }
722
723 @Test()
724 public void JUDDI_712_SaveBusinessProjectionWithSignature() throws CertificateException {
725 SaveBusiness sb = new SaveBusiness();
726 sb.setAuthInfo(authInfoJoe);
727 BusinessEntity be = new BusinessEntity();
728 Name n = new Name();
729 n.setValue("JUDDI_JUDDI_712_SaveBusinessProjectionWithSignature");
730 be.getName().add(n);
731 DigSigUtil ds = GetDigSig();
732 be = ds.signUddiEntity(be);
733 sb.getBusinessEntity().add(be);
734 try {
735 BusinessDetail saveBusiness = publication.saveBusiness(sb);
736 Assert.fail("unexpected success");
737 } catch (Exception ex) {
738 logger.info("Expected failure: " + ex.getMessage());
739 }
740 }
741
742 @Test()
743 public void JUDDI_712_SaveBusinessProjectionNoServiceKeyWithSignature() throws CertificateException {
744 SaveBusiness sb = new SaveBusiness();
745 sb.setAuthInfo(authInfoJoe);
746 BusinessEntity be = new BusinessEntity();
747 Name n = new Name();
748 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKeyWithSignature");
749 be.getName().add(n);
750 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
751
752
753 BusinessService bs = new BusinessService();
754 bs.getName().add(new Name("Joe's bs", null));
755 be.setBusinessServices(new BusinessServices());
756 be.getBusinessServices().getBusinessService().add(bs);
757
758 DigSigUtil ds = GetDigSig();
759 be = ds.signUddiEntity(be);
760 sb.getBusinessEntity().add(be);
761 try {
762 BusinessDetail saveBusiness = publication.saveBusiness(sb);
763 Assert.fail("unexpected success");
764 } catch (Exception ex) {
765 logger.info("Expected failure: " + ex.getMessage());
766 }
767 }
768
769 @Test()
770 public void JUDDI_712_SaveBusinessProjectionNoServiceKey2WithSignature() throws CertificateException {
771 SaveBusiness sb = new SaveBusiness();
772 sb.setAuthInfo(authInfoJoe);
773 BusinessEntity be = new BusinessEntity();
774 Name n = new Name();
775 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKey2WithSignature");
776 be.getName().add(n);
777 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
778
779
780 BusinessService bs = new BusinessService();
781 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
782 bs.getName().add(new Name("Joe's bs", null));
783 be.setBusinessServices(new BusinessServices());
784 be.getBusinessServices().getBusinessService().add(bs);
785
786 DigSigUtil ds = GetDigSig();
787 be = ds.signUddiEntity(be);
788 sb.getBusinessEntity().add(be);
789 try {
790 BusinessDetail saveBusiness = publication.saveBusiness(sb);
791 Assert.fail("unexpected success");
792 } catch (Exception ex) {
793 logger.info("Expected failure: " + ex.getMessage());
794 }
795 }
796
797 @Test()
798 public void JUDDI_712_SaveBusinessProjectionNoServiceKey3WithSignature() throws CertificateException {
799 SaveBusiness sb = new SaveBusiness();
800 sb.setAuthInfo(authInfoJoe);
801 BusinessEntity be = new BusinessEntity();
802 Name n = new Name();
803 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKey3WithSignature");
804 be.getName().add(n);
805 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
806
807
808 BusinessService bs = new BusinessService();
809
810 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
811 bs.getName().add(new Name("Joe's bs", null));
812 be.setBusinessServices(new BusinessServices());
813 be.getBusinessServices().getBusinessService().add(bs);
814
815 DigSigUtil ds = GetDigSig();
816 be = ds.signUddiEntity(be);
817 sb.getBusinessEntity().add(be);
818 try {
819 BusinessDetail saveBusiness = publication.saveBusiness(sb);
820 Assert.fail("unexpected success");
821 } catch (Exception ex) {
822 logger.info("Expected failure: " + ex.getMessage());
823 }
824 }
825
826 @Test()
827 public void JUDDI_712_SaveServiceProjectionNoServiceKey3WithSignature() throws CertificateException {
828 SaveBusiness sb = new SaveBusiness();
829 sb.setAuthInfo(authInfoJoe);
830 BusinessEntity be = new BusinessEntity();
831 Name n = new Name();
832 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey3WithSignature");
833 be.getName().add(n);
834 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
835
836
837 BusinessService bs = new BusinessService();
838 bs.setBusinessKey(null);
839 bs.setServiceKey(null);
840 bs.getName().add(new Name("Joe's bs", null));
841 DigSigUtil ds = GetDigSig();
842 bs = ds.signUddiEntity(bs);
843
844 be.setBusinessServices(new BusinessServices());
845 be.getBusinessServices().getBusinessService().add(bs);
846
847
848 sb.getBusinessEntity().add(be);
849 try {
850 BusinessDetail saveBusiness = publication.saveBusiness(sb);
851 Assert.fail("unexpected success");
852 } catch (Exception ex) {
853 logger.info("Expected failure: " + ex.getMessage());
854 }
855 }
856
857 @Test()
858 public void JUDDI_712_SaveServiceProjectionNoServiceKey1WithSignature() throws CertificateException {
859 SaveBusiness sb = new SaveBusiness();
860 sb.setAuthInfo(authInfoJoe);
861 BusinessEntity be = new BusinessEntity();
862 Name n = new Name();
863 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey1WithSignature");
864 be.getName().add(n);
865 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
866
867
868 BusinessService bs = new BusinessService();
869 bs.setBusinessKey(null);
870 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
871 bs.getName().add(new Name("Joe's bs", null));
872 DigSigUtil ds = GetDigSig();
873 bs = ds.signUddiEntity(bs);
874
875 be.setBusinessServices(new BusinessServices());
876 be.getBusinessServices().getBusinessService().add(bs);
877
878
879 sb.getBusinessEntity().add(be);
880 try {
881 BusinessDetail saveBusiness = publication.saveBusiness(sb);
882 Assert.fail("unexpected success");
883 } catch (Exception ex) {
884 logger.info("Expected failure: " + ex.getMessage());
885 }
886 }
887
888 @Test()
889 public void JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature() throws CertificateException {
890 SaveBusiness sb = new SaveBusiness();
891 sb.setAuthInfo(authInfoJoe);
892 BusinessEntity be = new BusinessEntity();
893 Name n = new Name();
894 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature");
895 be.getName().add(n);
896 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
897
898
899 BusinessService bs = new BusinessService();
900 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
901 bs.setServiceKey(null);
902 bs.getName().add(new Name("Joe's bs", null));
903 DigSigUtil ds = GetDigSig();
904 bs = ds.signUddiEntity(bs);
905
906 be.setBusinessServices(new BusinessServices());
907 be.getBusinessServices().getBusinessService().add(bs);
908
909
910 sb.getBusinessEntity().add(be);
911 try {
912 BusinessDetail saveBusiness = publication.saveBusiness(sb);
913 Assert.fail("unexpected success");
914 } catch (Exception ex) {
915 logger.info("Expected failure: " + ex.getMessage());
916 }
917 }
918
919 @Test(expected = ValueNotAllowedException.class)
920 public void JUDDI_712_SaveBusinessNoneDefined() throws Exception {
921 SaveBusiness sb = new SaveBusiness();
922 sb.setAuthInfo(authInfoJoe);
923 BusinessEntity be = new BusinessEntity();
924 Name n = new Name();
925 n.setValue("JUDDI_712_SaveServiceWithSignature");
926 be.getName().add(n);
927 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
928
929 try {
930 BusinessDetail saveBusiness = publication.saveBusiness(sb);
931 Assert.fail("unexpected success");
932 } catch (Exception ex) {
933 logger.info("Expected failure: " + ex.getMessage());
934 throw ex;
935 }
936 }
937
938 @Test()
939 public void JUDDI_712_SaveServiceWithSignature() throws CertificateException {
940 SaveBusiness sb = new SaveBusiness();
941 sb.setAuthInfo(authInfoJoe);
942 BusinessEntity be = new BusinessEntity();
943 Name n = new Name();
944 n.setValue("JUDDI_712_SaveServiceWithSignature");
945 be.getName().add(n);
946 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
947 sb.getBusinessEntity().add(be);
948 try {
949 BusinessDetail saveBusiness = publication.saveBusiness(sb);
950 } catch (Exception ex) {
951 logger.info("UnExpected failure: ", ex);
952 Assert.fail();
953 }
954
955 SaveService ss = new SaveService();
956 ss.setAuthInfo(authInfoJoe);
957 BusinessService bs = new BusinessService();
958 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
959 bs.setServiceKey(null);
960 bs.getName().add(new Name("Joe's bs", null));
961 DigSigUtil ds = GetDigSig();
962 bs = ds.signUddiEntity(bs);
963
964 be.setBusinessServices(new BusinessServices());
965 be.getBusinessServices().getBusinessService().add(bs);
966
967
968 sb.getBusinessEntity().add(be);
969 try {
970 publication.saveService(ss);
971 Assert.fail("unexpected success");
972 } catch (Exception ex) {
973 logger.info("Expected failure: " + ex.getMessage());
974 }
975 }
976
977 @Test()
978 public void JUDDI_712_SaveService1WithSignature() throws CertificateException {
979 SaveBusiness sb = new SaveBusiness();
980 sb.setAuthInfo(authInfoJoe);
981 BusinessEntity be = new BusinessEntity();
982 Name n = new Name();
983 n.setValue("JUDDI_712_SaveService1WithSignature");
984 be.getName().add(n);
985 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
986 sb.getBusinessEntity().add(be);
987 try {
988 BusinessDetail saveBusiness = publication.saveBusiness(sb);
989 } catch (Exception ex) {
990 logger.info("UnExpected failure: ", ex);
991 Assert.fail();
992 }
993
994 SaveService ss = new SaveService();
995 ss.setAuthInfo(authInfoJoe);
996 BusinessService bs = new BusinessService();
997 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
998 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
999 bs.setBindingTemplates(new BindingTemplates());
1000 BindingTemplate bt = new BindingTemplate();
1001 bt.setBindingKey(null);
1002 bt.setServiceKey(null);
1003 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1004 bs.getBindingTemplates().getBindingTemplate().add(bt);
1005 bs.getName().add(new Name("Joe's bs", null));
1006 DigSigUtil ds = GetDigSig();
1007 bs = ds.signUddiEntity(bs);
1008
1009 be.setBusinessServices(new BusinessServices());
1010 be.getBusinessServices().getBusinessService().add(bs);
1011
1012
1013 sb.getBusinessEntity().add(be);
1014 try {
1015 publication.saveService(ss);
1016 Assert.fail("unexpected success");
1017 } catch (Exception ex) {
1018 logger.info("Expected failure: " + ex.getMessage());
1019 }
1020 }
1021
1022 @Test()
1023 public void JUDDI_712_SaveService2WithSignature() throws CertificateException {
1024 SaveBusiness sb = new SaveBusiness();
1025 sb.setAuthInfo(authInfoJoe);
1026 BusinessEntity be = new BusinessEntity();
1027 Name n = new Name();
1028 n.setValue("JUDDI_712_SaveService2WithSignature");
1029 be.getName().add(n);
1030 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1031 sb.getBusinessEntity().add(be);
1032 try {
1033 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1034 } catch (Exception ex) {
1035 logger.info("UnExpected failure: ", ex);
1036 Assert.fail();
1037 }
1038
1039 SaveService ss = new SaveService();
1040 ss.setAuthInfo(authInfoJoe);
1041 BusinessService bs = new BusinessService();
1042 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1043 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1044 bs.setBindingTemplates(new BindingTemplates());
1045 BindingTemplate bt = new BindingTemplate();
1046 bt.setBindingKey(null);
1047 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1048 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1049 bs.getBindingTemplates().getBindingTemplate().add(bt);
1050 bs.getName().add(new Name("Joe's bs", null));
1051 DigSigUtil ds = GetDigSig();
1052 bs = ds.signUddiEntity(bs);
1053
1054 be.setBusinessServices(new BusinessServices());
1055 be.getBusinessServices().getBusinessService().add(bs);
1056
1057
1058 sb.getBusinessEntity().add(be);
1059 try {
1060 publication.saveService(ss);
1061 Assert.fail("unexpected success");
1062 } catch (Exception ex) {
1063 logger.info("Expected failure: " + ex.getMessage());
1064 }
1065 }
1066
1067 @Test()
1068 public void JUDDI_712_SaveService3WithSignature() throws CertificateException {
1069 SaveBusiness sb = new SaveBusiness();
1070 sb.setAuthInfo(authInfoJoe);
1071 BusinessEntity be = new BusinessEntity();
1072 Name n = new Name();
1073 n.setValue("JUDDI_712_SaveService3WithSignature");
1074 be.getName().add(n);
1075 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1076 sb.getBusinessEntity().add(be);
1077 try {
1078 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1079 } catch (Exception ex) {
1080 logger.info("UnExpected failure: ", ex);
1081 Assert.fail();
1082 }
1083
1084 SaveService ss = new SaveService();
1085 ss.setAuthInfo(authInfoJoe);
1086 BusinessService bs = new BusinessService();
1087 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1088 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1089 bs.setBindingTemplates(new BindingTemplates());
1090 BindingTemplate bt = new BindingTemplate();
1091 bt.setBindingKey(TckBusinessService.JOE_BINDING_KEY_1);
1092 bt.setServiceKey(null);
1093 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1094 bs.getBindingTemplates().getBindingTemplate().add(bt);
1095 bs.getName().add(new Name("Joe's bs", null));
1096 DigSigUtil ds = GetDigSig();
1097 bs = ds.signUddiEntity(bs);
1098
1099 be.setBusinessServices(new BusinessServices());
1100 be.getBusinessServices().getBusinessService().add(bs);
1101
1102
1103 sb.getBusinessEntity().add(be);
1104 try {
1105 publication.saveService(ss);
1106 Assert.fail("unexpected success");
1107 } catch (Exception ex) {
1108 logger.info("Expected failure: " + ex.getMessage());
1109 }
1110 }
1111
1112 @Test()
1113 public void JUDDI_712_SaveTModelWithSignature() throws CertificateException {
1114 SaveTModel sb = new SaveTModel();
1115 sb.setAuthInfo(authInfoJoe);
1116 DigSigUtil ds = GetDigSig();
1117 TModel bs = new TModel();
1118 bs.setName(new Name("Joe's Tmodel", null));
1119 bs = ds.signUddiEntity(bs);
1120
1121
1122 sb.getTModel().add(bs);
1123 try {
1124 publication.saveTModel(sb);
1125 Assert.fail("unexpected success");
1126 } catch (Exception ex) {
1127 logger.info("Expected failure: " + ex.getMessage());
1128 }
1129 }
1130
1131 @Test()
1132 public void JUDDI_712_SaveService4BTWithSignature() throws CertificateException {
1133 SaveBusiness sb = new SaveBusiness();
1134 sb.setAuthInfo(authInfoJoe);
1135 BusinessEntity be = new BusinessEntity();
1136 Name n = new Name();
1137 n.setValue("JUDDI_712_SaveService4BTWithSignature");
1138 be.getName().add(n);
1139 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1140 sb.getBusinessEntity().add(be);
1141 try {
1142 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1143 } catch (Exception ex) {
1144 logger.info("UnExpected failure: ", ex);
1145 Assert.fail();
1146 }
1147
1148 SaveService ss = new SaveService();
1149 ss.setAuthInfo(authInfoJoe);
1150 BusinessService bs = new BusinessService();
1151 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1152 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1153 bs.setBindingTemplates(new BindingTemplates());
1154 BindingTemplate bt = new BindingTemplate();
1155 bt.setBindingKey(TckBusinessService.JOE_BINDING_KEY_1);
1156 bt.setServiceKey(null);
1157 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1158
1159 bs.getName().add(new Name("Joe's bs", null));
1160 DigSigUtil ds = GetDigSig();
1161 bt = ds.signUddiEntity(bt);
1162 bs.getBindingTemplates().getBindingTemplate().add(bt);
1163 be.setBusinessServices(new BusinessServices());
1164 be.getBusinessServices().getBusinessService().add(bs);
1165
1166
1167 sb.getBusinessEntity().add(be);
1168 try {
1169 publication.saveService(ss);
1170 Assert.fail("unexpected success");
1171 } catch (Exception ex) {
1172 logger.info("Expected failure: " + ex.getMessage());
1173 }
1174 }
1175
1176 @Test()
1177 public void JUDDI_712_SaveService5BTWithSignature() throws CertificateException {
1178 SaveBusiness sb = new SaveBusiness();
1179 sb.setAuthInfo(authInfoJoe);
1180 BusinessEntity be = new BusinessEntity();
1181 Name n = new Name();
1182 n.setValue("JUDDI_712_SaveService5BTWithSignature");
1183 be.getName().add(n);
1184 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1185 sb.getBusinessEntity().add(be);
1186 try {
1187 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1188 } catch (Exception ex) {
1189 logger.info("UnExpected failure: ", ex);
1190 Assert.fail();
1191 }
1192
1193 SaveService ss = new SaveService();
1194 ss.setAuthInfo(authInfoJoe);
1195 BusinessService bs = new BusinessService();
1196 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1197 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1198 bs.setBindingTemplates(new BindingTemplates());
1199 BindingTemplate bt = new BindingTemplate();
1200 bt.setBindingKey(null);
1201 bt.setServiceKey(null);
1202 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1203
1204 bs.getName().add(new Name("Joe's bs", null));
1205 DigSigUtil ds = GetDigSig();
1206 bt = ds.signUddiEntity(bt);
1207 bs.getBindingTemplates().getBindingTemplate().add(bt);
1208 be.setBusinessServices(new BusinessServices());
1209 be.getBusinessServices().getBusinessService().add(bs);
1210
1211
1212 sb.getBusinessEntity().add(be);
1213 try {
1214 publication.saveService(ss);
1215 Assert.fail("unexpected success");
1216 } catch (Exception ex) {
1217 logger.info("Expected failure: " + ex.getMessage());
1218 }
1219 }
1220
1221 @Test()
1222 public void JUDDI_712_SaveService6BTWithSignature() throws CertificateException {
1223 SaveBusiness sb = new SaveBusiness();
1224 sb.setAuthInfo(authInfoJoe);
1225 BusinessEntity be = new BusinessEntity();
1226 Name n = new Name();
1227 n.setValue("JUDDI_712_SaveService6BTWithSignature");
1228 be.getName().add(n);
1229 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1230 sb.getBusinessEntity().add(be);
1231 try {
1232 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1233 } catch (Exception ex) {
1234 logger.info("UnExpected failure: ", ex);
1235 Assert.fail();
1236 }
1237
1238 SaveService ss = new SaveService();
1239 ss.setAuthInfo(authInfoJoe);
1240 BusinessService bs = new BusinessService();
1241 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1242 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1243 bs.setBindingTemplates(new BindingTemplates());
1244 BindingTemplate bt = new BindingTemplate();
1245 bt.setBindingKey(null);
1246 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1247 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1248
1249 bs.getName().add(new Name("Joe's bs", null));
1250 DigSigUtil ds = GetDigSig();
1251 bt = ds.signUddiEntity(bt);
1252 bs.getBindingTemplates().getBindingTemplate().add(bt);
1253 be.setBusinessServices(new BusinessServices());
1254 be.getBusinessServices().getBusinessService().add(bs);
1255
1256
1257 sb.getBusinessEntity().add(be);
1258 try {
1259 publication.saveService(ss);
1260 Assert.fail("unexpected success");
1261 } catch (Exception ex) {
1262 logger.info("Expected failure: " + ex.getMessage());
1263 }
1264 }
1265
1266 @Test()
1267 public void JUDDI_712_SaveBusinessWithSignature() throws CertificateException {
1268 SaveBusiness sb = new SaveBusiness();
1269 sb.setAuthInfo(authInfoJoe);
1270 BusinessEntity be = new BusinessEntity();
1271 Name n = new Name();
1272 n.setValue("JUDDI_712_SaveBindingWithSignature");
1273 be.getName().add(n);
1274 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1275 sb.getBusinessEntity().add(be);
1276 try {
1277 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1278 } catch (Exception ex) {
1279 logger.info("UnExpected failure: ", ex);
1280 Assert.fail();
1281 }
1282
1283 SaveService ss = new SaveService();
1284 ss.setAuthInfo(authInfoJoe);
1285 BusinessService bs = new BusinessService();
1286 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1287 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1288 bs.getName().add(new Name("joe's service", null));
1289
1290
1291 be.setBusinessServices(new BusinessServices());
1292 be.getBusinessServices().getBusinessService().add(bs);
1293
1294
1295 sb.getBusinessEntity().add(be);
1296 ServiceDetail saveService = null;
1297 ss.getBusinessService().add(bs);
1298 try {
1299 saveService = publication.saveService(ss);
1300 } catch (Exception ex) {
1301
1302 Assert.fail("unexpected failure " + ex.getMessage() + ex.toString());
1303 }
1304
1305
1306 bs = saveService.getBusinessService().get(0);
1307 bs.setBindingTemplates(new BindingTemplates());
1308 BindingTemplate bt = new BindingTemplate();
1309 bt.setBindingKey(null);
1310 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
1311 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
1312
1313 bs.getName().add(new Name("Joe's bs", null));
1314 DigSigUtil ds = GetDigSig();
1315 bt = ds.signUddiEntity(bt);
1316 bs.getBindingTemplates().getBindingTemplate().add(bt);
1317
1318 try {
1319 SaveBinding sb1 = new SaveBinding();
1320 sb1.setAuthInfo(authInfoJoe);
1321 sb1.getBindingTemplate().add(bt);
1322 publication.saveBinding(sb1);
1323 Assert.fail("unexpected success");
1324 } catch (Exception ex) {
1325 logger.info("Expected failure: " + ex.getMessage());
1326 }
1327 }
1328
1329 @Test()
1330 public void JUDDI_716_SaveBusinessWithSignatureX509IssuerSerial() throws CertificateException {
1331 SaveBusiness sb = new SaveBusiness();
1332 sb.setAuthInfo(authInfoJoe);
1333 BusinessEntity be = new BusinessEntity();
1334 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
1335
1336 Name n = new Name();
1337 n.setValue("JUDDI_716_SaveBusinessWithSignatureX509IssuerSerial");
1338 be.getName().add(n);
1339 DigSigUtil ds = GetDigSig();
1340 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
1341 be = ds.signUddiEntity(be);
1342 sb.getBusinessEntity().add(be);
1343 try {
1344 BusinessDetail saveBusiness = publication.saveBusiness(sb);
1345 GetBusinessDetail gsb=new GetBusinessDetail();
1346 gsb.setAuthInfo(authInfoJoe);
1347 gsb.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
1348 BusinessDetail businessDetail = inquiry.getBusinessDetail(gsb);
1349 PrintUDDI<BusinessEntity> printer = new PrintUDDI<BusinessEntity>();
1350 System.out.println(printer.print(businessDetail.getBusinessEntity().get(0)));
1351 AtomicReference<String> msg = new AtomicReference<String>();
1352 boolean b=ds.verifySignedUddiEntity(businessDetail.getBusinessEntity().get(0), msg);
1353 Assert.assertTrue(msg.get(),b );
1354 Assert.assertTrue(msg.get()==null || msg.get().length()==0);
1355
1356 } catch (Exception ex) {
1357 logger.error("unExpected failure: ", ex);
1358 Assert.fail("unexpected failure");
1359 }
1360 }
1361
1362 @Test(expected = DispositionReportFaultMessage.class)
1363 public void testJUDDI907_ChangeHistory() throws Exception{
1364 JUDDIApiImpl j = new JUDDIApiImpl();
1365 j.getEntityHistory(null);
1366 Assert.fail();
1367 }
1368 @Test(expected = DispositionReportFaultMessage.class)
1369 public void testJUDDI907_ChangeHistory1() throws Exception{
1370 JUDDIApiImpl j = new JUDDIApiImpl();
1371 j.getEntityHistory(new GetEntityHistoryMessageRequest());
1372 Assert.fail();
1373 }
1374
1375 @Test(expected = DispositionReportFaultMessage.class)
1376 public void testJUDDI907_ChangeHistory2() throws Exception{
1377 JUDDIApiImpl j = new JUDDIApiImpl();
1378 GetEntityHistoryMessageRequest r = new GetEntityHistoryMessageRequest();
1379 r.setEntityKey(TckBusiness.JOE_BUSINESS_KEY);
1380 j.getEntityHistory(r);
1381 Assert.fail();
1382 }
1383
1384 @Test
1385 public void testJUDDI907_ChangeHistory3() throws Exception{
1386 TckBusiness tb = new TckBusiness(publication, inquiry);
1387 tb.saveJoePublisherBusiness(authInfoJoe);
1388 JUDDIApiImpl j = new JUDDIApiImpl();
1389 GetEntityHistoryMessageRequest r = new GetEntityHistoryMessageRequest();
1390 r.setEntityKey(TckBusiness.JOE_BUSINESS_KEY);
1391 r.setAuthInfo(authInfoJoe);
1392 GetEntityHistoryMessageResponse entityHistory = j.getEntityHistory(r);
1393 tb.deleteJoePublisherBusiness(authInfoJoe);
1394 Assert.assertNotNull(entityHistory);
1395 Assert.assertNotNull(entityHistory.getChangeRecords());
1396 Assert.assertFalse(entityHistory.getChangeRecords().getChangeRecord().isEmpty());
1397 }
1398
1399 @Test
1400 public void testJUDDI907_ChangeHistory4() throws Exception{
1401
1402 JUDDIApiImpl j = new JUDDIApiImpl();
1403 GetEntityHistoryMessageRequest r = new GetEntityHistoryMessageRequest();
1404 r.setEntityKey(UUID.randomUUID().toString());
1405 r.setAuthInfo(authInfoJoe);
1406 GetEntityHistoryMessageResponse entityHistory = j.getEntityHistory(r);
1407 Assert.assertNotNull(entityHistory);
1408 Assert.assertNotNull(entityHistory.getChangeRecords());
1409 Assert.assertTrue(entityHistory.getChangeRecords().getChangeRecord().isEmpty());
1410
1411 }
1412
1413
1414 @Test
1415 public void testJira996SubscriotionTest() throws Exception {
1416 JUDDIApiImpl j = new JUDDIApiImpl();
1417 List<SubscriptionWrapper> allClientSubscriptionInfo = j.getAllClientSubscriptionInfo(authInfoJoe);
1418 }
1419 }