1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package kortsoft.kmx.deployer;
17
18 import java.io.File;
19 import java.util.Hashtable;
20
21 import javax.management.MBeanServer;
22 import javax.management.ObjectName;
23
24 import kortsoft.kmx.jmx.JmxConfig;
25
26 import org.jmock.Mock;
27 import org.jmock.MockObjectTestCase;
28
29 /***
30 * <a href="JarDeployerTest.java.html"><b><i>View Source</i></b></a>
31 *
32 * @author Alvaro
33 * @version $Revision: 1.1 $
34 *
35 */
36 public class JarDeployerTest extends MockObjectTestCase {
37
38 public void testDeployElement() throws Exception{
39 File file=new File("test.jar");
40 file.createNewFile();
41 Hashtable<String,String> table=new Hashtable<String,String>(2);
42 table.put(JarDeployer.FILENAME_JMX_PROPERTY,"test.jar");
43 table.put(JarDeployer.TYPE_JMX_PROPERTY,"jar");
44 ObjectName name =
45 new ObjectName(JmxConfig.getClassLoaderDomainName(),table);
46 JarDeployer jarD=new JarDeployer();
47 Mock mockMBeanServer=mock(MBeanServer.class);
48 jarD.setMBeanServer((MBeanServer)mockMBeanServer.proxy());
49 mockMBeanServer.expects(once()).method("registerMBean")
50 .with(isA(ClassLoader.class),eq(name));
51 jarD.deployElement(file);
52 }
53 }