KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > EjbEnvEntryValueType


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.ejb;
24
25 import java.util.Iterator JavaDoc;
26
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.deployment.EnvironmentProperty;
29 import com.sun.enterprise.tools.verifier.Result;
30 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
31
32 /**
33  * The environment entry value type must be one of the following Java types:
34  * String, Integer, Boolean, Double, Byte, Short, Long, and Float.
35  */

36 public class EjbEnvEntryValueType extends EjbTest implements EjbCheck {
37
38
39
40     /**
41      * The environment entry value type must be one of the following Java types:
42      * String, Integer, Boolean, Double, Byte, Short, Long, and Float.
43      *
44      * @param descriptor the Enterprise Java Bean deployment descriptor
45      *
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(EjbDescriptor descriptor) {
49
50         Result result = getInitializedResult();
51         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53         if (!descriptor.getEnvironmentProperties().isEmpty()) {
54             // environment entry value type must be one of the following Java types:
55
// String, Integer, Boolean, Double, Byte, Short, Long, and Float.
56
for (Iterator JavaDoc itr = descriptor.getEnvironmentProperties().iterator();
57                  itr.hasNext();) {
58                 EnvironmentProperty nextEnvironmentProperty =
59                         (EnvironmentProperty) itr.next();
60                 String JavaDoc envType = nextEnvironmentProperty.getType();
61                 if (!((envType.equals("java.lang.String")) ||
62                         (envType.equals("java.lang.Integer")) ||
63                         (envType.equals("java.lang.Boolean")) ||
64                         (envType.equals("java.lang.Double")) ||
65                         (envType.equals("java.lang.Byte")) ||
66                         (envType.equals("java.lang.Short")) ||
67                         (envType.equals("java.lang.Long")) ||
68                         (envType.equals("java.lang.Character")) ||
69                         (envType.equals("java.lang.Float")))) {
70                     addErrorDetails(result, compName);
71                     result.failed(smh.getLocalString
72                             (getClass().getName() + ".failed",
73                             "Error: Environment entry value [ {0} ] does not have" +
74                             " valid value type [ {1} ] within bean [ {2} ]",
75                             new Object JavaDoc[] {nextEnvironmentProperty.getName(),envType, descriptor.getName()}));
76                 }
77             }
78         }
79         if(result.getStatus() != Result.FAILED) {
80             addGoodDetails(result, compName);
81             result.passed(smh.getLocalString
82                     (getClass().getName() + ".passed",
83                     "Environment entry value has valid value type"));
84         }
85         return result;
86     }
87 }
88
Popular Tags