KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > app > AppWebContext


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.tools.verifier.tests.app;
24
25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest;
26 import java.util.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29
30 /**
31  * All web modules in the application have a non-blank context-root
32  */

33
34 public class AppWebContext extends ApplicationTest implements AppCheck {
35
36
37     /**
38      * All web modules in the application have a non-blank context-root
39      *
40      * @param descriptor the Application deployment descriptor
41      *
42      * @return <code>Result</code> the results for this assertion
43      */

44     public Result check(Application descriptor) {
45
46     Result result = getInitializedResult();
47
48   
49     if (descriptor.getWebBundleDescriptors().size() > 0) {
50         boolean oneWarning = false;
51         for (Iterator itr = descriptor.getWebBundleDescriptors().iterator(); itr.hasNext();) {
52         WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
53         if (wbd.getContextRoot().equals("")) {
54             // fail test can't be blank ,
55
if (!oneWarning) {
56             oneWarning =true;
57             }
58             result.addWarningDetails
59             (smh.getLocalString
60              (getClass().getName() + ".warning",
61               "Warning: [ {0} ] has blank context root defined within application [ {1} ]",
62               new Object JavaDoc[] {wbd.getName(), descriptor.getName()}));
63         } else {
64             result.addGoodDetails
65             (smh.getLocalString
66              (getClass().getName() + ".passed",
67               "[ {0} ] has context root defined as [ {1} ] within application[ {2} ].",
68               new Object JavaDoc[] {wbd.getName(), wbd.getContextRoot(), descriptor.getName()}));
69         }
70         }
71
72         if (oneWarning) {
73         result.setStatus(Result.WARNING);
74         } else {
75         result.setStatus(Result.PASSED);
76         }
77     } else {
78         result.notApplicable(smh.getLocalString
79                  (getClass().getName() + ".notApplicable",
80                   "There are no web components in application [ {0} ]",
81                   new Object JavaDoc[] {descriptor.getName()}));
82     }
83   
84     return result;
85     }
86 }
87
Popular Tags