#19 - Exceptions on plugin lookup can now be submitted lazily.
Introduced overloads on PluginRegistry which instead of taking an exception instance immediately (which requires instance creation beforehand) now accept a Supplier<E> so that the exception creation can actually be delayed until it's really needed. Deprecated the old methods taking exception instances directly.
This commit is contained in:
@@ -21,10 +21,12 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.plugin.core.PluginRegistry.Supplier;
|
||||
|
||||
/**
|
||||
* Unit test for {@link SimplePluginRegistry}.
|
||||
@@ -130,4 +132,21 @@ public class SimplePluginRegistryUnitTest {
|
||||
|
||||
assertThat(registry.countPlugins(), is(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #19
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testname() throws Exception {
|
||||
|
||||
registry = SimplePluginRegistry.create(Collections.<SamplePlugin> emptyList());
|
||||
|
||||
registry.getPluginFor("FOO", new Supplier<Exception>() {
|
||||
|
||||
@Override
|
||||
public Exception get() {
|
||||
return new IllegalStateException();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user