KickJava   Java API By Example, From Geeks To Geeks.

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


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 name must be of finite length.
33  */

34 public class WebEnvEntryName extends WebTest implements WebCheck {
35
36
37     /**
38      * The environment entry name must be of finite length.
39      *
40      * @param descriptor the Web deployment descriptor
41      *
42      * @return <code>Result</code> the results for this assertion
43      */

44     public Result check(WebBundleDescriptor descriptor) {
45
46     Result result = getInitializedResult();
47     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
48         boolean oneFailed = false;
49         EnvironmentProperty nextEnvironmentProperty;
50         String JavaDoc envName;
51     if (!descriptor.getEnvironmentProperties().isEmpty()) {
52
53         for (Iterator itr = descriptor.getEnvironmentProperties().iterator();
54          itr.hasNext();) {
55         nextEnvironmentProperty = (EnvironmentProperty) itr.next();
56                 envName = nextEnvironmentProperty.getName();
57         if (envName.length() > 0) {
58             result.addGoodDetails(smh.getLocalString
59                        ("tests.componentNameConstructor",
60                     "For [ {0} ]",
61                     new Object JavaDoc[] {compName.toString()}));
62             result.addGoodDetails
63             (smh.getLocalString
64              (getClass().getName() + ".passed",
65               "Environment entry value [ {0} ] has valid name within web archive [ {1} ]",
66               new Object JavaDoc[] {nextEnvironmentProperty.getName(),descriptor.getName()}));
67         } else {
68             oneFailed = true;
69             result.addErrorDetails(smh.getLocalString
70                        ("tests.componentNameConstructor",
71                     "For [ {0} ]",
72                     new Object JavaDoc[] {compName.toString()}));
73             result.addErrorDetails
74             (smh.getLocalString
75              (getClass().getName() + ".failed",
76               "Error: Environment entry name must be of finite length"));
77         }
78         }
79         if (!oneFailed){
80         result.setStatus(Result.PASSED);
81         } else {
82         result.setStatus(Result.FAILED);
83         }
84     } else {
85             result.setStatus(Result.NOT_APPLICABLE);
86         result.addNaDetails(smh.getLocalString
87                        ("tests.componentNameConstructor",
88                     "For [ {0} ]",
89                     new Object JavaDoc[] {compName.toString()}));
90         result.notApplicable(smh.getLocalString
91                  (getClass().getName() + ".notApplicable",
92                   "There are no environment entry elements defined within this web archive [ {0} ]",
93                   new Object JavaDoc[] {descriptor.getName()}));
94     }
95
96     return result;
97     }
98 }
99
Popular Tags