KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > app > WebURI


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.app;
24
25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest;
26 import java.util.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29
30 /**
31  * The web-uri element specifies the URI of a web application file,
32  * relative to the top level of the application package.
33  *
34  */

35
36 public class WebURI extends ApplicationTest implements AppCheck {
37
38
39     /**
40      * The web-uri element specifies the URI of a web application file,
41      * relative to the top level of the application package.
42      *
43      * @param descriptor the Application deployment descriptor
44      *
45      * @return <code>Result</code> the results for this assertion
46      */

47     public Result check(Application descriptor) {
48
49     Result result = getInitializedResult();
50
51   
52     // web-uri element specifies the URI of a web application file,
53
// relative to the top level of the application package
54
if (descriptor.getWebBundleDescriptors().size() > 0) {
55         boolean oneFailed = false;
56         for (Iterator itr = descriptor.getWebBundleDescriptors().iterator(); itr.hasNext();) {
57         WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
58     
59
60         // not sure what we can do to test this string?
61
if (wbd.getModuleDescriptor().getArchiveUri().endsWith(".war")) {
62             result.addGoodDetails
63             (smh.getLocalString
64              (getClass().getName() + ".passed",
65               "[ {0} ] specifies the URI [ {1} ] of web application file, relative to the top level of the application package [ {2} ].",
66               new Object JavaDoc[] {wbd.getName(), wbd.getModuleDescriptor().getArchiveUri(), descriptor.getName()}));
67         } else {
68             if (!oneFailed) {
69             oneFailed =true;
70             }
71             result.addErrorDetails
72             (smh.getLocalString
73              (getClass().getName() + ".failed",
74               "Error: [ {0} ] does not specify the URI [ {1} ] of web application file, relative to the top level of the application package [ {2} ]or does not end with \".war\"",
75               new Object JavaDoc[] {wbd.getName(), wbd.getModuleDescriptor().getArchiveUri(), descriptor.getName()}));
76         }
77         }
78         if (oneFailed) {
79         result.setStatus(Result.FAILED);
80         } else {
81         result.setStatus(Result.PASSED);
82         }
83     } else {
84         result.notApplicable(smh.getLocalString
85                  (getClass().getName() + ".notApplicable",
86                   "There are no web components in application [ {0} ]",
87                   new Object JavaDoc[] {descriptor.getName()}));
88     }
89     return result;
90
91     }
92 }
93
Popular Tags