KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, 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 javax.management.ObjectName JavaDoc;
25 import junit.framework.*;
26 import org.jboss.test.JBossTestCase;
27
28 /** Tests of deployed services locating resources within their sar
29  * @author Scott.Stark@jboss.org
30  * @version $Revision: 37406 $
31  */

32 public class ServiceRsrcsUnitTestCase extends JBossTestCase
33 {
34    // Constants -----------------------------------------------------
35
// Attributes ----------------------------------------------------
36

37    // Static --------------------------------------------------------
38
// Constructors --------------------------------------------------
39

40    public ServiceRsrcsUnitTestCase(String JavaDoc name)
41    {
42       super(name);
43    }
44
45    // Public --------------------------------------------------------
46

47    /** Test deployment of
48     *
49     * @exception Exception Description of Exception
50     */

51    public void testDeploySAR() throws Exception JavaDoc
52    {
53       ObjectName JavaDoc rsrc1 = new ObjectName JavaDoc("test:name=ResourceTsts1");
54       ObjectName JavaDoc rsrc2 = new ObjectName JavaDoc("test:name=ResourceTsts2");
55       String JavaDoc sar1 = "rsrc1.sar";
56       String JavaDoc sar2 = "rsrc2.sar";
57       String JavaDoc sar3 = "rsrc3.jar";
58       String JavaDoc sar4 = "rsrc4.sar";
59
60       // ResourceTsts case#1, a sar with the classes and resources
61
try
62       {
63          deploy(sar1);
64          assertTrue("test:name=ResourceTsts1", getServer().isRegistered(rsrc1));
65       }
66       finally
67       {
68          undeploy(sar1);
69       } // end of try-catch
70
getLog().info("test 1 passed");
71
72       // ResourceTsts case#2, a sar with the resources and the service in a nested jar
73
try
74       {
75          deploy(sar2);
76          assertTrue("test:name=ResourceTsts2", getServer().isRegistered(rsrc2));
77       }
78       finally
79       {
80          undeploy(sar2);
81       } // end of try-catch
82
getLog().info("test 2 passed");
83
84       /** ResourceTsts case#3, a jar with two sars with only
85       the service descriptor metadata and a jar containing the
86       service code.
87       */

88       try
89       {
90          deploy(sar3);
91          assertTrue("test:name=ResourceTsts1", getServer().isRegistered(rsrc1));
92          assertTrue("test:name=ResourceTsts2", getServer().isRegistered(rsrc2));
93       }
94       finally
95       {
96          undeploy(sar3);
97       } // end of try-catch
98
getLog().info("test 3 passed");
99
100       /** ResourceTsts case#4, a sar with a service descriptor with
101       mulitiple mbeans, a resource file with multiple configs
102       using a namespace, and the service code in a nested jar
103       */

104       try
105       {
106          deploy(sar4);
107          assertTrue("test:name=ResourceTsts1", getServer().isRegistered(rsrc1));
108          assertTrue("test:name=ResourceTsts2", getServer().isRegistered(rsrc2));
109       }
110       finally
111       {
112          undeploy(sar4);
113       } // end of try-catch
114
getLog().info("test 4 passed");
115    }
116
117 }
118
Popular Tags