KickJava   Java API By Example, From Geeks To Geeks.

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


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  * 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 resize-quantity specifies the number of beans to be created if the
45  * pool is empty
46  *
47  * valid values are o tp MAX_INT
48  *
49  *
50  * @author Irfan Ahmed
51  */

52 public class ASEjbBPPoolResizeQty 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 poolResizeQty = beanPool.getResizeQuantity();
71                 if(poolResizeQty!=null)
72                 {
73                     if(poolResizeQty.length()==0)
74                     {
75                         result.failed(smh.getLocalString(getClass().getName()+".failed1",
76                             "FAILED [AS-EJB bean-pool] : resize-quantity cannot be empty"));
77                     }
78                     else
79                     {
80                         try
81                         {
82                             int value = Integer.valueOf(poolResizeQty).intValue();
83                             if(value < 0 || value > Integer.MAX_VALUE)
84                             {
85                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
86                                     "FAILED [AS-EJB bean-pool] : resize-quantity 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                                 {
95                                     result.passed(smh.getLocalString(getClass().getName()+".passed1",
96                                  "PASSED [AS-EJB bean-pool] : resize-quantity is {0}", new Object JavaDoc[]{new Integer JavaDoc(value)}));
97                                 }
98                                 else
99                                 {
100                                     try{
101                                         maxPool = Integer.parseInt(maxPoolSize);
102                                     }catch(NumberFormatException JavaDoc nfe){
103                                         result.failed(smh.getLocalString(getClass().getName()+".failed3",
104                                         "FAILED [AS-EJB bean-pool] : The value {0} for max-pool-size is not a valid Integer number",new Object JavaDoc[]{maxPoolSize}));
105
106                                         return result;
107
108                                     }
109                                                                     //<addition author="irfan@sun.com" [bug/rfe]-id="4724439" >
110
if(value <= maxPool)
111                                     {
112                                         result.passed(smh.getLocalString(getClass().getName()+".passed2",
113                                         "PASSED [AS-EJB bean-pool] : resize-quantity 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                                                                     //</addition>
116
}
117                                     else
118                                     {
119                                         result.warning(smh.getLocalString(getClass().getName()+".warning",
120                                         "WARNING [AS-EJB bean-pool] : resize-quantity [{0}] is greater than max-pool-size [{1}]",new Object JavaDoc[]{new Integer JavaDoc(value), new Integer JavaDoc(maxPool)}));
121                                     }
122                                 }
123                             }
124                         }
125                         catch(NumberFormatException JavaDoc nfex)
126                         {
127                             Verifier.debug(nfex);
128                             result.failed(smh.getLocalString(getClass().getName()+".failed4",
129                                 "FAILED [AS-EJB bean-pool] : The value {0} for resize-quantity is not a valid Integer number",
130                                 new Object JavaDoc[]{poolResizeQty}));
131                         }
132                     }
133                 }
134                 else
135                 {
136                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
137                     "NOT APPLICABLE [AS-EJB bean-pool] : resize-quantity element not defined"));
138                 }
139             }
140             else
141             {
142                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2",
143                     "NOT APPLICABLE [AS-EJB] : bean-pool element not defined"));
144             }
145         }
146         else
147         {
148             result.addErrorDetails(smh.getLocalString
149                                    ("tests.componentNameConstructor",
150                                     "For [ {0} ]",
151                                     new Object JavaDoc[] {compName.toString()}));
152             result.addErrorDetails(smh.getLocalString
153                  (getClass().getName() + ".notRun",
154                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
155         }
156         return result;
157     }
158 }
159
160
161
Popular Tags