KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > JspLoadOnStartup


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.web;
24
25 import com.sun.enterprise.tools.verifier.tests.web.WebTest;
26 import java.util.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 /**
32  * The load-on-startup element contains an integer indicating the order
33  * in which the JSP should be loaded.
34  */

35 public class JspLoadOnStartup extends WebTest implements WebCheck {
36
37       
38     /**
39      * The load-on-startup element contains an integer indicating the order
40      * in which the JSP should be loaded.
41      *
42      * @param descriptor the Web deployment descriptor
43      *
44      * @return <code>Result</code> the results for this assertion
45      */

46     public Result check(WebBundleDescriptor descriptor) {
47
48     Result result = getInitializedResult();
49     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
50   
51
52     boolean oneFailed = false;
53     if (!descriptor.getJspDescriptors().isEmpty()) {
54         for (Iterator itr = descriptor.getJspDescriptors().iterator();
55          itr.hasNext();) {
56
57         WebComponentDescriptor nextJspDescriptor = (WebComponentDescriptor) itr.next();
58         Integer JavaDoc loadOnStartUp = new Integer JavaDoc(nextJspDescriptor.getLoadOnStartUp());
59         // DOL only allows int's to be stored, test will always pass as written, so need to check against -1 placeholder
60
if (loadOnStartUp.intValue() >= 0) {
61             // DOL needs to store string value representing load-on-startup value
62
result.addGoodDetails(smh.getLocalString
63             ("tests.componentNameConstructor",
64             "For [ {0} ]",
65             new Object JavaDoc[] {compName.toString()}));
66
67             result.addGoodDetails
68             (smh.getLocalString
69              (getClass().getName() + ".passed",
70               "load-on-startup [ {0} ] value found in [ {1} ]",
71               new Object JavaDoc[] {loadOnStartUp.toString(),nextJspDescriptor.getName()}));
72         } else {
73                     if (loadOnStartUp.intValue() == -1) {
74             result.addGoodDetails(smh.getLocalString
75                           ("tests.componentNameConstructor",
76                            "For [ {0} ]",
77                            new Object JavaDoc[] {compName.toString()}));
78                 result.addGoodDetails(smh.getLocalString(
79                 getClass().getName() + ".passed2",
80                             "load-on-startup is not specified for [ {0} ]",
81                 new Object JavaDoc[] {nextJspDescriptor.getName()}));
82                     } else {
83                         if (!oneFailed) {
84                             oneFailed = true;
85                         }
86             result.addErrorDetails(smh.getLocalString
87                            ("tests.componentNameConstructor",
88                         "For [ {0} ]",
89                         new Object JavaDoc[] {compName.toString()}));
90                 result.addErrorDetails
91                     (smh.getLocalString
92                 (getClass().getName() + ".failed",
93                 "Error: load-on-startup [ {0} ] invalid value found in [ {1} ]",
94                 new Object JavaDoc[] {loadOnStartUp.toString(),nextJspDescriptor.getName()}));
95                     }
96         }
97         }
98         if (oneFailed) {
99             result.setStatus(Result.FAILED);
100             } else {
101             result.setStatus(Result.PASSED);
102         }
103     } else {
104         result.addNaDetails(smh.getLocalString
105                    ("tests.componentNameConstructor",
106                     "For [ {0} ]",
107                     new Object JavaDoc[] {compName.toString()}));
108         result.notApplicable(smh.getLocalString
109                  (getClass().getName() + ".notApplicable",
110                   "There are no JSP's within this web archive [ {0} ]",
111                   new Object JavaDoc[] {descriptor.getName()}));
112     }
113
114     return result;
115     }
116 }
117
Popular Tags