KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > ias > ASConnectorSteadyPool


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.connector.ias;
25
26 import com.sun.enterprise.deployment.ConnectorDescriptor;
27 import com.sun.enterprise.tools.common.dd.connector.ResourceAdapter;
28 import com.sun.enterprise.tools.common.dd.connector.SunConnector;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31 import com.sun.enterprise.tools.verifier.tests.connector.*;
32
33
34 public class ASConnectorSteadyPool extends ConnectorTest implements ConnectorCheck {
35  public Result check(ConnectorDescriptor descriptor)
36  {
37      Result result = getInitializedResult();
38      ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
39      boolean oneFailed = false;
40      SunConnector sc = descriptor.getSunDescriptor();
41      if(sc == null)
42      {
43             result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
44               "NOT APPLICABLE [AS­CONNECTOR]: sun-ra.xml descriptor object could not be obtained"));
45                               
46      }
47      else{
48      ResourceAdapter ra = sc.getResourceAdapter();
49      if( ra == null)
50      {
51             result.addErrorDetails(smh.getLocalString
52                                    ("tests.componentNameConstructor",
53                                     "For [ {0} ]",
54                                     new Object JavaDoc[] {compName.toString()}));
55             result.addErrorDetails(smh.getLocalString
56                  (getClass().getName() + ".notRun",
57                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
58
59      }
60      String JavaDoc steadyPoolSize = ra.getAttributeValue("steady-pool-size");
61      if(steadyPoolSize.length()==0)
62      {
63          result.failed(smh.getLocalString(getClass().getName()+".failed1",
64                     "FAILED [AS-CONNECTOR resource-adapter] : steady-pool-size cannot be empty"));
65      }
66      else
67      {
68         try
69         {
70             int value = Integer.valueOf(steadyPoolSize).intValue();
71             if(value < 0 || value > Integer.MAX_VALUE)
72             {
73                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
74                     "FAILED [AS-CONNECTOR resource-adapter] : steady-pool-size cannot be {0}. It should be between 0 and {1}",
75                 new Object JavaDoc[]{new Integer JavaDoc(value),new Integer JavaDoc(Integer.MAX_VALUE)}));
76             }
77             else
78             {
79                 String JavaDoc maxPool = ra.getAttributeValue("max-pool-size");
80                 int maxPoolSize = 0;
81                 try{
82                     maxPoolSize = Integer.valueOf(maxPool).intValue();
83                 }catch(NumberFormatException JavaDoc nfe){
84                     result.failed(smh.getLocalString(getClass().getName()+".failed3","FAILED [AS-CONNECTOR resource-adapter] : steady-pool-size should be less than max-pool-size and the value {0} for max-pool-size is not a valid Integer number",new Object JavaDoc[]{maxPool}));
85                     return result;
86                 }
87                 if(value <= maxPoolSize)
88                 result.passed(smh.getLocalString(getClass().getName()+".passed",
89                    "PASSED [AS-CONNECTOR resource-adapter] : steady-pool-size is {0}",
90                          new Object JavaDoc[]{new Integer JavaDoc(value)}));
91                 else{
92                     result.failed(smh.getLocalString(getClass().getName()+".failed4","FAILED [AS-CONNECTOR resource-adapter] : steady-pool-size {0} should not be greater than max-pool-size {1}", new Object JavaDoc[]{steadyPoolSize,maxPool}));
93                 }
94             }
95         }
96         catch(NumberFormatException JavaDoc nfex)
97         {
98             Verifier.debug(nfex);
99             result.failed(smh.getLocalString(getClass().getName()+".failed5",
100             "FAILED [AS-CONNECTOR resource-adapter] : The value {0} for steady-pool-size is not a valid Integer number",new Object JavaDoc[]{steadyPoolSize}));
101         }
102      }
103      }
104         return result;
105  }
106  }
107
Popular Tags