KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > ConnectorServiceConfigTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 package com.sun.enterprise.management.config;
25
26 import com.sun.appserv.management.config.AMXConfig;
27 import com.sun.appserv.management.config.ConfigConfig;
28 import com.sun.appserv.management.config.ConnectorServiceConfig;
29
30 import com.sun.appserv.management.util.misc.ExceptionUtil;
31
32
33 import com.sun.enterprise.management.AMXTestBase;
34 import com.sun.enterprise.management.Capabilities;
35
36 /**
37  */

38 public final class ConnectorServiceConfigTest extends AMXTestBase
39 {
40     public ConnectorServiceConfigTest()
41     {
42         if ( checkNotOffline( "ensureDefaultInstance" ) )
43         {
44             ensureDefaultInstance( getConfigConfig() );
45         }
46     }
47     
48          public static ConnectorServiceConfig
49     ensureDefaultInstance( final ConfigConfig configConfig )
50     {
51         return configConfig.createConnectorServiceConfig();
52     }
53     
54         public synchronized void
55     testCreateRemove()
56     {
57         if ( checkNotOffline( "testCreateRemove" ) )
58         {
59             final ConfigConfig configConfig = getConfigConfig();
60             
61             // remove first, in case it's there
62
configConfig.removeConnectorServiceConfig();
63             
64             // create and remove
65
configConfig.createConnectorServiceConfig();
66             configConfig.removeConnectorServiceConfig();
67             
68             // leave it there
69
ensureDefaultInstance( configConfig );
70         }
71     }
72     
73         public synchronized void
74     testGetters()
75     {
76         if ( checkNotOffline( "ensureDefaultInstance" ) )
77         {
78             ensureDefaultInstance( getConfigConfig() );
79             
80             final ConnectorServiceConfig cs = getConfigConfig().getConnectorServiceConfig();
81             
82             final String JavaDoc value = cs.getShutdownTimeoutInSeconds();
83             assert( value != null );
84             
85             try
86             {
87                 final String JavaDoc newValue = "" + (Integer.parseInt( value ) + 1);
88                 cs.setShutdownTimeoutInSeconds( newValue );
89                 final String JavaDoc after = cs.getShutdownTimeoutInSeconds();
90                 assert( after.equals( newValue ) );
91                 
92                 cs.setShutdownTimeoutInSeconds( "30" );
93                 cs.setShutdownTimeoutInSeconds( newValue );
94             }
95             catch( Exception JavaDoc e )
96             {
97                 warning( getRootCauseStackTrace( e ) );
98                 
99                 failure( "ConnectorServiceConfig.setShutdownTimeoutInSeconds FAILED " +
100                     "(bug #6307916 in com.sun.appserv:type=connector-service MBean)" );
101             }
102         }
103     }
104 }
105
106
107
108
109
110
111
112
113
114
115
Popular Tags