KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > runtime > 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 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 ASSessionManager 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         SessionManager sessionMgr=null;
53
54         StoreProperties stroeProp=null;
55         ManagerProperties mgrProps=null;
56
57         WebProperty[] SPwebProps=null;
58         WebProperty[] MPwebProps=null;
59         if(sessionConfig !=null){
60             sessionMgr = sessionConfig.getSessionManager();
61         }
62         if (sessionConfig!=null && sessionMgr !=null){
63             mgrProps=sessionMgr.getManagerProperties();
64             stroeProp =sessionMgr.getStoreProperties();
65
66             if(stroeProp !=null )
67             SPwebProps=stroeProp.getWebProperty();
68
69             if(mgrProps !=null)
70             MPwebProps=mgrProps.getWebProperty();
71
72             if((SPwebProps ==null|| SPwebProps.length==0) && (MPwebProps ==null || MPwebProps.length==0)){
73                 notApp = true;
74             } else {
75                   if (SPwebProps !=null|| SPwebProps.length>0)
76                        if(ASWebProperty.checkWebProperties(SPwebProps,result ,descriptor, this )){
77                            oneFailed=true;
78                            addErrorDetails(result, compName);
79                            result.failed(smh.getLocalString
80                        (getClass().getName() + ".failed",
81                         "FAILED [AS-WEB session-manager] store-properties - Atleast one name/value pair is not valid in [ {0} ].",
82                         new Object JavaDoc[] {descriptor.getName()}));
83                          }
84
85                   if (MPwebProps !=null || MPwebProps.length>0)
86                         if(ASWebProperty.checkWebProperties(MPwebProps,result ,descriptor, this )){
87                             oneFailed=true;
88                             addErrorDetails(result, compName);
89                             result.failed(smh.getLocalString
90                        (getClass().getName() + ".failed1",
91                         "FAILED [AS-WEB session-manager] manager-properties - Atleast one name/value pair is not valid in [ {0} ].",
92                         new Object JavaDoc[] {descriptor.getName()}));
93                          }
94             }
95
96
97         } else {
98              notApp = true;
99         }
100         if(notApp) {
101             addNaDetails(result, compName);
102             result.notApplicable(smh.getLocalString
103                  (getClass().getName() + ".notApplicable",
104                   "NOT APPLICABLE [AS-WEB session-config] session-manager element not defined in the web archive [ {0} ].",
105                   new Object JavaDoc[] {descriptor.getName()}));
106
107         }
108
109         if (oneFailed) {
110             result.setStatus(Result.FAILED);
111         } else if(notApp) {
112             result.setStatus(Result.NOT_APPLICABLE);
113         }else {
114             result.setStatus(Result.PASSED);
115             addGoodDetails(result, compName);
116             result.passed
117             (smh.getLocalString
118                     (getClass().getName() + ".passed",
119                     "PASSED [AS-WEB session-config] session manager element(s) and their manager-properties and/or store-properties are valid within the web archive [ {0} ].",
120                     new Object JavaDoc[] {descriptor.getName()} ));
121         }
122         }catch(Exception JavaDoc ex){
123         oneFailed = true;
124             addErrorDetails(result, compName);
125             result.failed(smh.getLocalString
126                 (getClass().getName() + ".failed2",
127                     "FAILED [AS-WEB session-config] could not create the session-config object"));
128         
129         }
130         return result;
131     }
132 }
133
134
Popular Tags