KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.*;
29
30
31 /**
32  * Param value should not be empty string
33  * @author Arun Jain
34  */

35 public class ParamValue extends WebTest implements WebCheck {
36     
37
38      /**
39      *
40      * Param value should not be empty string
41      * @param descriptor the Web deployment descriptor
42      *
43      * @return <code>Result</code> the results for this assertion
44      */

45     public Result check(WebBundleDescriptor descriptor) {
46
47         Set contextParameters;
48         Iterator itr;
49         String JavaDoc epValue;
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52         EnvironmentProperty ep;
53         boolean passed = true;
54         boolean oneFailed = false;
55         boolean notApp = false;
56         
57     if (!descriptor.getContextParametersSet().isEmpty()) {
58             
59         // get the context parameters
60
contextParameters = descriptor.getContextParametersSet();
61         itr = contextParameters.iterator();
62         // test the environment property
63
while (itr.hasNext()) {
64         ep = (EnvironmentProperty)itr.next();
65         epValue = ep.getValue();
66                 if ( epValue.length() != 0) {
67             result.addGoodDetails(smh.getLocalString
68                        ("tests.componentNameConstructor",
69                     "For [ {0} ]",
70                     new Object JavaDoc[] {compName.toString()}));
71                     result.addGoodDetails(smh.getLocalString
72                                           (getClass().getName() + ".passed",
73                                            "Param named/value exists for in the web archive [ {0} ].",
74                                            new Object JavaDoc[] {descriptor.getName()}));
75                 } else {
76                     oneFailed = true;
77             result.addErrorDetails(smh.getLocalString
78                        ("tests.componentNameConstructor",
79                     "For [ {0} ]",
80                     new Object JavaDoc[] {compName.toString()}));
81                     result.addErrorDetails(smh.getLocalString
82                                            (getClass().getName() + ".failed",
83                                             "Error: Param name/value should not be empty strings"));
84                     
85                 }
86             }
87             
88         } else {
89             notApp = true;
90         result.addNaDetails(smh.getLocalString
91                        ("tests.componentNameConstructor",
92                     "For [ {0} ]",
93                     new Object JavaDoc[] {compName.toString()}));
94         result.notApplicable(smh.getLocalString
95                                  (getClass().getName() + ".notApplicable",
96                                   "There are no context parameters within the web archive [ {0} ]",
97                                   new Object JavaDoc[] {descriptor.getName()}));
98         }
99         if (oneFailed) {
100             result.setStatus(Result.FAILED);
101         } else if (notApp) {
102             result.setStatus(Result.NOT_APPLICABLE);
103         } else {
104             result.setStatus(Result.PASSED);
105         }
106     return result;
107     }
108 }
109
Popular Tags