KickJava   Java API By Example, From Geeks To Geeks.

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


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.ejb.Principal;
38 /** ejb [0,n]
39  * principal ?
40  * name [String]
41  *
42  * The principal tag defines a username on the platform
43  * @author Irfan Ahmed
44  */

45 public class ASEjbPrincipal 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         Ejb testCase = null;
54         boolean oneFailed = false;
55         
56         if(ejbJar!=null)
57         {
58             testCase = super.getEjb(descriptor.getName(),ejbJar);
59             
60             Principal principal = testCase.getPrincipal();
61             if(principal == null)
62             {
63                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
64                     "NOT APPLICABLE [AS-EJB ejb] : principal element not defined"));
65             }
66             else
67             {
68                 String JavaDoc principalName = principal.getName();
69                 if(principalName.length()==0)
70                 {
71                     result.failed(smh.getLocalString(getClass().getName()+".failed",
72                         "FAILED [AS-EJB principal] : name cannot be an empty String"));
73                 }
74                 else
75                 {
76                     result.passed(smh.getLocalString(getClass().getName()+".passed",
77                         "PASSED [AS-EJB principal] : name is {0}", new Object JavaDoc[]{principalName}));
78                 }
79             }
80         }
81         else
82         {
83             result.addErrorDetails(smh.getLocalString
84                  (getClass().getName() + ".notRun",
85                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
86         }
87         return result;
88     }
89 }
90
Popular Tags