KickJava   Java API By Example, From Geeks To Geeks.

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


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
36 /** ejb [0,n]
37  * bean-pool ?
38  * steady-pool-size ? [String]
39  * pool-resize-quantity ? [String]
40  * max-pool-size ? [String]
41  * pool-idle-timeout-in-seconds ? [String]
42  * max-wait-time-in-millis ? [String]
43  *
44  * The max-pool-size element specifies the maximum pool size.
45  *
46  * Valid values are 0 to MAX_INT
47  *
48  *
49  * @author Irfan Ahmed
50  */

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