KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > ias > 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.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 ASCookieProperty 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         CookieProperties cookieProp=null;
54
55
56         WebProperty[] cookieWebProps=null;
57
58         if(sessionConfig !=null){
59             cookieProp = sessionConfig.getCookieProperties();
60             if (cookieProp!=null)
61                 cookieWebProps=cookieProp.getWebProperty();
62         }
63
64         //System.out.println(">>>>>>>>>>>>checking for res " +webProps);
65
if (sessionConfig!=null && cookieProp !=null && cookieWebProps!=null && cookieWebProps.length !=0 ) {
66
67             if(ASWebProperty.checkWebProperties(cookieWebProps,result ,descriptor, this )){
68                   oneFailed=true;
69                   result.failed(smh.getLocalString
70                                 (getClass().getName() + ".failed",
71                                 "FAILED [AS-WEB session-config] cookie-properties : Atleast one name/value pair is not valid in [ {0} ].",
72                                 new Object JavaDoc[] {descriptor.getName()}));
73             }
74
75         } else {
76             notApp = true;
77         }
78             //System.out.println("There are no resource references defined within the ias-web archive");
79
if(notApp) {
80         result.notApplicable(smh.getLocalString
81                  (getClass().getName() + ".notApplicable",
82                   "NOT APPLICABLE [AS-WEB session-config] cookie-properties element not defined for {0}.",
83                   new Object JavaDoc[] {descriptor.getName()}));
84         }
85
86         if (oneFailed) {
87             result.setStatus(Result.FAILED);
88         } else if(notApp) {
89             result.setStatus(Result.NOT_APPLICABLE);
90         }else {
91             result.setStatus(Result.PASSED);
92             result.passed
93             (smh.getLocalString
94                     (getClass().getName() + ".passed",
95                     "PASSED [AS-WEB session-config] cookie-properties are valid within the web archive [ {0} ].",
96                     new Object JavaDoc[] {descriptor.getName()} ));
97         }
98     return result;
99     }
100
101     public SessionConfig getSessionConfig(WebBundleDescriptor descriptor) {
102         return descriptor.getIasWebApp().getSessionConfig();
103
104
105     }
106 }
107
108
Popular Tags