@Test public void testGetInstance$spi$enabled() throws Exception { System.clearProperty(RuntimeDelegate.APPLICATION_ENGINE_SPI_FINDER); new MockUp<ServiceLoader<RuntimeDelegate>>() { @Mock public Iterator<RuntimeDelegate> iterator() { return new Iterator<RuntimeDelegate>() { int counter=0; @Override public boolean hasNext() { this.counter++; return this.counter<3; } @Override public RuntimeDelegate next() { if(counter<2) { throw new ServiceConfigurationError("FAILURE"); } else { return new CustomRuntimeDelegate(); } } @Override public void remove() { } }; } }; assertThat(sut(),instanceOf(CustomRuntimeDelegate.class)); }
public static RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(result==null) { result=findDelegate(); if(result==null) { result=new DefaultRuntimeDelegate(); } RuntimeDelegate.CACHED_DELEGATE.set(result); } return result; } }
RuntimeDelegate { public static RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(result==null) { result=findDelegate(); if(result==null) { result=new DefaultRuntimeDelegate(); } RuntimeDelegate.CACHED_DELEGATE.set(result); } return result; } } }
RuntimeDelegate { public static RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(result==null) { result=findDelegate(); if(result==null) { result=new DefaultRuntimeDelegate(); } RuntimeDelegate.CACHED_DELEGATE.set(result); } return result; } } protected  RuntimeDelegate(); }
RuntimeDelegate { public static RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(result==null) { result=findDelegate(); if(result==null) { result=new DefaultRuntimeDelegate(); } RuntimeDelegate.CACHED_DELEGATE.set(result); } return result; } } 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 RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(result==null) { result=findDelegate(); if(result==null) { result=new DefaultRuntimeDelegate(); } RuntimeDelegate.CACHED_DELEGATE.set(result); } return result; } } 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; }