1 22 package org.jboss.test.classloader.test; 23 24 import javax.management.Attribute ; 25 import javax.management.ObjectName ; 26 27 import junit.framework.Test; 28 29 import org.jboss.test.JBossTestCase; 30 import org.jboss.test.JBossTestSetup; 31 32 37 public class ClasspathExtensionUnitTestCase extends JBossTestCase 38 { 39 ObjectName extension; 40 41 public ClasspathExtensionUnitTestCase(String name) 42 { 43 super(name); 44 45 try 46 { 47 extension = new ObjectName ("jboss.test:test=ClasspathTest,mbean=extension"); 48 } 49 catch (Exception ignored) 50 { 51 } 52 } 53 54 public void testClasspathExtension() throws Exception 55 { 56 assertTrue("Shouldn't find the resource before deployment", findResource() == false); 57 getServer().createMBean("org.jboss.deployment.ClasspathExtension", extension); 58 try 59 { 60 getServer().setAttribute(extension, new Attribute ("MetadataURL", getDeployURL("").toString())); 61 getServer().invoke(extension, "create", new Object [0], new String [0]); 62 getServer().invoke(extension, "start", new Object [0], new String [0]); 63 assertTrue("Should find the resource after deployment", findResource()); 64 } 65 finally 66 { 67 getServer().invoke(extension, "stop", new Object [0], new String [0]); 68 getServer().invoke(extension, "destroy", new Object [0], new String [0]); 69 getServer().unregisterMBean(extension); 70 } 71 assertTrue("Shouldn't find the resource after undeployment", findResource() == false); 72 } 73 74 private boolean findResource() 75 throws Exception 76 { 77 return ((Boolean ) getServer().invoke(new ObjectName ("jboss.test:test=ClasspathTest"), "findResource", 78 new Object [] { "classpath.sar" }, new String [] { String .class.getName() })).booleanValue(); 79 } 80 81 public static Test suite() throws Exception 82 { 83 return new JBossTestSetup(getDeploySetup(ClasspathExtensionUnitTestCase.class, "classpath.sar")); 84 } 85 } 86 | Popular Tags |