KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ias > ASEjbCommitOption


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias;
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the License). You may not use this file except in
7  * compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
11  * glassfish/bootstrap/legal/CDDLv1.0.txt.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * Header Notice in each file and include the License file
17  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
18  * If applicable, add the following below the CDDL Header,
19  * with the fields enclosed by brackets [] replaced by
20  * you own identifying information:
21  * "Portions Copyrighted [year] [name of copyright owner]"
22  *
23  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24  */

25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
34
35 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar;
36 import com.sun.enterprise.tools.common.dd.ejb.Ejb;
37 import com.sun.enterprise.tools.common.dd.ResourceRef;
38 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal;
39 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
40 import com.sun.enterprise.deployment.EjbEntityDescriptor;
41
42 /**
43  * @author Irfan Ahmed irfan@sun.com
44  */

45 public class ASEjbCommitOption extends EjbTest implements EjbCheck {
46
47     /**
48      * @param descriptor
49      * @return */

50     public Result check(EjbDescriptor descriptor)
51     {
52     Result result = getInitializedResult();
53     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
54
55         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
56         boolean oneFailed = false;
57         
58         if(ejbJar!=null)
59         {
60             Ejb testCase = getEjb(descriptor.getName(),ejbJar);
61             String JavaDoc commitOption = testCase.getCommitOption();
62             if(commitOption!=null)
63             {
64                 if(commitOption.length()==0)
65                 {
66                     result.failed(smh.getLocalString(getClass().getName()+".failed",
67                         "FAILED [AS-EJB ejb] : commit-option cannot be an empty String"));
68                 }
69                 else
70                 {
71                     if(!commitOption.equals("A") && !commitOption.equals("B") //4699329
72
&& !commitOption.equals("C"))
73                     {
74                         result.failed(smh.getLocalString(getClass().getName()+".failed1",//4699329
75
"FAILED [AS-EJB ejb] : commit-option cannot be {0}. " +
76                             "It must be one of A, B and "+
77                             "C", new Object JavaDoc[]{commitOption}));
78                     }
79                     else
80                     {
81                         if(descriptor instanceof EjbEntityDescriptor)
82                         {
83                             result.passed(smh.getLocalString(getClass().getName()+".passed",
84                                 "PASSED [AS-EJB ejb] : commit-option is {0}", new Object JavaDoc[]{commitOption}));
85                         }
86                         else
87                         {
88                             result.warning(smh.getLocalString(getClass().getName()+".warning",
89                                 "WARNING [AS-EJB ejb] : commit-option should be defined only for an Entity Bean"));
90                         }
91                     }
92                 }
93             }
94             else
95             {
96                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
97                     "NOT APPLICABLE [AS-EJB ejb] commit-option Element is not defined"));
98             }
99         }
100         else
101         {
102             result.addErrorDetails(smh.getLocalString
103                  (getClass().getName() + ".notRun",
104                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
105         }
106         return result;
107     }
108 }
109
Popular Tags