KickJava   Java API By Example, From Geeks To Geeks.

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


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
26 import org.jboss.test.JBossTestCase;
27 import org.jboss.deployment.IncompleteDeploymentException;
28
29 /**
30  * @author <a HREF="mailto:corby@users.sourceforge.net">Corby Page</a>
31  */

32 public class MBeanDependsOnConnectionManagerUnitTestCase extends JBossTestCase
33 {
34    // Attributes ----------------------------------------------------
35
ObjectName JavaDoc serviceControllerName;
36
37    public MBeanDependsOnConnectionManagerUnitTestCase( String JavaDoc name )
38    {
39       super( name );
40       try
41       {
42          serviceControllerName = new ObjectName JavaDoc( "jboss.system:service=ServiceController" );
43       }
44       catch ( Exception JavaDoc e )
45       {
46       } // end of try-catch
47
}
48
49    public void testMBeanDependsOnConnectionManager() throws Exception JavaDoc
50    {
51       String JavaDoc mBeanCodeUrl = "testdeploy.sar";
52       String JavaDoc mBeanUrl = "testmbeandependsOnConnectionManager-service.xml";
53       String JavaDoc connectionManagerUrl = "hsqldb-singleconnection-ds.xml";
54
55       ObjectName JavaDoc objectNameMBean = new ObjectName JavaDoc( "test:name=TestMBeanDependsOnConnectionManager" );
56       ObjectName JavaDoc objectNameConnectionManager = new ObjectName JavaDoc( "jboss.jca:service=DataSourceBinding,name=SingleConnectionDS" );
57
58       deploy( mBeanCodeUrl );
59       try
60       {
61          deploy( connectionManagerUrl );
62          try
63          {
64             deploy( mBeanUrl );
65             try
66             {
67
68                try
69                {
70                   undeploy( connectionManagerUrl );
71                   deploy( connectionManagerUrl );
72                }
73                catch ( IncompleteDeploymentException ex )
74                {
75                   getLog().info("incomplete deployment exception", ex);
76                   fail( "Connection Pool could not be recycled successfully!" );
77                }
78
79                // Double-check state
80
String JavaDoc mBeanState = (String JavaDoc)getServer().getAttribute( objectNameMBean, "StateString" );
81                assertEquals( "Test MBean not started!", "Started", mBeanState );
82                String JavaDoc connectionManagerState = (String JavaDoc)getServer().getAttribute(
83                   objectNameConnectionManager, "StateString" );
84                assertEquals( "Connnection Manager MBean not started!", "Started", connectionManagerState );
85             }
86             finally
87             {
88                undeploy( mBeanUrl );
89             }
90          }
91          finally
92          {
93             undeploy( connectionManagerUrl );
94          }
95       }
96       finally
97       {
98          undeploy( mBeanCodeUrl );
99       }
100    }
101 }
102
Popular Tags