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 2009/06/16 01:19:55 UTC
svn commit: r785023 - in /myfaces/tomahawk/trunk:
core/src/test/java/org/apache/myfaces/test/
core/src/test/resources/META-INF/ core/src/test/resources/META-INF/dtd/
sandbox/core/src/test/java/org/apache/myfaces/test/
sandbox/core/src/test/resources/ME...
Author: lu4242
Date: Mon Jun 15 23:19:55 2009
New Revision: 785023
URL: http://svn.apache.org/viewvc?rev=785023&view=rev
Log:
allow tests run offline
Added:
myfaces/tomahawk/trunk/core/src/test/resources/META-INF/
myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/
myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd (with props)
myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/
myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/
myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd (with props)
Modified:
myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java
myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java?rev=785023&r1=785022&r2=785023&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java Mon Jun 15 23:19:55 2009
@@ -19,6 +19,7 @@
package org.apache.myfaces.test;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
@@ -26,12 +27,17 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
/**
* This test makes sure all of our components, tags, renderers,
* validators, converters, action listeners, phase listeners and
@@ -51,7 +57,36 @@
protected List resource = new ArrayList();
private List className = new ArrayList();
+
+ public class DelegateEntityResolver extends ClassElementHandler
+ {
+ public DelegateEntityResolver()
+ {
+ super();
+ }
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "META-INF/dtd/web-jsptaglibrary_1_2.dtd"));
+ }
+ else if (publicId.equals("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "org/apache/myfaces/resource/web-facesconfig_1_1.dtd"));
+ }
+ else
+ {
+ return super.resolveEntity(publicId, systemId);
+ }
+ }
+ }
+
protected void setUp() throws Exception
{
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -59,7 +94,7 @@
factory.setNamespaceAware(false);
SAXParser parser = factory.newSAXParser();
- ClassElementHandler handler = new ClassElementHandler();
+ ClassElementHandler handler = new DelegateEntityResolver();
Iterator iterator = resource.iterator();
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java?rev=785023&r1=785022&r2=785023&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java Mon Jun 15 23:19:55 2009
@@ -19,6 +19,7 @@
package org.apache.myfaces.test;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -36,6 +37,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Insures the following ...
@@ -193,12 +197,42 @@
} // end for attributes
}
+
+ private static class DelegateEntityResolver implements EntityResolver
+ {
+ private EntityResolver _delegate;
+
+ public DelegateEntityResolver(EntityResolver delegate)
+ {
+ this._delegate = delegate;
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "META-INF/dtd/web-jsptaglibrary_1_2.dtd"));
+ }
+ else
+ {
+ return _delegate.resolveEntity(publicId, systemId);
+ }
+ }
+ }
private static class TldTestUtils {
private static Log log = LogFactory.getLog(TldTestUtils.class);
private static DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
+ static
+ {
+ dbf.setNamespaceAware(false);
+ dbf.setValidating(false);
+ }
public static Tld getTld(String name, InputStream stream)
throws Exception {
@@ -206,6 +240,7 @@
log.error(" input stream is null ");
DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setEntityResolver(new DelegateEntityResolver(null));
Document doc = db.parse(stream);
return TldParser.parse(doc, name);
Added: myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd?rev=785023&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd (added)
+++ myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd Mon Jun 15 23:19:55 2009
@@ -0,0 +1,79 @@
+<!--
+ * 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.
+-->
+<!--
+ ** This DTD contains only the programatic elements required for testing
+ ** For the DTD from Sun that includes documentation and other copyrighted information
+ ** please refer to the latest XSD at :
+ ** http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd
+-->
+<!ELEMENT taglib (tlib-version, jsp-version, short-name, uri?,
+display-name?, small-icon?, large-icon?, description?,
+validator?, listener*, tag+) >
+<!ATTLIST taglib id ID #IMPLIED xmlns CDATA #FIXED "http://java.sun.com/JSP/TagLibraryDescriptor">
+<!ELEMENT tlib-version (#PCDATA) >
+<!ELEMENT jsp-version (#PCDATA) >
+<!ELEMENT short-name (#PCDATA) >
+<!ELEMENT uri (#PCDATA) >
+<!ELEMENT description (#PCDATA) >
+<!ELEMENT validator (validator-class, init-param*, description?) >
+<!ELEMENT validator-class (#PCDATA) >
+<!ELEMENT init-param (param-name, param-value, description?)>
+<!ELEMENT param-name (#PCDATA)>
+<!ELEMENT param-value (#PCDATA)>
+<!ELEMENT listener (listener-class) >
+<!ELEMENT listener-class (#PCDATA) >
+<!ELEMENT tag (name, tag-class, tei-class?, body-content?, display-name?,
+small-icon?, large-icon?, description?, variable*, attribute*,
+example?) >
+<!ELEMENT tag-class (#PCDATA) >
+<!ELEMENT tei-class (#PCDATA) >
+<!ELEMENT body-content (#PCDATA) >
+<!ELEMENT display-name (#PCDATA) >
+<!ELEMENT large-icon (#PCDATA) >
+<!ELEMENT small-icon (#PCDATA) >
+<!ELEMENT example (#PCDATA) >
+<!ELEMENT variable ( (name-given | name-from-attribute), variable-class?, declare?, scope?, description?) >
+<!ELEMENT name-given (#PCDATA) >
+<!ELEMENT name-from-attribute (#PCDATA) >
+<!ELEMENT variable-class (#PCDATA) >
+<!ELEMENT declare (#PCDATA) >
+<!ELEMENT scope (#PCDATA) >
+<!ELEMENT attribute (name, required? , rtexprvalue?, type?, description?) >
+<!ELEMENT name (#PCDATA) >
+<!ELEMENT required (#PCDATA) >
+<!ELEMENT rtexprvalue (#PCDATA) >
+<!ELEMENT type (#PCDATA) >
+<!ATTLIST tlib-version id ID #IMPLIED>
+<!ATTLIST jsp-version id ID #IMPLIED>
+<!ATTLIST short-name id ID #IMPLIED>
+<!ATTLIST uri id ID #IMPLIED>
+<!ATTLIST description id ID #IMPLIED>
+<!ATTLIST example id ID #IMPLIED>
+<!ATTLIST tag id ID #IMPLIED>
+<!ATTLIST tag-class id ID #IMPLIED>
+<!ATTLIST tei-class id ID #IMPLIED>
+<!ATTLIST body-content id ID #IMPLIED>
+<!ATTLIST attribute id ID #IMPLIED>
+<!ATTLIST name id ID #IMPLIED>
+<!ATTLIST required id ID #IMPLIED>
+<!ATTLIST rtexprvalue id ID #IMPLIED>
+<!ATTLIST param-name id ID #IMPLIED>
+<!ATTLIST param-value id ID #IMPLIED>
+<!ATTLIST listener id ID #IMPLIED>
+<!ATTLIST listener-class id ID #IMPLIED>
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java?rev=785023&r1=785022&r2=785023&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractClassElementTestCase.java Mon Jun 15 23:19:55 2009
@@ -19,6 +19,7 @@
package org.apache.myfaces.test;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
@@ -26,12 +27,17 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared_tomahawk.test.ClassElementHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
/**
* This test makes sure all of our components, tags, renderers,
* validators, converters, action listeners, phase listeners and
@@ -51,7 +57,36 @@
protected List resource = new ArrayList();
private List className = new ArrayList();
+
+ public class DelegateEntityResolver extends ClassElementHandler
+ {
+ public DelegateEntityResolver()
+ {
+ super();
+ }
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "META-INF/dtd/web-jsptaglibrary_1_2.dtd"));
+ }
+ else if (publicId.equals("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "org/apache/myfaces/resource/web-facesconfig_1_1.dtd"));
+ }
+ else
+ {
+ return super.resolveEntity(publicId, systemId);
+ }
+ }
+ }
+
protected void setUp() throws Exception
{
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -59,7 +94,7 @@
factory.setNamespaceAware(false);
SAXParser parser = factory.newSAXParser();
- ClassElementHandler handler = new ClassElementHandler();
+ ClassElementHandler handler = new DelegateEntityResolver();
Iterator iterator = resource.iterator();
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java?rev=785023&r1=785022&r2=785023&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java Mon Jun 15 23:19:55 2009
@@ -19,6 +19,7 @@
package org.apache.myfaces.test;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -36,6 +37,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Insures the following ...
@@ -193,12 +197,42 @@
} // end for attributes
}
+
+ private static class DelegateEntityResolver implements EntityResolver
+ {
+ private EntityResolver _delegate;
+
+ public DelegateEntityResolver(EntityResolver delegate)
+ {
+ this._delegate = delegate;
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"))
+ {
+ return new InputSource(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(
+ "META-INF/dtd/web-jsptaglibrary_1_2.dtd"));
+ }
+ else
+ {
+ return _delegate.resolveEntity(publicId, systemId);
+ }
+ }
+ }
private static class TldTestUtils {
private static Log log = LogFactory.getLog(TldTestUtils.class);
private static DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
+ static
+ {
+ dbf.setNamespaceAware(false);
+ dbf.setValidating(false);
+ }
public static Tld getTld(String name, InputStream stream)
throws Exception {
@@ -206,6 +240,7 @@
log.error(" input stream is null ");
DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setEntityResolver(new DelegateEntityResolver(null));
Document doc = db.parse(stream);
return TldParser.parse(doc, name);
@@ -237,4 +272,4 @@
}
-}
\ No newline at end of file
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd?rev=785023&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd Mon Jun 15 23:19:55 2009
@@ -0,0 +1,79 @@
+<!--
+ * 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.
+-->
+<!--
+ ** This DTD contains only the programatic elements required for testing
+ ** For the DTD from Sun that includes documentation and other copyrighted information
+ ** please refer to the latest XSD at :
+ ** http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd
+-->
+<!ELEMENT taglib (tlib-version, jsp-version, short-name, uri?,
+display-name?, small-icon?, large-icon?, description?,
+validator?, listener*, tag+) >
+<!ATTLIST taglib id ID #IMPLIED xmlns CDATA #FIXED "http://java.sun.com/JSP/TagLibraryDescriptor">
+<!ELEMENT tlib-version (#PCDATA) >
+<!ELEMENT jsp-version (#PCDATA) >
+<!ELEMENT short-name (#PCDATA) >
+<!ELEMENT uri (#PCDATA) >
+<!ELEMENT description (#PCDATA) >
+<!ELEMENT validator (validator-class, init-param*, description?) >
+<!ELEMENT validator-class (#PCDATA) >
+<!ELEMENT init-param (param-name, param-value, description?)>
+<!ELEMENT param-name (#PCDATA)>
+<!ELEMENT param-value (#PCDATA)>
+<!ELEMENT listener (listener-class) >
+<!ELEMENT listener-class (#PCDATA) >
+<!ELEMENT tag (name, tag-class, tei-class?, body-content?, display-name?,
+small-icon?, large-icon?, description?, variable*, attribute*,
+example?) >
+<!ELEMENT tag-class (#PCDATA) >
+<!ELEMENT tei-class (#PCDATA) >
+<!ELEMENT body-content (#PCDATA) >
+<!ELEMENT display-name (#PCDATA) >
+<!ELEMENT large-icon (#PCDATA) >
+<!ELEMENT small-icon (#PCDATA) >
+<!ELEMENT example (#PCDATA) >
+<!ELEMENT variable ( (name-given | name-from-attribute), variable-class?, declare?, scope?, description?) >
+<!ELEMENT name-given (#PCDATA) >
+<!ELEMENT name-from-attribute (#PCDATA) >
+<!ELEMENT variable-class (#PCDATA) >
+<!ELEMENT declare (#PCDATA) >
+<!ELEMENT scope (#PCDATA) >
+<!ELEMENT attribute (name, required? , rtexprvalue?, type?, description?) >
+<!ELEMENT name (#PCDATA) >
+<!ELEMENT required (#PCDATA) >
+<!ELEMENT rtexprvalue (#PCDATA) >
+<!ELEMENT type (#PCDATA) >
+<!ATTLIST tlib-version id ID #IMPLIED>
+<!ATTLIST jsp-version id ID #IMPLIED>
+<!ATTLIST short-name id ID #IMPLIED>
+<!ATTLIST uri id ID #IMPLIED>
+<!ATTLIST description id ID #IMPLIED>
+<!ATTLIST example id ID #IMPLIED>
+<!ATTLIST tag id ID #IMPLIED>
+<!ATTLIST tag-class id ID #IMPLIED>
+<!ATTLIST tei-class id ID #IMPLIED>
+<!ATTLIST body-content id ID #IMPLIED>
+<!ATTLIST attribute id ID #IMPLIED>
+<!ATTLIST name id ID #IMPLIED>
+<!ATTLIST required id ID #IMPLIED>
+<!ATTLIST rtexprvalue id ID #IMPLIED>
+<!ATTLIST param-name id ID #IMPLIED>
+<!ATTLIST param-value id ID #IMPLIED>
+<!ATTLIST listener id ID #IMPLIED>
+<!ATTLIST listener-class id ID #IMPLIED>
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/test/resources/META-INF/dtd/web-jsptaglibrary_1_2.dtd
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL