KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias;
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 java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
34
35 import com.sun.enterprise.tools.common.dd.*;
36 import com.sun.enterprise.tools.common.dd.ejb.*;
37 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
38 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
39
40
41 /** ejb [0,n]
42  * jms-durable-subscription-name ? [String]
43  *
44  * The jms-durable-subscription-name is the name of a durable subscription associated
45  * with a message-driven bean.
46  * The name should not be a null string.
47  * The value is required if destination-type is Topic
48  * and subscription-durability is durable
49  * @author Irfan Ahmed
50  */

51 public class ASEjbJMSDurableSubscriptionName extends EjbTest implements EjbCheck {
52
53     public Result check(EjbDescriptor descriptor)
54     {
55     Result result = getInitializedResult();
56     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
57
58         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
59         boolean oneFailed = false;
60         
61         if(ejbJar!=null)
62         {
63             Ejb testCase = super.getEjb(descriptor.getName(),ejbJar);
64             String JavaDoc jmsDurableName = testCase.getJmsDurableSubscriptionName();
65             if(jmsDurableName != null)
66             {
67                 if(jmsDurableName.length()==0)
68                 {
69                     result.failed(smh.getLocalString(getClass().getName()+".failed",
70                         "FAILED [AS-EJB ejb] : jms-durable-subscription-name cannot be an empty string value"));
71                 }
72                 else
73                 {
74                     result.passed(smh.getLocalString(getClass().getName()+".passed",
75                         "PASSED [AS-EJB ejb] : jms-durable-subscription-name is {0}", new Object JavaDoc[]{jmsDurableName}));
76                 }
77             }
78             else
79             {
80                 if(descriptor instanceof EjbMessageBeanDescriptor)
81                 {
82                     EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor)descriptor;
83                     if(msgBeanDesc.hasTopicDest() && msgBeanDesc.hasDurableSubscription())
84                     {
85                         result.failed(smh.getLocalString(getClass().getName()+".failed",
86                             "FAILED [AS-EJB ejb] : jms-durable-subscription-name should be defined for an MDB with"+
87                             " destination type Topic and Durable subscription type"));
88                     }
89                     else
90                     {
91                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
92                             "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
93                     }
94                 }
95                 else
96                 {
97                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
98                         "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
99                 }
100             }
101         }
102         else
103         {
104             result.addErrorDetails(smh.getLocalString
105                  (getClass().getName() + ".notRun",
106                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
107         }
108         return result;
109     }
110 }
111
Popular Tags