[jboss-dev-forums] [Design of POJO Server] - Re: JBAS-6061 or weird nested jar

jaikiran do-not-reply at jboss.com
Tue Jan 20 10:03:41 EST 2009


I added a new test to the existing testcase org.jboss.test.virtual.test.ExceptionHandlerTestCase. Does this look good enough?

Index: src/test/java/org/jboss/test/virtual/test/ExceptionHandlerTestCase.java
  | ===================================================================
  | --- src/test/java/org/jboss/test/virtual/test/ExceptionHandlerTestCase.java	(revision 83104)
  | +++ src/test/java/org/jboss/test/virtual/test/ExceptionHandlerTestCase.java	(working copy)
  | @@ -25,10 +25,12 @@
  |  import java.util.List;
  | 
  |  
  | 
  |  import junit.framework.Test;
  | 
  | +
  | 
  |  import org.jboss.virtual.VFS;
  | 
  |  import org.jboss.virtual.VirtualFile;
  | 
  |  import org.jboss.virtual.plugins.context.helpers.NamesExceptionHandler;
  | 
  |  
  | 
  | +
  | 
  |  /**
  | 
  |   * ExceptionHandlerTestCase.
  | 
  |   *
  | 
  | @@ -57,4 +59,29 @@
  |        List<VirtualFile> children = child.getChildren();
  | 
  |        assertTrue(children.isEmpty());
  | 
  |     }
  | 
  | +
  | 
  | +   /**
  | 
  | +    * Cover the parent folder containing the jar with a {@link ExceptionHandler}
  | 
  | +    * and then try to load the jar (present in the parent folder) to test
  | 
  | +    * whether the exceptionhandler is applied to the child jar as well
  | 
  | +    * 
  | 
  | +    * @throws Exception
  | 
  | +    */
  | 
  | +   public void testExceptionHandlerForJarFiles() throws Exception
  | 
  | +   {
  | 
  | +      // Set a exception handler on parent folder
  | 
  | +      URL parentFolderURL = getResource("/vfs/test");
  | 
  | +      VFS parentFolderVFS = VFS.getVFS(parentFolderURL);
  | 
  | +      // let's add the sqljdbc.jar to the list of names that the exception handler has to handle
  | 
  | +      parentFolderVFS.setExceptionHandler(new NamesExceptionHandler("sqljdbc.jar"));
  | 
  | +
  | 
  | +      // Now let's create a VFS for the child jar
  | 
  | +      URL jarFileURL = getResource("/vfs/test/zipeinit.jar");
  | 
  | +      VFS jarFileVFS = VFS.getVFS(jarFileURL);
  | 
  | +      VirtualFile root = jarFileVFS.getRoot();
  | 
  | +      // time to access the messed up jar file. The NamesExceptionHandler is expected to handle this.
  | 
  | +      VirtualFile child = root.findChild("sqljdbc.jar");
  | 
  | +      List<VirtualFile> children = child.getChildren();
  | 
  | +      assertTrue(children.isEmpty());
  | 
  | +   }
  | 
  |  }
  | 
  | 

This one reproduces the error:

-------------------------------------------------------------------------------
  | Test set: org.jboss.test.virtual.test.ExceptionHandlerTestCase
  | -------------------------------------------------------------------------------
  | Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.132 sec <<< FAILURE!
  | testExceptionHandlerForJarFiles(org.jboss.test.virtual.test.ExceptionHandlerTestCase)  Time elapsed: 0.016 sec  <<< ERROR!
  | java.lang.RuntimeException: Failed to read zip file: org.jboss.virtual.plugins.context.zip.ZipFileWrapper at 1c74f37 - /tmp/vfs-nested.tmp/65e546ff_sqljdbc.jar
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:570)
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:700)
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChildren(ZipEntryContext.java:772)
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChildren(ZipEntryHandler.java:149)
  | 	at org.jboss.virtual.plugins.context.DelegatingHandler.getChildren(DelegatingHandler.java:120)
  | 	at org.jboss.virtual.plugins.context.AbstractVFSContext.getChildren(AbstractVFSContext.java:171)
  | 	at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:288)
  | 	at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:258)
  | 	at org.jboss.virtual.VFS.visit(VFS.java:429)
  | 	at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:423)
  | 	at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:372)
  | 	at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:353)
  | 	at org.jboss.test.virtual.test.ExceptionHandlerTestCase.testExceptionHandlerForJarFiles(ExceptionHandlerTestCase.java:84)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at junit.framework.TestCase.runTest(TestCase.java:154)
  | 	at junit.framework.TestCase.runBare(TestCase.java:127)
  | 	at junit.framework.TestResult$1.protect(TestResult.java:106)
  | 	at junit.framework.TestResult.runProtected(TestResult.java:124)
  | 	at junit.framework.TestResult.run(TestResult.java:109)
  | 	at junit.framework.TestCase.run(TestCase.java:118)
  | 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
  | 	at junit.framework.TestSuite.run(TestSuite.java:203)
  | 	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
  | 	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
  | 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
  | 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:163)
  | 	at org.apache.maven.surefire.Surefire.run(Surefire.java:84)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:261)
  | 	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:875)
  | Caused by: java.util.zip.ZipException: error in opening zip file
  | 	at java.util.zip.ZipFile.open(Native Method)
  | 	at java.util.zip.ZipFile.<init>(ZipFile.java:203)
  | 	at java.util.zip.ZipFile.<init>(ZipFile.java:234)
  | 	at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.ensureZipFile(ZipFileWrapper.java:175)
  | 	at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.acquire(ZipFileWrapper.java:245)
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryContext.initEntries(ZipEntryContext.java:466)
  | 	at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:561)
  | 	... 35 more
  | 

I haven't commited the test since i am not sure what's the policy on commiting (without a fix) failing/error testcases.

P.S: I think there is a typo in this existing testcase:
// Jaikiran: Is this a typo? Or is this intentional? The _sqljdbc.jar should be sqljdbc.jar isn't it?
  | vfs.setExceptionHandler(new NamesExceptionHandler("_sqljdbc.jar"));
  |       VirtualFile root = vfs.getRoot();
  |       VirtualFile zipeinit = root.findChild("zipeinit.jar");
  |       VirtualFile child = zipeinit.findChild("sqljdbc.jar");

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203300#4203300

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203300



More information about the jboss-dev-forums mailing list