KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.tools.verifier.tests.ejb.ias.cmpmapping;
25
26
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.tools.verifier.tests.ejb.*;
41 import com.sun.enterprise.tools.common.dd.cmpmapping.*;
42
43 public class ASCmpMappingTest extends EjbTest implements EjbCheck {
44
45     public Result check(EjbDescriptor descriptor)
46     {
47     Result result = getInitializedResult();
48     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
49         boolean oneFailed = false;
50         boolean notApp = false;
51
52         //<addition author="irfan@sun.com" [bug/rfe]-id="4715917" >
53
/*Set keys = descriptor.getEjbBundleDescriptor().getIasCmpMappingsKeys();
54
55         SunCmpMappings iasCmpMappings=null;
56         String forPmConfig=null;*/

57         SunCmpMappings iasCmpMappings = descriptor.getEjbBundleDescriptor().getIasCmpMappings();
58         String JavaDoc forPmConfig = com.sun.enterprise.deployment.EjbBundleXmlReader.IAS_CMP_MAPPING_JAR_ENTRY;
59         //</addition>
60

61         SunCmpMapping[] allIasCmpMapping=null;
62         SunCmpMapping iasCmpMapping=null;
63
64         /////test vars
65
String JavaDoc schema=null;
66
67
68         //<addition author="irfan@sun.com" [bug/rfe]-id="4715917" >
69
if(iasCmpMappings != null)
70         {
71         /*if(keys!=null && keys.size()>0)
72         {
73             Iterator it = keys.iterator();
74             while(it.hasNext()) {
75
76                 forPmConfig=(String) it.next();
77                 iasCmpMappings= descriptor.getEjbBundleDescriptor().getIasCmpMappings(forPmConfig);*/

78         //</addition>
79
allIasCmpMapping=iasCmpMappings.getSunCmpMapping();
80
81                 for(int rep=0;rep<allIasCmpMapping.length;rep++){
82
83                       iasCmpMapping=allIasCmpMapping[rep];
84
85                       //test logic
86
schema=iasCmpMapping.getSchema();
87                       if(validateSchema(schema)){
88
89                       result.passed(smh.getLocalString(getClass().getName()+".passed",
90                             "PASSED [AS-CMP-MAPPING] : schema [{0} ] is a valid entry, in the mapping file [ {1}], "+
91                             "of the ejb archive [ {2} ]. ",
92                             new Object JavaDoc[]{schema,forPmConfig,descriptor.getName()}));
93
94
95                       }else{
96                       oneFailed = true;
97
98                       result.failed(smh.getLocalString(getClass().getName()+".failed",
99                             "FAILED [AS-CMP-MAPPING] : schema [{0} ] is NOT a valid entry, in the mapping file [ {1}], "+
100                             "of the ejb archive [ {2} ]. "+
101                             "Either null or empty.",
102                             new Object JavaDoc[]{schema,forPmConfig,descriptor.getName()}));
103
104
105                       }
106
107
108
109                 }
110
111
112             //} 4715917 irfan
113

114         }
115         else
116         {
117             notApp = true;
118             result.notApplicable(smh.getLocalString
119                                  (getClass().getName() + ".notApplicable",
120                                   "NOT APPLICABLE [AS-CMP-MAPPING] : There is no ias-cmp-mappings file present, within the ejb archive [ {0} ].",
121                                   new Object JavaDoc[] {descriptor.getName()}));
122
123         }
124
125         if (oneFailed) {
126             result.setStatus(Result.FAILED);
127         } else if(notApp) {
128             result.setStatus(Result.NOT_APPLICABLE);
129         }else {
130             result.setStatus(Result.PASSED);
131         }
132
133
134         return result;
135     }
136
137     boolean validateSchema(String JavaDoc schema){
138         boolean valid=false;
139         if(schema !=null && !schema.trim().equals("")){
140             valid =true;
141         }
142         return valid;
143     }
144 }
145
146
Popular Tags