This project has retired. For details please refer to its Attic page.
UDDI_020_TmodelIntegrationTest xref
View Javadoc
1   /*
2    * Copyright 2001-2009 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    *      http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.apache.juddi.v3.tck;
16  
17  import javax.xml.ws.BindingProvider;
18  import org.apache.commons.configuration.ConfigurationException;
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  import org.apache.juddi.v3.client.config.UDDIClient;
22  import org.apache.juddi.v3.client.transport.Transport;
23  import org.junit.AfterClass;
24  import org.junit.Assert;
25  import org.junit.Assume;
26  import org.junit.BeforeClass;
27  import org.junit.Test;
28  import org.uddi.api_v3.TModelDetail;
29  import org.uddi.api_v3.TModelInfo;
30  import org.uddi.api_v3.TModelList;
31  import org.uddi.v3_service.UDDIInquiryPortType;
32  import org.uddi.v3_service.UDDIPublicationPortType;
33  import org.uddi.v3_service.UDDISecurityPortType;
34  
35  /**
36   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
37   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
38   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
39   */
40  public class UDDI_020_TmodelIntegrationTest {
41  
42          private static TckTModel tckTModelJoe = null;
43          private static TckTModel tckTModelSam = null;
44          private static Log logger = LogFactory.getLog(UDDI_020_TmodelIntegrationTest.class);
45          private static String authInfoJoe = null;
46          private static String authInfoSam = null;
47          private static UDDIClient manager;
48  
49          @BeforeClass
50          public static void startManager() throws ConfigurationException {
51                  if (!TckPublisher.isEnabled()) {
52                          return;
53                  }
54                  manager = new UDDIClient();
55                  manager.start();
56                  logger.debug("Getting auth tokens..");
57                  try {
58                          Transport transport = manager.getTransport("uddiv3");
59  
60                          UDDISecurityPortType security = transport.getUDDISecurityService();
61                          authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
62                          authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
63                          //Assert.assertNotNull(authInfoJoe);
64                          //Assert.assertNotNull(authInfoSam);
65  
66                          UDDIPublicationPortType publication = transport.getUDDIPublishService();
67                          UDDIInquiryPortType inquiry = transport.getUDDIInquiryService();
68                          if (!TckPublisher.isUDDIAuthMode()) {
69                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
70                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
71                          }
72                          tckTModelJoe = new TckTModel(publication, inquiry);
73  
74                          transport = manager.getTransport("uddiv3");
75                          publication = transport.getUDDIPublishService();
76                          inquiry = transport.getUDDIInquiryService();
77                          if (!TckPublisher.isUDDIAuthMode()) {
78                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
79                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
80                          }
81                          tckTModelSam = new TckTModel(publication, inquiry);
82  
83                  } catch (Exception e) {
84                          logger.error(e.getMessage(), e);
85                          Assert.fail("Could not obtain authInfo token.");
86                  }
87                  JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
88          }
89  
90          @AfterClass
91          public static void stopManager() throws ConfigurationException {
92                  if (!TckPublisher.isEnabled()) {
93                          return;
94                  }
95                  tckTModelJoe.deleteCreatedTModels(authInfoJoe);
96                  tckTModelSam.deleteCreatedTModels(authInfoSam);
97                  manager.stop();
98          }
99  
100         @Test
101         public void testJoePublisherTmodel() {
102                 Assume.assumeTrue(TckPublisher.isEnabled());
103                 tckTModelJoe.saveJoePublisherTmodel(authInfoJoe, true);
104 
105                 //Now if we use a finder it should be found.
106                 TModelList tModelList = tckTModelJoe.findJoeTModelDetail();
107                 Assert.assertNotNull(tModelList.getTModelInfos());
108 
109                 tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
110 
111                 //Even if it deleted you should still be able to access it through a getTModelDetail
112                 TModelDetail detail = tckTModelJoe.getJoePublisherTmodel(authInfoJoe);
113                 Assert.assertNotNull(detail.getTModel());
114 
115                 //However if we use a finder it should not be found.
116                 TModelList tModelList2 = tckTModelJoe.findJoeTModelDetail();
117                 Assert.assertNull(tModelList2.getTModelInfos());
118 
119                 //Make sure none of the found key generators is Joe's key generator
120                 TModelList tModelList3 = tckTModelJoe.findJoeTModelDetailByCategoryBag();
121                 for (TModelInfo tModelInfo : tModelList3.getTModelInfos().getTModelInfo()) {
122                         Assert.assertFalse("uddi:uddi.joepublisher.com:keygenerator".equals(tModelInfo.getTModelKey()));
123                 }
124         }
125 
126         @Test
127         public void testSamSyndicatorTmodelTest() {
128                 Assume.assumeTrue(TckPublisher.isEnabled());
129                 tckTModelSam.saveSamSyndicatorTmodel(authInfoSam);
130                 tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam);
131         }
132 }