KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > runtime > ASSessionProperty


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
25 package com.sun.enterprise.tools.verifier.tests.web.runtime;
26
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30 import com.sun.enterprise.deployment.WebBundleDescriptor;
31 import com.sun.enterprise.tools.verifier.tests.web.*;
32 import com.sun.enterprise.deployment.runtime.web.*;
33
34 //<addition author="irfan@sun.com" [bug/rfe]-id="4711198" >
35
/* Changed the result messages to reflect consistency between the result messages generated
36  * for the EJB test cases for SunONE specific deployment descriptors*/

37 //</addition>
38

39 public class ASSessionProperty extends WebTest implements WebCheck{
40
41
42 public Result check(WebBundleDescriptor descriptor) {
43
44
45     Result result = getInitializedResult();
46     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
47
48         boolean oneFailed = false;
49         boolean notApp = false;
50         try{
51         SessionConfig sessionConfig = (descriptor.getSunDescriptor()).getSessionConfig();
52         SessionProperties sessionProp=null;
53         WebProperty[] SPwebProps=null;
54
55         if(sessionConfig !=null){
56             sessionProp = sessionConfig.getSessionProperties();
57             if (sessionProp!=null)
58                 SPwebProps=sessionProp.getWebProperty();
59         }
60
61         if (sessionConfig!=null && sessionProp !=null && SPwebProps!=null && SPwebProps.length !=0 ) {
62
63             if(ASWebProperty.checkWebProperties(SPwebProps,result ,descriptor, this )){
64                   oneFailed=true;
65
66                   addErrorDetails(result, compName);
67                   result.failed(smh.getLocalString
68                                 (getClass().getName() + ".failed",
69                                 "FAILED [AS-WEB session-config] session-properties - Atleast one name/value pair is not valid in [ {0} ].",
70                                 new Object JavaDoc[] {descriptor.getName()}));
71             }
72
73         } else {
74             notApp = true;
75         }
76             
77         if(notApp) {
78             addNaDetails(result, compName);
79         result.notApplicable(smh.getLocalString
80                  (getClass().getName() + ".notApplicable",
81                   "NOT APPLICABLE [AS-WEB session-config] session-properties element(s) not defined in the web archive [ {0} ].",
82                   new Object JavaDoc[] {descriptor.getName()}));
83         }
84
85         if (oneFailed) {
86             result.setStatus(Result.FAILED);
87         } else if(notApp) {
88             result.setStatus(Result.NOT_APPLICABLE);
89         }else {
90             result.setStatus(Result.PASSED);
91             addGoodDetails(result, compName);
92             result.passed
93             (smh.getLocalString
94                     (getClass().getName() + ".passed",
95                     "PASSED [AS-WEB session-config] session-properties element(s) are valid within the web archive [ {0} ].",
96                     new Object JavaDoc[] {descriptor.getName()} ));
97         }
98         }catch(Exception JavaDoc ex){
99         oneFailed = true;
100             addErrorDetails(result, compName);
101             result.failed(smh.getLocalString
102                 (getClass().getName() + ".failed1",
103                     "FAILED [AS-WEB session-config] could not create the session-config object"));
104         
105         }
106     return result;
107     }
108
109 }
110
111
Popular Tags