Package org.jboss.virtual

Examples of org.jboss.virtual.VirtualFile.openStream()


      // Verify again - through new context
      {
         vf = VFS.getVirtualFile(root.toURI().toURL(), "test.jar");
         VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
         Manifest manifest = new Manifest(manifestFile.openStream());
         String actual = manifest.getMainAttributes().getValue("test");
         assertEquals("VFS found the wrong manifest", "v2", actual);
      }
   }
}
View Full Code Here


      byte[] bytes = new byte[] { 1, 2, 3, 4, 5 };
      MockVFSContext context = registerSimpleVFSContext();
      context.getMockRoot().setStream(bytes);

      VirtualFile file = VFS.getRoot(context.getRootURI());
      InputStream stream = file.openStream();
      byte[] buffer = new byte[bytes.length];
      stream.read(buffer);
     
      assertTrue(stream.read() == -1);
      assertTrue(Arrays.equals(bytes, buffer));
View Full Code Here

      context.getMockRoot().setIOException("openStream");

      VirtualFile file = VFS.getRoot(context.getRootURI());
      try
      {
         file.openStream();
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IOException.class, t);
View Full Code Here

      VirtualFile file = VFS.getRoot(context.getRootURI());
      file.close();
      try
      {
         file.openStream();
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalStateException.class, t);
View Full Code Here

      byte[] bytes = new byte[] { 1, 2, 3, 4, 5 };
      MockVFSContext context = registerSimpleVFSContext();
      context.getMockRoot().setStream(bytes);

      VirtualFile file = VFS.getRoot(context.getRootURI());
      InputStream stream = file.openStream();
      assertEquals(1, stream.read());
     
      file.closeStreams();
      assertEquals(-1, stream.read());
   }
View Full Code Here

      byte[] bytes = new byte[] { 1, 2, 3, 4, 5 };
      MockVFSContext context = registerSimpleVFSContext();
      context.getMockRoot().setStream(bytes);

      VirtualFile file = VFS.getRoot(context.getRootURI());
      InputStream stream = file.openStream();
      assertEquals(1, stream.read());
     
      file.close();
      assertEquals(-1, stream.read());
   }
View Full Code Here

      URL url = getResource("/vfs/test/nested/nested.jar");
      VirtualFile root = VFS.getRoot(url);
      assertNotNull(root);

      VirtualFile child = root.getChild("complex.jar/META-INF/MANIFEST.MF");
      InputStream in = child.openStream();
      in.close();
   }

   public void testJBVFS160() throws Exception
   {
View Full Code Here

      URL url = getResource("/vfs/test/cert_test.jar");
      VirtualFile jar = VFS.getRoot(url);
      VirtualFile clazz = jar.findChild("examplets/plugins/impl/AnotherInjectedPlugin.class");

      InputStream tmp = clazz.openStream();
      VFSUtils.copyStreamAndClose(tmp, new ByteArrayOutputStream()); // dummy read

      Certificate[] certs = clazz.getCertificates();
      assertNotNull("No certificates: " + clazz, certs);
   }
View Full Code Here

      VirtualFile child = findChild(path);
      if (child != null)
      {
         try
         {
            return child.openStream();
         }
         catch (Exception ignored)
         {
            log.debug("Error opening stream for " + child, ignored);
            return null;
View Full Code Here

      File tmpJar = File.createTempFile("testCopyJar", ".jar");
      tmpJar.deleteOnExit();

      try
      {
         InputStream is = jar.openStream();
         FileOutputStream fos = new FileOutputStream(tmpJar);
         byte[] buffer = new byte[1024];
         int read;
         while( (read = is.read(buffer)) > 0 )
         {
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.