Hibernate SVN: r20991 - entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7491/src/test/java/org/hibernate/ejb/test/packaging.
by hibernate-commits@lists.jboss.org
Author: alessandrolt
Date: 2011-11-07 13:26:21 -0500 (Mon, 07 Nov 2011)
New Revision: 20991
Modified:
entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7491/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
Log:
JBPAPP-7491 - including testJarVisitorFactory() to JarVisitorTest Test Case. This test asserts the correct return of JarVisitorFactory.getVisitor
Modified: entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7491/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
===================================================================
--- entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7491/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2011-11-07 18:21:16 UTC (rev 20990)
+++ entitymanager/patches/3.4.0.GA_CP04_JBPAPP-7491/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java 2011-11-07 18:26:21 UTC (rev 20991)
@@ -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;
@@ -176,6 +178,37 @@
localEntry.getInputStream().close();
}
}
+
+ public void testJarVisitorFactory() throws Exception{
+
+ //setting URL to accept vfs based protocol
+ URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ return new URLStreamHandler() {
+ protected URLConnection openConnection(URL u)
+ throws IOException {
+ 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);
+ assertEquals(FileZippedJarVisitor.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());
+ }
/**
* @see EJB-230