1 Reply Latest reply on Jun 21, 2008 1:08 PM by Scott Stark

    VirtualFileAdaptor behavior seems incorrect

    Scott Stark Master

      The current problem with the cts test serialization has to due with the behavior of the VirtualFileAdaptor. A VirtualFileAdaptor is created with a VirtualFile whose underlying handler is a ZipEntryHandler is created that has a path interop_W2JREMarshallTest_appclient_vehicle_client.jar, and a uri of vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR1/server/cts/tmp/jsr88/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar:

      ZipEntryHandler@2656127[path=interop_W2JREMarshallTest_appclient_vehicle_client.jar context=vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR1/server/cts/tmp/jsr88/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar real=vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR1/server/cts/tmp/jsr88/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar]

      When the VirtualFileAdaptor that wraps the associated VirtualFile, ends up writing out the path and rootURL as interop_W2JREMarshallTest_appclient_vehicle_client.jar and vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR1/server/cts/tmp/jsr88/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar.

       private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException
       {
       URL url = rootUrl;
       if (url == null)
       {
       VFS vfs = getFile().getVFS();
       url = vfs.getRoot().toURL();
       }
       String pathName = path;
       if (pathName == null)
       pathName = getFile().getPathName();
      
       ObjectOutputStream.PutField fields = out.putFields();
       fields.put("rootUrl", url);
       fields.put("path", pathName);
       out.writeFields();
       }
      


      This will not work when deserialized with the VirtualFileAdaptor.getFile() implementation. The only way this could work is if the following code used to return the root URL of the ear previously:

       VFS vfs = getFile().getVFS();
       url = vfs.getRoot().toURL();
      



        • 1. Re: VirtualFileAdaptor behavior seems incorrect
          Scott Stark Master

          I see Ales added a test that did not show the problem. I went through the server code to see exactly how the VirtualFile being passed to the ws VirtualFileAdaptor was being created. The issue is that a VirtualFile with a DelegatingHandler pointing to the client jar is asked for itself using getChild(""), and its this VirtualFile that is passed to the VirtualFileAdaptor. It is this file that is failing.

           public void testVirtualFileAdaptorEarInnerJar() throws Exception
           {
           URL rootURL = getResource("/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear");
           VFS vfs = VFS.getVFS(rootURL);
           VirtualFile file = vfs.getChild("interop_W2JREMarshallTest_appclient_vehicle_client.jar");
           assertNotNull(file);
           VirtualFile file2 = file.getChild("");
           assertNotNull(file2);
           VirtualFileAdaptor adaptor = new VirtualFileAdaptor(file2);
           // serialize
           adaptor = serializeDeserialize(adaptor, VirtualFileAdaptor.class);
           VirtualFileAdaptor child = adaptor.findChild("MarshallTest.xml");
           assertNotNull(child);
           }
          


          java.io.IOException: Child not found interop_W2JREMarshallTest_appclient_vehicle_client.jar for ZipEntryHandler@15675922[path= context=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar real=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar], available children: [ZipEntryHandler@12612903[path=META-INF context=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar real=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar/META-INF], ZipEntryHandler@4945063[path=MarshallTest.xml context=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar real=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar/MarshallTest.xml], ZipEntryHandler@14126576[path=com context=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar real=vfszip:/Users/svn/JBossAS/projects/vfs/trunk/target/test-classes/vfs/test/interop_W2JREMarshallTest_appclient_vehicle.ear/interop_W2JREMarshallTest_appclient_vehicle_client.jar/com]]
           at org.jboss.virtual.VirtualFile.findChild(VirtualFile.java:409)
           at org.jboss.test.virtual.support.VirtualFileAdaptor.getFile(VirtualFileAdaptor.java:83)
           at org.jboss.test.virtual.support.VirtualFileAdaptor.findChild(VirtualFileAdaptor.java:91)
           at org.jboss.test.virtual.test.JARSerializationUnitTestCase.testVirtualFileAdaptorEarInnerJar(JARSerializationUnitTestCase.java:264)
          


          See http://jira.jboss.com/jira/browse/JBVFS-36.

          The current testVirtualFileAdaptorEarInnerJar should have other tests that validate basic navigation assertations as serialization really is not the issue here.