KickJava   Java API By Example, From Geeks To Geeks.

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


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 ASConnectorIdleTimeout 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 idleTimeout = ra.getAttributeValue("idle-timeout-in-seconds");
50      if(idleTimeout.length()==0)
51      {
52          result.failed(smh.getLocalString(getClass().getName()+".failed1",
53                     "FAILED [AS-CONNECTOR resource-adapter] : idle-timeout-in-seconds cannot be empty"));
54      }
55      else
56      {
57         try
58         {
59             long value = Long.valueOf(idleTimeout).longValue();
60             if(value < 0 || value > Long.MAX_VALUE)
61             {
62                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
63                     "FAILED [AS-CONNECTOR resource-adapter] : idle-timeout-in-seconds 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] : idle-timeout-in-seconds 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 idle-timeout-in-seconds is not a valid Long number",new Object JavaDoc[]{idleTimeout}));
78         }
79      }
80      }
81         return result;
82  }
83  }
84
Popular Tags