This project has retired. For details please refer to its Attic page.
UDDI_090_SubscriptionListenerIntegrationBase xref
View Javadoc
1   /*
2    * Copyright 2014 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.v3.tck;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.UUID;
21  import javax.xml.bind.JAXB;
22  import javax.xml.datatype.DatatypeFactory;
23  import javax.xml.ws.BindingProvider;
24  import javax.xml.ws.Holder;
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.v3.client.UDDIConstants;
29  import org.apache.juddi.v3.client.config.UDDIClient;
30  import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
31  import org.apache.juddi.v3.client.transport.Transport;
32  import org.junit.Assert;
33  import org.junit.Assume;
34  import org.junit.Ignore;
35  import org.junit.Test;
36  import org.uddi.api_v3.AccessPoint;
37  import org.uddi.api_v3.AddPublisherAssertions;
38  import org.uddi.api_v3.BindingDetail;
39  import org.uddi.api_v3.BindingTemplate;
40  import org.uddi.api_v3.BindingTemplates;
41  import org.uddi.api_v3.BusinessEntity;
42  import org.uddi.api_v3.BusinessService;
43  import org.uddi.api_v3.CategoryBag;
44  import org.uddi.api_v3.CompletionStatus;
45  import org.uddi.api_v3.DeletePublisherAssertions;
46  import org.uddi.api_v3.Description;
47  import org.uddi.api_v3.FindBinding;
48  import org.uddi.api_v3.FindQualifiers;
49  import org.uddi.api_v3.FindRelatedBusinesses;
50  import org.uddi.api_v3.GetAssertionStatusReport;
51  import org.uddi.api_v3.GetBindingDetail;
52  import org.uddi.api_v3.GetBusinessDetail;
53  import org.uddi.api_v3.GetServiceDetail;
54  import org.uddi.api_v3.GetTModelDetail;
55  import org.uddi.api_v3.InstanceDetails;
56  import org.uddi.api_v3.KeyedReference;
57  import org.uddi.api_v3.Name;
58  import org.uddi.api_v3.PublisherAssertion;
59  import org.uddi.api_v3.SaveBinding;
60  import org.uddi.api_v3.SaveBusiness;
61  import org.uddi.api_v3.SaveService;
62  import org.uddi.api_v3.SaveTModel;
63  import org.uddi.api_v3.TModel;
64  import org.uddi.api_v3.TModelBag;
65  import org.uddi.api_v3.TModelInstanceDetails;
66  import org.uddi.api_v3.TModelInstanceInfo;
67  import org.uddi.sub_v3.DeleteSubscription;
68  import org.uddi.sub_v3.Subscription;
69  import org.uddi.sub_v3.SubscriptionFilter;
70  import org.uddi.v3_service.UDDIInquiryPortType;
71  import org.uddi.v3_service.UDDIPublicationPortType;
72  import org.uddi.v3_service.UDDISecurityPortType;
73  import org.uddi.v3_service.UDDISubscriptionPortType;
74  
75  /**
76   *
77   * @author Alex O'Ree
78   */
79  public abstract class UDDI_090_SubscriptionListenerIntegrationBase {
80  
81          protected static Log logger = LogFactory.getLog(UDDI_090_SubscriptionListenerIntegrationBase.class);
82          private static UDDISubscriptionPortType subscriptionMary = null;
83          private static UDDIInquiryPortType inquiryMary = null;
84          private static TckTModel tckTModelMary = null;
85          private static TckBusiness tckBusinessMary = null;
86          private static TckBusinessService tckBusinessServiceMary = null;
87          private static TckSubscriptionListener tckSubscriptionListenerMary = null;
88          private static String hostname = null;
89          private static UDDISubscriptionPortType subscriptionJoe = null;
90          private static UDDIInquiryPortType inquiryJoe = null;
91          private static UDDIPublicationPortType publicationMary = null;
92          private static UDDIPublicationPortType publicationJoe = null;
93          private static TckTModel tckTModelJoe = null;
94          private static TckBusiness tckBusinessJoe = null;
95          private static TckBusinessService tckBusinessServiceJoe = null;
96          private static TckSubscriptionListener tckSubscriptionListenerJoe = null;
97  
98          private static String authInfoJoe = null;
99          private static String authInfoMary = null;
100         private static UDDIClient manager;
101 
102         public static void stopManager() throws ConfigurationException {
103                 if (!TckPublisher.isEnabled()) {
104                         return;
105                 }
106                 tckTModelJoe.deleteCreatedTModels(authInfoJoe);
107                 tckTModelMary.deleteCreatedTModels(authInfoMary);
108                 manager.stop();
109                 //shutting down the TCK SubscriptionListener
110                 JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
111 
112         }
113 
114         public static void startManager() throws ConfigurationException {
115                 if (!TckPublisher.isEnabled()) {
116                         return;
117                 }
118                 try {
119                         manager = new UDDIClient();
120                         manager.start();
121 
122                         logger.debug("Getting auth tokens..");
123 
124                         Transport transport = manager.getTransport("uddiv3");
125                         UDDISecurityPortType security = transport.getUDDISecurityService();
126                         authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
127                         authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
128                         //Assert.assertNotNull(authInfoJoe);
129 
130                         publicationJoe = transport.getUDDIPublishService();
131                         inquiryJoe = transport.getUDDIInquiryService();
132                         subscriptionJoe = transport.getUDDISubscriptionService();
133                         if (!TckPublisher.isUDDIAuthMode()) {
134                                 TckSecurity.setCredentials((BindingProvider) publicationJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
135                                 TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
136                                 TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
137                         }
138 
139                         tckTModelJoe = new TckTModel(publicationJoe, inquiryJoe);
140                         tckBusinessJoe = new TckBusiness(publicationJoe, inquiryJoe);
141                         tckBusinessServiceJoe = new TckBusinessService(publicationJoe, inquiryJoe);
142                         tckSubscriptionListenerJoe = new TckSubscriptionListener(subscriptionJoe, publicationJoe);
143 
144                         transport = manager.getTransport("uddiv3");
145                         publicationMary = transport.getUDDIPublishService();
146                         inquiryMary = transport.getUDDIInquiryService();
147                         subscriptionMary = transport.getUDDISubscriptionService();
148                         if (!TckPublisher.isUDDIAuthMode()) {
149                                 TckSecurity.setCredentials((BindingProvider) publicationMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
150                                 TckSecurity.setCredentials((BindingProvider) inquiryMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
151                                 TckSecurity.setCredentials((BindingProvider) subscriptionMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
152                         }
153 
154                         tckTModelMary = new TckTModel(publicationMary, inquiryMary);
155                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
156 
157                         tckBusinessMary = new TckBusiness(publicationMary, inquiryMary);
158                         tckBusinessServiceMary = new TckBusinessService(publicationMary, inquiryMary);
159                         tckSubscriptionListenerMary = new TckSubscriptionListener(subscriptionMary, publicationMary);
160 
161                 } catch (Exception e) {
162                         logger.error(e.getMessage(), e);
163                         TckCommon.PrintMarker();
164                         Assert.fail("Could not obtain authInfo token.");
165                 }
166         }
167 
168         /**
169          * verifies the delivery of the notification, will block until timeout
170          * or success
171          *
172          * @param findMe
173          * @return true is success
174          */
175         public abstract boolean verifyDelivery(String findMe);
176 
177         /**
178          * reform transport specific resets of the listener
179          */
180         public abstract void reset();
181         
182         public abstract boolean IsEnabled();
183 
184         public abstract String getXMLLocationOfServiceForDelivery();
185 
186         /**
187          * used for logging purposes
188          *
189          * @return
190          */
191         public abstract String getTransport();
192 
193         /**
194          * listener port
195          *
196          * @return
197          */
198         public abstract int getPort();
199 
200         /**
201          * either returns localhost hostname or an email or delivery address
202          *
203          * @return
204          */
205         public abstract String getHostame();
206 
207         @Test
208         public void joePublisherUpdate_FIND_SERVICE() {
209                 Assume.assumeTrue(TckPublisher.isEnabled());
210                 Assume.assumeNotNull(getHostame());
211                 Assume.assumeTrue(IsEnabled());
212                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_SERVICE");
213                 try {
214                         TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
215                         String before = TckCommon.DumpAllServices(authInfoJoe, inquiryJoe);
216                         reset();
217 
218                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
219                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
220                         //Saving the binding template that will be called by the server for a subscription event
221                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
222                         //Saving the HTTP Listener Service
223                         tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
224                         //Saving the HTTP Subscription
225                         String saveNotifierSubscription = tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, getSubscription1XML());
226                         //Changing the service we subscribed to "JoePublisherService"
227                         Thread.sleep(1000);
228                         logger.info("Updating Service ********** ");
229                         tckBusinessServiceJoe.updateJoePublisherService(authInfoJoe, "Service One");
230 
231                         boolean found = verifyDelivery("Service One");
232 
233                         if (!found) {
234                                 logger.warn("Test failed, dumping service list");
235                                 logger.warn("BEFORE " + before);
236                                 logger.warn("After " + TckCommon.DumpAllServices(authInfoJoe, inquiryJoe));
237                                 TckCommon.PrintMarker();
238                                 Assert.fail("Notification does not contain the correct service");
239                         }
240                 } catch (Exception e) {
241                         logger.error("No exceptions please.");
242                         TckCommon.PrintMarker();
243                         e.printStackTrace();
244 
245                         Assert.fail();
246                 } finally {
247                         tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, getSubscriptionKey1());
248                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
249                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
250                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
251                 }
252         }
253 
254         @Test
255         public void joePublisherUpdate_FIND_BUSINESS() {
256                 Assume.assumeTrue(TckPublisher.isEnabled());
257                 Assume.assumeNotNull(getHostame());
258                 Assume.assumeTrue(IsEnabled());
259                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BUSINESS");
260                 try {
261                         TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
262                         TckCommon.DeleteBusiness(TckBusiness.MARY_BUSINESS_KEY, authInfoMary, publicationMary);
263                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
264 
265                         reset();
266 
267                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
268                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
269                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
270                         //Saving the Listener Service
271                         logger.info("Saving Joe's callback endpoint ********** ");
272                         tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
273                         //Saving the Subscription
274                         logger.info("Saving Joe's subscription********** ");
275                         tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, getSubscription2XML());
276                         //Changing the service we subscribed to "JoePublisherService"
277 
278                         logger.info("Saving Mary's Business ********** ");
279                         tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
280 
281                         boolean found = verifyDelivery("mary");
282 
283                         if (!found) {
284                                 logger.warn("Test failed, dumping business list");
285                                 logger.warn("BEFORE " + before);
286                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
287                                 TckCommon.PrintMarker();
288                                 Assert.fail("Notification does not contain the correct service");
289                         }
290                 } catch (Exception e) {
291                         logger.error("No exceptions please.");
292                         TckCommon.PrintMarker();
293                         e.printStackTrace();
294 
295                         Assert.fail();
296                 } finally {
297                         tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, getSubscriptionKey2());
298                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
299                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
300                         TckCommon.DeleteBusiness(TckBusiness.MARY_BUSINESS_KEY, authInfoMary, publicationMary);
301                         //tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
302                 }
303         }
304 
305         public abstract String getSubscription1XML();
306 
307         public abstract String getSubscription2XML();
308 
309         public abstract String getSubscription3XML();
310 
311         public abstract String getSubscriptionKey1();
312 
313         public abstract String getSubscriptionKey2();
314 
315         public abstract String getSubscriptionKey3();
316 
317         //tmodel tests
318         @Test
319         public void joePublisherUpdate_FIND_TMODEL() {
320                 Assume.assumeTrue(TckPublisher.isEnabled());
321                 Assume.assumeNotNull(getHostame());
322                 Assume.assumeTrue(IsEnabled());
323                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_TMODEL " + getXMLLocationOfServiceForDelivery() + " " + getPort() + " " + getHostame());
324                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
325                 try {
326                         reset();
327 
328                         String before = TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe);
329                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
330                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
331                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
332                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
333                         //Saving the Listener Service
334 
335                         tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
336                         //Saving the Subscription
337                         String saveNotifierSubscription = tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, getSubscription3XML());
338                         logger.info("subscription saved for " + saveNotifierSubscription);
339                         //Changing the service we subscribed to "JoePublisherService"
340                         Thread.sleep(1000);
341                         logger.info("Deleting tModel ********** ");
342                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY);
343 
344                         boolean found = verifyDelivery("tModel One");
345 
346                         if (!found) {
347                                 logger.warn("Test failed, dumping business list");
348                                 logger.warn("BEFORE " + before);
349                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
350                                 TckCommon.PrintMarker();
351                                 Assert.fail("Notification does not contain the correct service");
352                         }
353 
354                 } catch (Exception e) {
355                         logger.error("No exceptions please.");
356                         TckCommon.PrintMarker();
357                         e.printStackTrace();
358 
359                         Assert.fail();
360                 } finally {
361                         tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, getSubscriptionKey3());
362                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
363                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
364                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
365                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
366                 }
367         }
368 
369         /**
370          * getBusiness tests joe want's updates on mary's business
371          *
372          * @throws Exception
373          */
374         @Test
375         public void joePublisherUpdate_GET_BUSINESS_DETAIL() throws Exception {
376                 Assume.assumeTrue(TckPublisher.isEnabled());
377                 Assume.assumeNotNull(getHostame());
378                 Assume.assumeTrue(IsEnabled());
379                 logger.info("joePublisherUpdate_" + getTransport() + "_GET_BUSINESS_DETAIL");
380                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
381                 Holder<List<Subscription>> holder = null;
382                 try {
383                         reset();
384 
385                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
386 
387                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
388                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
389 
390                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
391                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
392 
393                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
394                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
395                         //Saving the Listener Service
396                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
397 
398                         //Saving the Subscription
399                         holder = new Holder<List<Subscription>>();
400                         holder.value = new ArrayList<Subscription>();
401                         Subscription sub = new Subscription();
402                         sub.setBindingKey(bindingkey);
403                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
404                         sub.setSubscriptionFilter(new SubscriptionFilter());
405                         sub.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
406                         sub.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
407 
408                         holder.value.add(sub);
409                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
410                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
411                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
412                         //Changing the service we subscribed to "JoePublisherService"
413                         Thread.sleep(1000);
414                         logger.info("updating Mary's business ********** ");
415                         updatePublisherBusiness(authInfoMary, saveMaryPublisherBusiness, publicationMary, "Updated Name");
416 
417                         boolean found = verifyDelivery(saveMaryPublisherBusiness.getBusinessKey());
418 
419                         if (!found) {
420                                 logger.warn("Test failed, dumping business list");
421                                 logger.warn("BEFORE " + before);
422                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
423                                 TckCommon.PrintMarker();
424                                 Assert.fail("Notification does not contain the correct service.");
425                         }
426 
427                 } catch (Exception e) {
428                         logger.error("No exceptions please.");
429                         TckCommon.PrintMarker();
430                         e.printStackTrace();
431 
432                         Assert.fail(e.getMessage());
433                 } finally {
434                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
435                         DeleteSubscription ds = new DeleteSubscription();
436                         ds.setAuthInfo(authInfoJoe);
437                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
438                         subscriptionJoe.deleteSubscription(ds);
439                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
440                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
441 
442                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
443                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
444                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
445                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
446 
447                 }
448         }
449 
450         /**
451          * getBusiness tests joe want's updates on mary's business
452          *
453          * @throws Exception
454          */
455         @Test
456         public void joePublisherUpdate_GET_TMODEL_DETAIL() throws Exception {
457                 Assume.assumeTrue(TckPublisher.isEnabled());
458                 Assume.assumeNotNull(getHostame());
459                 Assume.assumeTrue(IsEnabled());
460                 logger.info("joePublisherUpdate_" + getTransport() + "_GET_TMODEL_DETAIL");
461                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
462                 Holder<List<Subscription>> holder = null;
463                 try {
464                         reset();
465 
466                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
467                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
468                         TModel saveMaryPublisherTmodel = tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
469 
470                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
471                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
472                         //Saving the Listener Service
473                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
474 
475                         //Saving the Subscription
476                         holder = new Holder<List<Subscription>>();
477                         holder.value = new ArrayList<Subscription>();
478                         Subscription sub = new Subscription();
479                         sub.setBindingKey(bindingkey);
480                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
481                         sub.setSubscriptionFilter(new SubscriptionFilter());
482                         sub.getSubscriptionFilter().setGetTModelDetail(new GetTModelDetail());
483                         sub.getSubscriptionFilter().getGetTModelDetail().getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
484 
485                         holder.value.add(sub);
486                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
487                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
488                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
489                         //Changing the service we subscribed to "JoePublisherService"
490                         Thread.sleep(1000);
491                         logger.info("updating Mary's tModel ********** ");
492                         updateTModel(authInfoMary, saveMaryPublisherTmodel, publicationMary);
493 
494                         boolean found = verifyDelivery(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
495 
496                         if (!found) {
497                                 TckCommon.PrintMarker();
498                                 Assert.fail("Notification does not contain the correct service.");
499                         }
500 
501                 } catch (Exception e) {
502                         logger.error("No exceptions please.");
503                         TckCommon.PrintMarker();
504                         e.printStackTrace();
505 
506                         Assert.fail();
507                 } finally {
508                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
509                         DeleteSubscription ds = new DeleteSubscription();
510                         ds.setAuthInfo(authInfoJoe);
511                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
512                         subscriptionJoe.deleteSubscription(ds);
513                         //tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
514                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
515 
516                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
517                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
518                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
519                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
520 
521                 }
522         }
523 
524         //TODO If a subscriber specifies a maximum number of entries to be returned with a subscription and the amount of data to be returned exceeds 
525 //this limit, or if the node determines based on its policy that there are too many entries to be returned in a single group, 
526         //then the node SHOULD provide a chunkToken with results.  
527         //TODO  If no more results are pending, the value of the chunkToken MUST be "0".
528         public static void updateTModel(String authInfoMary, TModel saveMaryPublisherTmodel, UDDIPublicationPortType publicationMary) throws Exception {
529                 saveMaryPublisherTmodel.getDescription().add(new Description("a new description", null));
530                 SaveTModel stm = new SaveTModel();
531                 stm.setAuthInfo(authInfoMary);
532                 stm.getTModel().add(saveMaryPublisherTmodel);
533                 publicationMary.saveTModel(stm);
534         }
535 
536         /**
537          * adds a new name to the business, then resaves it
538          *
539          * @param auth
540          * @param biz
541          * @param pub
542          */
543         public static void updatePublisherBusiness(String auth, BusinessEntity biz, UDDIPublicationPortType pub, String name) throws Exception {
544                 biz.getName().add(new Name(name, null));
545                 SaveBusiness sb = new SaveBusiness();
546                 sb.setAuthInfo(auth);
547                 sb.getBusinessEntity().add(biz);
548                 pub.saveBusiness(sb);
549         }
550 
551         /**
552          * getService tests joe want's updates on mary's service
553          *
554          * @throws Exception
555          */
556         @Test
557         public void joePublisherUpdate_GET_SERVICE_DETAIL() throws Exception {
558                 Assume.assumeTrue(TckPublisher.isEnabled());
559                 Assume.assumeNotNull(getHostame());
560                 Assume.assumeTrue(IsEnabled());
561                 logger.info("joePublisherUpdate_" + getTransport() + "_GET_SERVICE_DETAIL");
562                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
563                 Holder<List<Subscription>> holder = null;
564                 try {
565                         reset();
566 
567                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
568 
569                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
570                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
571 
572                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
573                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
574 
575                         BusinessService bs = new BusinessService();
576                         bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
577                         bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
578                         bs.getName().add(new Name("Mary's service for " + getTransport(), null));
579                         SaveService ss = new SaveService();
580                         ss.getBusinessService().add(bs);
581                         ss.setAuthInfo(authInfoMary);
582                         bs = publicationMary.saveService(ss).getBusinessService().get(0);
583 
584                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
585                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
586                         //Saving the Listener Service
587                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
588 
589                         //Saving the Subscription
590                         holder = new Holder<List<Subscription>>();
591                         holder.value = new ArrayList<Subscription>();
592                         Subscription sub = new Subscription();
593                         sub.setBindingKey(bindingkey);
594                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
595                         sub.setSubscriptionFilter(new SubscriptionFilter());
596                         sub.getSubscriptionFilter().setGetServiceDetail(new GetServiceDetail());
597                         sub.getSubscriptionFilter().getGetServiceDetail().getServiceKey().add(bs.getServiceKey());
598 
599                         holder.value.add(sub);
600                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
601                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
602                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
603                         //Changing the service we subscribed to "JoePublisherService"
604                         Thread.sleep(1000);
605                         logger.info("updating Mary's service ********** ");
606                         updatePublisherService(authInfoMary, bs, publicationMary);
607 
608                         boolean found = verifyDelivery("Updated Name");
609 
610                         if (!found) {
611                                 logger.warn("Test failed, dumping business list");
612                                 logger.warn("BEFORE " + before);
613                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
614                                 TckCommon.PrintMarker();
615                                 Assert.fail("Notification does not contain the correct service.");
616                         }
617 
618                 } catch (Exception e) {
619                         logger.error("No exceptions please.");
620                         TckCommon.PrintMarker();
621                         e.printStackTrace();
622 
623                         Assert.fail();
624                 } finally {
625                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
626                         DeleteSubscription ds = new DeleteSubscription();
627                         ds.setAuthInfo(authInfoJoe);
628                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
629                         subscriptionJoe.deleteSubscription(ds);
630                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
631                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
632 
633                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
634                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
635                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
636                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
637 
638                 }
639         }
640 
641         /**
642          * getBinding tests joe want's updates on mary's binding
643          *
644          * @throws Exception
645          */
646         @Test
647         public void joePublisherUpdate_GET_BINDING_DETAIL() throws Exception {
648                 Assume.assumeTrue(TckPublisher.isEnabled());
649                 Assume.assumeNotNull(getHostame());
650                 Assume.assumeTrue(IsEnabled());
651                 logger.info("joePublisherUpdate_" + getTransport() + "_GET_BINDING_DETAIL");
652                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
653                 Holder<List<Subscription>> holder = null;
654                 try {
655                         reset();
656 
657                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
658 
659                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
660                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
661 
662                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
663                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
664 
665                         BusinessService bs = new BusinessService();
666                         bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
667                         bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
668                         bs.getName().add(new Name("Mary's service for " + getTransport(), null));
669                         bs.setBindingTemplates(new BindingTemplates());
670                         BindingTemplate bt = new BindingTemplate();
671                         bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint"));
672                         bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
673                         bt.setServiceKey(bs.getServiceKey());
674                         bt = UDDIClient.addSOAPtModels(bt);
675 
676                         bs.getBindingTemplates().getBindingTemplate().add(bt);
677                         SaveService ss = new SaveService();
678                         ss.getBusinessService().add(bs);
679                         ss.setAuthInfo(authInfoMary);
680                         bs = publicationMary.saveService(ss).getBusinessService().get(0);
681 
682                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
683                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
684                         //Saving the Listener Service
685                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
686 
687                         //Saving the Subscription
688                         holder = new Holder<List<Subscription>>();
689                         holder.value = new ArrayList<Subscription>();
690                         Subscription sub = new Subscription();
691                         sub.setBindingKey(bindingkey);
692                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
693                         sub.setSubscriptionFilter(new SubscriptionFilter());
694                         sub.getSubscriptionFilter().setGetBindingDetail(new GetBindingDetail());
695                         sub.getSubscriptionFilter().getGetBindingDetail().getBindingKey().add(bt.getBindingKey());
696 
697                         holder.value.add(sub);
698                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
699                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
700                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
701                         //Changing the service we subscribed to "JoePublisherService"
702                         Thread.sleep(1000);
703                         logger.info("updating Mary's binding ********** ");
704                         updatePublisherBinding(authInfoMary, bt, publicationMary);
705 
706                         boolean found = verifyDelivery(bt.getBindingKey());
707 
708                         if (!found) {
709                                 logger.warn("Test failed, dumping business list");
710                                 logger.warn("BEFORE " + before);
711                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
712                                 TckCommon.PrintMarker();
713                                 Assert.fail("Notification does not contain the correct service.");
714                         }
715 
716                 } catch (Exception e) {
717                         logger.error("No exceptions please.");
718                         TckCommon.PrintMarker();
719                         e.printStackTrace();
720 
721                         Assert.fail();
722                 } finally {
723                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
724                         DeleteSubscription ds = new DeleteSubscription();
725                         ds.setAuthInfo(authInfoJoe);
726                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
727                         subscriptionJoe.deleteSubscription(ds);
728                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
729                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
730 
731                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
732                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
733                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
734                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
735 
736                 }
737         }
738 
739         /**
740          * PUBLISHERASSERTION tests joe want's updates on mary's binding
741          *
742          * @throws Exception
743          */
744         @Test
745         // @Ignore
746         public void joePublisherUpdate_PUBLISHERASSERTION_DETAIL_TO() throws Exception {
747                 Assume.assumeTrue(TckPublisher.isEnabled());
748                 Assume.assumeNotNull(getHostame());
749                 Assume.assumeTrue(IsEnabled());
750                 logger.info("joePublisherUpdate_" + getTransport() + "_PUBLISHERASSERTION_DETAIL_TO");
751                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
752                 Holder<List<Subscription>> holder = null;
753                 try {
754                         reset();
755 
756                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
757 
758                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
759                         //tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
760 
761                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
762                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
763 
764                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
765                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
766                         //Saving the Listener Service
767                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
768 
769                         //Saving the Subscription
770                         holder = new Holder<List<Subscription>>();
771                         holder.value = new ArrayList<Subscription>();
772                         Subscription sub = new Subscription();
773                         sub.setBindingKey(bindingkey);
774                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
775                         sub.setSubscriptionFilter(new SubscriptionFilter());
776                         sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport());
777                         sub.getSubscriptionFilter().getGetAssertionStatusReport().setCompletionStatus(CompletionStatus.STATUS_TO_KEY_INCOMPLETE);
778 
779                         holder.value.add(sub);
780                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
781                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
782                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
783                         //Changing the service we subscribed to "JoePublisherService"
784                         Thread.sleep(1000);
785                         logger.info("saving Mary's publisher assertion********** ");
786                         AddPublisherAssertions pa = new AddPublisherAssertions();
787                         pa.setAuthInfo(authInfoMary);
788                         PublisherAssertion pas = new PublisherAssertion();
789                         pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
790                         pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
791                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
792                         pa.getPublisherAssertion().add(pas);
793 
794                         publicationMary.addPublisherAssertions(pa);
795 
796                         boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
797 
798                         DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
799                         deletePublisherAssertions.setAuthInfo(authInfoMary);
800                         deletePublisherAssertions.getPublisherAssertion().add(pas);
801                         publicationMary.deletePublisherAssertions(deletePublisherAssertions);
802                         if (!found) {
803                                 logger.warn("Test failed, dumping business list");
804                                 logger.warn("BEFORE " + before);
805                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
806                                 TckCommon.PrintMarker();
807                                 Assert.fail("Notification does not contain the correct service.");
808                         }
809 
810                 } catch (Exception e) {
811                         logger.error("No exceptions please.");
812                         TckCommon.PrintMarker();
813                         e.printStackTrace();
814 
815                         Assert.fail();
816                 } finally {
817                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
818                         DeleteSubscription ds = new DeleteSubscription();
819                         ds.setAuthInfo(authInfoJoe);
820                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
821                         subscriptionJoe.deleteSubscription(ds);
822                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
823                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
824 
825                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
826                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
827                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
828                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
829 
830                 }
831         }
832 
833         /**
834          * PUBLISHERASSERTION tests joe want's updates on mary's binding
835          *
836          * @throws Exception
837          */
838         @Test
839         //@Ignore
840         public void joePublisherUpdate_PUBLISHERASSERTION_DETAIL_FROM() throws Exception {
841                 Assume.assumeTrue(TckPublisher.isEnabled());
842                 Assume.assumeNotNull(getHostame());
843                 Assume.assumeTrue(IsEnabled());
844                 logger.info("joePublisherUpdate_" + getTransport() + "_PUBLISHERASSERTION_DETAIL_FROM");
845                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
846                 Holder<List<Subscription>> holder = null;
847                 try {
848                         reset();
849 
850                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
851 
852                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
853                         //tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
854 
855                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
856                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
857 
858                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
859                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
860                         //Saving the Listener Service
861                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
862 
863                         //Saving the Subscription
864                         holder = new Holder<List<Subscription>>();
865                         holder.value = new ArrayList<Subscription>();
866                         Subscription sub = new Subscription();
867                         sub.setBindingKey(bindingkey);
868                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
869                         sub.setSubscriptionFilter(new SubscriptionFilter());
870                         sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport());
871                         sub.getSubscriptionFilter().getGetAssertionStatusReport().setCompletionStatus(CompletionStatus.STATUS_FROM_KEY_INCOMPLETE);
872 
873                         holder.value.add(sub);
874                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
875                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
876                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
877                         //Changing the service we subscribed to "JoePublisherService"
878                         Thread.sleep(1000);
879                         logger.info("saving Mary's publisher assertion********** ");
880                         AddPublisherAssertions pa = new AddPublisherAssertions();
881                         pa.setAuthInfo(authInfoMary);
882                         PublisherAssertion pas = new PublisherAssertion();
883                         pas.setFromKey(TckBusiness.JOE_BUSINESS_KEY);
884                         pas.setToKey(TckBusiness.MARY_BUSINESS_KEY);
885                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
886                         pa.getPublisherAssertion().add(pas);
887 
888                         publicationMary.addPublisherAssertions(pa);
889 
890                         boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
891 
892                         DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
893                         deletePublisherAssertions.setAuthInfo(authInfoMary);
894                         deletePublisherAssertions.getPublisherAssertion().add(pas);
895                         publicationMary.deletePublisherAssertions(deletePublisherAssertions);
896                         if (!found) {
897                                 logger.warn("Test failed, dumping business list");
898                                 logger.warn("BEFORE " + before);
899                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
900                                 TckCommon.PrintMarker();
901                                 Assert.fail("Notification does not contain the correct service.");
902                         }
903 
904                 } catch (Exception e) {
905                         logger.error("No exceptions please.");
906                         TckCommon.PrintMarker();
907                         e.printStackTrace();
908 
909                         Assert.fail(e.getMessage());
910                 } finally {
911                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
912                         DeleteSubscription ds = new DeleteSubscription();
913                         ds.setAuthInfo(authInfoJoe);
914                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
915                         subscriptionJoe.deleteSubscription(ds);
916                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
917                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
918 
919                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
920                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
921                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
922                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
923 
924                 }
925         }
926 
927         /**
928          * PUBLISHERASSERTION tests joe want's updates on mary's binding
929          *
930          * @throws Exception
931          */
932         @Test
933         public void joePublisherUpdate_PUBLISHERASSERTION_DETAIL_NULL() throws Exception {
934                 Assume.assumeTrue(TckPublisher.isEnabled());
935                 Assume.assumeNotNull(getHostame());
936                 Assume.assumeTrue(IsEnabled());
937                 logger.info("joePublisherUpdate_" + getTransport() + "_PUBLISHERASSERTION_DETAIL_NULL");
938                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
939                 Holder<List<Subscription>> holder = null;
940                 try {
941                         reset();
942 
943                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
944 
945                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
946                         //tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
947 
948                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
949                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
950 
951                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
952                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
953                         //Saving the Listener Service
954                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
955 
956                         //Saving the Subscription
957                         holder = new Holder<List<Subscription>>();
958                         holder.value = new ArrayList<Subscription>();
959                         Subscription sub = new Subscription();
960                         sub.setBindingKey(bindingkey);
961                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
962                         sub.setSubscriptionFilter(new SubscriptionFilter());
963                         sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport());
964 
965                         holder.value.add(sub);
966                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
967                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
968                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
969                         //Changing the service we subscribed to "JoePublisherService"
970                         Thread.sleep(1000);
971                         logger.info("saving Mary's publisher assertion********** ");
972                         AddPublisherAssertions pa = new AddPublisherAssertions();
973                         pa.setAuthInfo(authInfoMary);
974                         PublisherAssertion pas = new PublisherAssertion();
975                         pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
976                         pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
977                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
978                         pa.getPublisherAssertion().add(pas);
979 
980                         publicationMary.addPublisherAssertions(pa);
981 
982                         boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
983 
984                         DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
985                         deletePublisherAssertions.setAuthInfo(authInfoMary);
986                         deletePublisherAssertions.getPublisherAssertion().add(pas);
987                         publicationMary.deletePublisherAssertions(deletePublisherAssertions);
988                         if (!found) {
989                                 logger.warn("Test failed, dumping business list");
990                                 logger.warn("BEFORE " + before);
991                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
992                                 TckCommon.PrintMarker();
993                                 Assert.fail("Notification does not contain the correct service.");
994                         }
995 
996                 } catch (Exception e) {
997                         logger.error("No exceptions please.");
998                         e.printStackTrace();
999                         TckCommon.PrintMarker();
1000                         Assert.fail(e.getMessage());
1001                 } finally {
1002                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
1003                         DeleteSubscription ds = new DeleteSubscription();
1004                         ds.setAuthInfo(authInfoJoe);
1005                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
1006                         subscriptionJoe.deleteSubscription(ds);
1007                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
1008                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
1009 
1010                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
1011                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
1012                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
1013                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1014 
1015                 }
1016         }
1017 
1018         /**
1019          * PUBLISHERASSERTION2 tests joe want's updates on mary's binding
1020          *
1021          * @throws Exception
1022          */
1023         @Test
1024         public void joePublisherUpdate_PUBLISHERASSERTION_DETAIL_COMPLETE() throws Exception {
1025                 Assume.assumeTrue(TckPublisher.isEnabled());
1026                 Assume.assumeNotNull(getHostame());
1027                 Assume.assumeTrue(IsEnabled());
1028                 logger.info("joePublisherUpdate_" + getTransport() + "_PUBLISHERASSERTION_DETAIL_COMPLETE");
1029                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
1030                 Holder<List<Subscription>> holder = null;
1031                 try {
1032                         reset();
1033 
1034                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
1035 
1036                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
1037                         //tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1038 
1039                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
1040                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
1041 
1042                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
1043                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
1044                         //Saving the Listener Service
1045                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
1046 
1047                         //Saving the Subscription
1048                         holder = new Holder<List<Subscription>>();
1049                         holder.value = new ArrayList<Subscription>();
1050                         Subscription sub = new Subscription();
1051                         sub.setBindingKey(bindingkey);
1052                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
1053                         sub.setSubscriptionFilter(new SubscriptionFilter());
1054                         sub.getSubscriptionFilter().setGetAssertionStatusReport(new GetAssertionStatusReport());
1055                         sub.getSubscriptionFilter().getGetAssertionStatusReport().setCompletionStatus(CompletionStatus.STATUS_COMPLETE);
1056 
1057                         holder.value.add(sub);
1058                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
1059                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
1060                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
1061                         //Changing the service we subscribed to "JoePublisherService"
1062                         Thread.sleep(1000);
1063                         logger.info("saving Mary's publisher assertion********** ");
1064                         AddPublisherAssertions pa = new AddPublisherAssertions();
1065                         pa.setAuthInfo(authInfoMary);
1066                         PublisherAssertion pas = new PublisherAssertion();
1067                         pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
1068                         pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
1069                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
1070                         pa.getPublisherAssertion().add(pas);
1071 
1072                         publicationMary.addPublisherAssertions(pa);
1073                         pa.setAuthInfo(authInfoJoe);
1074                         publicationJoe.addPublisherAssertions(pa);
1075 
1076                         boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
1077                         DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
1078                         deletePublisherAssertions.setAuthInfo(authInfoMary);
1079                         deletePublisherAssertions.getPublisherAssertion().add(pas);
1080                         publicationMary.deletePublisherAssertions(deletePublisherAssertions);
1081                         if (!found) {
1082                                 logger.warn("Test failed, dumping business list");
1083                                 logger.warn("BEFORE " + before);
1084                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
1085                                 TckCommon.PrintMarker();
1086                                 Assert.fail("Notification does not contain the correct service.");
1087                         }
1088 
1089                 } catch (Exception e) {
1090                         logger.error("No exceptions please.");
1091                         TckCommon.PrintMarker();
1092                         e.printStackTrace();
1093 
1094                         Assert.fail(e.getMessage());
1095                 } finally {
1096                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
1097                         DeleteSubscription ds = new DeleteSubscription();
1098                         ds.setAuthInfo(authInfoJoe);
1099                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
1100                         subscriptionJoe.deleteSubscription(ds);
1101                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
1102                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
1103 
1104                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
1105                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
1106                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
1107                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1108 
1109                 }
1110         }
1111 
1112         //
1113         /**
1114          * find related businesses i.e. setup subscriptions for all related
1115          * businesses to joe's biz then setup PA between Joe and Mary
1116          *
1117          * @throws Exception
1118          */
1119         @Test
1120         public void joePublisherUpdate_FIND_RELATED_BIZ() throws Exception {
1121                 Assume.assumeTrue(TckPublisher.isEnabled());
1122                 Assume.assumeNotNull(getHostame());
1123                 Assume.assumeTrue(IsEnabled());
1124                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_RELATED_BIZ");
1125                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
1126                 Holder<List<Subscription>> holder = null;
1127                 try {
1128                         reset();
1129 
1130                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
1131 
1132                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
1133 
1134                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
1135 
1136                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
1137                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
1138                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
1139                         //Saving the Listener Service
1140                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
1141 
1142                         //Saving the Subscription
1143                         holder = new Holder<List<Subscription>>();
1144                         holder.value = new ArrayList<Subscription>();
1145                         Subscription sub = new Subscription();
1146                         sub.setBindingKey(bindingkey);
1147                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
1148                         sub.setSubscriptionFilter(new SubscriptionFilter());
1149                         sub.getSubscriptionFilter().setFindRelatedBusinesses(new FindRelatedBusinesses());
1150                         sub.getSubscriptionFilter().getFindRelatedBusinesses().setBusinessKey(TckBusiness.MARY_BUSINESS_KEY);
1151 
1152                         holder.value.add(sub);
1153                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
1154                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
1155                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
1156                         //Changing the service we subscribed to "JoePublisherService"
1157                         Thread.sleep(1000);
1158 
1159                         logger.info("saving Mary's publisher assertion********** ");
1160                         AddPublisherAssertions pa = new AddPublisherAssertions();
1161                         pa.setAuthInfo(authInfoMary);
1162                         PublisherAssertion pas = new PublisherAssertion();
1163                         pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
1164                         pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
1165                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
1166                         pa.getPublisherAssertion().add(pas);
1167 
1168                         publicationMary.addPublisherAssertions(pa);
1169                         logger.info("saving Joe's publisher assertion********** ");
1170                         pa = new AddPublisherAssertions();
1171                         pa.setAuthInfo(authInfoJoe);
1172                         pas = new PublisherAssertion();
1173                         pas.setToKey(TckBusiness.JOE_BUSINESS_KEY);
1174                         pas.setFromKey(TckBusiness.MARY_BUSINESS_KEY);
1175                         pas.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent", "parent-child"));
1176                         pa.getPublisherAssertion().add(pas);
1177                         publicationJoe.addPublisherAssertions(pa);
1178 
1179                         //expecting that Joe gets notified that joe's and mary's businesses are now "related"
1180                         boolean found = verifyDelivery(TckBusiness.MARY_BUSINESS_KEY);
1181                         DeletePublisherAssertions deletePublisherAssertions = new DeletePublisherAssertions();
1182                         deletePublisherAssertions.setAuthInfo(authInfoMary);
1183                         deletePublisherAssertions.getPublisherAssertion().add(pas);
1184                         publicationMary.deletePublisherAssertions(deletePublisherAssertions);
1185 
1186                         deletePublisherAssertions = new DeletePublisherAssertions();
1187                         deletePublisherAssertions.setAuthInfo(authInfoJoe);
1188                         deletePublisherAssertions.getPublisherAssertion().add(pas);
1189                         // publicationJoe.deletePublisherAssertions(deletePublisherAssertions);
1190 
1191                         if (!found) {
1192                                 logger.warn("Test failed, dumping business list");
1193                                 logger.warn("BEFORE " + before);
1194                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
1195                                 TckCommon.PrintMarker();
1196                                 Assert.fail("Notification does not contain the correct service.");
1197                         }
1198 
1199                 } catch (Exception e) {
1200                         logger.error("No exceptions please.");
1201                         TckCommon.PrintMarker();
1202                         e.printStackTrace();
1203 
1204                         Assert.fail(e.getMessage());
1205                 } finally {
1206                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
1207                         DeleteSubscription ds = new DeleteSubscription();
1208                         ds.setAuthInfo(authInfoJoe);
1209                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
1210                         subscriptionJoe.deleteSubscription(ds);
1211                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
1212                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
1213 
1214                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
1215                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
1216                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
1217                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1218 
1219                 }
1220         }
1221 
1222         /**
1223          * getBinding tests joe want's updates on mary's binding
1224          *
1225          * @throws Exception
1226          */
1227         @Test
1228         public void joePublisherUpdate_FIND_BINDING_BY_SERVICEKEY_AND_TMI() throws Exception {
1229                 Assume.assumeTrue(TckPublisher.isEnabled());
1230                 Assume.assumeNotNull(getHostame());
1231                 Assume.assumeTrue(IsEnabled());
1232                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BINDING_BY_SERVICEKEY_AND_TMI");
1233                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
1234                 Holder<List<Subscription>> holder = null;
1235                 try {
1236                         reset();
1237 
1238                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
1239 
1240                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
1241                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1242 
1243                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
1244                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
1245 
1246                         BusinessService bs = new BusinessService();
1247                         bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
1248                         bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
1249                         bs.getName().add(new Name("Mary's service for " + getTransport(), null));
1250 
1251                         bs.setBindingTemplates(new BindingTemplates());
1252                         BindingTemplate bt = new BindingTemplate();
1253                         bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint"));
1254                         bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
1255                         bt.setServiceKey(bs.getServiceKey());
1256                         bt = UDDIClient.addSOAPtModels(bt);
1257 
1258                         bs.getBindingTemplates().getBindingTemplate().add(bt);
1259                         SaveService ss = new SaveService();
1260                         ss.getBusinessService().add(bs);
1261                         ss.setAuthInfo(authInfoMary);
1262                         bs = publicationMary.saveService(ss).getBusinessService().get(0);
1263 
1264                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
1265                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
1266                         //Saving the Listener Service
1267                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
1268 
1269                         //Saving the Subscription
1270                         holder = new Holder<List<Subscription>>();
1271                         holder.value = new ArrayList<Subscription>();
1272                         Subscription sub = new Subscription();
1273                         sub.setBindingKey(bindingkey);
1274                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
1275                         sub.setSubscriptionFilter(new SubscriptionFilter());
1276                         sub.getSubscriptionFilter().setFindBinding(new FindBinding());
1277                         //FAIL sub.getSubscriptionFilter().getFindBinding().setServiceKey(bs.getServiceKey());
1278                         sub.getSubscriptionFilter().getFindBinding().setTModelBag(new TModelBag());
1279 
1280                         //At least one of either a tModelBag or a find_tModel argument SHOULD be supplied, unless a categoryBag based search is being used.
1281                         sub.getSubscriptionFilter().getFindBinding().getTModelBag().getTModelKey().add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
1282                         //joe wants updates to mary's binding
1283 
1284                         holder.value.add(sub);
1285                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
1286                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
1287                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
1288                         //Changing the service we subscribed to "JoePublisherService"
1289                         Thread.sleep(1000);
1290                         logger.info("updating Mary's binding ********** ");
1291                         String newcontent = updatePublisherBindingAddTMI(authInfoMary, bt, publicationMary);
1292 
1293                         boolean found = verifyDelivery(newcontent);
1294 
1295                         if (!found) {
1296                                 logger.warn("Test failed, dumping business list");
1297                                 logger.warn("BEFORE " + before);
1298                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
1299                                 TckCommon.PrintMarker();
1300                                 Assert.fail("Notification does not contain the correct service.");
1301                         }
1302 
1303                 } catch (Exception e) {
1304                         logger.error("No exceptions please.");
1305                         TckCommon.PrintMarker();
1306                         e.printStackTrace();
1307 
1308                         Assert.fail(e.getMessage());
1309                 } finally {
1310                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
1311                         DeleteSubscription ds = new DeleteSubscription();
1312                         ds.setAuthInfo(authInfoJoe);
1313                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
1314                         subscriptionJoe.deleteSubscription(ds);
1315                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
1316                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
1317 
1318                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
1319                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
1320                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
1321                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1322 
1323                 }
1324         }
1325 
1326         /**
1327          * joe wants updates on all services with wsdm qos tmi. mary updates a
1328          * binding to trigger the call back
1329          *
1330          * @throws Exception
1331          */
1332         @Test
1333         public void joePublisherUpdate_FIND_BINDING_BY_CATBAG() throws Exception {
1334                 Assume.assumeTrue(TckPublisher.isEnabled());
1335                 Assume.assumeNotNull(getHostame());
1336                 Assume.assumeTrue(IsEnabled());
1337                 logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BINDING_BY_CATBAG");
1338                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
1339                 Holder<List<Subscription>> holder = null;
1340                 try {
1341                         reset();
1342 
1343                         String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
1344 
1345                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
1346                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1347 
1348                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
1349                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
1350 
1351                         BusinessService bs = new BusinessService();
1352                         bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey());
1353                         bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
1354                         bs.getName().add(new Name("Mary's service for " + getTransport(), null));
1355 
1356                         bs.setBindingTemplates(new BindingTemplates());
1357                         BindingTemplate bt = new BindingTemplate();
1358                         bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint"));
1359                         bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString());
1360                         bt.setServiceKey(bs.getServiceKey());
1361                         bt = UDDIClient.addSOAPtModels(bt);
1362 
1363                         bs.getBindingTemplates().getBindingTemplate().add(bt);
1364                         SaveService ss = new SaveService();
1365                         ss.getBusinessService().add(bs);
1366                         ss.setAuthInfo(authInfoMary);
1367                         bs = publicationMary.saveService(ss).getBusinessService().get(0);
1368 
1369                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
1370                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
1371                         //Saving the Listener Service
1372                         String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame());
1373 
1374                         //Saving the Subscription
1375                         holder = new Holder<List<Subscription>>();
1376                         holder.value = new ArrayList<Subscription>();
1377                         Subscription sub = new Subscription();
1378                         sub.setBindingKey(bindingkey);
1379                         sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
1380                         sub.setSubscriptionFilter(new SubscriptionFilter());
1381                         sub.getSubscriptionFilter().setFindBinding(new FindBinding());
1382 
1383                         //At least one of either a tModelBag or a find_tModel argument SHOULD be supplied, unless a categoryBag based search is being used.
1384                         sub.getSubscriptionFilter().getFindBinding().setCategoryBag(new CategoryBag());
1385                         sub.getSubscriptionFilter().getFindBinding().getCategoryBag().getKeyedReference().add(new KeyedReference("uddi:uddi.org:categorization:types", UDDIConstants.CategorizationTypes_Cacheable, "Cacheable"));
1386 
1387                         holder.value.add(sub);
1388                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
1389                         logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey());
1390                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
1391                         //Changing the service we subscribed to "JoePublisherService"
1392                         Thread.sleep(1000);
1393                         if (TckCommon.isDebug()){
1394                                 logger.info("dumping mary's binding before.... ");
1395                                 JAXB.marshal(bs, System.out);
1396                         }
1397                         logger.info("updating Mary's binding ********** ");
1398                         // BindingDetail after=new BindingDetail();
1399                         /*GetBindingDetail bindingDetail = new GetBindingDetail();
1400                          bindingDetail.setAuthInfo(authInfoMary);
1401                          bindingDetail.getBindingKey().add(bs.getBindingTemplates().getBindingTemplate().get(0).getBindingKey());*/
1402                         BindingDetail bindingDetail1 = null;//inquiryMary.getBindingDetail(bindingDetail);
1403                         bindingDetail1 = updatePublisherBindingAddCategory(authInfoMary, bt, publicationMary, new KeyedReference("uddi:uddi.org:categorization:types", UDDIConstants.CategorizationTypes_Cacheable, "Cacheable"), bindingDetail1);
1404 
1405                         if (TckCommon.isDebug()){
1406                                 logger.info("dumping mary's binding after.... ");
1407                                 JAXB.marshal(bindingDetail1, System.out);
1408                         }
1409                         boolean found = verifyDelivery(UDDIConstants.CategorizationTypes_Cacheable);
1410 
1411                         if (!found) {
1412                                 logger.warn("Test failed, dumping business list");
1413                                 logger.warn("BEFORE " + before);
1414                                 logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
1415                                 TckCommon.PrintMarker();
1416                                 Assert.fail("Notification does not contain the correct service.");
1417                         }
1418 
1419                 } catch (Exception e) {
1420                         logger.error("No exceptions please.");
1421                         TckCommon.PrintMarker();
1422                         e.printStackTrace();
1423 
1424                         Assert.fail(e.getMessage());
1425                 } finally {
1426                         //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
1427                         DeleteSubscription ds = new DeleteSubscription();
1428                         ds.setAuthInfo(authInfoJoe);
1429                         ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
1430                         subscriptionJoe.deleteSubscription(ds);
1431                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
1432                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
1433 
1434                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
1435                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
1436                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
1437                         tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
1438 
1439                 }
1440         }
1441 
1442         //find binding
1443         private void updatePublisherService(String authInfo, BusinessService bs, UDDIPublicationPortType pub) throws Exception {
1444                 bs.getName().add(new Name("Updated name", null));
1445                 SaveService ss = new SaveService();
1446                 ss.getBusinessService().add(bs);
1447                 ss.setAuthInfo(authInfo);
1448                 pub.saveService(ss);
1449         }
1450 
1451         /**
1452          * returns a string used to confirm delivery of an update
1453          *
1454          * @param authInfo
1455          * @param bt
1456          * @param pub
1457          * @return
1458          * @throws Exception
1459          */
1460         private String updatePublisherBinding(String authInfo, BindingTemplate bt, UDDIPublicationPortType pub) throws Exception {
1461                 SaveBinding sb = new SaveBinding();
1462                 sb.setAuthInfo(authInfo);
1463                 String ret = "http://" + UUID.randomUUID().toString();
1464                 bt.getAccessPoint().setValue(ret);
1465                 sb.getBindingTemplate().add(bt);
1466                 pub.saveBinding(sb);
1467                 return ret;
1468         }
1469 
1470         /**
1471          * returns a string used to confirm delivery of an update
1472          *
1473          * @param authInfo
1474          * @param bt
1475          * @param pub
1476          * @param cat
1477          * @return
1478          * @throws Exception
1479          */
1480         private String updatePublisherBindingAddTMI(String authInfo, BindingTemplate bt, UDDIPublicationPortType pub) throws Exception {
1481                 SaveBinding sb = new SaveBinding();
1482                 sb.setAuthInfo(authInfo);
1483                 if (bt.getTModelInstanceDetails() == null) {
1484                         bt.setTModelInstanceDetails(new TModelInstanceDetails());
1485                 }
1486                 TModelInstanceInfo tii = new TModelInstanceInfo();
1487                 tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
1488                 tii.setInstanceDetails(new InstanceDetails());
1489                 tii.getInstanceDetails().setInstanceParms("400");
1490                 bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
1491                 sb.getBindingTemplate().add(bt);
1492                 pub.saveBinding(sb);
1493                 return WSDMQosConstants.METRIC_FAULT_COUNT_KEY;
1494         }
1495 
1496         //TODO potential test case This argument specifies the filtering criteria which limits the scope of a subscription to a subset of registry records. It is required except when renewing an existing subscription.
1497         private BindingDetail updatePublisherBindingAddCategory(String authInfo, BindingTemplate bt, UDDIPublicationPortType pub, KeyedReference cat, BindingDetail outSaveBinding) throws Exception {
1498                 SaveBinding sb = new SaveBinding();
1499                 sb.setAuthInfo(authInfo);
1500                 if (bt.getCategoryBag() == null) {
1501                         bt.setCategoryBag(new CategoryBag());
1502                 }
1503                 bt.getCategoryBag().getKeyedReference().add(cat);
1504                 sb.getBindingTemplate().add(bt);
1505                 return pub.saveBinding(sb);
1506                 //return UDDIConstants.CategorizationTypes_Cacheable;
1507         }
1508 
1509 }