KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > cci > ConnectionImplClose


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  * ConnectionImplClose.java
25  *
26  * Created on October 4, 2000, 9:53 AM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector.cci;
30
31 import java.lang.reflect.Method JavaDoc;
32 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck;
33 import com.sun.enterprise.tools.verifier.Result;
34 import com.sun.enterprise.tools.verifier.tests.*;
35 import com.sun.enterprise.deployment.ConnectorDescriptor;
36
37 /**
38  * Check that the Client API Connection interface implements the close()
39  * method
40  * @author Jerome Dochez
41  * @version
42  */

43 public class ConnectionImplClose extends ConnectionTest implements ConnectorCheck {
44
45
46
47   /** <p>
48    * Check that the Client API Connection interface implements the close()
49    * method
50    * </p>
51    *
52    * @paramm descriptor deployment descriptor for the rar file
53    * @return result object containing the result of the individual test
54    * performed
55    */

56   public Result check(ConnectorDescriptor descriptor) {
57
58     // get the connection
59
Result result = getInitializedResult();
60     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
61     if(isCCIImplemented(descriptor, result))
62     {
63       Class JavaDoc c = testConnectionImpl(descriptor, result);
64       if (c==null) {
65         return result;
66       }
67       // now check the close() method
68
Method JavaDoc m = getMethod(c, "close", null);
69       if (m!=null) {
70         // passed
71
result.addGoodDetails(smh.getLocalString
72             ("tests.componentNameConstructor",
73              "For [ {0} ]",
74              new Object JavaDoc[] {compName.toString()}));
75         result.passed(smh.getLocalString(
76               getClass().getName() + ".passed",
77               "The connection interface [ {0} ] implements the close() method",
78               new Object JavaDoc[] {c.getName()} ));
79       } else {
80         result.addErrorDetails(smh.getLocalString
81             ("tests.componentNameConstructor",
82              "For [ {0} ]",
83              new Object JavaDoc[] {compName.toString()}));
84         result.failed(smh.getLocalString(
85               getClass().getName() + ".failed",
86               "Error: The connection interface [ {0} ] does not implement the close() method",
87               new Object JavaDoc[] {c.getName()} ));
88       }
89     }
90     else
91     {
92       // test is NA
93
result.addNaDetails(smh.getLocalString
94           ("tests.componentNameConstructor",
95            "For [ {0} ]",
96            new Object JavaDoc[] {compName.toString()}));
97       result.notApplicable(smh.getLocalString
98           ("com.sun.enterprise.tools.verifier.tests.connector.cci.notApp",
99            "The CCI interfaces do not seem to be implemented by this resource adapter"));
100     }
101     return result;
102   }
103 }
104
Popular Tags