KickJava   Java API By Example, From Geeks To Geeks.

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


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  * TransactionSupportExistence.java
25  *
26  * Created on September 28, 2000, 2:09 PM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector;
30
31 import java.io.File JavaDoc;
32 import com.sun.enterprise.tools.verifier.Result;
33 import com.sun.enterprise.tools.verifier.Verifier;
34 import com.sun.enterprise.deployment.ConnectorDescriptor;
35 import com.sun.enterprise.tools.verifier.tests.*;
36 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
37
38 /**
39  * Test the implementation of the proprer transaction support depending on the
40  * level of transaction declared in the deployment descriptor
41  *
42  * @author Jerome Dochez
43  * @version
44  */

45 public class TransactionSupportExistence
46     extends ConnectorTest
47     implements ConnectorCheck
48 {
49
50     /** <p>
51      * Test the implementation of the proprer transaction support depending on
52      * the level of transaction declared in the deployment descriptor :
53      * - NoTransaction neither XAResource or LocalTransaction should be
54      * implemented, warning if it does
55      * - LocalTransaction LocalTransaction has to be implemented
56      * - XATransaction XAResource has to be implemented
57      * </p>
58      *
59      * @param descriptor deployment descriptor for the rar file
60      * @return result object containing the result of the individual test
61      * performed
62      */

63     public Result check(ConnectorDescriptor descriptor) {
64                 
65         Result result = getInitializedResult();
66     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
67         if(!descriptor.getOutBoundDefined())
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.managed.notApplicableForInboundRA",
75                "Resource Adapter does not provide outbound communication"));
76           return result;
77         }
78         String JavaDoc connectorTransactionSupport =
79         descriptor.getOutboundResourceAdapter().getTransSupport();
80         
81         // No transaction support specified, this is an error
82
if (connectorTransactionSupport==null) {
83         result.addErrorDetails(smh.getLocalString
84                    ("tests.componentNameConstructor",
85                     "For [ {0} ]",
86                     new Object JavaDoc[] {compName.toString()}));
87         result.failed(smh.getLocalString
88               ("com.sun.enterprise.tools.verifier.tests.connector.TransactionSupport.nonexist",
89                "Error: No Transaction support specified for ressource adapter",
90                new Object JavaDoc[] {connectorTransactionSupport}));
91             return result;
92         }
93         
94         // get the rar file handle
95
// File jarFile = Verifier.getJarFile(descriptor.getModuleDescriptor().getArchiveUri());
96

