You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/04/07 03:43:27 UTC

svn commit: r931402 [3/3] - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/view/facelets/compiler/ main/resources/META-INF/ main/resources/org/apache/myfaces/resource/ test/java/org/apache/myfaces/vie...

Added: myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/xml.xsd
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/xml.xsd?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/xml.xsd (added)
+++ myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/xml.xsd Wed Apr  7 01:43:27 2010
@@ -0,0 +1,97 @@
+<?xml version='1.0'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
+<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
+
+ <xs:annotation>
+  <xs:documentation>
+   See http://www.w3.org/XML/1998/namespace.html and
+   http://www.w3.org/TR/REC-xml for information about this namespace.
+  </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+  <xs:documentation>This schema defines attributes and an attribute group
+        suitable for use by
+        schemas wishing to allow xml:base, xml:lang or xml:space attributes
+        on elements they define.
+
+        To enable this, such a schema must import this schema
+        for the XML namespace, e.g. as follows:
+        &lt;schema . . .>
+         . . .
+         &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+                    schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
+
+        Subsequently, qualified reference to any of the attributes
+        or the group defined below will have the desired effect, e.g.
+
+        &lt;type . . .>
+         . . .
+         &lt;attributeGroup ref="xml:specialAttrs"/>
+ 
+         will define a type which will schema-validate an instance
+         element with any of those attributes</xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+  <xs:documentation>In keeping with the XML Schema WG's standard versioning
+   policy, this schema document will persist at
+   http://www.w3.org/2001/03/xml.xsd.
+   At the date of issue it can also be found at
+   http://www.w3.org/2001/xml.xsd.
+   The schema document at that URI may however change in the future,
+   in order to remain compatible with the latest version of XML Schema
+   itself.  In other words, if the XML Schema namespace changes, the version
+   of this document at
+   http://www.w3.org/2001/xml.xsd will change
+   accordingly; the version at
+   http://www.w3.org/2001/03/xml.xsd will not change.
+  </xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="lang" type="xs:language">
+  <xs:annotation>
+   <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
+         codes as the enumerated possible values . . .</xs:documentation>
+  </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="space" default="preserve">
+  <xs:simpleType>
+   <xs:restriction base="xs:NCName">
+    <xs:enumeration value="default"/>
+    <xs:enumeration value="preserve"/>
+   </xs:restriction>
+  </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="base" type="xs:anyURI">
+  <xs:annotation>
+   <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
+                     information about this attribute.</xs:documentation>
+  </xs:annotation>
+ </xs:attribute>
+
+ <xs:attributeGroup name="specialAttrs">
+  <xs:attribute ref="xml:base"/>
+  <xs:attribute ref="xml:lang"/>
+  <xs:attribute ref="xml:space"/>
+ </xs:attributeGroup>
+
+</xs:schema>

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java?rev=931402&r1=931401&r2=931402&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java Wed Apr  7 01:43:27 2010
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.view.facelets;
 
+import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -55,21 +56,21 @@ import org.apache.myfaces.shared_impl.ap
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.myfaces.shared_impl.util.StateUtils;
 import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
-import org.apache.myfaces.test.mock.MockFacesContextFactory;
-import org.apache.myfaces.view.facelets.mock.MockHttpServletRequest;
-import org.apache.myfaces.view.facelets.mock.MockHttpServletResponse;
-import org.apache.myfaces.view.facelets.mock.MockResourceHandlerSupport;
-import org.apache.myfaces.view.facelets.mock.MockServletContext;
-import org.apache.myfaces.view.facelets.mock.MockViewDeclarationLanguageFactory;
-import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
 import org.apache.myfaces.test.el.MockExpressionFactory;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
+import org.apache.myfaces.test.mock.MockFacesContextFactory;
 import org.apache.myfaces.test.mock.MockPropertyResolver;
 import org.apache.myfaces.test.mock.MockRenderKit;
+import org.apache.myfaces.test.mock.MockServletContext;
 import org.apache.myfaces.test.mock.MockVariableResolver;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.apache.myfaces.view.facelets.mock.MockHttpServletRequest;
