DefaultPackagingService implements Packaging { @Override public PackageManager getPackageManager() { return PackagingService.getPackageManager(); } @SuppressWarnings("WeakerAccess")  DefaultPackagingService();   DefaultPackagingService(final @NotNull ClassLoader classLoader); @Override PackageManager getPackageManager(); @Override JcrPackageManager getPackageManager(final Session session); @Override JcrPackageDefinition createPackageDefinition(final Node defNode); @Override JcrPackage open(final Node node, final boolean allowInvalid);  }
@Test public void testGetPackageManagerNoSession() { assertNotNull("got package manager", new DefaultPackagingService().getPackageManager()); }
@Test public void testConstruct() throws Exception { DefaultPackagingService service = new DefaultPackagingService(); new OakMachine.Builder().build().adminInitAndInspect(session -> { JcrPackageManager manager = service.getPackageManager(session); }); }
@Test public void testConstructNoDelegation() throws Exception { DefaultPackagingService service = new DefaultPackagingService(new URLClassLoader(new URL[0], null)); new OakMachine.Builder().build().adminInitAndInspect(session -> { JcrPackageManager manager = service.getPackageManager(session); }); }
@Test public void testConstructWrongInterfaceClassLoader() throws Exception { final URLClassLoader classLoader = new URLClassLoader( new URL[]{JcrPackageManager.class.getProtectionDomain().getCodeSource().getLocation()}, null); DefaultPackagingService service = new DefaultPackagingService(classLoader); new OakMachine.Builder().build().adminInitAndInspect(session -> { JcrPackageManager manager = service.getPackageManager(session); }); }
@Test public void testExceptionHandlingWithReflection() throws Exception { DefaultPackagingService service = new DefaultPackagingService(); service.jcrPackageManagerClazz = FailingJcrPackageManager.class; new OakMachine.Builder().build().adminInitAndInspect(session -> { JcrPackageManager manager = service.getPackageManager(session); assertTrue(manager instanceof JcrPackageManagerImpl); }); }