KickJava   Java API By Example, From Geeks To Geeks.

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


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 ASCookieProperty 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         
51         try{
52             SessionConfig sessionConfig = (descriptor.getSunDescriptor()).getSessionConfig();
53             CookieProperties cookieProp=null;
54             WebProperty[] cookieWebProps=null;
55             if(sessionConfig !=null){
56                 cookieProp = sessionConfig.getCookieProperties();
57                 if (cookieProp!=null)
58                     cookieWebProps=cookieProp.getWebProperty();
59             }
60             if (sessionConfig!=null && cookieProp !=null && cookieWebProps!=null && cookieWebProps.length !=0 ){
61                 if(ASWebProperty.checkWebProperties(cookieWebProps,result ,descriptor, this )){
62                     oneFailed=true;
63                     addErrorDetails(result, compName);
64                     result.failed(smh.getLocalString
65                                 (getClass().getName() + ".failed",
66                                 "FAILED [AS-WEB session-config] cookie-properties : Atleast one name/value pair is not valid in [ {0} ].",
67                                 new Object JavaDoc[] {descriptor.getName()}));
68                 }
69
70             }else{
71                 notApp = true;
72             }
73             if(notApp){
74                 addNaDetails(result, compName);
75                 result.notApplicable(smh.getLocalString
76                  (getClass().getName() + ".notApplicable",
77                   "NOT APPLICABLE [AS-WEB session-config] cookie-properties element not defined for {0}.",
78                   new Object JavaDoc[] {descriptor.getName()}));
79             }
80             if (oneFailed){
81                 result.setStatus(Result.FAILED);
82             }else if(notApp){
83                 result.setStatus(Result.NOT_APPLICABLE);
84             }else {
85                 result.setStatus(Result.PASSED);
86                 addGoodDetails(result, compName);
87                 result.passed
88             (smh.getLocalString
89                     (getClass().getName() + ".passed",
90                     "PASSED [AS-WEB session-config] cookie-properties are valid within the web archive [ {0} ].",
91                     new Object JavaDoc[] {descriptor.getName()} ));
92             }
93         }catch(Exception JavaDoc ex){
94             oneFailed = true;
95             addErrorDetails(result, compName);
96             result.failed(smh.getLocalString
97                 (getClass().getName() + ".failed1",
98                     "FAILED [AS-WEB session-config] could not create the session-config object"));
99         
100         }
101     return result;
102     }
103    
104 }
105
106
Popular Tags