[jboss-dev-forums] [Embedded JBoss Development] - Re: Archive Conversion Design Descussion

johnbailey do-not-reply at jboss.com
Wed Aug 26 21:17:40 EDT 2009


I agree.  I have taken some of the prototyping and implemented an ZipExporter as described.   The example below demonstrates the usage. 


  | @Test
  |    public void testExportZip() throws Exception
  |    {
  |       // Get an archive instance
  |       MemoryMapArchive archive = new MemoryMapArchiveImpl("testArchive.jar");
  | 
  |       // Add some content
  |       Asset assetOne = new ClassLoaderAsset("org/jboss/declarchive/impl/base/asset/Test.properties");
  |       Path pathOne = new BasicPath("test.properties");
  |       archive.add(pathOne, assetOne);
  |       Asset assetTwo = new ClassLoaderAsset("org/jboss/declarchive/impl/base/asset/Test2.properties");
  |       Path pathTwo = new BasicPath("nested", "test2.properties");
  |       archive.add(pathTwo, assetTwo);
  | 
  |       // Export as Zip InputStream
  |       InputStream zipStream = ZipExporter.exportZip(archive);
  | 
  |       // Validate the InputStream was created 
  |       Assert.assertNotNull(zipStream);
  | 
  |       // Create a temp file
  |       File outFile = File.createTempFile("test", ".zip");
  |       // Write Zip contents to file
  |       writeOutFile(outFile, zipStream);
  | 
  |       // Use standard ZipFile library to read in written Zip file
  |       ZipFile expectedZip = new ZipFile(outFile);
  | 
  |       // Validate first entry
  |       assertAssetInZip(expectedZip, pathOne, assetOne);
  |       assertAssetInZip(expectedZip, pathTwo, assetTwo);
  | 
  |    }
  | 

I will continue to work on the ExplodedExporter as well. 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251931#4251931

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251931



More information about the jboss-dev-forums mailing list