KickJava   Java API By Example, From Geeks To Geeks.

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


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  * The content of the url-pattern element follows the rules specified in
33  * section 10 of the servlet spec.
34  * In this test, we only check for failure conditions.
35  * In URLPatternWarningCheck class we check for warnings.
36  */

37 public class URLPatternErrorCheck extends URLPattern {
38
39     protected void checkUrlPatternAndSetResult(String JavaDoc urlPattern, Descriptor descriptor, Result result, ComponentNameConstructor compName){
40      if (urlPattern != null &&
41                (urlPattern.startsWith("/") || (urlPattern.startsWith("*.") && urlPattern.length()!=2))){
42         result.passed(smh.getLocalString
43                               ("tests.componentNameConstructor",
44                                "For [ {0} ]",
45                                new Object JavaDoc[] {compName.toString()}));
46         result.addGoodDetails (smh.getLocalString
47                             (getClass().getName() + ".passed",
48                              "url-pattern [ {0} ] within [ {1} ] follows the rules specified in servlet specification",
49                              new Object JavaDoc[] {urlPattern, descriptor.getName()}));
50      } else {
51     oneFailed=true;
52         result.failed(smh.getLocalString
53                        ("tests.componentNameConstructor",
54                     "For [ {0} ]",
55                     new Object JavaDoc[] {compName.toString()}));
56         result.addErrorDetails (smh.getLocalString
57                          (getClass().getName() + ".failed",
58                           "Error: Content of the url-pattern element [ {0} ] does not follow the rules specified in servlet specification within [ {1} ]",
59                           new Object JavaDoc[] {urlPattern, descriptor.getName()}));
60      }
61     }
62 }
63
Popular Tags