KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > admin > CheckAdminObjectImpl


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  * CheckAdminObjectImpl.java
25  *
26  * Created on August 29, 2002
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector.admin;
30
31 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest;
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.*;
35 import com.sun.enterprise.deployment.ConnectorDescriptor;
36 import com.sun.enterprise.deployment.AdminObject;
37 import com.sun.enterprise.tools.verifier.tests.*;
38 import java.util.Iterator JavaDoc;
39 import java.util.Set JavaDoc;
40
41 /**
42  * Test for each adminobject, that "adminobject-class"
43  * implements "adminobject-interface".
44  *
45  * @author Anisha Malhotra
46  * @version
47  */

48 public class CheckAdminObjectImpl
49     extends ConnectorTest
50     implements ConnectorCheck
51 {
52
53   /** <p>
54    * Test for each adminobject, that "adminobject-class"
55    * implements "adminobject-interface".
56    * </p>
57    *
58    * @param descriptor deployment descriptor for the rar file
59    * @return result object containing the result of the individual test
60    * performed
61    */

62   public Result check(ConnectorDescriptor descriptor) {
63
64     Result result = getInitializedResult();
65     ComponentNameConstructor compName =
66       getVerifierContext().getComponentNameConstructor();
67     if(!descriptor.hasAdminObjects())
68     {
69       result.addNaDetails(smh.getLocalString
70           ("tests.componentNameConstructor",
71            "For [ {0} ]",
72            new Object JavaDoc[] {compName.toString()}));
73       result.notApplicable(smh.getLocalString
74           ("com.sun.enterprise.tools.verifier.tests.connector.admin.notApp",
75            "Resource Adapter does not define any administered objects"));
76       return result;
77     }
78     Set JavaDoc adminObjects = descriptor.getAdminObjects();
79     boolean oneFailed = false;
80     Iterator JavaDoc iter = adminObjects.iterator();
81     while(iter.hasNext())
82     {
83       AdminObject adminObj = (AdminObject) iter.next();
84       String JavaDoc intf = adminObj.getAdminObjectInterface();
85       String JavaDoc impl = adminObj.getAdminObjectClass();
86       Class JavaDoc implClass = null;
87       try
88       {
89         implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
90       }
91       catch(ClassNotFoundException JavaDoc e)
92       {
93         result.addErrorDetails(smh.getLocalString
94             ("tests.componentNameConstructor",
95              "For [ {0} ]",
96              new Object JavaDoc[] {compName.toString()}));
97         result.failed(smh.getLocalString
98             ("com.sun.enterprise.tools.verifier.tests.connector.admin.nonexist",
99              "Error: The class [ {0} ] as defined under adminobject-class in the deployment descriptor does not exist",
100              new Object JavaDoc[] {impl}));
101         return result;
102       }
103       if(!isImplementorOf(implClass, intf))
104       {
105         oneFailed = true;
106         result.addErrorDetails(smh.getLocalString
107             ("tests.componentNameConstructor",
108              "For [ {0} ]",
109              new Object JavaDoc[] {compName.toString()}));
110         result.failed(smh.getLocalString(getClass().getName() + ".failed",
111               "Error: adminobject-class [ {0} ] does not implement adminobject-interface [ {1} ].",
112               new Object JavaDoc[] {impl, intf}));
113         return result;
114       }
115     }
116     if(!oneFailed)
117     {
118       result.addGoodDetails(smh.getLocalString
119           ("tests.componentNameConstructor",
120            "For [ {0} ]",
121            new Object JavaDoc[] {compName.toString()}));
122       result.passed(smh.getLocalString(getClass().getName() + ".passed",
123             "Success: all adminobject-class implement their corresponding adminobject-interface"));
124     }
125     return result;
126   }
127 }
128
Popular Tags