KickJava   Java API By Example, From Geeks To Geeks.

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


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 environment entry value type must be one of the following Java types:
33  * String, Integer, Boolean, Double, Byte, Short, Long, and Float.
34  */

35 public class WebEnvEntryValueType extends WebTest implements WebCheck {
36
37
38     /**
39      * The environment entry value type must be one of the following Java types:
40      * String, Integer, Boolean, Double, Byte, Short, Long, and Float.
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     boolean oneFailed = false;
52     if (!descriptor.getEnvironmentProperties().isEmpty()) {
53         // environment entry value type must be one of the following Java types:
54
// String, Integer, Boolean, Double, Byte, Short, Long, and Float.
55
for (Iterator itr2 = descriptor.getEnvironmentProperties().iterator();
56          itr2.hasNext();) {
57         EnvironmentProperty nextEnvironmentProperty =
58             (EnvironmentProperty) itr2.next();
59                 String JavaDoc envType = nextEnvironmentProperty.getType();
60         if ((envType.equals("java.lang.String")) ||
61             (envType.equals("java.lang.Integer")) ||
62             (envType.equals("java.lang.Boolean")) ||
63             (envType.equals("java.lang.Double")) ||
64             (envType.equals("java.lang.Byte")) ||
65             (envType.equals("java.lang.Short")) ||
66             (envType.equals("java.lang.Long")) ||
67             (envType.equals("java.lang.Character")) ||
68             (envType.equals("java.lang.Float"))) {
69             result.addGoodDetails(smh.getLocalString
70                        ("tests.componentNameConstructor",
71                     "For [ {0} ]",
72                     new Object JavaDoc[] {compName.toString()}));
73             result.addGoodDetails
74             (smh.getLocalString
75              (getClass().getName() + ".passed",
76               "Environment entry value [ {0} ] has valid value type [ {1} ] within web archive [ {2} ]",
77               new Object JavaDoc[] {nextEnvironmentProperty.getName(),envType,descriptor.getName()}));
78         } else {
79             oneFailed = true;
80             result.addErrorDetails(smh.getLocalString
81                        ("tests.componentNameConstructor",
82                     "For [ {0} ]",
83                     new Object JavaDoc[] {compName.toString()}));
84             result.addErrorDetails
85             (smh.getLocalString
86              (getClass().getName() + ".failed",
87               "Error: Environment entry value [ {0} ] does not have valid value type [ {1} ] within web archive [ {2} ]",
88               new Object JavaDoc[] {nextEnvironmentProperty.getName(),envType,descriptor.getName()}));
89         }
90         }
91         if (!oneFailed){
92         result.setStatus(Result.PASSED);
93         } else {
94         result.setStatus(Result.FAILED);
95         }
96     } else {
97         result.addNaDetails(smh.getLocalString
98                        ("tests.componentNameConstructor",
99                     "For [ {0} ]",
100                     new Object JavaDoc[] {compName.toString()}));
101         result.notApplicable(smh.getLocalString
102                  (getClass().getName() + ".notApplicable",
103                   "There are no environment entry elements defined within this web archive [ {0} ]",
104                   new Object JavaDoc[] {descriptor.getName()}));
105     }
106
107     return result;
108     }
109 }
110
Popular Tags