KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > ias > 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.ias;
26
27 import java.util.*;
28 import com.sun.enterprise.deployment.*;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
32 import com.sun.enterprise.deployment.WebBundleDescriptor;
33 import com.sun.enterprise.tools.verifier.tests.web.*;
34 import com.sun.enterprise.tools.common.dd.webapp.*;
35
36 //<addition author="irfan@sun.com" [bug/rfe]-id="4711198" >
37
/* Changed the result messages to reflect consistency between the result messages generated
38  * for the EJB test cases for SunONE specific deployment descriptors*/

39 //</addition>
40

41 public class ASSessionProperty extends WebTest implements WebCheck{
42
43
44 public Result check(WebBundleDescriptor descriptor) {
45
46
47     Result result = getInitializedResult();
48     WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor);
49
50         boolean oneFailed = false;
51         boolean notApp = false;
52         SessionConfig sessionConfig = getSessionConfig(descriptor);
53         SessionProperties sessionProp=null;
54
55         WebProperty[] SPwebProps=null;
56
57         if(sessionConfig !=null){
58             sessionProp = sessionConfig.getSessionProperties();
59             if (sessionProp!=null)
60                 SPwebProps=sessionProp.getWebProperty();
61         }
62
63         //System.out.println(">>>>>>>>>>>>checking for res " +webProps);
64
if (sessionConfig!=null && sessionProp !=null && SPwebProps!=null && SPwebProps.length !=0 ) {
65
66             if(ASWebProperty.checkWebProperties(SPwebProps,result ,descriptor, this )){
67                   oneFailed=true;
68                   result.failed(smh.getLocalString
69                                 (getClass().getName() + ".failed",
70                                 "FAILED [AS-WEB session-config] session-properties - Atleast one name/value pair is not valid in [ {0} ].",
71                                 new Object JavaDoc[] {descriptor.getName()}));
72             }
73
74         } else {
75             notApp = true;
76         }
77             //System.out.println("There are no resource references defined within the ias-web archive");
78
if(notApp) {
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             result.passed
92             (smh.getLocalString
93                     (getClass().getName() + ".passed",
94                     "PASSED [AS-WEB session-config] session-properties element(s) are valid within the web archive [ {0} ].",
95                     new Object JavaDoc[] {descriptor.getName()} ));
96         }
97     return result;
98     }
99
100     public SessionConfig getSessionConfig(WebBundleDescriptor descriptor) {
101         return descriptor.getIasWebApp().getSessionConfig();
102
103
104     }
105 }
106
107
Popular Tags