use of com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt in project dubbo by alibaba.
the class ExtensionLoaderTest method test_getDefaultExtension.
@Test
public void test_getDefaultExtension() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getDefaultExtension();
assertThat(ext, instanceOf(SimpleExtImpl1.class));
String name = ExtensionLoader.getExtensionLoader(SimpleExt.class).getDefaultExtensionName();
assertEquals("impl1", name);
}
use of com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_getAdaptiveExtension_UrlNpe.
@Test
public void test_getAdaptiveExtension_UrlNpe() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
try {
ext.echo(null, "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("url == null", e.getMessage());
}
}
use of com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_getAdaptiveExtension_ExceptionWhenNotAdaptiveMethod.
@Test
public void test_getAdaptiveExtension_ExceptionWhenNotAdaptiveMethod() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
try {
ext.bang(url, 33);
fail();
} catch (UnsupportedOperationException expected) {
assertThat(expected.getMessage(), containsString("method "));
assertThat(expected.getMessage(), containsString("of interface com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt is not adaptive method!"));
}
}
use of com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt in project dubbo by alibaba.
the class ExtensionLoaderTest method test_AddExtension_ExceptionWhenExistedExtension.
@Test
public void test_AddExtension_ExceptionWhenExistedExtension() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getExtension("impl1");
try {
ExtensionLoader.getExtensionLoader(AddExt1.class).addExtension("impl1", AddExt1_ManualAdd1.class);
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Extension name impl1 already existed(Extension interface com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1)!"));
}
}
use of com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_getAdaptiveExtension_customizeAdaptiveKey.
@Test
public void test_getAdaptiveExtension_customizeAdaptiveKey() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
map.put("key2", "impl2");
URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
String echo = ext.yell(url, "haha");
assertEquals("Ext1Impl2-yell", echo);
// note: URL is value's type
url = url.addParameter("key1", "impl3");
echo = ext.yell(url, "haha");
assertEquals("Ext1Impl3-yell", echo);
}
Aggregations