View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.config;
21  
22  import java.net.URL;
23  import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
24  import org.junit.Test;
25  import org.xml.sax.SAXException;
26  
27  /**
28   *
29   * @author lu4242
30   */
31  public class ConfigFilesXmlValidationUtilsTestCase extends AbstractJsfTestCase
32  {
33      
34      @Test
35      public void testCurrentStandardJSFFacesConfig() throws Exception
36      {
37          URL url = getClass().getResource("/META-INF/standard-faces-config.xml");
38          ConfigFilesXmlValidationUtils.validateFacesConfigFile(
39              url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url));
40      }
41      
42      @Test
43      public void testJSF11Config1() throws Exception
44      {
45          URL url = getClass().getResource("a-config.xml");
46          ConfigFilesXmlValidationUtils.validateFacesConfigFile(
47              url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url));
48      }    
49      
50      @Test(expected = SAXException.class)
51      public void testJSFInvalidConfig1() throws Exception
52      {
53          URL url = getClass().getResource("invalid-config_1.xml");
54          ConfigFilesXmlValidationUtils.validateFacesConfigFile(
55              url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url));
56      }
57      
58  	/*
59      @Test(expected = SAXException.class)
60      public void testJSFInvalidConfig2() throws Exception
61      {
62          URL url = getClass().getResource("invalid-config_2.xml");
63          ConfigFilesXmlValidationUtils.validateFacesConfigFile(
64              url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url));
65      }*/    
66  }