This project has retired. For details please refer to its Attic page.
UDDI_040_BusinessServiceIntegrationTest 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.v3_service.UDDIInquiryPortType;
29  import org.uddi.v3_service.UDDIPublicationPortType;
30  import org.uddi.v3_service.UDDISecurityPortType;
31  
32  /**
33   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
34   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
35   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
36   */
37  public class UDDI_040_BusinessServiceIntegrationTest {
38  
39          protected static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
40          protected static TckTModel tckTModelJoe = null;
41          protected static TckBusiness tckBusinessJoe = null;
42          protected static TckBusinessService tckBusinessServiceJoe = null;
43          protected static TckTModel tckTModelSam = null;
44          protected static TckBusiness tckBusinessSam = null;
45          protected static TckBusinessService tckBusinessServiceSam = null;
46          protected static UDDIInquiryPortType inquiryJoe=null;
47          protected static UDDIInquiryPortType inquirySam=null;
48          protected static String authInfoJoe = null;
49          protected static String authInfoSam = null;
50          private static UDDIClient manager;
51  
52          @AfterClass
53          public static void stopManager() throws ConfigurationException {
54               if (!TckPublisher.isEnabled()) return;
55                  tckTModelJoe.deleteCreatedTModels(authInfoJoe);
56                  tckTModelSam.deleteCreatedTModels(authInfoSam);
57                  manager.stop();
58          }
59  
60          @BeforeClass
61          public static void startManager() throws ConfigurationException {
62               if (!TckPublisher.isEnabled()) return;
63                  manager = new UDDIClient();
64                  manager.start();
65  
66                  logger.debug("Getting auth tokens..");
67                  try {
68                          Transport transport = manager.getTransport("uddiv3");
69                          UDDISecurityPortType security = transport.getUDDISecurityService();
70                          authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
71                          authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
72                          //Assert.assertNotNull(authInfoJoe);
73                          //Assert.assertNotNull(authInfoSam);
74  
75  
76                          UDDIPublicationPortType publication = transport.getUDDIPublishService();
77                          UDDIInquiryPortType inquiry = transport.getUDDIInquiryService();
78                          if (!TckPublisher.isUDDIAuthMode()) {
79                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
80                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
81                          }
82                          tckTModelJoe = new TckTModel(publication, inquiry);
83                          tckBusinessJoe = new TckBusiness(publication, inquiry);
84                          tckBusinessServiceJoe = new TckBusinessService(publication, inquiry);
85                          inquiryJoe = inquiry;
86  
87                          transport = manager.getTransport("uddiv3");
88                          publication = transport.getUDDIPublishService();
89                          inquiry = transport.getUDDIInquiryService();
90                          if (!TckPublisher.isUDDIAuthMode()) {
91                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
92                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
93                          }
94                          tckTModelSam = new TckTModel(publication, inquiry);
95                          tckBusinessSam = new TckBusiness(publication, inquiry);
96                          tckBusinessServiceSam = new TckBusinessService(publication, inquiry);
97                          inquirySam = inquiry;
98                          
99                          transport = manager.getTransport("uddiv3");
100                         publication = transport.getUDDIPublishService();
101                         inquiry = transport.getUDDIInquiryService();
102                         String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
103                         if (!TckPublisher.isUDDIAuthMode()) {
104                                 TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
105                                 TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
106                         }
107                         
108                         TckTModel tckTModel = new TckTModel(publication, inquiry);
109                         tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
110                         tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
111                 } catch (Exception e) {
112                         logger.error(e.getMessage(), e);
113                         Assert.fail("Could not obtain authInfo token.");
114                 }
115                 JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
116         }
117 
118         @Test
119         public void joepublisher() throws Exception {
120              Assume.assumeTrue(TckPublisher.isEnabled());
121                 try {
122                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
123                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
124                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
125                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
126                 } finally {
127                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
128                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
129                 }
130         }
131 
132         @Test
133         public void samsyndicator() throws Exception {
134              Assume.assumeTrue(TckPublisher.isEnabled());
135                 try {
136 
137                         tckTModelSam.saveSamSyndicatorTmodel(authInfoSam);
138                         tckBusinessSam.saveSamSyndicatorBusiness(authInfoSam);
139                         tckBusinessServiceSam.saveSamSyndicatorService(authInfoSam);
140                         tckBusinessServiceSam.deleteSamSyndicatorService(authInfoSam);
141                 } finally {
142                         tckBusinessSam.deleteSamSyndicatorBusiness(authInfoSam);
143                         tckTModelSam.deleteSamSyndicatorTmodel(authInfoSam);
144                 }
145         }
146 
147         /**
148          * 5.2.16.3 paragraph 4 Data contained within businessEntity structures
149          * can be rearranged with this API call. This can be done by redefining
150          * parent container relationships for other registered information. For
151          * instance, if a new businessEntity is saved with information about a
152          * businessService that is registered already as part of a different
153          * businessEntity, this results in the businessService being moved from
154          * its current container to the new businessEntity. This condition
155          * occurs when the businessKey of the businessService being saved
156          * matches the businessKey of the businessEntity being saved. An attempt
157          * to delete or move a businessService in this manner by a party who is
158          * not the publisher of the businessService MUST be rejected with an
159          * error E_userMismatch.
160          */
161         @Test
162         public void joepublisherMoveBusinessService() {
163              Assume.assumeTrue(TckPublisher.isEnabled());
164                 try {
165                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
166                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
167                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
168                         tckBusinessJoe.checkServicesBusinessOne(1);
169                         tckBusinessJoe.saveJoePublisherBusiness3(authInfoJoe);
170                         //check that this business has no services
171                         tckBusinessJoe.checkServicesBusinessThree(0);
172                         //Now move the service from one to three
173                         tckBusinessJoe.saveJoePublisherBusiness1to3(authInfoJoe);
174                         tckBusinessJoe.checkServicesBusinessOne(0);
175                         tckBusinessJoe.checkServicesBusinessThree(1);
176                 } catch (Exception e) {
177                         logger.error(e);
178                         Assert.fail(e.getMessage());
179                 } finally {
180                         tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
181                         tckBusinessJoe.deleteJoePublisherBusiness3(authInfoJoe);
182                         tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
183                         tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
184                 }
185         }
186 }