+import org.apache.myfaces.view.facelets.mock.MockHttpServletResponse;
+import org.apache.myfaces.view.facelets.mock.MockResourceHandlerSupport;
+import org.apache.myfaces.view.facelets.mock.MockViewDeclarationLanguageFactory;
+import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
 
 public abstract class FaceletTestCase extends TestCase
 {
@@ -134,7 +135,7 @@ public abstract class FaceletTestCase ex
         super.setUp();
         URI context = this.getContext();
 
-        this.servletContext = new MockServletContext(context);
+        this.servletContext = new MockServletContext();
         this.servletRequest = new MockHttpServletRequest(this.servletContext,
                 context);
         this.servletResponse = new MockHttpServletResponse();
@@ -142,6 +143,8 @@ public abstract class FaceletTestCase ex
         externalContext = new MockExternalContext(servletContext,
                 servletRequest, servletResponse);
 
+        this.servletContext.setDocumentRoot(new File(context));
+
         // Set up JSF API Objects
         FactoryFinder.releaseFactories();
         

Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java Wed Apr  7 01:43:27 2010
@@ -0,0 +1,83 @@
+package org.apache.myfaces.view.facelets.compiler;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.myfaces.shared_impl.config.MyfacesConfig;
+import org.apache.myfaces.view.facelets.FaceletTestCase;
+import org.apache.myfaces.view.facelets.tag.TagLibrary;
+import org.xml.sax.SAXException;
+
+
+public class TagLibraryTestCase extends FaceletTestCase
+{
+    public final static String TAGLIB_SCHEMA_PATH = "/org/apache/myfaces/resource/web-facelettaglibrary_2_0.xsd";
+    
+    private URL _validLibUrl = null;
+    private URL _invalidLibUrl = null;
+    private URL _invalidOldLibUrl = null;
+
+    public void setUp() throws Exception {
+        super.setUp();
+        _validLibUrl = resolveUrl("/testlib.taglib.xml");
+        _invalidLibUrl = resolveUrl("/testlib_invalid.taglib.xml");
+        _invalidOldLibUrl = resolveUrl("/testlib_old_invalid.taglib.xml");        
+
+        // set document root for loading schema file as resource
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        String path = cl.getResource(TAGLIB_SCHEMA_PATH.substring(1)).getPath();
+        File documentRoot = new File(path.substring(0, path.indexOf(TAGLIB_SCHEMA_PATH)));
+        servletContext.setDocumentRoot(documentRoot);
+    }
+
+    public void testLoadValidLibraryWithValidation() throws Exception
+    {
+        servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "true");
+
+        TagLibrary lib = TagLibraryConfig.create(_validLibUrl);
+        assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
+    }
+
+    public void testLoadValidLibraryWithoutValidation() throws Exception
+    {
+        servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "false");
+
+        TagLibrary lib = TagLibraryConfig.create(_validLibUrl);
+        assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
+    }
+    /*
+    public void testLoadInvalidLibraryWithValidation() throws Exception
+    {
+        servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "true");
+
+        try {
+            TagLibraryConfig.create(_invalidLibUrl);
+            fail("IOException expected");
+        } catch (IOException ioe) {
+            assertTrue(ioe.getCause() instanceof SAXException);
+        }
+
+    }
+
+    public void testLoadInvalidLibraryWithoutValidation() throws Exception
+    {
+        servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "false");
+
+        TagLibrary lib = TagLibraryConfig.create(_invalidLibUrl);
+        assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib_invalid"));
+    }
+
+    public void testLoadInvalidOldLibraryWithValidation() throws Exception
+    {
+        servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "true");
+
+        try {
+            TagLibraryConfig.create(_invalidOldLibUrl);
+            fail("IOException expected");
+        } catch (IOException ioe) {
+            assertTrue(ioe.getCause() instanceof SAXException);
+        }
+    }
+    */
+}

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib.taglib.xml?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib.taglib.xml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib.taglib.xml Wed Apr  7 01:43:27 2010
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<facelet-taglib version="2.0"
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">
+
+    <namespace>http://myfaces.apache.org/testlib</namespace>
+
+</facelet-taglib>
\ No newline at end of file

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_invalid.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_invalid.taglib.xml?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_invalid.taglib.xml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_invalid.taglib.xml Wed Apr  7 01:43:27 2010
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<facelet-taglib version="2.0"
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">
+
+    <namespace>http://myfaces.apache.org/testlib_invalid</namespace>
+    <unknown-tag>foo</unknown-tag>
+
+</facelet-taglib>

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_old_invalid.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_old_invalid.taglib.xml?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_old_invalid.taglib.xml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_old_invalid.taglib.xml Wed Apr  7 01:43:27 2010
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE facelet-taglib PUBLIC
+  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
+  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
+
+<facelet-taglib>
+    <namespace>http://myfaces.apache.org/testlib_old_invalid</namespace>
+
+</facelet-taglib>