#48 - Aligned factory methods in SimplePluginRegistry with OrderAwarePluginRegistry.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,21 +15,17 @@
|
||||
*/
|
||||
package org.springframework.plugin.core;
|
||||
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.plugin.core.SimplePluginRegistry;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class SamplePluginHost {
|
||||
|
||||
private PluginRegistry<SamplePlugin, String> registry = SimplePluginRegistry.create();
|
||||
private PluginRegistry<SamplePlugin, String> registry = SimplePluginRegistry.empty();
|
||||
|
||||
/**
|
||||
* @param registry the registry to set
|
||||
*/
|
||||
public void setRegistry(PluginRegistry<SamplePlugin, String> registry) {
|
||||
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
@@ -37,7 +33,6 @@ public class SamplePluginHost {
|
||||
* @return the registry
|
||||
*/
|
||||
public PluginRegistry<SamplePlugin, String> getRegistry() {
|
||||
|
||||
return registry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Unit test for {@link SimplePluginRegistry}.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class SimplePluginRegistryUnitTest {
|
||||
@@ -48,18 +48,18 @@ public class SimplePluginRegistryUnitTest {
|
||||
public void setUp() {
|
||||
|
||||
plugin = new SamplePluginImplementation();
|
||||
registry = SimplePluginRegistry.create();
|
||||
registry = SimplePluginRegistry.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the registry contains the plugin it was initialized with.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void assertRegistryInitialized() throws Exception {
|
||||
|
||||
registry = SimplePluginRegistry.create(Arrays.asList(plugin));
|
||||
registry = SimplePluginRegistry.of(plugin);
|
||||
|
||||
assertThat(registry.countPlugins(), is(1));
|
||||
assertTrue(registry.contains(plugin));
|
||||
@@ -71,7 +71,7 @@ public class SimplePluginRegistryUnitTest {
|
||||
@Test
|
||||
public void assertFindsEmailNotificationProvider() {
|
||||
|
||||
registry = SimplePluginRegistry.create(Arrays.asList(plugin));
|
||||
registry = SimplePluginRegistry.of(plugin);
|
||||
|
||||
String delimiter = "FOO";
|
||||
|
||||
@@ -130,7 +130,7 @@ public class SimplePluginRegistryUnitTest {
|
||||
List<SamplePlugin> plugins = new ArrayList<SamplePlugin>();
|
||||
plugins.add(null);
|
||||
|
||||
registry = SimplePluginRegistry.create(plugins);
|
||||
registry = SimplePluginRegistry.of(plugins);
|
||||
|
||||
assertThat(registry.countPlugins(), is(0));
|
||||
}
|
||||
@@ -139,9 +139,9 @@ public class SimplePluginRegistryUnitTest {
|
||||
* @see #19
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testname() throws Exception {
|
||||
public void throwsExceptionFromSupplier() throws Exception {
|
||||
|
||||
registry = SimplePluginRegistry.create(Collections.<SamplePlugin> emptyList());
|
||||
registry = SimplePluginRegistry.empty();
|
||||
|
||||
registry.getPluginFor("FOO", () -> new IllegalStateException());
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class SimplePluginRegistryUnitTest {
|
||||
*/
|
||||
public void throwsExceptionIfRequiredPluginIsNotFound() {
|
||||
|
||||
registry = SimplePluginRegistry.create(Collections.emptyList());
|
||||
registry = SimplePluginRegistry.empty();
|
||||
|
||||
o_O.expect(IllegalArgumentException.class);
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SimplePluginRegistryUnitTest {
|
||||
*/
|
||||
public void throwsExceptionWithMessafeIfRequiredPluginIsNotFound() {
|
||||
|
||||
registry = SimplePluginRegistry.create(Collections.emptyList());
|
||||
registry = SimplePluginRegistry.of(Collections.emptyList());
|
||||
|
||||
o_O.expect(IllegalArgumentException.class);
|
||||
o_O.expectMessage("message");
|
||||
|
||||
Reference in New Issue
Block a user