Author: alessandrolt
Date: 2011-12-23 11:18:10 -0500 (Fri, 23 Dec 2011)
New Revision: 21007
Modified:
entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7819/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
Log:
JBPAPP-7819 - including testJarVisitorFactory() to JarVisitorTest Test Case. This test
asserts the correct return of JarVisitorFactory.getVisitor
Modified:
entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7819/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
===================================================================
---
entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7819/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2011-12-23
16:16:15 UTC (rev 21006)
+++
entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7819/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2011-12-23
16:18:10 UTC (rev 21007)
@@ -4,6 +4,8 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
import java.util.Set;
import javax.persistence.Embeddable;
@@ -56,6 +58,45 @@
assertEquals( 0, visitor.getMatchingEntries()[1].size() );
assertEquals( 0, visitor.getMatchingEntries()[2].size() );
}
+
+ /**
+ * related to JBPAPP-7819
+ */
+ public void testJarVisitorFactory() throws Exception{
+
+ //setting URL to accept vfs based protocol
+ URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if("vfsfile".equals(protocol) || "vfszip".equals(protocol)) {
+ return new URLStreamHandler() {
+ protected URLConnection openConnection(URL u)
+ throws IOException {
+ return null;
+ }
+ };
+ } else
+ return null;
+ }
+ });
+
+ URL jarUrl = new URL ("file:./target/test-packages/defaultpar.par");
+ JarVisitor jarVisitor = JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
+ assertEquals(FileZippedJarVisitor.class.getName(), jarVisitor.getClass().getName());
+
+ jarUrl = new URL ("file:./target/test-packages/explodedpar.par");
+ jarVisitor = JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
+ assertEquals(ExplodedJarVisitor.class.getName(), jarVisitor.getClass().getName());
+
+ jarUrl = new URL ("vfszip:./target/test-packages/defaultpar.par");
+ jarVisitor = JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
+ //ideally it should be FileZippedJarVisitor as well, but there is a bug in
FileZippedJarVisitor
+ //which causes regression for some tests in EAP test suite. InputStreamZippedJarVisitor
is safer than it, for now.
+ assertEquals(InputStreamZippedJarVisitor.class.getName(),
jarVisitor.getClass().getName());
+
+ jarUrl = new URL ("vfsfile:./target/test-packages/explodedpar.par");
+ jarVisitor = JarVisitorFactory.getVisitor(jarUrl, getFilters(), null);
+ assertEquals(ExplodedJarVisitor.class.getName(), jarVisitor.getClass().getName());
+ }
public void testInputStreamZippedJar() throws Exception {
String jarFileName = "file:./target/test-packages/defaultpar.par";