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.TckPublisher;
24import org.apache.juddi.v3.tck.TckSecurity;
25import org.apache.juddi.v3.tck.TckTModel;
26import org.junit.AfterClass;
27import org.junit.Assert;
28import org.junit.BeforeClass;
29import org.junit.Test;
30import org.uddi.api_v3.CategoryBag;
31import org.uddi.api_v3.KeyedReference;
32import org.uddi.api_v3.Name;
33import org.uddi.api_v3.TModel;
34import org.uddi.api_v3.TModelDetail;
35import org.uddi.api_v3.TModelInfo;
36import org.uddi.api_v3.TModelList;
37import org.uddi.v3_service.DispositionReportFaultMessage;
38import org.uddi.v3_service.UDDISecurityPortType;
3940/**41 * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>42 * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>43 */44publicclassAPI_020_TmodelTest {
4546privatestatic TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
47privatestatic Log logger = LogFactory.getLog(API_020_TmodelTest.class);
48privatestaticAPI_010_PublisherTest api010 = new API_010_PublisherTest();
49privatestatic String authInfoJoe = null;
50privatestatic String authInfoSam = null;
5152 @BeforeClass
53publicstaticvoid setup() throws ConfigurationException, RemoteException {
54 Registry.start();
55 logger.debug("Getting auth tokens..");
56try {
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 } catch (DispositionReportFaultMessage e) {
63 logger.error(e.getMessage(), e);
64 Assert.fail("Could not obtain authInfo token.");
65 }
66 }
6768 @AfterClass
69publicstaticvoid stopRegistry() throws ConfigurationException {
70 Registry.stop();
71 }
7273 @Test
74publicvoid testJoePublisherTmodel() {
75 tckTModel.saveJoePublisherTmodel(authInfoJoe, true);
7677//Now if we use a finder it should be found.78 TModelList tModelList = tckTModel.findJoeTModelDetail();
79 Assert.assertNotNull(tModelList.getTModelInfos());
8081 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
8283//Even if it deleted you should still be able to access it through a getTModelDetail84 TModelDetail detail = tckTModel.getJoePublisherTmodel(authInfoJoe);
85 Assert.assertNotNull(detail.getTModel());
8687//However if we use a finder it should not be found.88 TModelList tModelList2 = tckTModel.findJoeTModelDetail();
89 Assert.assertNull(tModelList2.getTModelInfos());
9091//Make sure none of the found key generators is Joe's key generator92 TModelList tModelList3 = tckTModel.findJoeTModelDetailByCategoryBag();
93for (TModelInfo tModelInfo : tModelList3.getTModelInfos().getTModelInfo()) {
94 Assert.assertFalse("uddi:uddi.joepublisher.com:keygenerator".equals(tModelInfo.getTModelKey()));
95 }
96 }
9798 @Test
99publicvoid testSamSyndicatorTmodelTest() {
100 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
101 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
102 }
103104105 @Test
106publicvoid testJUDDI956Test(){
107 tckTModel.saveJoePublisherTmodel(authInfoJoe, true);
108 TModel one = new TModel();
109 one.setTModelKey("uddi:uddi.joepublisher.com:juddi956");
110 one.setName(new Name("JUDDI-956 Test case", "EN"));
111112 tckTModel.saveTModel(authInfoJoe, one, false);
113 TModel two = new TModel();
114 two.setTModelKey("uddi:uddi.joepublisher.com:juddi956-2");
115 two.setName(new Name("JUDDI-956 Test case", "EN"));
116 two.setCategoryBag(new CategoryBag());
117 two.getCategoryBag().getKeyedReference().add(new KeyedReference("uddi:uddi.joepublisher.com:juddi956", "juddi956", "a value"));
118 tckTModel.saveTModel(authInfoJoe, one, false);
119120 tckTModel.deleteTModel(authInfoJoe, null, "uddi:uddi.joepublisher.com:juddi956-2");
121 tckTModel.deleteTModel(authInfoJoe, null, "uddi:uddi.joepublisher.com:juddi956");
122 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
123124 }
125 }