97 // File f=Verifier.getArchiveFile(descriptor.getModuleDescriptor().getArchiveUri());
98
if (connectorTransactionSupport.equals(ConnectorTagNames.DD_NO_TRANSACTION)) {
99             boolean oneFailed=false;
100             if (findImplementorOf(descriptor, "javax.resource.spi.LocalTransaction")!=null) {
101                 oneFailed = true;
102         result.addWarningDetails(smh.getLocalString
103                       ("tests.componentNameConstructor",
104                        "For [ {0} ]",
105                        new Object JavaDoc[] {compName.toString()}));
106                 result.warning(smh.getLocalString(getClass().getName() + ".warning",
107                 "Warning: Transaction support {0} is specified for ressource adapter but [ {1} ] is implemented",
108         new Object JavaDoc[] {"NoTransaction", "javax.resource.spi.LocalTransaction"}));
109             }
110             if (findImplementorOf(descriptor, "javax.transaction.xa.XAResource")!=null) {
111                 oneFailed = true;
112         result.addWarningDetails(smh.getLocalString
113                       ("tests.componentNameConstructor",
114                        "For [ {0} ]",
115                        new Object JavaDoc[] {compName.toString()}));
116                 result.warning(smh.getLocalString(getClass().getName() + ".warning",
117                 "Warning: Transaction support {0} is specified for ressource adapter but [ {1} ] is implemented",
118         new Object JavaDoc[] {"NoTransaction", "javax.transaction.xa.XAResource"}));
119             }
120             if (!oneFailed) {
121                 result.addGoodDetails(smh.getLocalString
122                       ("tests.componentNameConstructor",
123                        "For [ {0} ]",
124                        new Object JavaDoc[] {compName.toString()}));
125         result.passed(smh.getLocalString(getClass().getName() + ".passed1",
126                     "Transaction support NoTransaction is specified for ressource adapter and [ {0} ] are not implemented",
127                     new Object JavaDoc[] {"javax.transaction.xa.XAResource, javax.resource.spi.LocalTransaction"}));
128             }
129         }
130         else {
131             if (connectorTransactionSupport.equals(ConnectorTagNames.DD_LOCAL_TRANSACTION)) {
132                 if (findImplementorOf(descriptor, "javax.resource.spi.LocalTransaction")==null) {
133                     result.addErrorDetails(smh.getLocalString
134                       ("tests.componentNameConstructor",
135                        "For [ {0} ]",
136                        new Object JavaDoc[] {compName.toString()}));
137         result.failed(smh.getLocalString(getClass().getName() + ".nonexist",
138                     "Error: Transaction support {0} is specified for ressource adapter but [ {1} ] is not implemented",
139             new Object JavaDoc[] {"LocalTransaction", "javax.resource.spi.LocalTransaction"}));
140                 } else {
141                     if (findImplementorOf(descriptor, "javax.transaction.xa.XAResource")!=null) {
142             result.addWarningDetails(smh.getLocalString
143                       ("tests.componentNameConstructor",
144                        "For [ {0} ]",
145                        new Object JavaDoc[] {compName.toString()}));
146                         result.addWarningDetails(smh.getLocalString(getClass().getName() + ".warning",
147                         "Warning: Transaction support {0} is specified for ressource adapter but [ {1} ] is implemented",
148                         new Object JavaDoc[] {"LocalTransaction", "javax.transaction.xa.XAResource"}));
149                     } else {
150                         result.addGoodDetails(smh.getLocalString
151                       ("tests.componentNameConstructor",
152                        "For [ {0} ]",
153                        new Object JavaDoc[] {compName.toString()}));
154             result.passed(smh.getLocalString(getClass().getName() + ".passed2",
155                             "Transaction support {0} is specified for ressource adapter and [ {1} ] is(are) implemented",
156                         new Object JavaDoc[] {"LocalTransaction", "javax.resource.spi.LocalTransaction"}));
157                     }
158                 }
159             } else {
160                 if (connectorTransactionSupport.equals(ConnectorTagNames.DD_XA_TRANSACTION)) {
161                     boolean oneFailed = false;
162                     if (findImplementorOf(descriptor, "javax.resource.spi.LocalTransaction")==null) {
163                         oneFailed = true;
164                         result.addErrorDetails(smh.getLocalString
165                       ("tests.componentNameConstructor",
166                        "For [ {0} ]",
167                        new Object JavaDoc[] {compName.toString()}));
168             result.failed(smh.getLocalString(getClass().getName() + ".nonexist",
169                         "Error: Transaction support {0} is specified for ressource adapter but [ {1} ] is not implemented",
170                 new Object JavaDoc[] {"XATransaction", "javax.resource.spi.LocalTransaction"}));
171                     }
172                     if (findImplementorOf(descriptor, "javax.transaction.xa.XAResource")==null) {
173                         oneFailed = true;
174                         result.addErrorDetails(smh.getLocalString
175                       ("tests.componentNameConstructor",
176                        "For [ {0} ]",
177                        new Object JavaDoc[] {compName.toString()}));
178             result.failed(smh.getLocalString(getClass().getName() + ".nonexist",
179                         "Error: Transaction support {0} is specified for ressource adapter but [ {1} ] is not implemented",
180                 new Object JavaDoc[] {"XATransaction", "javax.transaction.xa.XAResource"}));
181                     }
182                     if (!oneFailed) {
183                         result.addGoodDetails(smh.getLocalString
184                       ("tests.componentNameConstructor",
185                        "For [ {0} ]",
186                        new Object JavaDoc[] {compName.toString()}));
187             result.passed(smh.getLocalString(getClass().getName() + ".passed2",
188                             "Transaction support {0} is specified for ressource adapter and [ {1} ] is(are) implemented",
189                             new Object JavaDoc[] {"XATransaction", "javax.transaction.xa.Transaction, javax.resource.spi.LocalTransaction"}));
190                     }
191                 } else {
192                     // unknow transaction support
193
result.addErrorDetails(smh.getLocalString
194                       ("tests.componentNameConstructor",
195                        "For [ {0} ]",
196                        new Object JavaDoc[] {compName.toString()}));
197             result.failed(smh.getLocalString
198                     ("com.sun.enterprise.tools.verifier.tests.connector.TransactionSupport.failed",
199                         "Error: Deployment descriptor transaction-support [ {0} ] for ressource adapter is not valid",
200                 new Object JavaDoc[] {connectorTransactionSupport}));
201                 }
202             }
203         }
204         return result;
205     }
206 }
207
Popular Tags