Examples of AssembledDirectory


Examples of org.jboss.virtual.AssembledDirectory

         throw new RuntimeException("Assembled context already exists for name: " + name);

      try
      {
         AssembledContext context = new AssembledContext(name, rootName);
         AssembledDirectory directory = context.getRoot().getVirtualFile();
         registry.put(name, directory);
         return directory;
      }
      catch (IOException e)
      {
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

   @Override
   public AssembledDirectory getVirtualFile()
   {
      checkClosed();
      increment();
      return new AssembledDirectory(this);
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      assertFalse(AssembledDirectory.antMatch(file, exp));
   }

   public void testAddClass() throws Exception
   {
      AssembledDirectory directory = AssembledContextFactory.getInstance().create("foo.jar");
      directory.addClass(VirtualFile.class);


      List<VirtualFile> children = directory.getChildren();
      assertEquals(children.size(), 1);
      VirtualFile curr = children.get(0);
      System.out.println("test org/");
      assertEquals("org", curr.getName());
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      System.setProperty("test.classes.url", classesURL.toString());
      URL libURL = super.getResource("/vfs/sundry/jar");
      assertNotNull("libURL", libURL);     
      System.setProperty("test.lib.url", libURL.toString());

      AssembledDirectory directory = AssembledContextFactory.getInstance().create("foo.jar");
      String[] includes = {"org/jboss/virtual/*.class", "org/jboss/virtual/**/context/jar/*.class"};
      String[] excludes = {"**/Nested*"};
      directory.addResources("org/jboss/virtual/VirtualFile.class", includes, excludes, Thread.currentThread().getContextClassLoader());
      List<VirtualFile> children = directory.getChildren();
      assertEquals(children.size(), 1);
      VirtualFile curr = children.get(0);
      System.out.println("test org/");
      assertEquals("org", curr.getName());

      System.out.println("test org/jboss");
      children = curr.getChildren();
      assertEquals(children.size(), 1);
      curr = children.get(0);
      assertEquals("jboss", curr.getName());

      System.out.println("test org/jboss/virtual");
      children = curr.getChildren();
      assertEquals(children.size(), 1);
      curr = children.get(0);
      assertEquals("virtual", curr.getName());
      children = curr.getChildren();
      boolean found;
      found = false;
      for (VirtualFile child: children)
      {
         if (child.getName().equals("VFS.class"))
         {
            found = true;
            break;
         }
      }
      assertTrue("VFS.class was found", found);

      found = false;
      for (VirtualFile child: children)
      {
         if (child.getName().equals("VirtualFile.class"))
         {
            found = true;
            assertEquals("org/jboss/virtual/VirtualFile.class", child.getPathName());
            break;
         }
      }
      assertTrue("VirtualFile.class was found", found);

      found = false;
      for (VirtualFile child: children)
      {
         if (child.getName().equals("plugins"))
         {
            found = true;
            break;
         }
      }
      assertTrue("plugins/", found);

      System.out.println("Test org/jboss/virtual/plugins/context/jar");
      VirtualFile jar = directory.getChild("org/jboss/virtual/plugins/context/jar");
      assertNotNull(jar);
      assertEquals("jar", jar.getName());

      children = jar.getChildren();
      for (VirtualFile child: children)
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      AssembledDirectory.removeAssembledDirectory(directory);
   }

   public void testMkDir() throws Exception
   {
      AssembledDirectory directory = AssembledContextFactory.getInstance().create("foo.jar");
      directory.mkdir("META-INF");
      assertNotNull(directory.getChild("META-INF"));
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      assertNotNull(directory.getChild("META-INF"));
   }

   public void testRemoveAndClear() throws Exception
   {
      AssembledDirectory directory = AssembledContextFactory.getInstance().create("foo.jar");
      AssembledDirectory metainf = directory.mkdir("META-INF");
      assertNotNull(directory.getChild("META-INF"));

      VirtualFile resource = metainf.addBytes(new byte[]{1, 2, 3}, "bytes.tmp");
      assertEquals(resource, metainf.getChild("bytes.tmp"));
      metainf.remove("bytes.tmp");
      assertNull(metainf.getChild("bytes.tmp"));

      metainf.addBytes(new byte[]{1, 2, 3}, "bytes1.tmp");
      metainf.addBytes(new byte[]{1, 2, 3}, "bytes2.tmp");
      metainf.clear();
      assertNull(metainf.getChild("bytes1.tmp"));
      assertNull(metainf.getChild("bytes2.tmp"));
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      assertNull(metainf.getChild("bytes2.tmp"));
   }

   public void testAddPath() throws Exception
   {
      AssembledDirectory sar = AssembledContextFactory.getInstance().create("foo.sar");
      URL url = getResource("/vfs/test/jar1.jar");
      VirtualFile jar1 = VFS.getRoot(url);

      sar.addPath(jar1);
      List<VirtualFile> children = sar.getChildrenRecursively();
      assertNotNull(children);
      assertEquals(10, children.size());

      sar.clear();

      sar.addPath(jar1, new VirtualFileFilter()
      {
         public boolean accepts(VirtualFile file)
         {
            return "META-INF".equalsIgnoreCase(file.getName());
         }
      });
      children = sar.getChildrenRecursively();
      assertNotNull(children);
      assertEquals(2, children.size());
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      assertEquals(2, children.size());
   }

   public void testAddChild() throws Exception
   {
      AssembledDirectory sar = AssembledContextFactory.getInstance().create("foo.sar");
      URL url = getResource("/vfs/test/jar1.jar");
      VirtualFile jar1 = VFS.getRoot(url);

      sar.addChild(jar1);
      List<VirtualFile> children = sar.getChildrenRecursively();
      assertNotNull(children);
      assertEquals(11, children.size());

      sar.clear();

      sar.addChild(jar1, "jar2.jar");
      VirtualFile child = sar.getChild("jar2.jar");
      children = child.getChildrenRecursively();
      assertNotNull(children);
      assertEquals(10, children.size());
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

      assertEquals(10, children.size());
   }

   public void testDirectory() throws Exception
   {
      AssembledDirectory sar = AssembledContextFactory.getInstance().create("foo.sar");
      URL url = getResource("/vfs/test/jar1.jar");
      VirtualFile jar1 = VFS.getRoot(url);
      sar.addChild(jar1);

      VirtualFile temp = VFSUtils.temp(sar);
      assertNotNull(temp);
      temp.delete();
   }
View Full Code Here

Examples of org.jboss.virtual.AssembledDirectory

public class Handler extends HostlessHandler
{
   protected URLConnection openConnection(URL url) throws IOException
   {
      String host = url.getHost();
      AssembledDirectory directory = AssembledContextFactory.getInstance().find(host);
      if (directory == null)
         throw new IOException("vfs does not exist: " + url);

      VirtualFile vf = directory.getChild(url.getPath());
      if (vf == null)
         throw new IOException("vfs does not exist: " + url);

      return new VirtualFileURLConnection(url, vf);
   }
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.