@Test
public void testCreatePackageDefinition() 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 jcrPackage = null;
        try {
            jcrPackage = manager.upload(testPack, false, true, null);
            JcrPackageDefinition def = service.createPackageDefinition(jcrPackage.getDefNode());
            assertTrue("should be real definition", def instanceof JcrPackageDefinitionImpl);
        } finally {
            if (jcrPackage != null) {
                jcrPackage.close();
            }
        }
    });
}