@Test
public void testOpen() throws Exception {

    final DefaultPackagingService service = new DefaultPackagingService();
    File testPack = TestPackageUtil.prepareTestPackage("test-package-with-etc.zip");
    new OakMachine.Builder().build().adminInitAndInspect(session -> {
        JcrPackageManager manager = service.getPackageManager(session);
        JcrPackage uploaded = null;
        JcrPackage opened = null;
        try {
            uploaded = manager.upload(testPack, false, true, null);
            opened = service.open(uploaded.getNode(), false);
            assertTrue("should be valid package", opened.isValid());
        } finally {
            if (uploaded != null) {
                uploaded.close();
            }
            if (opened != null) {
                opened.close();
            }
        }
    });
}