KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > session > SessionType


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.ejb.session;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.deployment.EjbSessionDescriptor;
28 import java.lang.ClassLoader JavaDoc;
29 import com.sun.enterprise.tools.verifier.tests.*;
30 import java.lang.reflect.*;
31 import com.sun.enterprise.tools.verifier.*;
32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
33
34 /**
35  * Session Bean State management test (stateful/stateless).
36  * If the enterprise bean is a Session Bean, the Bean provider must use
37  * the "session-type" element to declare whether the session bean
38  * is stateful or stateless.
39  */

40 public class SessionType extends EjbTest implements EjbCheck {
41
42
43     /**
44      * Session Bean State management test (stateful/stateless).
45      * If the enterprise bean is a Session Bean, the Bean provider must use
46      * the "session-type" element to declare whether the session bean
47      * is stateful or stateless.
48      *
49      * @param descriptor the Enterprise Java Bean deployment descriptor
50      *
51      * @return <code>Result</code> the results for this assertion
52      */

53     public Result check(EjbDescriptor descriptor) {
54
55     Result result = getInitializedResult();
56     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
57
58     if (descriptor instanceof EjbSessionDescriptor) {
59         String JavaDoc stateType = ((EjbSessionDescriptor)descriptor).getSessionType();
60         if ((EjbSessionDescriptor.STATELESS.equals(stateType)) ||
61         (EjbSessionDescriptor.STATEFUL.equals(stateType))) {
62         result.addGoodDetails(smh.getLocalString
63                       ("tests.componentNameConstructor",
64                        "For [ {0} ]",
65                        new Object JavaDoc[] {compName.toString()}));
66             
67         result.passed(smh.getLocalString
68                   (getClass().getName() + ".passed",
69                    "[ {0} ] is valid stateType within bean [ {1} ].",
70                    new Object JavaDoc[] {stateType,descriptor.getName()}));
71         } else {
72         result.addErrorDetails(smh.getLocalString
73                        ("tests.componentNameConstructor",
74                     "For [ {0} ]",
75                     new Object JavaDoc[] {compName.toString()}));
76         result.failed(smh.getLocalString
77                   (getClass().getName() + ".failed",
78                    "Error: [ {0} ] is not valid stateType within bean [ {1} ].",
79                    new Object JavaDoc[] {stateType, descriptor.getName()}));
80         }
81         return result;
82     } else {
83         result.addNaDetails(smh.getLocalString
84                 ("tests.componentNameConstructor",
85                  "For [ {0} ]",
86                  new Object JavaDoc[] {compName.toString()}));
87         result.notApplicable(smh.getLocalString
88                  (getClass().getName() + ".notApplicable",
89                   "[ {0} ] expected {1} bean, but called with {2} bean.",
90                   new Object JavaDoc[] {getClass(),"Session","Entity"}));
91         return result;
92     }
93     }
94 }
95
Popular Tags