KickJava   Java API By Example, From Geeks To Geeks.

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


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.ias.beanpool;
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.common.dd.ejb.*;
34
35 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
36
37 /** ejb [0,n]
38  * bean-pool ?
39  * steady-pool-size ? [String]
40  * pool-resize-quantity ? [String]
41  * max-pool-size ? [String]
42  * pool-idle-timeout-in-seconds ? [String]
43  * max-wait-time-in-millis ? [String]
44  *
45  * The max-wait-time-in-millis specifies the maximum time that the caller is
46  * willing to wait to get a bean from the bean pool
47  *
48  * Valid values are from 0 to MAX_LONG
49  *
50  *
51  * @author Irfan Ahmed
52  */

53 public class ASEjbBPMaxWaitTime extends ASEjbBeanPool
54 {
55     
56     public Result check(EjbDescriptor descriptor)
57     {
58
59     Result result = getInitializedResult();
60     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
61
62         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
63         String JavaDoc ejbName = null;
64         Ejb testCase = null;
65         boolean oneFailed = false;
66         if(ejbJar!=null)
67         {
68             getBeanPool(descriptor,ejbJar);
69             if(beanPool!=null)
70             {
71                 String JavaDoc maxWaitTime = beanPool.getMaxWaitTimeInMillis();
72                 if(maxWaitTime!=null)
73                 {
74                     if(maxWaitTime.length()==0)
75                     {
76                         result.failed(smh.getLocalString(getClass().getName()+".failed1",
77                             "FAILED [AS-EJB bean-pool] : max-wait-time-in-millis cannot be empty"));
78                     }
79                     else
80                     {
81                         if(descriptor instanceof EjbMessageBeanDescriptor)
82                         {
83                             result.warning(smh.getLocalString(getClass().getName()+".warning",
84                                 "WARNING [AS-EJB bean-pool] : max-wait-time-in-millis is not applicable for Message Driven Beans"));
85                         }
86                         try
87                         {
88                             long value = Long.valueOf(maxWaitTime).longValue();
89                             if(value < 0 || value > Long.MAX_VALUE)
90                             {
91                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
92                                     "FAILED [AS-EJB bean-pool] : max-wait-time-in-millis cannot be {0}. It should be between 0 and {1}",
93                                     new Object JavaDoc[]{new Long JavaDoc(value),new Long JavaDoc(Long.MAX_VALUE)}));
94                             }
95                             else
96                             {
97                                 result.passed(smh.getLocalString(getClass().getName()+".passed",
98                                     "PASSED [AS-EJB bean-pool] : max-wait-time-in-millis is {0}",
99                                     new Object JavaDoc[]{new Long JavaDoc(value)}));
100                             }
101                         }
102                         catch(NumberFormatException JavaDoc nfex)
103                         {
104                             Verifier.debug(nfex);
105                             result.failed(smh.getLocalString(getClass().getName()+".failed3",
106                                 "FAILED [AS-EJB bean-pool] : The value {0} for max-wait-time-in-millis is not a valid Long number",
107                                 new Object JavaDoc[]{maxWaitTime}));
108                         }
109                     }
110                 }
111                 else
112                 {
113                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
114                     "NOT APPLICABLE [AS-EJB bean-pool] : max-wait-time-in-millis element not defined"));
115                 }
116             }
117             else
118             {
119                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
120                     "NOT APPLICABLE [AS-EJB] : bean-pool element not defined"));
121             }
122         }
123         else
124         {
125             result.addErrorDetails(smh.getLocalString
126                                    ("tests.componentNameConstructor",
127                                     "For [ {0} ]",
128                                     new Object JavaDoc[] {compName.toString()}));
129             result.addErrorDetails(smh.getLocalString
130                  (getClass().getName() + ".notRun",
131                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
132         }
133         return result;
134     }
135 }
136
Popular Tags