KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > messagebean > EjbCreateReturnType


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.ejb.messagebean;
25
26 import java.lang.reflect.Method JavaDoc;
27 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31
32 /**
33  * Verify that message beans implement the ejbCreate method with a void return
34  * type
35  *
36  * @author Jerome Dochez
37  * @version
38  */

39 public class EjbCreateReturnType extends MessageBeanTest {
40
41     /**
42      * <p>
43      * @return the name of the method on the message bean this test applies to
44      * </p>
45      */

46     protected String JavaDoc getMethodName() {
47         return "ejbCreate";
48     }
49     
50     /**
51      * Run a verifier test against an individual declared message
52      * drive bean component
53      *
54      * @param descriptor the Enterprise Java Bean deployment descriptor
55      *
56      * @return <code>Result</code> the results for this assertion
57      */

58     public Result check(EjbMessageBeanDescriptor descriptor) {
59         
60         Result result = getInitializedResult();
61     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
62         Class JavaDoc mbc = loadMessageBeanClass(descriptor, result);
63         if (mbc!=null) {
64             Method JavaDoc m = getMethod(mbc, getMethodName(),null);
65             if (m!=null) {
66                 String JavaDoc returnType = m.getReturnType().getName();
67                 if ("void".equalsIgnoreCase(returnType)) {
68                 result.addGoodDetails(smh.getLocalString
69                        ("tests.componentNameConstructor",
70                     "For [ {0} ]",
71                     new Object JavaDoc[] {compName.toString()}));
72             result.passed(smh.getLocalString
73               ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateReturnType.passed",
74                             "Message-Drive bean [ {0} ] {1} implementation has a void return type",
75                new Object JavaDoc[] {(descriptor).getEjbClassName(),m.getName()}));
76                 } else {
77                     result.addErrorDetails(smh.getLocalString
78                        ("tests.componentNameConstructor",
79                     "For [ {0} ]",
80                     new Object JavaDoc[] {compName.toString()}));
81             result.failed(smh.getLocalString
82               ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateReturnType.failed",
83                             "Error: Message-Drive bean [ {0} ] {1} return type is [ {1} ]",
84                new Object JavaDoc[] {(descriptor).getEjbClassName(), returnType}));
85                 }
86             } else {
87                 result.addErrorDetails(smh.getLocalString
88                        ("tests.componentNameConstructor",
89                     "For [ {0} ]",
90                     new Object JavaDoc[] {compName.toString()}));
91         result.failed(smh.getLocalString
92             ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateExists.failed",
93                     "Error: Message-Drive bean [ {0} ] does not implement an {1} with no arguments",
94                 new Object JavaDoc[] {(descriptor).getEjbClassName(), getMethodName()}));
95             }
96         }
97         return result;
98     }
99 }
100
Popular Tags