1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 27 import javax.management.ObjectName ; 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 45 public final class LibrariesTest extends AMXTestBase 46 { 47 public LibrariesTest() 48 { 49 } 50 51 private final Set <String > READ_ONLY_LIBRARIES = 52 GSetUtil.newUnmodifiableStringSet( 53 "MEjbApp", "__ejb_container_timer_app", "__JWSappclients" ); 54 55 private final Set <String > DONT_TEST_LIBRARIES = 57 GSetUtil.newUnmodifiableStringSet( "admingui" ); 58 59 private static final String [] TEST_LIBS = new String [] { "/foo", "/bar" }; 60 61 83 84 public void 85 testLibraries() 86 { 87 final Set <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 objectName = Util.getObjectName( amx ); 99 100 final String [] saveLibs = l.getLibraries(); 101 assert( saveLibs != null ); 102 103 final String [] testLibs = ArrayUtil.newArray( saveLibs, TEST_LIBS ); 104 try 105 { 106 l.setLibraries( testLibs ); 107 } 108 catch( Exception 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 |