parent
b0aa80c6a8
commit
0d29dd3788
|
@ -1,5 +0,0 @@
|
||||||
package org.bench4q.agent.parameterization;
|
|
||||||
|
|
||||||
public interface Parameterization {
|
|
||||||
public String getCurrentValue();
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.bench4q.agent.Main;
|
import org.bench4q.agent.Main;
|
||||||
|
|
||||||
public abstract class BasePlugin {
|
public abstract class BaseParameterization {
|
||||||
private UUID testId;
|
private UUID testId;
|
||||||
|
|
||||||
protected UUID getTestId() {
|
protected UUID getTestId() {
|
||||||
|
@ -15,7 +15,7 @@ public abstract class BasePlugin {
|
||||||
this.testId = testId;
|
this.testId = testId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BasePlugin(String testId) {
|
protected BaseParameterization(String testId) {
|
||||||
this.setTestId(UUID.fromString(testId));
|
this.setTestId(UUID.fromString(testId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bench4q.agent.parameterization.Parameterization;
|
import org.bench4q.agent.plugin.BaseParameterization;
|
||||||
import org.bench4q.agent.plugin.BasePlugin;
|
|
||||||
import org.bench4q.agent.plugin.Constructor;
|
import org.bench4q.agent.plugin.Constructor;
|
||||||
import org.bench4q.agent.plugin.Parameter;
|
import org.bench4q.agent.plugin.Parameter;
|
||||||
import org.bench4q.agent.plugin.Plugin;
|
import org.bench4q.agent.plugin.Plugin;
|
||||||
|
@ -19,7 +18,7 @@ import org.bench4q.agent.utils.ParameterParser;
|
||||||
import org.bench4q.agent.utils.Type.SupportTypes;
|
import org.bench4q.agent.utils.Type.SupportTypes;
|
||||||
|
|
||||||
@Plugin(value = "CsvProvider")
|
@Plugin(value = "CsvProvider")
|
||||||
public class CsvProvider extends BasePlugin implements Parameterization {
|
public class CsvProvider extends BaseParameterization {
|
||||||
private static final String ENABLE_CheckBox = "enable";
|
private static final String ENABLE_CheckBox = "enable";
|
||||||
|
|
||||||
public static final char DEFAULT_SEPARATOR = ',';
|
public static final char DEFAULT_SEPARATOR = ',';
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.bench4q.agent.test.plugin;
|
package org.bench4q.agent.test.plugin;
|
||||||
|
|
||||||
import org.bench4q.agent.helper.ClassHelper;
|
import org.bench4q.agent.helper.ClassHelper;
|
||||||
|
import org.bench4q.agent.plugin.Plugin;
|
||||||
import org.bench4q.agent.plugin.PluginManager;
|
import org.bench4q.agent.plugin.PluginManager;
|
||||||
import org.bench4q.agent.plugin.TypeConverter;
|
import org.bench4q.agent.plugin.TypeConverter;
|
||||||
|
import org.bench4q.agent.plugin.basic.http.HttpPlugin;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -12,8 +14,34 @@ public class Test_PluginManager {
|
||||||
public void test_getInit() {
|
public void test_getInit() {
|
||||||
PluginManager pluginManager = new PluginManager(new ClassHelper(),
|
PluginManager pluginManager = new PluginManager(new ClassHelper(),
|
||||||
new TypeConverter());
|
new TypeConverter());
|
||||||
assertEquals(5, pluginManager.getPlugins().size());
|
assertEquals(6, pluginManager.getPlugins().size());
|
||||||
assertTrue(pluginManager.getPlugins().containsKey(
|
assertTrue(pluginManager.getPlugins().containsKey("Http"));
|
||||||
"org.bench4q.agent.plugin.basic.http.HttpPlugin"));
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_InitializePlugin_IN_RightWay() {
|
||||||
|
PluginManager pluginManager = new PluginManager(new ClassHelper(),
|
||||||
|
new TypeConverter());
|
||||||
|
HttpPlugin httpPlugin = (HttpPlugin) pluginManager.initializePlugin(
|
||||||
|
pluginManager.getPlugins().get("Http"), null);
|
||||||
|
assertNotNull(httpPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_InitializePlugin_Without_Constructor_Annotation() {
|
||||||
|
PluginManager pluginManager = new PluginManager(new ClassHelper(),
|
||||||
|
new TypeConverter());
|
||||||
|
pluginManager.getPlugins().put("WithoutConstructorAnnotation",
|
||||||
|
WithoutConstructorAnnotationPlugin.class);
|
||||||
|
WithoutConstructorAnnotationPlugin plugin = (WithoutConstructorAnnotationPlugin) pluginManager
|
||||||
|
.initializePlugin(
|
||||||
|
pluginManager.getPlugins().get(
|
||||||
|
"WithoutConstructorAnnotation"), null);
|
||||||
|
assertNull(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Plugin("WithoutConstructorAnnotation")
|
||||||
|
public static class WithoutConstructorAnnotationPlugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue