This project has retired. For details please refer to its Attic page.
JUDDI_300_MultiNodeIntegrationTest xref
View Javadoc
1   /*
2    * Copyright 2015 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.math.BigInteger;
19  import java.util.List;
20  import javax.xml.bind.JAXB;
21  import javax.xml.datatype.XMLGregorianCalendar;
22  import javax.xml.ws.BindingProvider;
23  import javax.xml.ws.Holder;
24  import org.junit.Assert;
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.UDDIService;
30  import org.apache.juddi.v3.client.config.UDDIClient;
31  import org.apache.juddi.v3.client.cryptor.TransportSecurityHelper;
32  import org.apache.juddi.v3.client.transport.Transport;
33  import org.apache.juddi.v3_service.JUDDIApiPortType;
34  import org.junit.AfterClass;
35  import org.junit.Assume;
36  import org.junit.BeforeClass;
37  import org.junit.Ignore;
38  import org.junit.Test;
39  import org.uddi.api_v3.AccessPoint;
40  import org.uddi.api_v3.AddPublisherAssertions;
41  import org.uddi.api_v3.AssertionStatusItem;
42  import org.uddi.api_v3.BindingDetail;
43  import org.uddi.api_v3.BindingTemplate;
44  import org.uddi.api_v3.BindingTemplates;
45  import org.uddi.api_v3.BusinessDetail;
46  import org.uddi.api_v3.BusinessEntity;
47  import org.uddi.api_v3.BusinessService;
48  import org.uddi.api_v3.BusinessServices;
49  import org.uddi.api_v3.Contact;
50  import org.uddi.api_v3.DeleteBinding;
51  import org.uddi.api_v3.DeleteBusiness;
52  import org.uddi.api_v3.DeletePublisherAssertions;
53  import org.uddi.api_v3.DeleteService;
54  import org.uddi.api_v3.DeleteTModel;
55  import org.uddi.api_v3.Description;
56  import org.uddi.api_v3.GetBindingDetail;
57  import org.uddi.api_v3.GetBusinessDetail;
58  import org.uddi.api_v3.GetOperationalInfo;
59  import org.uddi.api_v3.GetServiceDetail;
60  import org.uddi.api_v3.GetTModelDetail;
61  import org.uddi.api_v3.KeyedReference;
62  import org.uddi.api_v3.Name;
63  import org.uddi.api_v3.OperationalInfos;
64  import org.uddi.api_v3.PersonName;
65  import org.uddi.api_v3.PublisherAssertion;
66  import org.uddi.api_v3.SaveBinding;
67  import org.uddi.api_v3.SaveBusiness;
68  import org.uddi.api_v3.ServiceDetail;
69  import org.uddi.api_v3.TModel;
70  import org.uddi.api_v3.TModelDetail;
71  import org.uddi.custody_v3.KeyBag;
72  import org.uddi.custody_v3.TransferEntities;
73  import org.uddi.custody_v3.TransferToken;
74  import org.uddi.repl_v3.ChangeRecordIDType;
75  import org.uddi.repl_v3.CommunicationGraph;
76  import org.uddi.repl_v3.Operator;
77  import org.uddi.repl_v3.OperatorStatusType;
78  import org.uddi.repl_v3.ReplicationConfiguration;
79  
80  import org.uddi.v3_service.UDDICustodyTransferPortType;
81  import org.uddi.v3_service.UDDIInquiryPortType;
82  import org.uddi.v3_service.UDDIPublicationPortType;
83  import org.uddi.v3_service.UDDIReplicationPortType;
84  
85  import org.uddi.v3_service.UDDISecurityPortType;
86  
87  /**
88   * Contains all multinode tests, replication, custody transfer. This is juddi
89   * specific since most of these function depend on a juddi specific api in order
90   * to configure, since the uddi spec doesn't define a mechanism to do so.
91   *
92   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
93   */
94  public class JUDDI_300_MultiNodeIntegrationTest {
95  
96          private static final Log logger = LogFactory.getLog(JUDDI_300_MultiNodeIntegrationTest.class);
97          private static UDDIClient manager;
98          private static String rootNode1Token;
99          private static String rootNode2Token;
100         private static String uddiNode1Token;
101         private static String uddiNode2Token;
102         
103         private static JUDDIApiPortType juddiApiServiceNode1;
104         private static JUDDIApiPortType juddiApiServiceNode2;
105 
106         private static String maryTokenNode1;
107         private static String samTokenNode2;
108         private static UDDICustodyTransferPortType custodySam;
109         private static UDDICustodyTransferPortType custodyMary;
110         private static UDDIPublicationPortType publishMary;
111         private static UDDIPublicationPortType publishSamNode2;
112         private static UDDIPublicationPortType publishUddiNode1;
113         private static UDDIPublicationPortType publishUddiNode2;
114         private static UDDIInquiryPortType inquiryMary;
115         private static UDDIInquiryPortType inquirySamNode2;
116         
117         static TckBusiness maryBizNode1;
118         static TckTModel maryTModelNode1;
119         static TckTModel uddiTmodelNode1;
120         
121         static TckBusinessService samServiceNode2;
122         static TckBusiness samBizNode2;
123         static TckTModel samTModelNode2;
124         static TckTModel uddiTmodelNode2;
125 
126         static final String CFG_node1_MARY = "uddiv3";
127         static final String CFG_node2_SAM = "uddiv3-2";
128 
129         @BeforeClass
130         public static void startRegistry() throws Exception {
131                 if (!TckPublisher.isEnabled()) {
132                         return;
133                 }
134                 if (!TckPublisher.isJUDDI()) {
135                         return;
136                 }
137 
138                 testSetupReplicationConfig();
139 
140         }
141 
142         static synchronized void init() throws Exception {
143                 if (manager != null) {
144                         return;
145                 }
146                 manager = new UDDIClient();
147                 manager.start();
148 
149                 Transport node1 = manager.getTransport(CFG_node1_MARY);
150                 juddiApiServiceNode1 = node1.getJUDDIApiService();
151                 custodyMary = node1.getUDDICustodyTransferService();
152                 inquiryMary = node1.getUDDIInquiryService();
153                 publishMary = node1.getUDDIPublishService();
154                // UDDIService uddiService = new UDDIService();
155 
156                 //replicationMary = uddiService.getUDDIReplicationPort();
157                 //((BindingProvider) replicationMary).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, manager.getClientConfig().getUDDINode(CFG_node1_MARY).getReplicationUrl());
158                 //TransportSecurityHelper.applyTransportSecurity((BindingProvider) replicationMary);
159                 //logger.info("Using replication endpoint Node1...@" + ((BindingProvider)replicationMary).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
160                 UDDISecurityPortType secNode1 = node1.getUDDISecurityService();
161                 rootNode1Token = TckSecurity.getAuthToken(secNode1, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
162                 maryTokenNode1 = TckSecurity.getAuthToken(secNode1, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
163                 uddiNode1Token = TckSecurity.getAuthToken(secNode1, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
164 
165                 Transport node2 = manager.getTransport(CFG_node2_SAM);
166                 UDDISecurityPortType secNode2 = node2.getUDDISecurityService();
167                 rootNode2Token = TckSecurity.getAuthToken(secNode2, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
168                 samTokenNode2 = TckSecurity.getAuthToken(secNode2, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
169                 uddiNode2Token = TckSecurity.getAuthToken(secNode2, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
170                 //replicationSam = uddiService.getUDDIReplicationPort();
171                 //((BindingProvider) replicationSam).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, manager.getClientConfig().getUDDINode(CFG_node2_SAM).getReplicationUrl());
172                 //TransportSecurityHelper.applyTransportSecurity((BindingProvider) replicationSam);
173                 //logger.info("Using replication endpoint Node2...@" + ((BindingProvider)replicationSam).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
174 
175                 juddiApiServiceNode2 = node2.getJUDDIApiService();
176                 custodySam = node2.getUDDICustodyTransferService();
177                 inquirySamNode2 = node2.getUDDIInquiryService();
178                 publishSamNode2 = node2.getUDDIPublishService();
179                 
180                 Transport node2Uddi = manager.getTransport(CFG_node2_SAM);
181                 publishUddiNode2 = node2Uddi.getUDDIPublishService();
182                 
183                 Transport node1Uddi = manager.getTransport(CFG_node1_MARY);
184                 publishUddiNode1 = node1Uddi.getUDDIPublishService();
185                 
186                 
187                 samServiceNode2 = new TckBusinessService(publishSamNode2, inquirySamNode2);
188 
189                 samBizNode2 = new TckBusiness(publishSamNode2, inquirySamNode2);
190                 samTModelNode2 = new TckTModel(publishSamNode2, inquirySamNode2);
191                 maryBizNode1 = new TckBusiness(publishMary, inquiryMary);
192                 maryTModelNode1 = new TckTModel(publishMary, inquiryMary);
193                 uddiTmodelNode1 = new TckTModel(publishUddiNode1,node1Uddi.getUDDIInquiryService() );
194                 uddiTmodelNode2= new TckTModel(publishUddiNode2,node2Uddi.getUDDIInquiryService() );
195 
196                 if (!TckPublisher.isUDDIAuthMode()) {
197                         TckSecurity.setCredentials((BindingProvider) publishUddiNode2, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
198                         TckSecurity.setCredentials((BindingProvider) publishUddiNode1, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
199                         
200                         TckSecurity.setCredentials((BindingProvider) juddiApiServiceNode1, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
201                         TckSecurity.setCredentials((BindingProvider) juddiApiServiceNode2, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
202                         TckSecurity.setCredentials((BindingProvider) custodyMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
203                         TckSecurity.setCredentials((BindingProvider) inquiryMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
204                         TckSecurity.setCredentials((BindingProvider) publishMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
205                         //TckSecurity.setCredentials((BindingProvider) replicationMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
206 
207                         TckSecurity.setCredentials((BindingProvider) custodySam, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
208                         TckSecurity.setCredentials((BindingProvider) inquirySamNode2, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
209                         //TckSecurity.setCredentials((BindingProvider) replicationSam, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
210                         TckSecurity.setCredentials((BindingProvider) publishSamNode2, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
211 
212                 }
213         }
214 
215         static void refreshTokens() throws Exception {
216                 manager.start();
217                 Transport node1 = manager.getTransport(CFG_node1_MARY);
218 
219                 UDDISecurityPortType secNode1 = node1.getUDDISecurityService();
220                 rootNode1Token = TckSecurity.getAuthToken(secNode1, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
221                 maryTokenNode1 = TckSecurity.getAuthToken(secNode1, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
222 
223                 Transport node2 = manager.getTransport(CFG_node2_SAM);
224                 UDDISecurityPortType secNode2 = node2.getUDDISecurityService();
225                 rootNode2Token = TckSecurity.getAuthToken(secNode2, TckPublisher.getRootPublisherId(), TckPublisher.getRootPassword());
226                 samTokenNode2 = TckSecurity.getAuthToken(secNode2, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
227 
228         }
229 
230         @AfterClass
231         public static void stopRegistry() throws ConfigurationException {
232                 if (!TckPublisher.isEnabled()) {
233                         return;
234                 }
235                 if (!TckPublisher.isJUDDI()) {
236                         return;
237                 }
238                 if (manager != null) {
239                         manager.stop();
240                 }
241         }
242 
243         private static boolean Contains(List<Operator> operator, Operator op) {
244                 for (Operator o : operator) {
245                         if (o.getOperatorNodeID().equals(op.getOperatorNodeID())) {
246                                 return true;
247                         }
248                 }
249                 return false;
250         }
251 
252         @Test
253         public void santityTest() {
254 
255         }
256 
257         public static void testSetupReplicationConfig() {
258                 //this only runs if it is JUDDI and Replication is enabled
259                 if (!TckPublisher.isReplicationEnabled() || !TckPublisher.isJUDDI()) {
260                         logger.info("TCK says that replication is disabled...skipping replication config...");
261                         return;
262                 }
263                 try {
264                         init();
265                         refreshTokens();
266                         logger.info("fetching current replication config...");
267 
268                         ReplicationConfiguration replicationNode1 = null;
269                         try {
270                                 replicationNode1 = juddiApiServiceNode1.getReplicationNodes(rootNode1Token);
271                         } catch (Exception ex) {
272                                 logger.error("Error getting replication config",ex);
273                                 Assert.fail(ex.getMessage());
274 
275                         }
276                         //if (replicationNode1.getCommunicationGraph() == null) {
277                         replicationNode1.setCommunicationGraph(new CommunicationGraph());
278                         //}
279 
280                         replicationNode1.getOperator().clear();
281                         replicationNode1.getSignature().clear();
282 
283                         Operator op = new Operator();
284                         op.setOperatorNodeID("uddi:juddi.apache.org:node1");
285                         op.setSoapReplicationURL(manager.getClientConfig().getUDDINode(CFG_node1_MARY).getReplicationUrl());
286                         op.setOperatorStatus(OperatorStatusType.NORMAL);
287                         op.getContact().add(new Contact());
288                         op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
289                         op.getContact().get(0).setUseType("admin");
290                         //if (!Contains(replicationNode1.getOperator(), op)) {
291                                 replicationNode1.getOperator().add(op);
292                         //}
293 
294                         op = new Operator();
295                         op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
296                         op.setSoapReplicationURL(manager.getClientConfig().getUDDINode(CFG_node2_SAM).getReplicationUrl());
297                         op.setOperatorStatus(OperatorStatusType.NORMAL);
298                         op.getContact().add(new Contact());
299                         op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
300                         op.getContact().get(0).setUseType("admin");
301                         //if (!Contains(replicationNode1.getOperator(), op)) 
302                         {
303                                 replicationNode1.getOperator().add(op);
304                         }
305                         //if (!replicationNode1.getCommunicationGraph().getNode().contains("uddi:another.juddi.apache.org:node2")) {
306                                 replicationNode1.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
307                         //}
308                         //if (!replicationNode1.getCommunicationGraph().getNode().contains("uddi:juddi.apache.org:node1")) {
309                                 replicationNode1.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
310                         //}
311                         replicationNode1.setSerialNumber(0L);
312                         replicationNode1.setTimeOfConfigurationUpdate("");
313                         replicationNode1.setMaximumTimeToGetChanges(BigInteger.ONE);
314                         replicationNode1.setMaximumTimeToSyncRegistry(BigInteger.ONE);
315 
316                         if (replicationNode1.getRegistryContact().getContact() == null) {
317                                 replicationNode1.getRegistryContact().setContact(new Contact());
318                                 replicationNode1.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
319                         }
320 
321                         if (TckCommon.isDebug()) {
322                                 JAXB.marshal(replicationNode1, System.out);
323                         }
324 
325                         logger.info(manager.getClientConfig().getConfigurationFile() + " Setting replication config on Node 1...@" + ((BindingProvider) juddiApiServiceNode1).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
326                         logger.info("Setting replication url on Node 1...@" + manager.getClientConfig().getUDDINode(CFG_node1_MARY).getReplicationUrl());
327                         juddiApiServiceNode1.setReplicationNodes(rootNode1Token, replicationNode1);
328                         logger.info("Setting replication config on Node 2...@" + ((BindingProvider) juddiApiServiceNode2).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
329                         logger.info("Setting replication url on Node 2...@" + manager.getClientConfig().getUDDINode(CFG_node2_SAM).getReplicationUrl());
330                         juddiApiServiceNode2.setReplicationNodes(rootNode2Token, replicationNode1);
331 
332                 } catch (Exception ex) {
333                         TckCommon.PrintMarker();
334                         ex.printStackTrace();
335                         TckCommon.PrintMarker();
336                 }
337         }
338 
339         /**
340          * transfer business from mary/node1 to sam/node2, then delete
341          *
342          * @throws Exception
343          */
344         @Test
345         @Ignore
346         public void testMultiNodeBusinessCustodyTransfer() throws Exception {
347                 logger.info("testMultiNodeBusinessCustodyTransfer");
348                 try {
349                         Assume.assumeTrue(TckPublisher.isReplicationEnabled() && TckPublisher.isCustodyTransferEnabled());
350                         Assume.assumeTrue(TckPublisher.isJUDDI());
351                         refreshTokens();
352                         testSetupReplicationConfig();
353 
354                         getReplicationStatus();
355 
356                         //create mary's business, node1
357                         BusinessEntity mary = new BusinessEntity();
358                         mary.getName().add(new Name("Mary's biz on " + CFG_node1_MARY, null));
359                         mary.setBusinessServices(new BusinessServices());
360                         BusinessService bs = new BusinessService();
361                         bs.getName().add(new Name("Mary's service", null));
362                         bs.setBindingTemplates(new BindingTemplates());
363                         BindingTemplate bt = new BindingTemplate();
364                         bt.setAccessPoint(new AccessPoint("http://localhost/mary", "wsdlDeployment"));
365                         bs.getBindingTemplates().getBindingTemplate().add(bt);
366                         mary.getBusinessServices().getBusinessService().add(bs);
367 
368                         SaveBusiness sb = new SaveBusiness();
369                         sb.setAuthInfo(maryTokenNode1);
370                         sb.getBusinessEntity().add(mary);
371                         BusinessDetail saveBusiness = publishMary.saveBusiness(sb);
372 
373                         Thread.sleep(5000); //sleep a bit and wait for replication to do it's thing
374 
375                         GetOperationalInfo operationalInfo = new GetOperationalInfo();
376                         operationalInfo.setAuthInfo(maryTokenNode1);
377                         operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
378                         OperationalInfos beforeNode1 = inquiryMary.getOperationalInfo(operationalInfo);
379 
380                         operationalInfo.setAuthInfo(samTokenNode2);
381                         OperationalInfos beforeNode2 = null;
382                         int timeout = TckPublisher.getSubscriptionTimeout();
383                         while (timeout > 0) {
384                                 logger.info("Waiting for the update...");
385                                 try {
386                                         GetBusinessDetail gbd = new GetBusinessDetail();
387                                         gbd.setAuthInfo(samTokenNode2);
388                                         gbd.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
389 
390                                         BusinessDetail businessDetail = inquirySamNode2.getBusinessDetail(gbd);
391                                         if (businessDetail != null
392                                                 && !businessDetail.getBusinessEntity().isEmpty()) {
393                                                 logger.info("Mary's business exists on Sams node, grabbing the operational info to confirm ownership...");
394                                         }
395                                         beforeNode2 = inquirySamNode2.getOperationalInfo(operationalInfo);
396                                         break;
397                                 } catch (Exception ex) {
398                                         logger.warn(ex.getMessage());
399                                 }
400                                 timeout--;
401                                 Thread.sleep(1000);
402 
403                         }
404                         Assert.assertNotNull(beforeNode1);
405                         Assert.assertNotNull(beforeNode2);
406 
407                         JAXB.marshal(beforeNode1, System.out);
408                         JAXB.marshal(beforeNode2, System.out);
409                         //confirm we're replicated correctly
410                         Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getAuthorizedName(), beforeNode2.getOperationalInfo().get(0).getAuthorizedName());
411                         Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getEntityKey(), beforeNode2.getOperationalInfo().get(0).getEntityKey());
412                         Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getEntityKey(), saveBusiness.getBusinessEntity().get(0).getBusinessKey());
413                         Assert.assertEquals(beforeNode1.getOperationalInfo().get(0).getNodeID(), beforeNode2.getOperationalInfo().get(0).getNodeID());
414 
415                         //get a transfer token, node1
416                         KeyBag kb = new KeyBag();
417                         kb.getKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
418                         Holder<String> sourceNode = new Holder<String>();
419                         Holder<XMLGregorianCalendar> expiration = new Holder<XMLGregorianCalendar>();
420                         Holder<byte[]> token = new Holder<byte[]>();
421                         custodyMary.getTransferToken(maryTokenNode1, kb, sourceNode, expiration, token);
422 
423                         //sam accepts the transfer token, node 2
424                         TransferEntities transferEntities = new TransferEntities();
425                         transferEntities.setAuthInfo(samTokenNode2);
426                         transferEntities.setKeyBag(kb);
427                         transferEntities.setTransferToken(new TransferToken());
428                         transferEntities.getTransferToken().setExpirationTime(expiration.value);
429                         transferEntities.getTransferToken().setNodeID(sourceNode.value);
430                         transferEntities.getTransferToken().setOpaqueToken(token.value);
431                         custodySam.transferEntities(transferEntities);
432                         //stuff happens
433                         //Thread.sleep(5000);
434                         //confirm the transfer
435                         timeout = TckPublisher.getSubscriptionTimeout();
436                         OperationalInfos afterNode1 = null;
437                         OperationalInfos afterNode2 = null;
438                         while (timeout > 0) {
439                                 logger.info("Waiting for the update...");
440                                 try {
441                                         operationalInfo.setAuthInfo(maryTokenNode1);
442                                         //operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
443                                         afterNode1 = inquiryMary.getOperationalInfo(operationalInfo);
444                                         if (afterNode1.getOperationalInfo().get(0).getAuthorizedName().equals(TckPublisher.getSamPublisherId())) {
445                                                 logger.info("Mary's biz on node 1 is now owned by Sam");
446                                                 //node 1 is up to date
447                                                 operationalInfo.setAuthInfo(samTokenNode2);
448                                                 afterNode2 = inquirySamNode2.getOperationalInfo(operationalInfo);
449                                                 if (afterNode2.getOperationalInfo().get(0).getAuthorizedName().equals(TckPublisher.getSamPublisherId())) {
450                                                         //node 2 is up to date
451                                                         logger.info("Mary's biz on node 2 is now owned by Sam");
452                                                         break;
453                                                 } else {
454                                                         logger.info("Mary's biz on node 2 is still owned by Mary");
455                                                 }
456                                         } else {
457                                                 logger.info("Mary's biz on node 1 is still owned by Mary");
458                                         }
459                                 } catch (Exception ex) {
460                                         logger.warn(ex.getMessage());
461                                 }
462                                 timeout--;
463                                 Thread.sleep(1000);
464 
465                         }
466                         //operationalInfo.setAuthInfo(maryTokenNode1);
467                         // operationalInfo.getEntityKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
468 
469                         Assert.assertNotNull(afterNode1);
470                         Assert.assertNotNull(afterNode2);
471                         if (TckCommon.isDebug()) {
472                                 JAXB.marshal(afterNode1, System.out);
473                                 JAXB.marshal(afterNode2, System.out);
474 
475                         }
476                         //confirm we're replicated correctly
477                         Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getAuthorizedName(), afterNode2.getOperationalInfo().get(0).getAuthorizedName());
478                         Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getEntityKey(), afterNode2.getOperationalInfo().get(0).getEntityKey());
479                         Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getEntityKey(), saveBusiness.getBusinessEntity().get(0).getBusinessKey());
480                         Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getNodeID(), afterNode2.getOperationalInfo().get(0).getNodeID());
481                         //confirm that the entity now belongs to sam
482 
483                         Assert.assertEquals(afterNode1.getOperationalInfo().get(0).getAuthorizedName(), TckPublisher.getSamPublisherId());
484                         Assert.assertNotEquals(beforeNode1.getOperationalInfo().get(0).getNodeID(), afterNode1.getOperationalInfo().get(0).getNodeID());
485 
486                 } finally {
487                         resetTmodels();
488                         resetBusinesses();
489                 }
490         }
491 
492         /**
493          * covers business, tmodels and publisher assertions
494          *
495          * @throws Exception
496          */
497         @Test
498         //@Ignore
499         public void testReplicationTModelBusinessPublisherAssertionAddDelete() throws Exception {
500                 Assume.assumeTrue(TckPublisher.isReplicationEnabled());
501                 Assume.assumeTrue(TckPublisher.isJUDDI());
502                 try {
503                         //TckCommon.PrintMarker();
504                         logger.info("testReplicationTModelBusinessPublisherAssertionAddDelete");
505 
506                         resetTmodels();
507                         resetBusinesses();
508 
509                         TModel saveMaryPublisherTmodel = maryTModelNode1.saveMaryPublisherTmodel(maryTokenNode1);
510                         samTModelNode2.saveSamSyndicatorTmodel(samTokenNode2);
511 
512                         BusinessEntity saveMaryPublisherBusiness = maryBizNode1.saveMaryPublisherBusiness(maryTokenNode1);
513 
514                         uddiTmodelNode2.saveTModel(uddiNode2Token, TckTModel.TMODEL_PUBLISHER_TMODEL_XML_PARENT, TckTModel.TMODEL_PUBLISHER_TMODEL_KEY_ROOT);
515                         try{
516                                 uddiTmodelNode2.saveUDDIPublisherTmodel(uddiNode2Token);
517                                 uddiTmodelNode2.saveTmodels(uddiNode2Token);
518                         }catch (Throwable t) {
519                             //already exists
520                         }
521                        
522                         // TModel saveSamSyndicatorTmodel = samTModelNode2.saveSamSyndicatorTmodel(samTokenNode2);
523                         BusinessEntity saveSamSyndicatorBusiness = samBizNode2.saveSamSyndicatorBusiness(samTokenNode2);
524 
525                         // getReplicationStatus();//block until synched
526                         //confirm mary's tmodel is on the other node
527                         GetTModelDetail findTModel = new GetTModelDetail();
528                         findTModel.setAuthInfo(samTokenNode2);
529                         findTModel.getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
530                         TModelDetail tModelDetail = null;
531 
532                         int timeout = TckPublisher.getSubscriptionTimeout();
533 
534                         while (timeout > 0) {
535                                 logger.info("Waiting for the update...");
536                                 try {
537                                         tModelDetail = inquirySamNode2.getTModelDetail(findTModel);
538                                         break;
539                                 } catch (Exception ex) {
540                                         logger.warn(ex.getMessage());
541                                         tModelDetail = null;
542 
543                                 }
544                                 timeout--;
545                                 Thread.sleep(1000);
546 
547                         }
548 
549                         if (tModelDetail==null)
550                             TckCommon.PrintMarker();
551                         Assert.assertNotNull("node 2 never got mary's tmodel key generator", tModelDetail);
552                         Assert.assertNotNull(tModelDetail.getTModel());
553                         Assert.assertTrue(tModelDetail.getTModel().size() == 1);
554                         Assert.assertTrue(tModelDetail.getTModel().get(0).getTModelKey().equals(TckTModel.MARY_PUBLISHER_TMODEL_KEY));
555 
556                         GetBusinessDetail gbd = new GetBusinessDetail();
557                         gbd.setAuthInfo(samTokenNode2);
558                         gbd.getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
559 
560                         //confirm mary's biz made it too
561                         timeout = TckPublisher.getSubscriptionTimeout();
562                         BusinessDetail businessDetail = null;
563                         while (timeout > 0) {
564                                 logger.info("Waiting for the update...");
565                                 try {
566                                         businessDetail = inquirySamNode2.getBusinessDetail(gbd);
567                                         break;
568                                 } catch (Exception ex) {
569                                         logger.warn(ex.getMessage());
570                                         businessDetail = null;
571 
572                                 }
573                                 timeout--;
574                                 Thread.sleep(1000);
575 
576                         }
577                         logger.info("Business replicated");
578                         Assert.assertNotNull(businessDetail);
579                         Assert.assertNotNull(businessDetail.getBusinessEntity());
580                         Assert.assertTrue(businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(TckBusiness.MARY_BUSINESS_KEY));
581 
582                         logger.info(">>> Saving a new publisher assertion on node 2 (sam)");
583                         //setup a publisher assertion
584                         PublisherAssertion pa = new PublisherAssertion();
585                         pa.setFromKey(TckBusiness.SAM_BUSINESS_KEY);
586                         pa.setToKey(TckBusiness.MARY_BUSINESS_KEY);
587                         pa.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent-child", "child"));
588                         AddPublisherAssertions apa = new AddPublisherAssertions();
589                         apa.setAuthInfo(samTokenNode2);
590                         apa.getPublisherAssertion().add(pa);
591                         publishSamNode2.addPublisherAssertions(apa);
592 
593                         logger.info("Confirming that the assertion is saved on node2 (sam, origin)");
594                         List<AssertionStatusItem> assertionStatusReport = null;
595                         boolean found = false;
596                         assertionStatusReport = publishSamNode2.getAssertionStatusReport(samTokenNode2, null);
597                         logger.info("Publisher assertions returned: " + assertionStatusReport.size());
598                         for (int x = 0; x < assertionStatusReport.size(); x++) {
599                                 JAXB.marshal(assertionStatusReport.get(x), System.out);
600                                 if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
601                                         && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
602                                         && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
603                                         && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
604                                         && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
605                                         found = true;
606                                         break;
607                                 }
608 
609                         }
610                         Assert.assertTrue("Assertion not found on Sam's node (2)!!", found);
611                         logger.info("Ok it's saved.");
612                         //wait for synch
613                         timeout = TckPublisher.getSubscriptionTimeout();
614                         logger.info("confirming that the assertion made it to node 1");
615                         found = false;
616                         while (timeout > 0) {
617                                 logger.info("Waiting for the update...");
618                                 try {
619                                         assertionStatusReport = publishMary.getAssertionStatusReport(maryTokenNode1, null);
620                                         logger.info("Publisher assertions returned: " + assertionStatusReport.size());
621                                         for (int x = 0; x < assertionStatusReport.size(); x++) {
622                                                 JAXB.marshal(assertionStatusReport.get(x), System.out);
623                                                 if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
624                                                         && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
625                                                         && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
626                                                         && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
627                                                         && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
628                                                         found = true;
629                                                         break;
630                                                 }
631 
632                                         }
633                                         if (found) {
634                                                 break;
635                                         }
636                                 } catch (Exception ex) {
637                                         logger.warn(ex.getMessage());
638                                         Assert.fail("Unexpected failure " + ex.getMessage());
639 
640                                 }
641                                 timeout--;
642                                 Thread.sleep(1000);
643 
644                         }
645                         Assert.assertTrue("Assertion wasn't replicated", found);
646 
647                         logger.info("Publisher Assertion replicated...");
648                         logger.info("confirming the pa is still on node 2 origin (sam)");
649                         found = false;
650                         assertionStatusReport = publishSamNode2.getAssertionStatusReport(samTokenNode2, null);
651                         logger.info("Publisher assertions returned: " + assertionStatusReport.size());
652                         for (int x = 0; x < assertionStatusReport.size(); x++) {
653                                 JAXB.marshal(assertionStatusReport.get(x), System.out);
654                                 if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
655                                         && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
656                                         && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
657                                         && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
658                                         && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
659                                         found = true;
660                                         break;
661                                 }
662 
663                         }
664                         Assert.assertTrue("The PA is not found on node 2(origin), very strange", found);
665 
666                         //delete the pa
667                         DeletePublisherAssertions dpa = new DeletePublisherAssertions();
668                         dpa.setAuthInfo(samTokenNode2);
669                         dpa.getPublisherAssertion().add(pa);
670                         String sam = TckCommon.DumpAllBusinesses(samTokenNode2, inquirySamNode2);
671                         String mary = TckCommon.DumpAllBusinesses(maryTokenNode1, inquiryMary);
672                         logger.info("Publisher Assertion deletion...");
673                         try {
674                                 publishSamNode2.deletePublisherAssertions(dpa);
675                         } catch (Exception ex) {
676                                 ex.printStackTrace();
677                                 logger.info("Sam's businesses " + sam);
678                                 logger.info("Mary's businesses " + mary);
679                                 Assert.fail("unable to delete the assertion on sam's node!");
680                         }
681                         //wait for synch
682                         timeout = TckPublisher.getSubscriptionTimeout();
683 
684                         found = false;
685                         while (timeout > 0) {
686                                 logger.info("Waiting for the update...");
687                                 try {
688                                         assertionStatusReport = publishMary.getAssertionStatusReport(maryTokenNode1, null);
689                                         found = false;
690                                         for (int x = 0; x < assertionStatusReport.size(); x++) {
691                                                 JAXB.marshal(assertionStatusReport.get(x), System.out);
692                                                 if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
693                                                         && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
694                                                         && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
695                                                         && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
696                                                         && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) //still there
697                                                 {
698                                                         found = true;
699                                                 }
700 
701                                         }
702                                         if (!found) {
703                                                 break;
704                                         }
705                                 } catch (Exception ex) {
706                                         logger.warn(ex.getMessage());
707                                         Assert.fail("Unexpected failure " + ex.getMessage());
708 
709                                 }
710                                 timeout--;
711                                 Thread.sleep(1000);
712 
713                         }
714                         Assert.assertFalse("Assertion deletion wasn't replicated", found);
715                         logger.info("Publisher assertion deletion replicated");
716                         //clean up
717                         maryBizNode1.deleteMaryPublisherBusiness(maryTokenNode1);
718                         maryTModelNode1.deleteMaryPublisherTmodel(maryTokenNode1);
719 
720                         //delete both
721                         timeout = TckPublisher.getSubscriptionTimeout();
722                         businessDetail = null;
723                         while (timeout > 0) {
724                                 logger.info("Waiting for the update...");
725                                 try {
726                                         businessDetail = inquirySamNode2.getBusinessDetail(gbd);
727 
728                                 } catch (Exception ex) {
729                                         logger.warn(ex.getMessage());
730                                         businessDetail = null;
731                                         break;
732                                 }
733                                 timeout--;
734                                 Thread.sleep(1000);
735 
736                         }
737                         //check node2 for delete biz, should be gone
738 
739                         if (businessDetail != null) {
740                                 Assert.fail(TckBusiness.MARY_BUSINESS_KEY + " wasn't deleted on node 2");
741                         }
742                         logger.info("Mary's business deletion was replicated");
743 
744                         tModelDetail = inquirySamNode2.getTModelDetail(findTModel);
745                         while (timeout > 0) {
746                                 logger.info("Waiting for the update...");
747                                 try {
748 
749                                         tModelDetail = inquirySamNode2.getTModelDetail(findTModel);
750                                         Assert.assertNotNull(tModelDetail);
751                                         Assert.assertNotNull(tModelDetail.getTModel());
752                                         Assert.assertNotNull(tModelDetail.getTModel().get(0));
753                                         Assert.assertEquals(tModelDetail.getTModel().get(0).getTModelKey(), TckTModel.MARY_PUBLISHER_TMODEL_KEY);
754                                         if (tModelDetail.getTModel().get(0).isDeleted()) {
755                                                 break;
756                                         }
757                                 } catch (Exception ex) {
758                                         logger.warn(ex.getMessage());
759                                         tModelDetail = null;
760                                         break;
761                                 }
762                                 timeout--;
763                                 Thread.sleep(1000);
764 
765                         }
766                         Assert.assertNotNull(tModelDetail);
767                         Assert.assertNotNull(tModelDetail.getTModel());
768                         Assert.assertNotNull(tModelDetail.getTModel().get(0));
769                         Assert.assertEquals(tModelDetail.getTModel().get(0).getTModelKey(), TckTModel.MARY_PUBLISHER_TMODEL_KEY);
770                         Assert.assertEquals(tModelDetail.getTModel().get(0).isDeleted(), true);
771                         logger.info("Mary's tModel was deleted(hidden) replicated");
772                         // TckCommon.PrintMarker();
773 
774                 } finally {
775 
776                         try{
777                                 samBizNode2.deleteSamSyndicatorBusiness(samTokenNode2);
778                         } catch (Throwable t) {
779                             
780                         }
781                         resetTmodels();
782                         resetBusinesses();
783 
784                 }
785                 //check node2 for a "hidden" tmodel should be accessible via getDetails
786         }
787 
788         @Test
789         public void testReplicationPublisherAssertionSet() throws Exception {
790                 Assume.assumeTrue(TckPublisher.isReplicationEnabled());
791                 Assume.assumeTrue(TckPublisher.isJUDDI());
792                 logger.info("testReplicationPublisherAssertionSet");
793         }
794 
795         /**
796          * covers adding and removing a service and a binding
797          *
798          * @throws Exception
799          */
800         @Test
801         @Ignore
802         public void testReplicationServiceBindingAddRemove() throws Exception {
803                 Assume.assumeTrue(TckPublisher.isReplicationEnabled());
804                 Assume.assumeTrue(TckPublisher.isJUDDI());
805                 logger.info("testReplicationServiceBindingAddRemove");
806 
807                 try {
808                         //TckCommon.PrintMarker();
809 
810                         resetBusinesses();
811                         resetTmodels();
812                        
813                         uddiTmodelNode2.saveUDDIPublisherTmodel(uddiNode2Token);
814                         uddiTmodelNode2.saveTmodels(uddiNode2Token);
815                         //samTModelNode2.saveTmodels(rootNode2Token); //should be owned by the uddi account?
816                         
817                         samTModelNode2.saveSamSyndicatorTmodel(samTokenNode2);
818                         samBizNode2.saveSamSyndicatorBusiness(samTokenNode2);
819 
820                         // getReplicationStatus();//block until synched
821                         //confirm sam's tmodel is on the other node
822                         GetTModelDetail findTModel = new GetTModelDetail();
823                         findTModel.setAuthInfo(maryTokenNode1);
824                         findTModel.getTModelKey().add(TckTModel.SAM_SYNDICATOR_TMODEL_KEY);
825                         TModelDetail tModelDetail = null;
826 
827                         int timeout = TckPublisher.getSubscriptionTimeout();
828 
829                         while (timeout > 0) {
830                                 logger.info("Waiting for the update...");
831                                 try {
832                                         tModelDetail = inquiryMary.getTModelDetail(findTModel);
833                                         break;
834                                 } catch (Exception ex) {
835                                         logger.warn(ex.getMessage());
836                                         tModelDetail = null;
837 
838                                 }
839                                 timeout--;
840                                 Thread.sleep(1000);
841 
842                         }
843 
844                         Assert.assertNotNull(tModelDetail);
845                         Assert.assertNotNull(tModelDetail.getTModel());
846                         Assert.assertTrue(tModelDetail.getTModel().size() == 1);
847                         Assert.assertTrue(tModelDetail.getTModel().get(0).getTModelKey().equals(TckTModel.SAM_SYNDICATOR_TMODEL_KEY));
848 
849                         GetBusinessDetail gbd = new GetBusinessDetail();
850                         gbd.setAuthInfo(maryTokenNode1);
851                         gbd.getBusinessKey().add(TckBusiness.SAM_BUSINESS_KEY);
852 
853                         //confirm mary's biz made it too
854                         timeout = TckPublisher.getSubscriptionTimeout();
855                         BusinessDetail businessDetail = null;
856                         while (timeout > 0) {
857                                 logger.info("Waiting for the update...");
858                                 try {
859                                         businessDetail = inquiryMary.getBusinessDetail(gbd);
860                                         break;
861                                 } catch (Exception ex) {
862                                         logger.warn(ex.getMessage());
863                                         businessDetail = null;
864 
865                                 }
866                                 timeout--;
867                                 Thread.sleep(1000);
868 
869                         }
870 
871                         Assert.assertNotNull(businessDetail);
872                         Assert.assertNotNull(businessDetail.getBusinessEntity());
873                         Assert.assertTrue(businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(TckBusiness.SAM_BUSINESS_KEY));
874                         logger.info("Business replicated");
875 
876                         //save a service
877                         samServiceNode2.saveSamSyndicatorService(samTokenNode2);
878 
879                         GetServiceDetail gsd = new GetServiceDetail();
880                         gsd.setAuthInfo(maryTokenNode1);
881                         gsd.getServiceKey().add(TckBusinessService.SAM_SERVICE_KEY);
882 
883                         //confirm sam's service made it too
884                         timeout = TckPublisher.getSubscriptionTimeout();
885                         ServiceDetail sd = null;
886                         while (timeout > 0) {
887                                 logger.info("Waiting for the update...");
888                                 try {
889                                         sd = inquiryMary.getServiceDetail(gsd);
890                                         break;
891                                 } catch (Exception ex) {
892                                         logger.warn(ex.getMessage());
893                                         sd = null;
894 
895                                 }
896                                 timeout--;
897                                 Thread.sleep(1000);
898 
899                         }
900 
901                         Assert.assertNotNull(sd);
902                         Assert.assertNotNull(sd.getBusinessService());
903                         Assert.assertTrue(sd.getBusinessService().get(0).getBusinessKey().equals(TckBusiness.SAM_BUSINESS_KEY));
904                         Assert.assertTrue(sd.getBusinessService().get(0).getServiceKey().equals(TckBusinessService.SAM_SERVICE_KEY));
905                         logger.info("Service replicated");
906 
907                         BindingTemplate newbt = new BindingTemplate();
908                         newbt.setServiceKey(TckBusinessService.SAM_SERVICE_KEY);
909                         newbt.setAccessPoint(new AccessPoint("http://localhost", "wsdlDeployment"));
910                         newbt.getDescription().add(new Description("a new accesspoint that's replicated!", "en"));
911                         SaveBinding saveBind = new SaveBinding();
912                         saveBind.setAuthInfo(samTokenNode2);
913                         saveBind.getBindingTemplate().add(newbt);
914                         logger.info("Binding saved");
915                         BindingDetail saveBinding = publishSamNode2.saveBinding(saveBind);
916 
917                         GetBindingDetail bindingDetail = new GetBindingDetail();
918                         bindingDetail.setAuthInfo(maryTokenNode1);
919                         bindingDetail.getBindingKey().add(saveBinding.getBindingTemplate().get(0).getBindingKey());
920 
921                         //confirm sam's binding made it too
922                         timeout = TckPublisher.getSubscriptionTimeout();
923                         BindingDetail savedMary = null;
924                         while (timeout > 0) {
925                                 logger.info("Waiting for the update...");
926                                 try {
927                                         savedMary = inquiryMary.getBindingDetail(bindingDetail);
928                                         break;
929                                 } catch (Exception ex) {
930                                         logger.warn(ex.getMessage());
931                                         savedMary = null;
932 
933                                 }
934                                 timeout--;
935                                 Thread.sleep(1000);
936 
937                         }
938                         Assert.assertNotNull(savedMary);
939                         Assert.assertNotNull(savedMary.getBindingTemplate());
940                         Assert.assertNotNull(savedMary.getBindingTemplate().get(0));
941                         Assert.assertEquals(savedMary.getBindingTemplate().get(0).getBindingKey(), saveBinding.getBindingTemplate().get(0).getBindingKey());
942                         Assert.assertEquals(savedMary.getBindingTemplate().get(0).getServiceKey(), saveBinding.getBindingTemplate().get(0).getServiceKey());
943                         logger.info("Binding was replicated");
944 
945                         //delete the binding
946                         DeleteBinding db = new DeleteBinding();
947                         db.setAuthInfo(samTokenNode2);
948                         db.getBindingKey().add(saveBinding.getBindingTemplate().get(0).getBindingKey());
949                         publishSamNode2.deleteBinding(db);
950                         logger.info("binding deleted");
951 
952                         //confirm deletion
953                         timeout = TckPublisher.getSubscriptionTimeout();
954                         BindingDetail gbindd = null;
955                         GetBindingDetail getBindingDetail = new GetBindingDetail();
956                         getBindingDetail.setAuthInfo(maryTokenNode1);
957                         getBindingDetail.getBindingKey().add(saveBinding.getBindingTemplate().get(0).getBindingKey());
958                         while (timeout > 0) {
959                                 logger.info("Waiting for the update...");
960                                 try {
961                                         gbindd = inquiryMary.getBindingDetail(getBindingDetail);
962 
963                                 } catch (Exception ex) {
964                                         logger.warn(ex.getMessage());
965                                         gbindd = null;
966                                         break;
967                                 }
968                                 timeout--;
969                                 Thread.sleep(1000);
970 
971                         }
972                         //check node2 for delete biz, should be gone
973 
974                         if (gbindd != null) {
975                                 Assert.fail(saveBinding.getBindingTemplate().get(0).getBindingKey() + " wasn't deleted on node 1");
976                         }
977                         logger.info("binding deletion was replicated");
978 
979                         //delete the service
980                         DeleteService delsvc = new DeleteService();
981                         delsvc.setAuthInfo(samTokenNode2);
982                         delsvc.getServiceKey().add(TckBusinessService.SAM_SERVICE_KEY);
983                         publishSamNode2.deleteService(delsvc);
984                         logger.info("service deleted");
985 
986                         ServiceDetail sdd = null;
987                         //confirm deletion
988                         GetServiceDetail getServiceDetail = new GetServiceDetail();
989                         getServiceDetail.setAuthInfo(maryTokenNode1);
990                         getServiceDetail.getServiceKey().add(TckBusinessService.SAM_SERVICE_KEY);
991                         timeout = TckPublisher.getSubscriptionTimeout();
992                         while (timeout > 0) {
993                                 logger.info("Waiting for the update...");
994                                 try {
995                                         sdd = inquiryMary.getServiceDetail(getServiceDetail);
996 
997                                 } catch (Exception ex) {
998                                         logger.warn(ex.getMessage());
999                                         sdd = null;
1000                                         break;
1001                                 }
1002                                 timeout--;
1003                                 Thread.sleep(1000);
1004 
1005                         }
1006                         //check node2 for delete biz, should be gone
1007 
1008                         if (sdd != null) {
1009                                 Assert.fail(TckBusinessService.SAM_SERVICE_KEY + " wasn't deleted on node 1");
1010                         }
1011                         logger.info("service deletion was replicated");
1012 
1013                         //clean up
1014                         samBizNode2.deleteSamSyndicatorBusiness(samTokenNode2);
1015                         samTModelNode2.deleteSamSyndicatorTmodel(samTokenNode2);
1016 
1017                         //delete both
1018                         timeout = TckPublisher.getSubscriptionTimeout();
1019                         businessDetail = null;
1020 
1021                         while (timeout > 0) {
1022                                 logger.info("Waiting for the update...");
1023                                 try {
1024                                         businessDetail = inquiryMary.getBusinessDetail(gbd);
1025 
1026                                 } catch (Exception ex) {
1027                                         logger.warn(ex.getMessage());
1028                                         businessDetail = null;
1029                                         break;
1030                                 }
1031                                 timeout--;
1032                                 Thread.sleep(1000);
1033 
1034                         }
1035                         //check node2 for delete biz, should be gone
1036 
1037                         if (businessDetail != null) {
1038                                 Assert.fail(TckBusiness.SAM_BUSINESS_KEY + " wasn't deleted on node 1");
1039                         }
1040                         logger.info("sam's business deletion was replicated");
1041 
1042                         tModelDetail = inquiryMary.getTModelDetail(findTModel);
1043                         Assert.assertNotNull(tModelDetail);
1044                         Assert.assertNotNull(tModelDetail.getTModel());
1045                         Assert.assertNotNull(tModelDetail.getTModel().get(0));
1046                         Assert.assertEquals(tModelDetail.getTModel().get(0).getTModelKey(), TckTModel.SAM_SYNDICATOR_TMODEL_KEY);
1047                         Assert.assertEquals(tModelDetail.getTModel().get(0).isDeleted(), true);
1048                         logger.info("sam's tModel was deleted(hidden) replicated");
1049                         // TckCommon.PrintMarker();
1050                         logger.info("Test passed");
1051 
1052                 } finally {
1053                         //TckCommon.PrintMarker();
1054                         //logger.fatal("The test failed, attempting to clean up the business and tModels");
1055                         try {
1056                                 DeleteBusiness db = new DeleteBusiness();
1057                                 db.setAuthInfo(samTokenNode2);
1058                                 db.getBusinessKey().add(TckBusiness.SAM_BUSINESS_KEY);
1059                                 try {
1060                                         publishSamNode2.deleteBusiness(db);
1061                                 } catch (Exception ex) {
1062                                 }
1063                                 int timeout = TckPublisher.getSubscriptionTimeout();
1064                                 GetBusinessDetail findTModel = new GetBusinessDetail();
1065                                 findTModel.setAuthInfo(maryTokenNode1);
1066                                 findTModel.getBusinessKey().add(TckBusiness.SAM_BUSINESS_KEY);
1067                                 BusinessDetail tModelDetail = null;
1068                                 while (timeout > 0) {
1069                                         logger.info("Waiting for the update...");
1070                                         try {
1071                                                 tModelDetail = inquiryMary.getBusinessDetail(findTModel);
1072                                         } catch (Exception ex) {
1073                                                 logger.warn(ex.getMessage());
1074                                                 tModelDetail = null;
1075                                                 break;
1076 
1077                                         }
1078                                         timeout--;
1079                                         try {
1080                                                 Thread.sleep(1000);
1081                                         } catch (InterruptedException ex) {
1082 
1083                                         }
1084 
1085                                 }
1086                                 Assert.assertNull(tModelDetail);
1087 
1088                         } catch (Exception ex) {
1089                                 ex.printStackTrace();
1090                         }
1091                         resetTmodels();
1092 
1093                 }
1094 
1095         }
1096 
1097         /**
1098          * this function basically waits until the nodes are done synchronizing
1099          *
1100          * @throws Exception
1101          */
1102         private void getReplicationStatus() throws Exception {
1103               //  logger.info("Getting replication status....Mary's node1...");
1104                 //  waitUntilSynched(replicationMary);
1105                 //  logger.info("Getting replication status....Sam's node2...");
1106                 //  waitUntilSynched(replicationSam);
1107         }
1108 
1109         private void waitUntilSynched(UDDIReplicationPortType repl) throws Exception {
1110                 List<ChangeRecordIDType> mary = repl.getHighWaterMarks();
1111                 JAXB.marshal(mary.get(0), System.out);
1112 
1113                 Long highmary = mary.get(0).getOriginatingUSN();
1114                 Thread.sleep(1000);
1115                 Long highmary2 = mary.get(0).getOriginatingUSN();
1116                 int counter = 0;
1117                 while (highmary2 > highmary && counter < 90) { //indicates that there are still changes being processed
1118                         highmary = highmary2;
1119                         //= mary.get(0).getOriginatingUSN();
1120                         Thread.sleep(1000);
1121                         mary = repl.getHighWaterMarks();
1122                         highmary2 = mary.get(0).getOriginatingUSN();
1123                         logger.info("Changes are still being processesed...." + highmary2 + ">" + highmary);
1124                         counter++;
1125                 }
1126                 if (counter == 90) {
1127                         TckCommon.PrintMarker();
1128                         logger.info("Changes are still being processed after a " + counter + "sec wait!!");
1129                 }
1130 
1131         }
1132 
1133         private void resetTmodels() {
1134 
1135                 logger.info("resetting tmodels");
1136                 DeleteTModel dtm = new DeleteTModel();
1137                 dtm.setAuthInfo(rootNode1Token);
1138                 dtm.getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
1139                 try {
1140                         juddiApiServiceNode1.adminDeleteTModel(dtm);
1141                         logger.info("Node1 mary deleted");
1142                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquirySamNode2, samTokenNode2);
1143                 } catch (Exception ex) {
1144                         logger.info("unable to delete tmodel " + ex.getMessage());
1145                 }
1146 
1147                 dtm = new DeleteTModel();
1148                 dtm.setAuthInfo(rootNode1Token);
1149                 dtm.getTModelKey().add(TckTModel.JOE_PUBLISHER_TMODEL_KEY);
1150                 try {
1151                         juddiApiServiceNode1.adminDeleteTModel(dtm);
1152                         logger.info("Node1 joe deleted");
1153                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquirySamNode2, samTokenNode2);
1154                 } catch (Exception ex) {
1155                         logger.info("unable to delete tmodel " + ex.getMessage());
1156                 }
1157 
1158                 dtm = new DeleteTModel();
1159                 dtm.setAuthInfo(rootNode1Token);
1160                 dtm.getTModelKey().add(TckTModel.SAM_SYNDICATOR_TMODEL_KEY);
1161                 try {
1162                         juddiApiServiceNode1.adminDeleteTModel(dtm);
1163                         logger.info("Node1 sam deleted");
1164                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquirySamNode2, samTokenNode2);
1165                 } catch (Exception ex) {
1166                         logger.info("unable to delete tmodel " + ex.getMessage());
1167                 }
1168 
1169                 dtm = new DeleteTModel();
1170                 dtm.setAuthInfo(rootNode2Token);
1171                 dtm.getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
1172                 try {
1173                         juddiApiServiceNode2.adminDeleteTModel(dtm);
1174                         logger.info("Node2 mary deleted");
1175                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquiryMary, maryTokenNode1);
1176                 } catch (Exception ex) {
1177                         logger.info("unable to delete tmodel " + ex.getMessage());
1178                 }
1179 
1180                 dtm = new DeleteTModel();
1181                 dtm.setAuthInfo(rootNode2Token);
1182                 dtm.getTModelKey().add(TckTModel.JOE_PUBLISHER_TMODEL_KEY);
1183                 try {
1184                         juddiApiServiceNode2.adminDeleteTModel(dtm);
1185                         logger.info("Node2 joe deleted");
1186                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquiryMary, maryTokenNode1);
1187                 } catch (Exception ex) {
1188                         logger.info("unable to delete tmodel " + ex.getMessage());
1189                 }
1190 
1191                 dtm = new DeleteTModel();
1192                 dtm.setAuthInfo(rootNode2Token);
1193                 dtm.getTModelKey().add(TckTModel.SAM_SYNDICATOR_TMODEL_KEY);
1194                 try {
1195                         juddiApiServiceNode2.adminDeleteTModel(dtm);
1196                         logger.info("Node2 sam deleted");
1197                         waitForTModelAdminDeletion(dtm.getTModelKey().get(0), inquiryMary, maryTokenNode1);
1198                 } catch (Exception ex) {
1199                         logger.info("unable to delete tmodel " + ex.getMessage());
1200                 }
1201         }
1202 
1203         private void resetBusinesses() {
1204                 logger.info("resetting businesses");
1205                 DeleteBusiness dtm = new DeleteBusiness();
1206                 dtm.setAuthInfo(rootNode1Token);
1207                 dtm.getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
1208                 try {
1209                         publishMary.deleteBusiness(dtm);
1210                         logger.info("Node1 mary deleted");
1211                 } catch (Exception ex) {
1212                         logger.info("unable to delete business " + ex.getMessage());
1213                 }
1214                 dtm.setAuthInfo(rootNode2Token);
1215                 try {
1216                         publishSamNode2.deleteBusiness(dtm);
1217                         logger.info("Node2 mary deleted");
1218                 } catch (Exception ex) {
1219                         logger.info("unable to delete business " + ex.getMessage());
1220                 }
1221 
1222                 dtm = new DeleteBusiness();
1223                 dtm.setAuthInfo(rootNode1Token);
1224                 dtm.getBusinessKey().add(TckBusiness.JOE_BUSINESS_KEY);
1225                 try {
1226                         publishMary.deleteBusiness(dtm);
1227                         logger.info("Node1 joe deleted");
1228                 } catch (Exception ex) {
1229                         logger.info("unable to delete business " + ex.getMessage());
1230                 }
1231                 dtm.setAuthInfo(rootNode2Token);
1232                 try {
1233                         publishSamNode2.deleteBusiness(dtm);
1234                         logger.info("Node2 joe deleted");
1235                 } catch (Exception ex) {
1236                         logger.info("unable to delete business " + ex.getMessage());
1237                 }
1238 
1239                 dtm = new DeleteBusiness();
1240                 dtm.setAuthInfo(rootNode1Token);
1241                 dtm.getBusinessKey().add(TckBusiness.SAM_BUSINESS_KEY);
1242                 try {
1243                         publishMary.deleteBusiness(dtm);
1244                         logger.info("Node1 sam deleted");
1245                 } catch (Exception ex) {
1246                         logger.info("unable to delete business " + ex.getMessage());
1247                 }
1248                 dtm.setAuthInfo(rootNode2Token);
1249                 try {
1250                         publishSamNode2.deleteBusiness(dtm);
1251                         logger.info("Node2 sam deleted");
1252                 } catch (Exception ex) {
1253                         logger.info("unable to delete business " + ex.getMessage());
1254                 }
1255 
1256         }
1257 
1258         private void waitForTModelAdminDeletion(String tModelKey, UDDIInquiryPortType inquiry, String token) {
1259 
1260                 int timeout = TckPublisher.getSubscriptionTimeout();
1261                 GetTModelDetail findTModel = new GetTModelDetail();
1262                 findTModel.setAuthInfo(token);
1263                 findTModel.getTModelKey().add(tModelKey);
1264                 TModel tModelDetail = null;
1265                 while (timeout > 0) {
1266                         logger.info("Waiting for the update...");
1267                         try {
1268                             TModelDetail tModelDetail1 = inquiry.getTModelDetail(findTModel);
1269                             if (tModelDetail1==null || tModelDetail1.getTModel().isEmpty()) {
1270                                 tModelDetail = null;
1271                                 break;
1272                             } else {
1273                                 tModelDetail = tModelDetail1.getTModel().get(0);
1274                             }
1275                         } catch (Exception ex) {
1276                                 logger.warn(ex.getMessage());
1277                                 tModelDetail = null;
1278                                 break;
1279                         }
1280                         timeout--;
1281                         try {
1282                                 Thread.sleep(1000);
1283                         } catch (InterruptedException ex) {
1284 
1285                         }
1286 
1287                 }
1288                 Assert.assertNull("the tModel with the key " + tModelKey + " wasn't deleted", tModelDetail);
1289                 logger.info("******************** " + tModelKey + " confired removed at all nodes");
1290 
1291         }
1292 
1293         /**
1294          * If the same key is created at two nodes before the replication change
1295          * record has been distributed, it's possible for the same record to be
1296          * owned by two different nodes. After a short period of time, both
1297          * records should be rejected
1298          *
1299          * <a href="http://www.uddi.org/pubs/uddi-v3.0.2-20041019.htm#_Toc85908178">7.3.9</a>
1300          * for more info on collision detection
1301          *
1302          * requires support for conditional new data inserts and concurrence
1303          * from nodes.
1304          *
1305          * @throws Exception
1306          */
1307         @Test
1308         @Ignore
1309         public void replicationConflictMaintainOwership() throws Exception {
1310                 try {
1311                         resetTmodels();
1312 
1313                         maryTModelNode1.saveMaryPublisherTmodel(maryTokenNode1);
1314                         samTModelNode2.saveMaryPublisherTmodel(samTokenNode2);
1315 
1316                         //TODO assert both records removed
1317                 } finally {
1318                         resetTmodels();
1319                 }
1320 
1321         }
1322 
1323 }