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.v2.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.JAXWSv2TranslationTransport;
23  import org.junit.AfterClass;
24  import org.junit.Assert;
25  import org.junit.Assume;
26  import org.junit.BeforeClass;
27  import org.junit.Ignore;
28  import org.junit.Test;
29  import org.uddi.api_v2.TModelDetail;
30  import org.uddi.api_v2.TModelInfo;
31  import org.uddi.api_v2.TModelList;
32  import org.uddi.v2_service.Inquire;
33  import org.uddi.v2_service.Publish;
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()) return;
52                  manager = new UDDIClient();
53                  manager.start();
54                  logger.debug("Getting auth tokens..");
55                  try {
56                          JAXWSv2TranslationTransport transport = (JAXWSv2TranslationTransport) manager.getTransport("uddiv2");
57  
58                          Publish security = transport.getUDDIv2PublishService();
59                          authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
60                          authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
61                          //Assert.assertNotNull(authInfoJoe);
62                          //Assert.assertNotNull(authInfoSam);
63  
64                          Publish publication = transport.getUDDIv2PublishService();
65                          Inquire inquiry = transport.getUDDIv2InquiryService();
66                          if (!TckPublisher.isUDDIAuthMode()) {
67                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
68                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
69                          }
70                          tckTModelJoe = new TckTModel(publication, inquiry);
71  
72                          transport = (JAXWSv2TranslationTransport) manager.getTransport("uddiv2");
73                          publication = transport.getUDDIv2PublishService();
74                          inquiry = transport.getUDDIv2InquiryService();
75                          if (!TckPublisher.isUDDIAuthMode()) {
76                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
77                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
78                          }
79                          tckTModelSam = new TckTModel(publication, inquiry);
80  
81                  } catch (Exception e) {
82                          logger.error(e.getMessage(), e);
83                          Assert.fail("Could not obtain authInfo token.");
84                  }
85          }
86  
87          @AfterClass
88          public static void stopManager() throws ConfigurationException {
89                  if (!TckPublisher.isEnabled()) return;
90                  tckTModelJoe.deleteCreatedTModels(authInfoJoe);
91                  tckTModelSam.deleteCreatedTModels(authInfoSam);
92                  manager.stop();
93          }
94  
95          @Test
96          @Ignore //commented out 2017-10-9, uddiv2 behaves different?
97          public void testJoePublisherTmodel() {
98                  Assume.assumeTrue(TckPublisher.isEnabled());
99                  tckTModelJoe.saveJoePublisherTmodel(authInfoJoe, true);
100 
101                 //Now if we use a finder it should be found.
102                 TModelList tModelList = tckTModelJoe.findJoeTModelDetail();
103                 Assert.assertNotNull(tModelList.getTModelInfos());
104 
105                 tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
106 
107                 //Even if it deleted you should still be able to access it through a getTModelDetail
108                 TModelDetail detail = tckTModelJoe.getJoePublisherTmodel(authInfoJoe);
109                 Assert.assertNotNull(detail.getTModel());
110 
111                 //However if we use a finder it should not be found.
112                 TModelList tModelList2 = tckTModelJoe.findJoeTModelDetail();
113                 
114                 Assert.assertTrue(tModelList2.getTModelInfos()==null || tModelList2.getTModelInfos().getTModelInfo().isEmpty());
115 
116                 //Make sure none of the found key generators is Joe's key generator
117                 TModelList tModelList3 = tckTModelJoe.findJoeTModelDetailByCategoryBag();
118                 for (TModelInfo tModelInfo : tModelList3.getTModelInfos().getTModelInfo()) {
119                         Assert.assertFalse(TckTModel.JOE_PUBLISHER_TMODEL_KEY.equals(tModelInfo.getTModelKey()));
120                 }
121         }
122 
123         @Test
124         public void testSamSyndicatorTmodelTest() {
125                 Assume.assumeTrue(TckPublisher.isEnabled());
126                 tckTModelSam.saveSamSyndicatorTmodel(authInfoSam);
127                 tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam);
128         }
129 }