KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.management.config;
24
25 import java.util.Map JavaDoc;
26
27 import com.sun.appserv.management.base.Container;
28 import com.sun.appserv.management.base.XTypes;
29
30 import com.sun.appserv.management.config.AMXConfig;
31 import com.sun.appserv.management.config.ClusterConfig;
32 import com.sun.appserv.management.config.DomainConfig;
33
34
35 import com.sun.enterprise.management.AMXTestBase;
36 import com.sun.enterprise.management.Capabilities;
37 import com.sun.enterprise.management.ClusterSupportRequired;
38
39 /**
40     Test the creation/removal of ClusterConfig
41  */

42 public final class ClusterConfigTest extends ConfigMgrTestBase
43     implements ClusterSupportRequired
44 {
45         public
46     ClusterConfigTest ()
47     {
48         if ( checkNotOffline( "ensureDefaultInstance" ) )
49         {
50             ensureDefaultInstance( getDomainConfig() );
51         }
52     }
53     
54         public static String JavaDoc
55     getDefaultInstanceName()
56     {
57         return getDefaultInstanceName( "test-cluster" );
58     }
59     
60         public static ClusterConfig
61     ensureDefaultInstance( final DomainConfig domainConfig )
62     {
63         ClusterConfig result =
64             domainConfig.getClusterConfigMap().get( getDefaultInstanceName() );
65         
66         if ( result == null )
67         {
68             result = domainConfig.createClusterConfig(
69                         getDefaultInstanceName(), null, null );
70         }
71         
72         return result;
73     }
74     
75         protected Container
76     getProgenyContainer()
77     {
78         return getDomainConfig();
79     }
80
81         protected String JavaDoc
82     getProgenyJ2EEType()
83     {
84         return XTypes.CLUSTER_CONFIG;
85     }
86
87
88         protected void
89     removeProgeny( final String JavaDoc name )
90     {
91         getDomainConfig().removeClusterConfig( name );
92     }
93     
94
95         protected final AMXConfig
96     createProgeny(
97         final String JavaDoc name,
98         final Map JavaDoc<String JavaDoc,String JavaDoc> options )
99     {
100         assert( name != null && name.length() >= 1 );
101         return getDomainConfig().createClusterConfig( name, null, options );
102     }
103     
104         public void
105     testCreateWithIllegalConfig()
106     {
107         try
108         {
109             getDomainConfig().createClusterConfig( "dummy-cluster-1", "no such config", null );
110             failure( "expecting failure creating cluster with illegal config name" );
111             
112             getDomainConfig().createClusterConfig( "dummy-cluster-2", "server-config", null );
113             failure( "expecting failure creating cluster with name 'server-config'" );
114             
115             getDomainConfig().createClusterConfig( "dummy-cluster-2", "default-config", null );
116             failure( "expecting failure creating name 'default-config'" );
117         }
118         catch( Exception JavaDoc e )
119         {
120             // good
121
}
122     }
123 }
124
125
126
127
128
129
130
131
132
Popular Tags