KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > runtime > ASEjbJMSDurableSubscriptionName


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime;
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the License). You may not use this file except in
7  * compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
11  * glassfish/bootstrap/legal/CDDLv1.0.txt.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * Header Notice in each file and include the License file
17  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
18  * If applicable, add the following below the CDDL Header,
19  * with the fields enclosed by brackets [] replaced by
20  * you own identifying information:
21  * "Portions Copyrighted [year] [name of copyright owner]"
22  *
23  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24  */

25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
32
33 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
34
35
36 /** ejb [0,n]
37  * jms-durable-subscription-name ? [String]
38  *
39  * The jms-durable-subscription-name is the name of a durable subscription associated
40  * with a message-driven bean.
41  * The name should not be a null string.
42  * The value is required if destination-type is Topic
43  * and subscription-durability is durable
44  * @author Irfan Ahmed
45  */

46 public class ASEjbJMSDurableSubscriptionName extends EjbTest implements EjbCheck {
47
48     public Result check(EjbDescriptor descriptor)
49     {
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53         boolean oneFailed = false;
54         try{
55             EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor)descriptor;
56             String JavaDoc jmsDurableName = msgBeanDesc.getDurableSubscriptionName();
57             if(jmsDurableName != null){
58                 if(jmsDurableName.length()==0)
59                 {
60                     addErrorDetails(result, compName);
61                     result.failed(smh.getLocalString(getClass().getName()+".failed",
62                         "FAILED [AS-EJB ejb] : jms-durable-subscription-name cannot be an empty string value"));
63                 }else{
64                     addGoodDetails(result, compName);
65                     result.passed(smh.getLocalString(getClass().getName()+".passed",
66                         "PASSED [AS-EJB ejb] : jms-durable-subscription-name is {0}", new Object JavaDoc[]{jmsDurableName}));
67                 }
68             }else{
69                 if(descriptor instanceof EjbMessageBeanDescriptor){
70                     if(msgBeanDesc.hasTopicDest() && msgBeanDesc.hasDurableSubscription()){
71                         boolean failed = false;
72                         int count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/mdb-resource-adapter");
73                         if (count > 0) {
74                             String JavaDoc value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/mdb-resource-adapter/resource-adapter-mid");
75                             if(value==null || value.length()==0){
76                                 failed = true;
77                             }
78                         }
79                         else {
80                             failed = true;
81                         }
82                         if (failed) {
83                             addErrorDetails(result, compName);
84                             result.failed(smh.getLocalString(getClass().getName()+".failed1",
85                                 "FAILED [AS-EJB ejb] : jms-durable-subscription-name should be defined for an MDB with"+
86                                 " destination type Topic and Durable subscription type"));
87                         }
88                     }else{
89                         addNaDetails(result, compName);
90                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
91                             "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
92                     }
93                 }else{
94                     addNaDetails(result, compName);
95                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
96                         "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
97                 }
98             }
99         }catch(Exception JavaDoc ex){
100             addErrorDetails(result, compName);
101             result.addErrorDetails(smh.getLocalString
102                 (getClass().getName() + ".notRun",
103                 "NOT RUN [AS-EJB] : Could not create a descriptor object"));
104         }
105         return result;
106     }
107 }
108
Popular Tags