KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 /**
32  * url-pattern element must not contain New Line (NL) or Carriage Return (CR)
33  * In the schema j2ee_1_4.xsd it states that
34        The url-patternType contains the url pattern of the mapping.
35         It must follow the rules specified in Section 11.2 of the
36         Servlet API Specification. This pattern is assumed to be in
37         URL-decoded form and must not contain CR(#xD) or LF(#xA).
38         If it contains those characters, the container must inform
39         the developer with a descriptive error message.
40  */

41 //This test won't be exercised now as DOL already has this test (see bug#4903530)
42
//But we should have it so that if any day DOL removes that test, we would catch it.
43
public class URLPatternContainsCRLF extends URLPattern {
44
45     protected void checkUrlPatternAndSetResult(String JavaDoc urlPattern, Descriptor descriptor, Result result, ComponentNameConstructor compName){
46         if (urlPattern == null) return; //some other test takes care of this.
47
// In Ascii table, Line Feed (LF) decimal value is 10 and Carriage Return (CR) decimal value is 13
48
final int LF = 10, CR = 13;
49         if (urlPattern.indexOf(CR)!=-1 || urlPattern.indexOf(LF)!=-1) {
50             oneFailed=true;
51             result.failed(smh.getLocalString
52                                    ("tests.componentNameConstructor",
53                                     "For [ {0} ]",
54                                     new Object JavaDoc[] {compName.toString()}));
55             result.addErrorDetails (smh.getLocalString
56                                          (getClass().getName() + ".failed",
57                                           "url-pattern [ {0} ] within [ {1} ] contains a carriage return or line feed char",
58                                           new Object JavaDoc[] {urlPattern, descriptor.getName()}));
59         } else {
60             result.passed(smh.getLocalString
61                                   ("tests.componentNameConstructor",
62                                    "For [ {0} ]",
63                                    new Object JavaDoc[] {compName.toString()}));
64             result.addGoodDetails (smh.getLocalString
65                                     (getClass().getName() + ".passed",
66                                      "url-pattern [ {0} ] within [ {1} ] does not contain carriage return or line feed char",
67                                      new Object JavaDoc[] {urlPattern, descriptor.getName()}));
68         }
69     }
70 }
71
Popular Tags