KickJava   Java API By Example, From Geeks To Geeks.

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


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 ASConnectorMaxWait 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      String JavaDoc maxWait = ra.getAttributeValue("max-wait-time-in-millis");
50      if(maxWait.length()==0)
51      {
52          result.failed(smh.getLocalString(getClass().getName()+".failed1",
53                     "FAILED [AS-CONNECTOR resource-adapter] : max-wait-time-in-millis cannot be empty"));
54      }
55      else
56      {
57         try
58         {
59             long value = Long.valueOf(maxWait).longValue();
60             if(value < 0 || value > Long.MAX_VALUE)
61             {
62                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
63                     "FAILED [AS-CONNECTOR resource-adapter] : max-wait-time-in-millis cannot be {0}. It should be between 0 and {1}",
64                 new Object JavaDoc[]{new Long JavaDoc(value),new Long JavaDoc(Long.MAX_VALUE)}));
65             }
66             else
67             {
68                 result.passed(smh.getLocalString(getClass().getName()+".passed",
69                    "PASSED [AS-CONNECTOR resource-adapter] : max-wait-time-in-millis is {0}",
70                          new Object JavaDoc[]{new Long JavaDoc(value)}));
71             }
72         }
73         catch(NumberFormatException JavaDoc nfex)
74         {
75             Verifier.debug(nfex);
76             result.failed(smh.getLocalString(getClass().getName()+".failed3",
77             "FAILED [AS-CONNECTOR resource-adapter] : The value {0} for max-wait-time-in-millis is not a valid Long number",new Object JavaDoc[]{maxWait}));
78         }
79      }
80      }
81         return result;
82  }
83  }
84
Popular Tags