KickJava   Java API By Example, From Geeks To Geeks.

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


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.EnterpriseBeans;
37
38 /** enterprise-beans
39  * unique-id ? [String]
40  *
41  * The unique-id is automatically generated and updated at deployment/redeployment
42  * The test is crude and only checks if the value promoted is not null.
43  * @author Irfan Ahmed
44  */

45 public class ASEntBeanUniqueID extends EjbTest implements EjbCheck {
46
47     public Result check(EjbDescriptor descriptor) {
48
49     Result result = getInitializedResult();
50     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
51
52         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
53         String JavaDoc ejbName = null;
54         
55         if(descriptor.getEjbBundleDescriptor().getTestsDone().contains(getClass().getName()))
56         {
57             result.setStatus(Result.NOT_RUN);
58             result.addGoodDetails(smh.getLocalString("enterpriseBeans.allReadyRun",
59                 "NOT RUN [AS-EJB enterprise-beans] unique-id test is a JAR Level Test. This test has already been run once"));
60             return result;
61         }
62         descriptor.getEjbBundleDescriptor().setTestsDone(getClass().getName());
63         
64         if(ejbJar!=null)
65         {
66             EnterpriseBeans entBean = ejbJar.getEnterpriseBeans();
67             String JavaDoc entBeanUniqueID = entBean.getUniqueId();
68             if(entBeanUniqueID == null)
69             {
70                 result.passed(smh.getLocalString(getClass().getName()+".passed",
71                     "PASSED [AS-EJB enterprise-beans] The unique-id key should not be defined. It will be " +
72                       "automatically generated at deployment time."));
73             }
74             else
75             {
76                 result.warning(smh.getLocalString
77                      (getClass().getName() + ".warning",
78                       "WARNING [AS-EJB enterprise-beans] : unique-id Element should not be defined. It is " +
79                       "automatically generated at deployment time."));
80             }
81         }
82         else
83         {
84             result.addErrorDetails(smh.getLocalString
85                  (getClass().getName() + ".notRun",
86                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
87         }
88         return result;
89     }
90 }
Popular Tags