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 at7 * http://www.apache.org/licenses/LICENSE-2.08 * 9 * Unless required by applicable law or agreed to in writing, software10 * 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 and13 * limitations under the License.14 */15package org.apache.juddi.api.impl;
1617import java.rmi.RemoteException;
1819import org.apache.commons.configuration.ConfigurationException;
20import org.apache.commons.logging.Log;
21import org.apache.commons.logging.LogFactory;
22import org.apache.juddi.Registry;
23import org.apache.juddi.v3.tck.TckBusiness;
24import org.apache.juddi.v3.tck.TckBusinessService;
25import org.apache.juddi.v3.tck.TckPublisher;
26import org.apache.juddi.v3.tck.TckSecurity;
27import org.apache.juddi.v3.tck.TckTModel;
28import org.junit.AfterClass;
29import org.junit.Assert;
30import org.junit.BeforeClass;
31import org.junit.Test;
32import org.uddi.v3_service.UDDISecurityPortType;
3334/**35 * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>36 * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>37 */38publicclassAPI_040_BusinessServiceTest39 {
40privatestatic Log logger = LogFactory.getLog(API_040_BusinessServiceTest.class);
4142privatestaticAPI_010_PublisherTest api010 = new API_010_PublisherTest();
43privatestatic TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
44privatestatic TckBusiness tckBusiness = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
45privatestatic TckBusinessService tckBusinessService = new TckBusinessService(new UDDIPublicationImpl(), new UDDIInquiryImpl());
4647privatestatic String authInfoJoe = null;
48privatestatic String authInfoSam = null;
4950 @BeforeClass
51publicstaticvoid setup() throws ConfigurationException {
52 Registry.start();
53 logger.info("API_040_BusinessServiceTest");
54 logger.debug("Getting auth tokens..");
5556try {
57 api010.saveJoePublisher();
58 api010.saveSamSyndicator();
59 UDDISecurityPortType security = new UDDISecurityImpl();
60 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
61 authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
62 String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
63 tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
64 tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
65 } catch (RemoteException e) {
66 logger.error(e.getMessage(), e);
67 Assert.fail("Could not obtain authInfo token.");
68 }
69 }
7071 @AfterClass
72publicstaticvoid stopRegistry() throws ConfigurationException {
73 tckTModel.deleteCreatedTModels(authInfoJoe);
74 Registry.stop();
75 }
7677 @Test
78publicvoid joepublisher() {
79try {
80 tckTModel.saveJoePublisherTmodel(authInfoJoe);
81 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
82 tckBusinessService.saveJoePublisherService(authInfoJoe);
83 tckBusinessService.deleteJoePublisherService(authInfoJoe);
84 } finally {
85 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
86 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
87 }
88 }
8990 @Test
91publicvoid joepublisher2Services() {
92try {
93 tckTModel.saveJoePublisherTmodel(authInfoJoe);
94 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
95 tckBusinessService.saveJoePublisherService(authInfoJoe);
96 tckBusinessService.saveJoePublisherService2(authInfoJoe);
97 tckBusinessService.deleteJoePublisherService(authInfoJoe);
98 tckBusinessService.deleteJoePublisherService2(authInfoJoe);
99 } finally {
100 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
101 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
102 }
103 }
104105 @Test
106publicvoid joepublisher2UpdateBusiness() {
107try {
108 tckTModel.saveJoePublisherTmodel(authInfoJoe);
109 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
110 tckBusinessService.saveJoePublisherService(authInfoJoe);
111 tckBusinessService.saveJoePublisherService2(authInfoJoe);
112 tckBusiness.updateJoePublisherBusiness(authInfoJoe);
113 tckBusinessService.deleteJoePublisherService(authInfoJoe);
114 tckBusinessService.deleteJoePublisherService2(authInfoJoe);
115 } finally {
116 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
117 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
118 }
119 }
120/**121 * 5.2.16.3 paragraph 4122 * Data contained within businessEntity structures can be rearranged with 123 * this API call. This can be done by redefining parent container relationships 124 * for other registered information. For instance, if a new businessEntity 125 * is saved with information about a businessService that is registered 126 * already as part of a different businessEntity, this results in the 127 * businessService being moved from its current container to the new businessEntity. 128 * This condition occurs when the businessKey of the businessService being 129 * saved matches the businessKey of the businessEntity being saved. 130 * An attempt to delete or move a businessService in this manner by 131 * a party who is not the publisher of the businessService MUST be 132 * rejected with an error E_userMismatch.133 */134 @Test
135publicvoid joepublisherMoveBusinessService() {
136try {
137 tckTModel.saveJoePublisherTmodel(authInfoJoe);
138 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
139 tckBusinessService.saveJoePublisherService(authInfoJoe);
140 tckBusiness.checkServicesBusinessOne(1);
141 tckBusiness.saveJoePublisherBusiness3(authInfoJoe);
142//check that this business has no services143 tckBusiness.checkServicesBusinessThree(0);
144//Now move the service from one to three145 tckBusiness.saveJoePublisherBusiness1to3(authInfoJoe);
146 tckBusiness.checkServicesBusinessOne(0);
147 tckBusiness.checkServicesBusinessThree(1);
148 } catch (Exception e) {
149 e.printStackTrace();
150 Assert.fail(e.getMessage());
151 } finally {
152 tckBusinessService.deleteJoePublisherService(authInfoJoe);
153 tckBusiness.deleteJoePublisherBusiness3(authInfoJoe);
154 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
155 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
156 }
157 }
158159 @Test
160publicvoid samsyndicator() {
161try {
162// For sam's service projection, joe's information must be loaded163 tckTModel.saveJoePublisherTmodel(authInfoJoe);
164 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
165 tckBusinessService.saveJoePublisherService(authInfoJoe);
166167 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
168 tckBusiness.saveSamSyndicatorBusinessWithProjection(authInfoSam);
169 tckBusinessService.saveSamSyndicatorService(authInfoSam);
170 tckBusinessService.deleteSamSyndicatorService(authInfoSam);
171 } finally {
172 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
173 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
174175 tckBusinessService.deleteJoePublisherService(authInfoJoe);
176 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
177 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
178 }
179 }
180181 }