KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > appclient > AppClientEnvEntryValueType


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

34 public class AppClientEnvEntryValueType extends AppClientTest implements AppClientCheck {
35
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 app-client deployment descriptor
43      *
44      * @return <code>Result</code> the results for this assertion
45      */

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