KickJava   Java API By Example, From Geeks To Geeks.

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


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-max-messages-load ? [String]
43  *
44  * The jms-max-messages-load specifies the maximum number of messages to
45  * load into a JMS Session.
46  * It is valid only for MDBs
47  * The value should be between 1 and MAX_INT
48  * @author Irfan Ahmed
49  */

50 public class ASEjbJMSMaxMessagesLoad extends EjbTest implements EjbCheck {
51
52     public Result check(EjbDescriptor descriptor)
53     {
54     Result result = getInitializedResult();
55     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
56
57         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
58         boolean oneFailed = false;
59         
60         if(ejbJar!=null)
61         {
62             Ejb ejbs[] = ejbJar.getEnterpriseBeans().getEjb();
63             Ejb testCase = null;
64             for(int i=0;i<ejbs.length;i++)
65             {
66                 if(ejbs[i].getEjbName().equals(descriptor.getName()))
67                 {
68                     testCase = ejbs[i];
69                     break;
70                 }
71             }
72             
73             String JavaDoc jmsMaxMsgs = testCase.getJmsMaxMessagesLoad();
74             if(jmsMaxMsgs != null)
75             {
76                 if(jmsMaxMsgs.length()==0)
77                 {
78                     result.failed(smh.getLocalString(getClass().getName()+".failed",
79                         "FAILED [AS-EJB ejb] : jms-max-messages-load cannot be an empty string value"));
80                 }
81                 else
82                 {
83                     try
84                     {
85                         int value = Integer.valueOf(jmsMaxMsgs).intValue();
86                         if(value<1 || value>Integer.MAX_VALUE)
87                         {
88                             result.failed(smh.getLocalString(getClass().getName()+".failed2",
89                                 "FAILED [AS-EJB ejb] : {0} is not a valid value for jms-max-messages-load. It should be " + '\n' +
90                                 "between 0 and MAX_INT", new Object JavaDoc[]{jmsMaxMsgs}));
91                         }
92                         else
93                         {
94                             result.passed(smh.getLocalString(getClass().getName()+".passed",
95                                 "PASSED [AS-EJB ejb] : jms-max-messages-load is {0}", new Object JavaDoc[]{jmsMaxMsgs}));
96                         }
97                     }
98                     catch(NumberFormatException JavaDoc nfex)
99                     {
100                         Verifier.debug(nfex);
101                         result.failed(smh.getLocalString(getClass().getName()+".failed3",
102                             "FAILED [AS-EJB ejb] : {0} value is not a number", new Object JavaDoc[]{jmsMaxMsgs}));
103                     }
104                 }
105             }
106             else
107             {
108                 if(descriptor instanceof EjbMessageBeanDescriptor)
109                 {
110                     //<addition author="irfan@sun.com" [bug/rfe]-id="4724447" >
111
/*Change in message output ms->jms */
112                     result.warning(smh.getLocalString(getClass().getName()+".warning",
113                         "WARNING [AS-EJB ejb] : jms-max-messages-load should be defined for MDBs"));
114                 }
115                 else
116                 {
117                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
118                         "NOT APPLICABLE [AS-EJB ejb] : jms-max-messages-load element is not defined"));
119                 }
120             }
121         }
122         else
123         {
124             result.addErrorDetails(smh.getLocalString
125                  (getClass().getName() + ".notRun",
126                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
127         }
128         return result;
129     }
130 }
131
Popular Tags