use of com.alipay.sofa.ark.container.model.PluginModel in project sofa-ark by alipay.
the class ExtensionServiceTest method testExtensionServiceNotInstance.
@Test
public void testExtensionServiceNotInstance() {
PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
pluginManagerService.registerPlugin(pluginModel);
try {
ArkServiceLoader.loadExtensionFromArkPlugin(ServiceA.class, "", "mock-plugin");
} catch (ArkRuntimeException ex) {
Assert.assertTrue(ex.getMessage().contains("not type of"));
}
}
use of com.alipay.sofa.ark.container.model.PluginModel in project sofa-ark by alipay.
the class ExtensionServiceTest method testNoExtensionAnnotation.
@Test
public void testNoExtensionAnnotation() {
PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
pluginManagerService.registerPlugin(pluginModel);
try {
ArkServiceLoader.loadExtensionFromArkPlugin(ServiceD.class, "", "mock-plugin");
} catch (ArkRuntimeException ex) {
Assert.assertTrue(ex.getMessage().contains(String.format("is not annotated by %s.", Extension.class)));
}
}
use of com.alipay.sofa.ark.container.model.PluginModel in project sofa-ark by alipay.
the class HandleArchiveTest method testIncludePlugin.
@Test
public void testIncludePlugin() {
try {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
System.setProperty(PLUGIN_ACTIVE_INCLUDE, "pluginA");
PluginModel pluginModel = new PluginModel();
pluginModel.setPluginName("pluginA");
Assert.assertFalse(handleArchiveStage.isPluginExcluded(pluginModel));
pluginModel.setPluginName("pluginB");
Assert.assertTrue(handleArchiveStage.isPluginExcluded(pluginModel));
pluginModel.setPluginName("pluginC");
Assert.assertTrue(handleArchiveStage.isPluginExcluded(pluginModel));
} finally {
System.clearProperty(PLUGIN_ACTIVE_INCLUDE);
}
}
use of com.alipay.sofa.ark.container.model.PluginModel in project sofa-ark by alipay.
the class HandleArchiveTest method testIncludeExcludePlugin.
@Test
public void testIncludeExcludePlugin() {
try {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
System.setProperty(PLUGIN_ACTIVE_INCLUDE, "pluginA");
System.setProperty(PLUGIN_ACTIVE_EXCLUDE, "pluginA,pluginB");
PluginModel pluginModel = new PluginModel();
pluginModel.setPluginName("pluginA");
Assert.assertFalse(handleArchiveStage.isPluginExcluded(pluginModel));
pluginModel.setPluginName("pluginB");
Assert.assertTrue(handleArchiveStage.isPluginExcluded(pluginModel));
pluginModel.setPluginName("pluginC");
Assert.assertTrue(handleArchiveStage.isPluginExcluded(pluginModel));
} finally {
System.clearProperty(PLUGIN_ACTIVE_EXCLUDE);
System.clearProperty(PLUGIN_ACTIVE_INCLUDE);
}
}
use of com.alipay.sofa.ark.container.model.PluginModel in project sofa-ark by alipay.
the class HandleArchiveTest method testNoIncludeExcludeBiz.
@Test
public void testNoIncludeExcludeBiz() {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
PluginModel pluginModel = new PluginModel();
pluginModel.setPluginName("pluginA");
Assert.assertFalse(handleArchiveStage.isPluginExcluded(pluginModel));
pluginModel.setPluginName("pluginB");
Assert.assertFalse(handleArchiveStage.isPluginExcluded(pluginModel));
}
Aggregations