KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Must check for the existence of the tld file.
33  * @author Arun Jain
34  */

35 public class TaglibLocation extends Taglib implements WebCheck {
36     
37
38      /**
39      * .tld file exists test.
40      *
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     Result result = getInitializedResult();
48     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
49         boolean passed = true;
50         TagLibConfigurationDescriptor taglibDescriptor;
51         String JavaDoc taglibLocation;
52         Enumeration taglibConfig = (new Vector()).elements();
53         if (descriptor.getJspConfigDescriptor() != null) {
54             taglibConfig = descriptor.getJspConfigDescriptor().getTagLibs();
55         }
56
57         if (taglibConfig.hasMoreElements()){
58             while (taglibConfig.hasMoreElements()) {
59                 // test all the Tag lib descriptors.
60
taglibDescriptor = (TagLibConfigurationDescriptor) taglibConfig.nextElement();
61                 taglibLocation = taglibDescriptor.getTagLibLocation();
62                 if(passed == false)
63                     check(descriptor, taglibLocation, result);
64                 else
65                     passed = check(descriptor, taglibLocation, result);
66             }
67         } else {
68         result.addNaDetails(smh.getLocalString
69                        ("tests.componentNameConstructor",
70                     "For [ {0} ]",
71                     new Object JavaDoc[] {compName.toString()}));
72             result.notApplicable(smh.getLocalString
73                                  (getClass().getName() + ".notApplicable",
74                                   "There are no TagLibConfigurationDescriptors within the web archive [ {0} ]",
75                                   new Object JavaDoc[] {descriptor.getName()}));
76             result.setStatus(Result.NOT_APPLICABLE);
77             return result;
78             
79         }
80         
81         if ( passed) {
82             result.setStatus(Result.PASSED);
83         } else {
84             result.setStatus(Result.FAILED);
85          }
86         
87         return result;
88     }
89 }
90
Popular Tags