KickJava   Java API By Example, From Geeks To Geeks.

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


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  * InteractionSpecJavaBeansCompliance.java
25  *
26  * Created on October 5, 2000, 5:02 PM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector.cci;
30
31 import java.io.File JavaDoc;
32 import java.beans.*;
33 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck;
34 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest;
35 import com.sun.enterprise.tools.verifier.tests.*;
36 import com.sun.enterprise.tools.verifier.*;
37 import com.sun.enterprise.deployment.ConnectorDescriptor;
38
39 /**
40  *
41  * @author Jerome Dochez
42  * @version
43  */

44 public class InteractionSpecJavaBeansCompliance extends ConnectionFactoryTest implements ConnectorCheck {
45
46
47     /** <p>
48      * all connector tests should implement this method. it run an individual
49      * test against the resource adapter deployment descriptor.
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         boolean oneFailed=false;
59         Result result = getInitializedResult();
60     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
61         
62         if (isCCIImplemented(descriptor, result)) {
63             //File jarFile = Verifier.getJarFile(descriptor.getModuleDescriptor().getArchiveUri());
64
// File f=Verifier.getArchiveFile(descriptor.getModuleDescriptor().getArchiveUri());
65
Class JavaDoc mcf = findImplementorOf(descriptor, "javax.resource.cci.InteractionSpec");
66             if (mcf != null) {
67                 try {
68                     BeanInfo bi = Introspector.getBeanInfo(mcf, Object JavaDoc.class);
69                     PropertyDescriptor[] properties = bi.getPropertyDescriptors();
70                     for (int i=0; i<properties.length;i++) {
71                         // each property should have a getter/setter
72
if (properties[i].getReadMethod()==null ||
73                             properties[i].getWriteMethod()==null) {
74                                 // this is an error.
75
oneFailed=true;
76                                 result.addErrorDetails(smh.getLocalString
77                                ("tests.componentNameConstructor",
78                             "For [ {0} ]",
79                             new Object JavaDoc[] {compName.toString()}));
80                 result.failed(smh.getLocalString
81                           (getClass().getName() + ".failed",
82                            "Error: The javax.resource.cci.InteractionSpec implementation [ {0} ] of the property [ {1} ] is not JavaBeans compliant",
83                            new Object JavaDoc[] {mcf.getName(), properties[i].getName()} ));
84             }
85                         if (!properties[i].isConstrained() && !properties[i].isBound()) {
86                             oneFailed=true;
87                             result.addErrorDetails(smh.getLocalString
88                            ("tests.componentNameConstructor",
89                             "For [ {0} ]",
90                             new Object JavaDoc[] {compName.toString()}));
91                 result.failed(smh.getLocalString
92                       (getClass().getName() + ".failed2",
93                        "Error: The property [ {0} ] of the javax.resource.cci.InteractionSpec implementation [ {1} ] is not bound or constrained",
94                        new Object JavaDoc[] {properties[i].getName(), mcf.getName()} ));
95                         }
96                     }
97                 } catch (IntrospectionException ie) {
98             result.addNaDetails(smh.getLocalString
99                       ("tests.componentNameConstructor",
100                        "For [ {0} ]",
101                        new Object JavaDoc[] {compName.toString()}));
102                     result.notApplicable(smh.getLocalString
103                         (getClass().getName() + ".failed",
104                         "Error: The javax.resource.cci.InteractionSpec implementation [ {0} ] is not JavaBeans compliant",
105                         new Object JavaDoc[] {mcf.getName()} ));
106                     return result;
107                 }
108                 // now iterates over the properties and look for descrepencies
109
} else {
110         result.addNaDetails(smh.getLocalString
111                       ("tests.componentNameConstructor",
112                        "For [ {0} ]",
113                        new Object JavaDoc[] {compName.toString()}));
114                 result.notApplicable(smh.getLocalString
115                     (getClass().getName() + ".nonexist",
116                     "Error: While the CCI interfaces are implemented, the javax.resource.cci.InteractionSpec is not"));
117                 return result;
118             }
119                 
120         } else {
121         result.addNaDetails(smh.getLocalString
122                       ("tests.componentNameConstructor",
123                        "For [ {0} ]",
124                        new Object JavaDoc[] {compName.toString()}));
125         result.notApplicable(smh.getLocalString
126                 ("com.sun.enterprise.tools.verifier.tests.connector.cci.InteractionExistence.notapp",
127                  "NotApplicable : The CCI interfaces do not seem to be implemented by this resource adapter"));
128             return result;
129         }
130         if (!oneFailed) {
131             result.addGoodDetails(smh.getLocalString
132                       ("tests.componentNameConstructor",
133                        "For [ {0} ]",
134                        new Object JavaDoc[] {compName.toString()}));
135         result.passed(smh.getLocalString
136                 (getClass().getName() + ".passed",
137                 "The javax.resource.cci.InteractionSpec implementation is JavaBeans compliant"));
138         }
139         return result;
140     }
141 }
142
Popular Tags