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.v2.tck;
16  
17  import org.apache.juddi.v2.tck.*;
18  import javax.xml.ws.BindingProvider;
19  import org.apache.commons.configuration.ConfigurationException;
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  import org.apache.juddi.v3.client.config.UDDIClient;
23  import org.apache.juddi.v3.client.transport.JAXWSv2TranslationTransport;
24  import org.apache.juddi.v3.client.transport.Transport;
25  import org.junit.AfterClass;
26  import org.junit.Assert;
27  import org.junit.Assume;
28  import org.junit.BeforeClass;
29  import org.junit.Test;
30  import org.uddi.v2_service.*;
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 Inquire inquiryJoe=null;
47          protected static Inquire 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                          JAXWSv2TranslationTransport transport = (JAXWSv2TranslationTransport) manager.getTransport("uddiv2");
69                          
70                          Publish security = transport.getUDDIv2PublishService();
71                          authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
72                          authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
73                          //Assert.assertNotNull(authInfoJoe);
74                          //Assert.assertNotNull(authInfoSam);
75  
76  
77                          Publish publication = transport.getUDDIv2PublishService();
78                          Inquire inquiry = transport.getUDDIv2InquiryService();
79                          if (!TckPublisher.isUDDIAuthMode()) {
80                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
81                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
82                          }
83                          tckTModelJoe = new TckTModel(publication, inquiry);
84                          tckBusinessJoe = new TckBusiness(publication, inquiry);
85                          tckBusinessServiceJoe = new TckBusinessService(publication, inquiry);
86                          inquiryJoe = inquiry;
87  
88                          transport = (JAXWSv2TranslationTransport) manager.getTransport("uddiv2");
89                          publication = transport.getUDDIv2PublishService();
90                          inquiry = transport.getUDDIv2InquiryService();
91                          if (!TckPublisher.isUDDIAuthMode()) {
92                                  TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
93                                  TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
94                          }
95                          tckTModelSam = new TckTModel(publication, inquiry);
96                          tckBusinessSam = new TckBusiness(publication, inquiry);
97                          tckBusinessServiceSam = new TckBusinessService(publication, inquiry);
98                          inquirySam = inquiry;
99                          
100                         transport = (JAXWSv2TranslationTransport) manager.getTransport("uddiv2");
101                         publication = transport.getUDDIv2PublishService();
102                         inquiry = transport.getUDDIv2InquiryService();
103                         String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
104                         if (!TckPublisher.isUDDIAuthMode()) {
105                                 TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
106                                 TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
107                         }
108                         
109                         TckTModel tckTModel = new TckTModel(publication, inquiry);
110                         tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
111                         tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
112                 } catch (Exception e) {
113                         logger.error(e.getMessage(), e);
114                         Assert.fail("Could not obtain authInfo token.");
115                 }
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 }