@Test
public void createJar() throws Exception
{

  JarFile jar = new JarFile(JarHelper.createJar("apex", folder.getRoot(), true));
  logger.debug("Created jar {} with MANIFEST only.", jar.getName());
  assertNotNull("MANIFEST exists", jar.getManifest());
  assertNull(jar.getEntry(file));
  assertNull(jar.getEntry(dir));
  jar.close();
  Files.write(folder.newFile(file).toPath(), data);
  folder.newFolder(dir);
  jar = new JarFile(JarHelper.createJar("apex", folder.getRoot(), true));
  logger.debug("Created jar {} with a file and a directory.", jar.getName());
  assertNotNull("MANIFEST exists", jar.getManifest());
  ZipEntry entry = jar.getEntry(file);
  assertNotNull(entry);
  assertFalse(entry.isDirectory());
  byte[] data = new byte[JarHelperTest.data.length];
  jar.getInputStream(entry).read(data);
  assertArrayEquals(data, JarHelperTest.data);
  assertTrue(jar.getEntry(dir).isDirectory());
  jar.close();
  folder.newFolder(META);
  Manifest manifest = new Manifest();
  manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, version);
  manifest.write(new FileOutputStream(folder.newFile(JarFile.MANIFEST_NAME)));
  jar = new JarFile(JarHelper.createJar(JarHelperTest.class.getSimpleName(), folder.getRoot(), true));
  logger.debug("Created jar {} with a file, a directory and a MANIFEST.", jar.getName());
  assertEquals("MANIFEST version", jar.getManifest().getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION), version);
  entry = jar.getEntry(file);
  assertNotNull(entry);
  assertFalse(entry.isDirectory());
  jar.getInputStream(entry).read(data);
  assertArrayEquals(data, JarHelperTest.data);
  assertTrue(jar.getEntry(dir).isDirectory());
  jar.close();
}