public void testVFNestedJarSerialization()
throws Exception
{
// this expects to be run with a working dir of the container root
URL rootURL = getResource("/vfs/test");
VFS vfs = VFS.getVFS(rootURL);
VirtualFile inner = vfs.findChild("outer.jar/jar1.jar");
File vfsSer = File.createTempFile("testVFNestedJarSerialization", ".ser");
vfsSer.deleteOnExit();
// Write out the vfs inner jar file
FileOutputStream fos = new FileOutputStream(vfsSer);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(inner);
oos.close();
// Read in the VF from the serialized file
FileInputStream fis = new FileInputStream(vfsSer);
ObjectInputStream ois = new ObjectInputStream(fis);
inner = (VirtualFile) ois.readObject();
ois.close();
List<VirtualFile> contents = inner.getChildren();
// META-INF/*, org/jboss/test/vfs/support/jar1/* at least
assertTrue("jar1.jar children.length("+contents.size()+") >= 2", contents.size() >= 2);
for(VirtualFile vf : contents)
{
log.info(" "+vf.getName());
}
VirtualFile vf = vfs.findChild("outer.jar/jar1.jar");
VirtualFile jar1MF = vf.findChild("META-INF/MANIFEST.MF");
InputStream mfIS = jar1MF.openStream();
Manifest mf = new Manifest(mfIS);
Attributes mainAttrs = mf.getMainAttributes();
String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);