/** * Gets the JAR working directory. * @param j2sramp * @return the private JAR working directory * @throws Exception */ public static File getJarWorkDir(ZipToSrampArchive j2sramp) throws Exception { Field field = getJarWorkDirField(j2sramp); boolean oldAccessible = field.isAccessible(); field.setAccessible(true); File workDir = (File) field.get(j2sramp); field.setAccessible(oldAccessible); return workDir; }
/** * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#JarToSrampArchive(java.io.InputStream)}. */ @Test public void testJarToSrampArchiveInputStream() throws Exception { InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$ ZipToSrampArchive j2sramp = null; try { j2sramp = new ZipToSrampArchive(resourceAsStream){}; File jarWorkDir = getJarWorkDir(j2sramp); Assert.assertNotNull(jarWorkDir); Assert.assertTrue(jarWorkDir.isDirectory()); Collection<File> files = FileUtils.listFiles(jarWorkDir, new String[] {"xsd", "wsdl"}, true); //$NON-NLS-1$ //$NON-NLS-2$ Assert.assertEquals(2, files.size()); Set<String> fnames = new HashSet<String>(); for (File f : files) { fnames.add(f.getName()); } Assert.assertTrue(fnames.contains("teetime.xsd")); //$NON-NLS-1$ Assert.assertTrue(fnames.contains("teetime.wsdl")); //$NON-NLS-1$ } finally { if (j2sramp != null) j2sramp.close(); } }
j2sramp = new ZipToSrampArchive(tempFile) {}; File jarWorkDir = getJarWorkDir(j2sramp); Assert.assertNotNull(jarWorkDir); Assert.assertTrue(jarWorkDir.isDirectory());