Examples of Vfs


Examples of org.jboss.virtual.VFS

   public void testInnerJarUsingURLStream()
      throws Exception
   {
      URL rootURL = getResource("/vfs/test");
      VFS vfs = VFS.getVFS(rootURL);
      VirtualFile inner = vfs.findChild("outer.jar/jar1.jar");
      log.info("IsFile: "+inner.isLeaf());
      log.info(inner.getLastModified());
      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.toURL().openStream();
      Manifest mf = new Manifest(mfIS);
      Attributes mainAttrs = mf.getMainAttributes();
      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
View Full Code Here

Examples of org.jboss.virtual.VFS

    */
   public void testClassScan()
      throws Exception
   {
      URL rootURL = getResource("/vfs/test/outer.jar");
      VFS vfs = VFS.getVFS(rootURL);

      HashSet<String> expectedClasses = new HashSet<String>();
      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class");
      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
      expectedClasses.add("jar2.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class");
      expectedClasses.add("org/jboss/test/vfs/support/CommonClass.class");
      super.enableTrace("org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter");
      SuffixMatchFilter classVisitor = new SuffixMatchFilter(".class", VisitorAttributes.RECURSE);
      List<VirtualFile> classes = vfs.getChildren(classVisitor);
      int count = 0;
      for (VirtualFile cf : classes)
      {
         String path = cf.getPathName();
         if( path.endsWith(".class") )
View Full Code Here

Examples of org.jboss.virtual.VFS

   public void testClassScanUnpacked()
      throws Exception
   {
      super.enableTrace("org.jboss");
      URL rootURL = getResource("/vfs/test/unpacked-outer.jar");
      VFS vfs = VFS.getVFS(rootURL);
  
      HashSet<String> expectedClasses = new HashSet<String>();
      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class");
      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
      expectedClasses.add("jar2.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class");
      expectedClasses.add("org/jboss/test/vfs/support/CommonClass.class");
      super.enableTrace("org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter");
      SuffixMatchFilter classVisitor = new SuffixMatchFilter(".class", VisitorAttributes.RECURSE);
      List<VirtualFile> classes = vfs.getChildren(classVisitor);
      int count = 0;
      for (VirtualFile cf : classes)
      {
         String path = cf.getPathName();
         if( path.endsWith(".class") )
View Full Code Here

Examples of org.jboss.virtual.VFS

    */
   public void testClassScanFilesonly()
      throws Exception
   {
      URL rootURL = getResource("/vfs/test/jar1-filesonly.jar");
      VFS vfs = VFS.getVFS(rootURL);
  
      HashSet<String> expectedClasses = new HashSet<String>();
      expectedClasses.add("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
      expectedClasses.add("org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
      super.enableTrace("org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter");
      SuffixMatchFilter classVisitor = new SuffixMatchFilter(".class", VisitorAttributes.RECURSE);
      List<VirtualFile> classes = vfs.getChildren(classVisitor);
      int count = 0;
      for (VirtualFile cf : classes)
      {
         String path = cf.getPathName();
         if( path.endsWith(".class") )
         {
            assertTrue(path, expectedClasses.contains(path));
            count ++;
         }
      }
      assertEquals("There were 2 classes", 2, count);

      // Make sure we can walk path-wise to the class
      VirtualFile jar1 = vfs.getRoot();
      VirtualFile parent = jar1;
      String className = "org/jboss/test/vfs/support/jar1/ClassInJar1.class";
      VirtualFile ClassInJar1 = vfs.findChild(className);
      String[] paths = className.split("/");
      StringBuilder vfsPath = new StringBuilder();
      for(String path : paths)
      {
         vfsPath.append(path);
View Full Code Here

Examples of org.jboss.virtual.VFS

    */
   public void testFilesOnlyJar()
      throws Exception
   {
      URL rootURL = getResource("/vfs/test");
      VFS vfs = VFS.getVFS(rootURL);

      VirtualFile jar = vfs.findChild("jar1-filesonly.jar");
      VirtualFile metadataLocation = jar.findChild("META-INF");
      assertNotNull(metadataLocation);
      VirtualFile mfFile = metadataLocation.findChild("MANIFEST.MF");
      assertNotNull(mfFile);
      InputStream is = mfFile.openStream();
View Full Code Here

Examples of org.jboss.virtual.VFS

      File tmp = new File(tmpRoot, "vfs.ser");
      tmp.createNewFile();
      tmp.deleteOnExit();
      log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
      URL rootURL = tmpRoot.toURL();
      VFS vfs = VFS.getVFS(rootURL);
      VirtualFile tmpVF = vfs.findChild("vfs.ser");
      FileOutputStream fos = new FileOutputStream(tmp);
      ObjectOutputStream oos = new ObjectOutputStream(fos);
      oos.writeObject(tmpVF);
      oos.close();
View Full Code Here

Examples of org.jboss.virtual.VFS

      jos.write("testVFJarSerialization".getBytes());
      jos.close();
      log.info("+++ testVFJarSerialization, tmp="+tmpJar.getCanonicalPath());

      URI rootURI = tmpRoot.toURI();
      VFS vfs = VFS.getVFS(rootURI);
      File vfsSer = new File(tmpRoot, "vfs.ser");
      vfsSer.createNewFile();
      vfsSer.deleteOnExit();

      VirtualFile tmpVF = vfs.findChild("tst.jar");
      // Validate the vf jar against the tmp file attributes
      long lastModified = tmpJar.lastModified();
      long size = tmpJar.length();
      String name = tmpJar.getName();
      String vfsPath = tmpJar.getPath();
View Full Code Here

Examples of org.jboss.virtual.VFS

   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);
View Full Code Here

Examples of org.jboss.virtual.VFS

      // Root the vfs at the link file parent directory
      URL linkURL = super.getResource("/vfs/links/war1.vfslink.properties");
      File linkFile = new File(linkURL.toURI());
      File vfsRoot = linkFile.getParentFile();
      assertNotNull("vfs/links/war1.vfslink.properties", linkURL);
      VFS vfs = VFS.getVFS(vfsRoot.toURI());

      // We should find the test-link.war the link represents
      VirtualFile war = vfs.findChild("test-link.war");
      assertNotNull("war", war);

      // Validate the WEB-INF/classes child link
      VirtualFile classes = war.findChild("WEB-INF/classes");
      String classesName = classes.getName();
View Full Code Here

Examples of org.jboss.virtual.VFS

    * @throws Exception
    */
   public void testDirURLs() throws Exception
   {
      URL rootURL = getResource("/vfs/test");
      VFS vfs = VFS.getVFS(rootURL);

      VirtualFile outerJar = vfs.findChild("unpacked-outer.jar");
      URL outerURL = outerJar.toURL();
      log.debug("outerURL: "+outerURL);
      assertTrue(outerURL+" ends in '/'", outerURL.getPath().endsWith("/"));
      // Validate that jar1 is under unpacked-outer.jar
      URL jar1URL = new URL(outerURL, "jar1.jar");
      log.debug("jar1URL: "+jar1URL+", path="+jar1URL.getPath());
      assertTrue("jar1URL path ends in unpacked-outer.jar/jar1.jar!/",
            jar1URL.getPath().endsWith("unpacked-outer.jar/jar1.jar"));
      VirtualFile jar1 = outerJar.findChild("jar1.jar");
      assertEquals(jar1URL, jar1.toURL());

      VirtualFile packedJar = vfs.findChild("jar1.jar");
      jar1URL = packedJar.findChild("org/jboss/test/vfs/support").toURL();
      assertTrue("Jar directory entry URLs must end in /: " + jar1URL.toString(), jar1URL.toString().endsWith("/"));
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.