This project has retired. For details please refer to its Attic page.
API_020_TmodelTest 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.api.impl;
16  
17  import java.rmi.RemoteException;
18  
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.Registry;
23  import org.apache.juddi.v3.tck.TckPublisher;
24  import org.apache.juddi.v3.tck.TckSecurity;
25  import org.apache.juddi.v3.tck.TckTModel;
26  import org.junit.AfterClass;
27  import org.junit.Assert;
28  import org.junit.BeforeClass;
29  import org.junit.Test;
30  import org.uddi.api_v3.CategoryBag;
31  import org.uddi.api_v3.KeyedReference;
32  import org.uddi.api_v3.Name;
33  import org.uddi.api_v3.TModel;
34  import org.uddi.api_v3.TModelDetail;
35  import org.uddi.api_v3.TModelInfo;
36  import org.uddi.api_v3.TModelList;
37  import org.uddi.v3_service.DispositionReportFaultMessage;
38  import org.uddi.v3_service.UDDISecurityPortType;
39  
40  /**
41   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
42   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
43   */
44  public class API_020_TmodelTest {
45  	
46  	private static TckTModel tckTModel                = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
47  	private static Log logger                         = LogFactory.getLog(API_020_TmodelTest.class);
48  	private static API_010_PublisherTest api010       = new API_010_PublisherTest();
49  	private static String authInfoJoe                 = null;
50  	private static String authInfoSam                 = null;
51  	
52  	@BeforeClass
53  	public static void setup() throws ConfigurationException, RemoteException {
54  		Registry.start();
55  		logger.debug("Getting auth tokens..");
56  		try {
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  	}
67  	
68  	@AfterClass
69  	public static void stopRegistry() throws ConfigurationException {
70  		Registry.stop();
71  	}
72  	
73  	@Test
74  	public void testJoePublisherTmodel() {
75  		tckTModel.saveJoePublisherTmodel(authInfoJoe, true);
76  		
77  		//Now if we use a finder it should be found.
78  		TModelList tModelList = tckTModel.findJoeTModelDetail();
79  		Assert.assertNotNull(tModelList.getTModelInfos());
80  		
81  		tckTModel.deleteJoePublisherTmodel(authInfoJoe);
82  		
83  		//Even if it deleted you should still be able to access it through a getTModelDetail
84  		TModelDetail detail = tckTModel.getJoePublisherTmodel(authInfoJoe);
85  		Assert.assertNotNull(detail.getTModel());
86  		
87  		//However if we use a finder it should not be found.
88  		TModelList tModelList2 = tckTModel.findJoeTModelDetail();
89  		Assert.assertNull(tModelList2.getTModelInfos());
90  		
91  		//Make sure none of the found key generators is Joe's key generator
92  		TModelList tModelList3 = tckTModel.findJoeTModelDetailByCategoryBag();
93  		for (TModelInfo tModelInfo : tModelList3.getTModelInfos().getTModelInfo()) {
94  			Assert.assertFalse("uddi:uddi.joepublisher.com:keygenerator".equals(tModelInfo.getTModelKey()));
95  		}
96  	}
97  	
98  	@Test
99  	public void testSamSyndicatorTmodelTest() {
100 		tckTModel.saveSamSyndicatorTmodel(authInfoSam);
101 		tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
102 	}	
103 	
104      
105      @Test
106      public void 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"));
111           
112           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);
119           
120           tckTModel.deleteTModel(authInfoJoe, null, "uddi:uddi.joepublisher.com:juddi956-2");
121           tckTModel.deleteTModel(authInfoJoe, null, "uddi:uddi.joepublisher.com:juddi956");
122           tckTModel.deleteJoePublisherTmodel(authInfoJoe);
123           
124      }
125 }