KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.IOException JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 import java.util.Set JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Collections JavaDoc;
32
33 import javax.management.ObjectName JavaDoc;
34
35 import com.sun.appserv.management.base.AMX;
36 import com.sun.appserv.management.base.Util;
37 import com.sun.appserv.management.base.Container;
38 import com.sun.appserv.management.base.XTypes;
39
40 import com.sun.appserv.management.config.AMXConfig;
41 import com.sun.appserv.management.config.HTTPServiceConfig;
42 import com.sun.appserv.management.config.VirtualServerConfig;
43 import com.sun.appserv.management.config.HTTPAccessLogConfig;
44 import com.sun.appserv.management.config.VirtualServerConfigKeys;
45
46 import com.sun.appserv.management.util.misc.MapUtil;
47
48
49 import com.sun.enterprise.management.AMXTestBase;
50 import com.sun.enterprise.management.Capabilities;
51
52 /**
53  */

54 public final class VirtualServerConfigTest extends ConfigMgrTestBase
55 {
56     static final String JavaDoc HOSTS = "localhost";
57     
58         public
59     VirtualServerConfigTest ()
60     {
61     }
62     
63         protected Container
64     getProgenyContainer()
65     {
66         return getHTTPService();
67     }
68
69         protected String JavaDoc
70     getProgenyJ2EEType()
71     {
72         return XTypes.VIRTUAL_SERVER_CONFIG;
73     }
74
75
76         protected void
77     removeProgeny( final String JavaDoc name )
78     {
79         getHTTPService().removeVirtualServerConfig( name );
80     }
81
82         protected final VirtualServerConfig
83     create(String JavaDoc name)
84     {
85         return (VirtualServerConfig)createProgeny( name, null );
86     }
87     
88         private Map JavaDoc<String JavaDoc,String JavaDoc>
89     getOptional()
90     {
91         final Map JavaDoc<String JavaDoc,String JavaDoc> m = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
92         m.put( VirtualServerConfigKeys.STATE_KEY, VirtualServerConfigKeys.STATE_DISABLED );
93         m.put( VirtualServerConfigKeys.DOC_ROOT_PROPERTY_KEY, "/" );
94         m.put( VirtualServerConfigKeys.ACCESS_LOG_PROPERTY_KEY, "/" );
95         
96         return m;
97     }
98
99         protected final AMXConfig
100     createProgeny(
101         final String JavaDoc name,
102         final Map JavaDoc<String JavaDoc,String JavaDoc> extra )
103     {
104         final Map JavaDoc<String JavaDoc,String JavaDoc> allOptions = MapUtil.newMap( extra, getOptional() );
105         
106         return( getHTTPService().createVirtualServerConfig( name, "localhost", allOptions ) );
107     }
108
109         protected final HTTPServiceConfig
110     getHTTPService()
111     {
112         return getConfigConfig().getHTTPServiceConfig();
113     }
114
115         public void
116     testCreateHTTPAccessLog()
117         throws Exception JavaDoc
118     {
119         if ( ! checkNotOffline( "testCreateRemove" ) )
120         {
121             return;
122         }
123         
124         final String JavaDoc NAME = "VirtualServerConfigMgrTest-testCreateHTTPAccessLog";
125         try
126         {
127             removeEx( NAME );
128             final VirtualServerConfig newVS =
129                 (VirtualServerConfig)createProgeny( NAME, null);
130             assert newVS != null;
131             //trace( "newVS.getState: " + newVS.getState() );
132
// assert newVS.getState().equals("disabled");
133

134             assert( newVS.getHTTPAccessLogConfig() == null );
135             
136             final HTTPAccessLogConfig accessLog =
137                 newVS.createHTTPAccessLogConfig( false, "${com.sun.aas.instanceRoot}/logs/access", null);
138             assert ( accessLog != null );
139             assert ( Util.getObjectName( accessLog ).equals( Util.getObjectName( newVS.getHTTPAccessLogConfig() ) ) );
140             
141             newVS.removeHTTPAccessLogConfig();
142         }
143         finally
144         {
145             remove( NAME );
146         }
147     }
148 }
149
150
151
Popular Tags