KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28
29 import com.sun.appserv.management.base.AMX;
30 import com.sun.appserv.management.base.Util;
31
32 import com.sun.appserv.management.config.Libraries;
33
34 import com.sun.appserv.management.util.misc.GSetUtil;
35 import com.sun.appserv.management.util.misc.ArrayUtil;
36
37 import com.sun.appserv.management.config.WebModuleConfig;
38
39 import com.sun.enterprise.management.AMXTestBase;
40
41
42
43 /**
44  */

45 public final class LibrariesTest extends AMXTestBase
46 {
47     public LibrariesTest()
48     {
49     }
50     
51     private final Set JavaDoc<String JavaDoc> READ_ONLY_LIBRARIES =
52         GSetUtil.newUnmodifiableStringSet(
53             "MEjbApp", "__ejb_container_timer_app", "__JWSappclients" );
54     
55     // see bug#6323557 "admin GUI becomes non-responsive after adding a library"
56
private final Set JavaDoc<String JavaDoc> DONT_TEST_LIBRARIES =
57         GSetUtil.newUnmodifiableStringSet( "admingui" );
58
59     private static final String JavaDoc[] TEST_LIBS = new String JavaDoc[] { "/foo", "/bar" };
60     
61     /**
62         public void
63     testGUIHang()
64     {
65         final String[] TEST_LIBS = new String[] { "/foo", "/bar" };
66         final ObjectName objectName = Util.newObjectName( "amx:j2eeType=X-WebModuleConfig,name=admingui" );
67         final WebModuleConfig cfg = getProxyFactory().getProxy( objectName );
68         
69         final String[] saveLibs = cfg.getLibraries();
70         assert( saveLibs != null );
71         
72         final String[] testLibs = ArrayUtil.newArray( saveLibs, TEST_LIBS );
73         try
74         {
75             cfg.setLibraries( testLibs );
76         }
77         finally
78         {
79             cfg.setLibraries( saveLibs );
80         }
81     }
82     */

83     
84         public void
85     testLibraries()
86     {
87         final Set JavaDoc<Libraries> all = getTestUtil().getAllAMX( Libraries.class );
88         
89         for( final Libraries l : all )
90         {
91             final AMX amx = (AMX)l;
92             
93             if ( DONT_TEST_LIBRARIES.contains( amx.getName() ) )
94             {
95                 continue;
96             }
97             
98             final ObjectName JavaDoc objectName = Util.getObjectName( amx );
99
100             final String JavaDoc[] saveLibs = l.getLibraries();
101             assert( saveLibs != null );
102             
103             final String JavaDoc[] testLibs = ArrayUtil.newArray( saveLibs, TEST_LIBS );
104             try
105             {
106                 l.setLibraries( testLibs );
107             }
108             catch( Exception JavaDoc e )
109             {
110                 if ( ! READ_ONLY_LIBRARIES.contains( ((AMX)l).getName() ) )
111                 {
112                 warning ("Couldn't change Libraries Attribute for " + objectName +
113                     " (probably read-only, though not advertised as such)" );
114                 }
115             }
116             finally
117             {
118                 l.setLibraries( saveLibs );
119             }
120             
121         }
122     }
123  
124 }
125
126
127
Popular Tags