KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 package com.sun.enterprise.tools.verifier.tests.web;
25
26 import com.sun.enterprise.tools.verifier.Result;
27 import com.sun.enterprise.tools.verifier.TagLibDescriptor;
28 import com.sun.enterprise.tools.verifier.Context;
29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
30 import com.sun.enterprise.deployment.WebBundleDescriptor;
31
32 /**
33  *
34  */

35 public class TagLibPublicID extends WebTest implements WebCheck {
36
37     public Result check(WebBundleDescriptor descriptor) {
38
39         Result result = getInitializedResult();
40         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
41
42         String JavaDoc acceptablePubidLiterals[] = {
43             "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" ,
44             "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" };
45
46         String JavaDoc acceptableURLs[] = {"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd",
47                                    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"};
48         Context context = getVerifierContext();
49         TagLibDescriptor tlds[] = context.getTagLibDescriptors();
50
51         addGoodDetails(result, compName);
52         result.passed(smh.getLocalString
53                 (getClass().getName() + ".passed",
54                         "Test passed successfully"));
55
56         if (tlds != null && tlds.length !=0) {
57             boolean oneFailed = false;
58             // iterate over all the tag lib descriptors present in war file
59
for (int i=0;i<tlds.length;i++) {
60                 String JavaDoc publicID = tlds[i].getPublicID();
61                 String JavaDoc systemID = tlds[i].getSystemID();
62                 if (publicID==null) continue;
63                 boolean match = false;
64                 for (int k=0;k<acceptablePubidLiterals.length;k++) {
65                     if (publicID.compareTo(acceptablePubidLiterals[k])==0 && systemID.compareTo(acceptableURLs[k])==0) {
66                         match=true;
67                         addGoodDetails(result, compName);
68                         result.passed
69                                 (smh.getLocalString
70                                 (getClass().getName() + ".passed1",
71                                         "The deployment descriptor [ {0} ] has the proper PubidLiteral: [ {1} ] and sytemID: [ {2} ]",
72                                         new Object JavaDoc[] {tlds[i].getUri(), acceptablePubidLiterals[k], acceptableURLs[k]}));
73                         break;
74                     }
75                 }
76
77                 if (!match) {
78                     oneFailed=true;
79                     addErrorDetails(result, compName);
80                     result.addErrorDetails
81                             (smh.getLocalString
82                             (getClass().getName() + ".failed",
83                                     "The deployment descriptor for [ {0} ] does not have an expected PubidLiteral or SystemID",
84                                     new Object JavaDoc[] {tlds[i].getUri()}));
85
86                 }
87             }
88             if(oneFailed)
89                 result.setStatus(Result.FAILED);
90             return result;
91
92         }
93         return result;
94     }
95 }
96
Popular Tags