KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > IIOPListenerConfigTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/tests/com/sun/enterprise/management/config/IIOPListenerConfigTest.java,v 1.5 2006/03/09 20:30:54 llc Exp $
26  * $Revision: 1.5 $
27  * $Date: 2006/03/09 20:30:54 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Set JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.HashMap JavaDoc;
34
35 import javax.management.ObjectName JavaDoc;
36
37 import com.sun.appserv.management.base.AMX;
38 import com.sun.appserv.management.base.Container;
39 import com.sun.appserv.management.base.XTypes;
40 import com.sun.appserv.management.util.misc.MapUtil;
41
42 import com.sun.appserv.management.base.Util;
43 import com.sun.appserv.management.config.AMXConfig;
44 import com.sun.appserv.management.config.IIOPServiceConfig;
45 import com.sun.appserv.management.config.IIOPListenerConfig;
46 import com.sun.appserv.management.config.SSLConfig;
47 import com.sun.appserv.management.config.PropertiesAccess;
48 import com.sun.appserv.management.config.IIOPListenerConfigKeys;
49
50
51 import com.sun.enterprise.management.AMXTestBase;
52 import com.sun.enterprise.management.Capabilities;
53
54 /**
55  */

56 public final class IIOPListenerConfigTest extends ConfigMgrTestBase
57 {
58     static final String JavaDoc ADDRESS = "0.0.0.0";
59     static final Map JavaDoc<String JavaDoc,String JavaDoc> OPTIONAL = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
60     static
61     {
62         OPTIONAL.put( PropertiesAccess.PROPERTY_PREFIX + "xyz", "abc");
63         OPTIONAL.put( IIOPListenerConfigKeys.ENABLED_KEY , "false");
64         OPTIONAL.put( IIOPListenerConfigKeys.SECURITY_ENABLED_KEY, "true");
65     }
66
67         public
68     IIOPListenerConfigTest ()
69     {
70     }
71     
72         protected Container
73     getProgenyContainer()
74     {
75         return getIIOPService();
76     }
77
78         protected String JavaDoc
79     getProgenyJ2EEType()
80     {
81         return XTypes.IIOP_LISTENER_CONFIG;
82     }
83
84
85         protected void
86     removeProgeny( final String JavaDoc name )
87     {
88         getIIOPService().removeIIOPListenerConfig( name );
89     }
90     
91
92         protected final ObjectName JavaDoc
93     create(String JavaDoc name)
94     {
95         return Util.getObjectName( createProgeny( name, null ) );
96     }
97     
98         protected final AMXConfig
99     createProgeny( final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
100     {
101         final Map JavaDoc<String JavaDoc,String JavaDoc> allOptions = MapUtil.newMap( options, OPTIONAL );
102         
103         final int port = (name.hashCode() % 32000) + 32000;
104         allOptions.put( IIOPListenerConfigKeys.PORT_KEY, "" + port );
105         
106         return getIIOPService().createIIOPListenerConfig(name, ADDRESS, allOptions );
107     }
108     
109         protected final IIOPServiceConfig
110     getIIOPService()
111     {
112         return getConfigConfig().getIIOPServiceConfig();
113     }
114
115         public void
116     testCreateSSL()
117         throws Exception JavaDoc
118     {
119         if ( ! checkNotOffline( "testCreateSSL" ) )
120         {
121             return;
122         }
123         
124         final String JavaDoc NAME = "IIOPListenerConfigMgr-testCreateSSL";
125         
126         removeEx( NAME );
127             
128         final IIOPListenerConfig newListener =
129             (IIOPListenerConfig)createProgeny( NAME, null );
130             
131         try
132         {
133             final Map JavaDoc<String JavaDoc,IIOPListenerConfig> listeners =
134                 getIIOPService().getIIOPListenerConfigMap();
135             
136             final IIOPListenerConfig listener =
137                 (IIOPListenerConfig)listeners.get( NAME );
138             assert listener != null;
139             assert listener == newListener;
140             
141             final String JavaDoc CERT_NICKNAME = NAME + "Cert";
142             
143             final SSLConfig ssl = listener.createSSLConfig( CERT_NICKNAME, null);
144             assert ssl != null;
145             assert ssl.getCertNickname().equals( CERT_NICKNAME );
146             
147             listener.removeSSLConfig();
148         }
149         finally
150         {
151             remove( NAME );
152         }
153     }
154 /*
155         public void
156     testCreateSSLClientConfig()
157         throws Exception
158     {
159         final Set<IIOPServiceConfig> s = getQueryMgr().getJ2EETypeProxies("X-IIOPServiceConfig");
160         assert s.size() >= 0;
161         IIOPServiceConfig iiopService = (IIOPServiceConfig)s.iterator().next();
162         assert iiopService != null;
163         Map sslParams = new HashMap();
164         sslParams.put("CertNickname", "mycert");
165         final ObjectName on = iiopService.createIIOPSSLClientConfig(sslParams);
166         assert on != null && on.equals(iiopService.getIIOPSSLClientConfigObjectName());
167         IIOPSSLClientConfig sslClientConfig = iiopService.getIIOPSSLClientConfig();
168         assert sslClientConfig != null;
169     }
170  */

171 }
172
173
174
Popular Tags