KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jmx > test > SimpleURLDeploymentScannerUnitTestCase


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.test.jmx.test;
23
24 import java.net.URL JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27
28 import junit.framework.Test;
29
30 import org.jboss.mx.util.ObjectNameFactory;
31 import org.jboss.system.ServiceMBean;
32
33 /**
34  * SimpleURLDeploymentScannerUnitTestCase.
35  *
36  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
37  * @author <a HREF="dimitris@jboss.org">Dimitris Andreadis</a>
38  * @version $Revision: 44464 $
39  */

40 public class SimpleURLDeploymentScannerUnitTestCase extends AbstractURLDeploymentScannerTest
41 {
42    ObjectName JavaDoc test = ObjectNameFactory.create("test:name=DefaultPkgService");
43    String JavaDoc module = "defaultpkg.sar";
44    
45    public void testSomething() throws Exception JavaDoc
46    {
47       hotDeploy(module);
48       try
49       {
50          assertEquals(new Integer JavaDoc(ServiceMBean.STARTED), getServer().getAttribute(test, "State"));
51       }
52       finally
53       {
54          hotUndeploy(module);
55       }
56       assertFalse(getServer().isRegistered(test));
57    }
58    
59    /**
60     * Test JBAS-3118 feature
61     */

62    public void testSuspendResumeDeployment() throws Exception JavaDoc
63    {
64       // tell the scanner to ignore the deployment
65
URL JavaDoc deployment = getTargetURL(module);
66       suspendDeployment(deployment);
67       
68       try
69       {
70          // now deploy, but expect that nothing happens at this point
71
hotDeploy(module);
72          assertFalse(getServer().isRegistered(test));
73          
74          // tell the scanner to resume the deployment,
75
// wait and see if it was actually deployed
76
resumeDeployment(deployment, false);
77          super.sleep(2000);
78          assertEquals(new Integer JavaDoc(ServiceMBean.STARTED), getServer().getAttribute(test, "State"));
79          
80          // suspend again and undeploy, the module shouldn't be undeployed
81
suspendDeployment(deployment);
82          hotUndeploy(module);
83          assertEquals(new Integer JavaDoc(ServiceMBean.STARTED), getServer().getAttribute(test, "State"));
84          
85          // tell the scanner to resume the deployment,
86
// wait and see if it was actually undeployed
87
resumeDeployment(deployment, false);
88          super.sleep(2000);
89          assertFalse(getServer().isRegistered(test));
90       }
91       catch (Exception JavaDoc ignore)
92       {
93          hotUndeploy(module);
94       }
95    }
96    
97    public static Test suite() throws Exception JavaDoc
98    {
99       return getTestSuite(SimpleURLDeploymentScannerUnitTestCase.class);
100    }
101    
102    public SimpleURLDeploymentScannerUnitTestCase(String JavaDoc name)
103    {
104       super(name);
105    }
106 }
107
Popular Tags