Package org.crsh.vfs.spi.url

Examples of org.crsh.vfs.spi.url.URLDriver


  public FS mount(Class<?> clazz) throws IOException, URISyntaxException {
    if (clazz == null) {
      throw new NullPointerException();
    }
    URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
    URLDriver driver = new URLDriver();
    driver.merge(url);
    return mount(driver);
  }
View Full Code Here


    archive.addClass(FSTestCase.class);
    ZipExporter exporter = archive.as(ZipExporter.class);
    exporter.exportTo(file, true);

    //
    URLDriver driver = new URLDriver();
    driver.merge(file.toURI().toURL());
    Node root = driver.root();
    assertEquals("", driver.name(root));
    assertTrue(driver.isDir(root));

    //
    Iterator<Node> rootChildren = driver.children(root).iterator();
    Node org = rootChildren.next();
    assertFalse(rootChildren.hasNext());
    assertEquals("org", driver.name(org));
    assertTrue(driver.isDir(org));

    //
    Iterator<Node> orgChildren = driver.children(org).iterator();
    Node crsh = orgChildren.next();
    assertFalse(orgChildren.hasNext());
    assertEquals("crsh", driver.name(crsh));
    assertTrue(driver.isDir(crsh));

    //
    Iterator<Node> vfsChildren = driver.children(crsh).iterator();
    Node vfs = vfsChildren.next();
    assertFalse(vfsChildren.hasNext());
    assertEquals("vfs", driver.name(vfs));
    assertTrue(driver.isDir(vfs));

    //
    Iterator<Node> clazzChildren = driver.children(vfs).iterator();
    Node clazz = clazzChildren.next();
    assertFalse(clazzChildren.hasNext());
    assertEquals(FSTestCase.class.getSimpleName() + ".class", driver.name(clazz));
    assertFalse(driver.isDir(clazz));
    Iterator<InputStream> in = driver.open(clazz);
    assertTrue(in.hasNext());
    in.next().close();
    assertFalse(in.hasNext());
  }
View Full Code Here

  }

  public void testNestedJar() throws Exception {

    //
    URLDriver driver = new URLDriver();
    driver.merge(new URL("jar:" + warFile.toURI().toURL() + "!/WEB-INF/"));
    Node root = driver.root();
    Node lib = driver.child(root, "lib");
    Node foo_jar = driver.child(lib, "foo.jar");
    assertNotNull(foo_jar);
    Iterator<InputStream> in = driver.open(foo_jar);
    assertNotNull(in);
    assertTrue(in.hasNext());
    byte[] bytes = Utils.readAsBytes(in.next());
    assertFalse(in.hasNext());

    //
    URL url = new URL("jar:jar:" + warFile.toURI().toURL() + "!/WEB-INF/lib/foo.jar!/org/crsh/");
    driver = new URLDriver();
    driver.merge(url);
    root = driver.root();
    Node vfs = driver.child(root, "vfs");
    Node FSTestCase_class = driver.child(vfs, "FSTestCase.class");
    assertNotNull(FSTestCase_class);
    in = driver.open(FSTestCase_class);
    assertNotNull(in);
    assertTrue(in.hasNext());
    bytes = Utils.readAsBytes(in.next());
    assertFalse(in.hasNext());
  }
View Full Code Here

    assertFalse(in.hasNext());
  }

  public void testBar() throws Exception {

    URLDriver driver = new URLDriver();
    driver.merge(new URL("jar:" + warFile.toURI().toURL() + "!/WEB-INF/lib/foo.jar!/META-INF/crsh/"));


  }
View Full Code Here

    java.io.File file = java.io.File.createTempFile("test", ".jar");
    file.deleteOnExit();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class);
    jar.addClass(FSTestCase.class);
    jar.as(ZipExporter.class).exportTo(file, true);
    URLDriver driver = new URLDriver();
    driver.merge(file.toURI().toURL());
    driver.merge(file.toURI().toURL());
    Node node = driver.child(driver.child(driver.child(driver.child(driver.root(), "org"), "crsh"), "vfs"), "FSTestCase.class");
    Iterator<InputStream> i = driver.open(node);
    assertTrue(i.hasNext());
    i.next();
    assertTrue(i.hasNext());
    i.next();
    assertFalse(i.hasNext());
View Full Code Here

  /** . */
  final URLDriver driver;

  public ClasspathResolver(ClassLoader loader) {

    URLDriver driver = null;
    try {
      driver = new URLDriver();
      driver.merge(loader);
    }
    catch (Exception e) {
      e.printStackTrace();
    }

View Full Code Here

TOP

Related Classes of org.crsh.vfs.spi.url.URLDriver

Copyright © 2018 www.massapicom. 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.