This project has retired. For details please refer to its Attic page.
JNDIRegistrationTest xref
View Javadoc
1   /*
2    * Copyright 2001-2010 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.rmi;
16  
17  import org.apache.commons.configuration.ConfigurationException;
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.mockejb.jndi.MockContextFactory;
21  
22  /**
23   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
24   */
25  public class JNDIRegistrationTest 
26  {
27  	@Test
28  	public void registerToJNDI_AnonymousPort() throws ConfigurationException
29  	{
30  		try {
31  			MockContextFactory.setAsInitial();
32  			//register all jUDDI services, under an anonymous port
33  		    JNDIRegistration.getInstance().register(0);
34  		    JNDIRegistration.getInstance().unregister();
35  		    
36  		} catch (Exception e) {
37  			e.printStackTrace();
38  			Assert.fail();
39  		}
40  	}
41  	
42  	@Test
43  	public void registerToJNDI_UserDefinedPort() throws ConfigurationException
44  	{
45  		try {
46  			MockContextFactory.setAsInitial();
47  			//register all jUDDI services, under an use defined port
48  		    JNDIRegistration.getInstance().register(34567);
49  		    JNDIRegistration.getInstance().unregister();
50  		    
51  		} catch (Exception e) {
52  			e.printStackTrace();
53  			Assert.fail();
54  		}
55  	}
56  	
57  	
58  }