KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > management > test > DeploymentDescriptorUnitTestCase


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.management.test;
23
24 import javax.management.ObjectName JavaDoc;
25
26 import org.jboss.test.JBossTestCase;
27
28 /**
29  * Verify the deployment descriptors are exposed for the various
30  * deployed module types.
31  *
32  * Currently using existing deployments from ./deploy rathen than
33  * creating dummy deployments. If those change too often, we need
34  * to add some test deployments here.
35  *
36  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
37  * @version $Revision: 37406 $
38  */

39 public class DeploymentDescriptorUnitTestCase extends JBossTestCase
40 {
41    public DeploymentDescriptorUnitTestCase(String JavaDoc name)
42    {
43       super(name);
44    }
45
46    /**
47     * A -service.xml module (conf/jboss-service.xml)
48     */

49    public void testGetServiceXmlDescriptor() throws Exception JavaDoc
50    {
51       String JavaDoc moduleName = "jboss-service.xml";
52       String JavaDoc moduleType = "ServiceModule";
53       
54       String JavaDoc descriptor = getDescriptor(moduleType, moduleName);
55       assertTrue("Empty or null deployment descriptor: " + descriptor + " for module: " + moduleName,
56             descriptor != null && !descriptor.equals(""));
57    }
58    
59    /**
60     * A .sar module (deploy/jbossweb-tomcat55.sar)
61     */

62    public void testGetSarDescriptor() throws Exception JavaDoc
63    {
64       String JavaDoc moduleName = "jbossweb-tomcat55.sar";
65       String JavaDoc moduleType = "ServiceModule";
66       
67       String JavaDoc descriptor = getDescriptor(moduleType, moduleName);
68       assertTrue("Empty or null deployment descriptor: " + descriptor + " for module: " + moduleName,
69             descriptor != null && !descriptor.equals(""));
70    }
71    
72    /**
73     * A -deployer.xml module (deploy/ejb-deployer.xml)
74     */

75    public void testGetDeployerXmlDescriptor() throws Exception JavaDoc
76    {
77       String JavaDoc moduleName = "ejb-deployer.xml";
78       String JavaDoc moduleType = "ServiceModule";
79       
80       String JavaDoc descriptor = getDescriptor(moduleType, moduleName);
81       assertTrue("Empty or null deployment descriptor: " + descriptor + " for module: " + moduleName,
82             descriptor != null && !descriptor.equals(""));
83    }
84    
85    /**
86     * A .deployer module (deploy/jboss-aop.deployer)
87     */

88    public void testGetDeployerDescriptor() throws Exception JavaDoc
89    {
90       String JavaDoc moduleName = "jboss-aop.deployer";
91       String JavaDoc moduleType = "ServiceModule";
92       
93       String JavaDoc descriptor = getDescriptor(moduleType, moduleName);
94       assertTrue("Empty or null deployment descriptor: " + descriptor + " for module: " + moduleName,
95             descriptor != null && !descriptor.equals(""));
96    }
97    
98    /**
99     * Get the "deploymentDescriptor" attribute for a deployed module
100     */

101    private String JavaDoc getDescriptor(String JavaDoc moduleType, String JavaDoc moduleName) throws Exception JavaDoc
102    {
103       ObjectName JavaDoc target = new ObjectName JavaDoc(
104             "jboss.management.local:J2EEServer=Local,j2eeType=" + moduleType + ",name=" + moduleName);
105       
106       getLog().debug("Getting 'deploymentDescriptor' attribute from " + target);
107       
108       return (String JavaDoc)getServer().getAttribute(target, "deploymentDescriptor");
109    }
110 }
Popular Tags