KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > RunMeLastTest


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 package com.sun.enterprise.management;
24
25 import java.io.File JavaDoc;
26 import java.io.PrintStream JavaDoc;
27
28 import java.util.Set JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Arrays JavaDoc;
32
33
34 import com.sun.appserv.management.base.Util;
35 import com.sun.appserv.management.base.AMX;
36
37 import com.sun.appserv.management.helper.RefHelper;
38
39 import com.sun.appserv.management.util.misc.StringUtil;
40
41 import com.sun.enterprise.management.TestUtil;
42 import com.sun.enterprise.management.AMXTestBase;
43 import com.sun.enterprise.management.Capabilities;
44 import com.sun.enterprise.management.config.DanglingRefsTest;
45 import com.sun.enterprise.management.support.CoverageInfo;
46
47
48 /**
49     This test should normally be run before the generic tests
50     so that it can set up default items for many of the config elements
51     so that the generic tests will actually test them. Otherwise,
52     when the generic tests are run, they won't see any instances
53     of many of the AMXConfig MBeans.
54     <p>
55     If there are errors doing this, disable this test in amxtest.classes,
56     fix the error in the specific place it's occurring, then re-enabled
57     this test.
58  */

59 public final class RunMeLastTest extends AMXTestBase
60 {
61         public
62     RunMeLastTest( )
63     {
64     }
65     
66         private void
67     emitCoverage()
68         throws java.io.IOException JavaDoc
69     {
70         final CoverageInfoAnalyzer analyzer =
71             new CoverageInfoAnalyzer( getDomainRoot() );
72         
73         final String JavaDoc summary = analyzer.getCoverageSummary();
74         
75         final File JavaDoc dataFile = new File JavaDoc ("amx-tests.coverage");
76         final PrintStream JavaDoc out = new PrintStream JavaDoc( dataFile );
77         out.println( summary );
78         out.close();
79     
80         if ( getVerbose() )
81         {
82             trace( "NOTE: code coverage data save in file " +
83                 StringUtil.quote( "" + dataFile ) );
84         }
85     }
86     
87         public void
88     testLast()
89         throws Exception JavaDoc
90     {
91         emitDanglingRefs();
92         
93         if ( getTestUtil().asAMXDebugStuff( getDomainRoot() ) != null )
94         {
95             emitCoverage();
96         }
97     }
98     
99         public static Capabilities
100     getCapabilities()
101     {
102         return getOfflineCapableCapabilities( true );
103     }
104     
105     
106         public void
107     emitDanglingRefs()
108         throws ClassNotFoundException JavaDoc
109     {
110         new DanglingRefsTest().testAllDangling();
111     }
112 }
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Popular Tags