KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Set JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.HashMap JavaDoc;
29
30 import javax.management.ObjectName JavaDoc;
31 import javax.management.JMException JavaDoc;
32
33
34 import com.sun.enterprise.management.AMXTestBase;
35 import com.sun.enterprise.management.Capabilities;
36
37 import com.sun.appserv.management.config.DomainConfig;
38 import com.sun.appserv.management.config.LifecycleModuleConfig;
39
40 import com.sun.appserv.management.helper.RefHelper;
41
42 import com.sun.enterprise.management.support.AMXLifecycleModule;
43
44 /**
45  */

46 public final class LifecycleModuleConfigTest extends AMXTestBase
47 {
48     // built-into server already
49
private static final String JavaDoc IMPL_CLASSNAME = AMXLifecycleModule.class.getName();
50         
51     private static final String JavaDoc TEST_NAME_BASE = "custom";
52     private static final String JavaDoc TEST_TYPE = "CustomMBeanConfigTest";
53     
54         public
55     LifecycleModuleConfigTest ()
56     {
57         if ( checkNotOffline( "ensureDefaultInstance" ) )
58         {
59             ensureDefaultInstance( getDomainConfig() );
60         }
61     }
62     
63        public static String JavaDoc
64     getDefaultInstanceName()
65     {
66         return getDefaultInstanceName( "LifecycleModuleConfig" );
67     }
68     
69         public static LifecycleModuleConfig
70     ensureDefaultInstance( final DomainConfig domainConfig )
71     {
72         LifecycleModuleConfig result =
73             domainConfig.getLifecycleModuleConfigMap().get( getDefaultInstanceName() );
74         
75         if ( result == null )
76         {
77             result = createInstance(
78                 domainConfig,
79                 getDefaultInstanceName(),
80                 IMPL_CLASSNAME,
81                 1 );
82         }
83         
84         return result;
85     }
86     
87         public static LifecycleModuleConfig
88     createInstance(
89         final DomainConfig domainConfig,
90         final String JavaDoc name,
91         final String JavaDoc classname,
92         final int loadOrder )
93     {
94         final boolean isFailureFatal = false;
95         final boolean enabled = true;
96         final String JavaDoc classpath = "/test";
97         final String JavaDoc description = null;
98         
99         final LifecycleModuleConfig life =
100             domainConfig.createLifecycleModuleConfig( name,
101                                 description,
102                                 classname,
103                                 classpath,
104                                 "" + loadOrder,
105                                 isFailureFatal,
106                                 enabled,
107                                 null );
108         
109         return life;
110     }
111     
112     
113         public Map JavaDoc<String JavaDoc,LifecycleModuleConfig>
114     getLifecycleModuleConfigs()
115     {
116         return getDomainConfig().getLifecycleModuleConfigMap();
117     }
118     
119         private void
120     _testGetAll()
121     {
122         
123         final Map JavaDoc<String JavaDoc,LifecycleModuleConfig> all = getLifecycleModuleConfigs();
124         assert( all != null );
125     }
126     
127         private void
128     sanityCheck( final LifecycleModuleConfig config )
129     {
130         config.setClassname( config.getClassname() );
131         
132         final String JavaDoc classpath = config.getClasspath();
133         config.setClasspath( classpath == null ? "" : classpath );
134         
135         config.setLoadOrder( config.getLoadOrder() );
136         
137         config.setIsFailureFatal( config.getIsFailureFatal() );
138         
139         config.setEnabled( config.getEnabled() );
140     }
141
142         public synchronized void
143     testAttrs()
144     {
145         ensureDefaultInstance( getDomainConfig() );
146         
147         final Map JavaDoc<String JavaDoc,LifecycleModuleConfig> all = getLifecycleModuleConfigs();
148         
149         if ( all.size() != 0 )
150         {
151             for( final LifecycleModuleConfig config : all.values() )
152             {
153                 sanityCheck( config );
154             }
155         }
156         else
157         {
158             warning( "LifecycleModuleConfigTest: No LifecycleModuleConfig to test" );
159         }
160     }
161     
162         public synchronized void
163     testCreateRemove()
164     {
165         final DomainConfig domainConfig = getDomainConfig();
166         
167     }
168 }
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Popular Tags