KickJava   Java API By Example, From Geeks To Geeks.

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


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 steady-pool-size element specifies the initial and minimum number of beans
45  * that must be maintained in the bean pool.
46  *
47  * Valid values are from 0 to MAX_INT
48  *
49  *
50  * @author Irfan Ahmed
51  */

52 public class ASEjbBPSteadyPoolSize extends ASEjbBeanPool
53 {
54     
55     public Result check(EjbDescriptor descriptor)
56     {
57
58     Result result = getInitializedResult();
59     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
60
61         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
62         String JavaDoc ejbName = null;
63         Ejb testCase = null;
64         boolean oneFailed = false;
65         if(ejbJar!=null)
66         {
67             getBeanPool(descriptor,ejbJar);
68             if(beanPool!=null)
69             {
70                 String JavaDoc steadyPoolSize = beanPool.getSteadyPoolSize();
71                 if(steadyPoolSize!=null)
72                 {
73                     if(steadyPoolSize.length()==0)
74                     {
75                         result.failed(smh.getLocalString(getClass().getName()+".failed1",
76                             "FAILED [AS-EJB bean-pool] : steady-pool-size cannot be empty"));
77                     }
78                     else
79                     {
80                         try
81                         {
82                             int value = Integer.valueOf(steadyPoolSize).intValue();
83                             if(value < 0 || value > Integer.MAX_VALUE)
84                             {
85                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
86                                     "FAILED [AS-EJB bean-pool] : steady-pool-size cannot be {0}. It should be between 0 and {1}",
87                                     new Object JavaDoc[]{new Integer JavaDoc(value),new Integer JavaDoc(Integer.MAX_VALUE)}));
88                             }
89                             else
90                             {
91                                 String JavaDoc maxPoolSize = beanPool.getMaxPoolSize();
92                                 int maxPool = 0;
93                                 if(maxPoolSize == null){
94                                     result.passed(smh.getLocalString(getClass().getName()+".passed1",
95                                     "PASSED [AS-EJB bean-pool] : steady-pool-size is {0}",new Object JavaDoc[] { new Integer JavaDoc(value)}));
96                                 }
97                                 else
98                                 {
99                                     try{
100                                         maxPool = Integer.parseInt(maxPoolSize);
101                                     }catch(NumberFormatException JavaDoc nfe){
102                                         result.failed(smh.getLocalString(getClass().getName()+".failed3",
103                                         "FAILED [AS-EJB bean-pool] : The value {0} for max-pool-size is not a valid Integer number",new Object JavaDoc[]{maxPoolSize}));
104
105                                         return result;
106
107                                     }
108                                                                     //<addition author="irfan@sun.com" [bug/rfe]-id="4724439" >
109
//if(value < maxPool){
110
if(value <= maxPool){
111                                                                     //</addition>
112
result.passed(smh.getLocalString(getClass().getName()+".passed2",
113                                         "PASSED [AS-EJB bean-pool] : steady-pool-size is {0} and is less-than/equal-to max-pool-size [{1}]",
114                                         new Object JavaDoc[]{new Integer JavaDoc(value), new Integer JavaDoc(maxPool)}));
115                                     }else{
116                                         result.warning(smh.getLocalString(getClass().getName()+".warning","WARNING [AS-EJB bean-pool] : steady-pool-size [{0}] is greater than max-pool-size[{1}]", new Object JavaDoc[]{new Integer JavaDoc(value), new Integer JavaDoc(maxPool)}));
117                                     }
118                                 }
119                             }
120                         }
121                         catch(NumberFormatException JavaDoc nfex)
122                         {
123                             Verifier.debug(nfex);
124                             result.failed(smh.getLocalString(getClass().getName()+".failed4",
125                                 "FAILED [AS-EJB bean-pool] : The value {0} for steady-pool-size is not a valid Integer number",
126                                 new Object JavaDoc[]{steadyPoolSize}));
127                         }
128                     }
129                 }
130                 else
131                 {
132                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
133                     "NOT APPLICABLE [AS-EJB bean-pool] : steady-pool-size element not defined"));
134                 }
135             }
136             else
137             {
138                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2",
139                     "NOT APPLICABLE [AS-EJB] : bean-pool element not defined"));
140             }
141         }
142         else
143         {
144             result.addErrorDetails(smh.getLocalString
145                                    ("tests.componentNameConstructor",
146                                     "For [ {0} ]",
147                                     new Object JavaDoc[] {compName.toString()}));
148             result.addErrorDetails(smh.getLocalString
149                  (getClass().getName() + ".notRun",
150                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
151         }
152         return result;
153     }
154 }
155
156
Popular Tags