KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > ias > ASSessionManager


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

42 //</addition>
43

44 public class ASSessionManager extends WebTest implements WebCheck{
45
46
47 public Result check(WebBundleDescriptor descriptor) {
48
49
50     Result result = getInitializedResult();
51     WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor);
52
53         boolean oneFailed = false;
54         boolean notApp = false;
55         SessionConfig sessionConfig = getSessionConfig(descriptor);
56         SessionManager sessionMgr=null;
57
58         StoreProperties stroeProp=null;
59         ManagerProperties mgrProps=null;
60
61         WebProperty[] SPwebProps=null;
62         WebProperty[] MPwebProps=null;
63
64         if(sessionConfig !=null){
65         sessionMgr = sessionConfig.getSessionManager();
66
67         }
68
69         //System.out.println(">>>>>>>>>>>>checking for res " +webProps);
70
if (sessionConfig!=null && sessionMgr !=null) {
71             mgrProps=sessionMgr.getManagerProperties();
72             stroeProp =sessionMgr.getStoreProperties();
73
74             if(stroeProp !=null )
75             SPwebProps=stroeProp.getWebProperty();
76
77             if(mgrProps !=null)
78             MPwebProps=mgrProps.getWebProperty();
79
80             if((SPwebProps ==null|| SPwebProps.length==0) && (MPwebProps ==null || MPwebProps.length==0)){
81                 notApp = true;
82             } else {
83                   if (SPwebProps !=null|| SPwebProps.length>0)
84                         if(ASWebProperty.checkWebProperties(SPwebProps,result ,descriptor, this )){
85                            oneFailed=true;
86                            result.failed(smh.getLocalString
87                        (getClass().getName() + ".failed",
88                         "FAILED [AS-WEB session-manager] store-properties - Atleast one name/value pair is not valid in [ {0} ].",
89                         new Object JavaDoc[] {descriptor.getName()}));
90                          }
91
92                   if (MPwebProps !=null || MPwebProps.length>0)
93                         if(ASWebProperty.checkWebProperties(MPwebProps,result ,descriptor, this )){
94                            oneFailed=true;
95                            result.failed(smh.getLocalString
96                        (getClass().getName() + ".failed1",
97                         "FAILED [AS-WEB session-manager] manager-properties - Atleast one name/value pair is not valid in [ {0} ].",
98                         new Object JavaDoc[] {descriptor.getName()}));
99                          }
100             }
101
102
103         } else {
104             notApp = true;
105         }
106             //System.out.println("There are no resource references defined within the ias-web archive");
107
if(notApp) {
108             result.notApplicable(smh.getLocalString
109                  (getClass().getName() + ".notApplicable",
110                   "NOT APPLICABLE [AS-WEB session-config] session-manager element not defined in the web archive [ {0} ].",
111                   new Object JavaDoc[] {descriptor.getName()}));
112
113         }
114
115         if (oneFailed) {
116             result.setStatus(Result.FAILED);
117         } else if(notApp) {
118             result.setStatus(Result.NOT_APPLICABLE);
119         }else {
120             result.setStatus(Result.PASSED);
121             result.passed
122             (smh.getLocalString
123                     (getClass().getName() + ".passed",
124                     "PASSED [AS-WEB session-config] session manager element(s) and their manager-properties and/or store-properties are valid within the web archive [ {0} ].",
125                     new Object JavaDoc[] {descriptor.getName()} ));
126         }
127     return result;
128     }
129
130     public SessionConfig getSessionConfig(WebBundleDescriptor descriptor) {
131         return descriptor.getIasWebApp().getSessionConfig();
132
133
134     }
135 }
136
137
Popular Tags