KickJava   Java API By Example, From Geeks To Geeks.

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


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 ejb element specifies the URI of a ejb-jar, relative to
32  * the top level of the application package.
33  *
34  */

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

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