@Test public void testSetInstance$securityManager$happyPath() throws Exception { class CustomSecurityManager extends SecurityManager { private final List<Permission> permissions=Lists.newArrayList(); @Override public void checkPermission(Permission permission) { this.permissions.add(permission); } }; final CustomSecurityManager manager=new CustomSecurityManager(); new MockUp<RuntimeDelegate>() { @Mock public SecurityManager getSecurityManager() { return manager; } }; RuntimeDelegate.setInstance(null); assertThat(hasReflectionPermission(manager.permissions),equalTo(true)); }
public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = getSecurityManager(); if (security != null) { security.checkPermission(SUPPRESS_ACCESS_CHECKS_PERMISSION); } synchronized(RuntimeDelegate.CACHED_DELEGATE) { RuntimeDelegate.CACHED_DELEGATE.set(delegate); } }
RuntimeDelegate { public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = getSecurityManager(); if (security != null) { security.checkPermission(SUPPRESS_ACCESS_CHECKS_PERMISSION); } synchronized(RuntimeDelegate.CACHED_DELEGATE) { RuntimeDelegate.CACHED_DELEGATE.set(delegate); } } }
RuntimeDelegate { public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = getSecurityManager(); if (security != null) { security.checkPermission(SUPPRESS_ACCESS_CHECKS_PERMISSION); } synchronized(RuntimeDelegate.CACHED_DELEGATE) { RuntimeDelegate.CACHED_DELEGATE.set(delegate); } } protected  RuntimeDelegate(); }
RuntimeDelegate { public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = getSecurityManager(); if (security != null) { security.checkPermission(SUPPRESS_ACCESS_CHECKS_PERMISSION); } synchronized(RuntimeDelegate.CACHED_DELEGATE) { RuntimeDelegate.CACHED_DELEGATE.set(delegate); } } protected  RuntimeDelegate(); static RuntimeDelegate getInstance(); static void setInstance(final RuntimeDelegate delegate); abstract boolean isOffline(); abstract WriteSession createSession(); abstract ResourceSnapshotResolver createResourceResolver(URI canonicalBase, ReadSession session); abstract void registerShutdownListener(ShutdownListener listener); }
RuntimeDelegate { public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = getSecurityManager(); if (security != null) { security.checkPermission(SUPPRESS_ACCESS_CHECKS_PERMISSION); } synchronized(RuntimeDelegate.CACHED_DELEGATE) { RuntimeDelegate.CACHED_DELEGATE.set(delegate); } } protected  RuntimeDelegate(); static RuntimeDelegate getInstance(); static void setInstance(final RuntimeDelegate delegate); abstract boolean isOffline(); abstract WriteSession createSession(); abstract ResourceSnapshotResolver createResourceResolver(URI canonicalBase, ReadSession session); abstract void registerShutdownListener(ShutdownListener listener); static final String APPLICATION_ENGINE_SPI_FINDER; static final String APPLICATION_ENGINE_SPI_CFG; static final String APPLICATION_ENGINE_SPI_PROPERTY; }