KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.tools.verifier.tests.web;
24
25 import com.sun.enterprise.tools.verifier.tests.web.WebTest;
26 import java.util.*;
27 import java.io.*;
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.util.FileClassLoader;
32
33
34 /**
35  * The session-timeout element deinfes the default session timeout interval
36  * for all sessions created in this web application. The units used must
37  * be expressed in whole minutes.
38  */

39 public class SessionTimeout extends WebTest implements WebCheck {
40
41     
42     /**
43      * The session-timeout element deinfes the default session timeout interval
44      * for all sessions created in this web application. The units used must
45      * be expressed in whole minutes.
46      *
47      * @param descriptor the Web deployment descriptor
48      *
49      * @return <code>Result</code> the results for this assertion
50      */

51     public Result check(WebBundleDescriptor descriptor) {
52
53     Result result = getInitializedResult();
54 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
55
56     boolean na = false;
57     boolean foundIt = false;
58     Integer JavaDoc sessionTimeout = new Integer JavaDoc(descriptor.getSessionTimeout());
59     // tomcat doesn't throw exception to DOL if you pass "ten" to xml element,
60
// it initializes session-timeout to -1, hence this check
61
if (sessionTimeout.intValue() == -1 ) {
62         na = true;
63     } else if (sessionTimeout.intValue() >= 0 ) {
64         foundIt = true;
65     } else {
66         foundIt = false;
67     }
68    
69     // always true until DOL lets something other than integer thru...
70
if (na) {
71         result.addNaDetails(smh.getLocalString
72                        ("tests.componentNameConstructor",
73                     "For [ {0} ]",
74                     new Object JavaDoc[] {compName.toString()}));
75         result.notApplicable(smh.getLocalString
76               (getClass().getName() + ".notApplicable",
77                "Not Applicable: Servlet session-timeout [ {0} ] element does not define the default session timeout interval.",
78                new Object JavaDoc[] {sessionTimeout.toString()}));
79     } else if (foundIt) {
80         result.addGoodDetails(smh.getLocalString
81                   ("tests.componentNameConstructor",
82                    "For [ {0} ]",
83                    new Object JavaDoc[] {compName.toString()}));
84         result.passed(smh.getLocalString
85                   (getClass().getName() + ".passed",
86                "Servlet session-timeout [ {0} ] element defines the default session timeout interval expressed in whole minutes.",
87                new Object JavaDoc[] {sessionTimeout.toString()}));
88     } else {
89         result.addErrorDetails(smh.getLocalString
90                        ("tests.componentNameConstructor",
91                     "For [ {0} ]",
92                     new Object JavaDoc[] {compName.toString()}));
93         result.failed(smh.getLocalString
94               (getClass().getName() + ".failed",
95                "Error: Servlet session-timeout [ {0} ] element does not define the default session timeout interval expressed in whole minutes.",
96                new Object JavaDoc[] {sessionTimeout.toString()}));
97     }
98     return result;
99     }
100 }
101
Popular Tags