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/11/13 21:09:38 UTC
svn commit: r1034859 -
/myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java
Author: lu4242
Date: Sat Nov 13 20:09:38 2010
New Revision: 1034859
URL: http://svn.apache.org/viewvc?rev=1034859&view=rev
Log:
MFCOMMONS-23 Test for classes on tld and faces-config.xml requires connection to java.sun.com
Modified:
myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java?rev=1034859&r1=1034858&r2=1034859&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/test/java/org/apache/myfaces/commons/test/AbstractTagLibTestCase.java Sat Nov 13 20:09:38 2010
@@ -19,6 +19,7 @@
package org.apache.myfaces.commons.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.beanutils.Prop
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 ...
@@ -209,6 +213,31 @@ public abstract class AbstractTagLibTest
} // 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
{
@@ -216,6 +245,11 @@ public abstract class AbstractTagLibTest
private static DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
+ static
+ {
+ dbf.setNamespaceAware(false);
+ dbf.setValidating(false);
+ }
public static Tld getTld(String name, InputStream stream)
throws Exception
@@ -224,6 +258,7 @@ public abstract class AbstractTagLibTest
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);
@@ -260,4 +295,4 @@ public abstract class AbstractTagLibTest
}
}
}
-}
\ No newline at end of file
+}