KickJava   Java API By Example, From Geeks To Geeks.

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


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
25 package com.sun.enterprise.tools.verifier.tests.ejb.messagebean;
26
27 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.jms.IASJmsUtil;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32
33 /**
34  * Verify that message beans message-selector is valid
35  *
36  * @author Jerome Dochez
37  * @version
38  */

39 public class HasValidMessageSelector extends MessageBeanTest {
40
41     /**
42      * Run a verifier test against an individual declared message
43      * drive bean component
44      *
45      * @param descriptor the Enterprise Java Bean deployment descriptor
46      *
47      * @return <code>Result</code> the results for this assertion
48      */

49     public Result check(EjbMessageBeanDescriptor descriptor) {
50         
51         Result result = getInitializedResult();
52     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53         String JavaDoc messageSelector = descriptor.getJmsMessageSelector();
54         if (messageSelector != null) {
55             try {
56                 IASJmsUtil.validateJMSSelector(messageSelector);
57             result.addGoodDetails(smh.getLocalString
58                        ("tests.componentNameConstructor",
59                     "For [ {0} ]",
60                     new Object JavaDoc[] {compName.toString()}));
61         result.passed(smh.getLocalString
62                 ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.HasValidMessageSelector.failed",
63                     "Message-driven bean [ {0} ] defines a valid message selector",
64                     new Object JavaDoc[] {descriptor.getName()}));
65             } catch (Exception JavaDoc e) {
66             result.addErrorDetails(smh.getLocalString
67                        ("tests.componentNameConstructor",
68                     "For [ {0} ]",
69                     new Object JavaDoc[] {compName.toString()}));
70         result.failed(smh.getLocalString
71                 ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.HasValidMessageSelector.failed",
72                     "Error : Message-driven bean [ {0} ] defines an invalid message selector",
73                     new Object JavaDoc[] {descriptor.getName()}));
74             }
75         } else {
76         result.addNaDetails(smh.getLocalString
77                        ("tests.componentNameConstructor",
78                     "For [ {0} ]",
79                     new Object JavaDoc[] {compName.toString()}));
80         result.notApplicable(smh.getLocalString
81         ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.HasValidMessageSelector.notApplicable",
82                  "Message-driven bean [ {0} ] does not define a message selector",
83                 new Object JavaDoc[] {descriptor.getName()}));
84         }
85         return result;
86     }
87 }
88
Popular Tags