use of com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_urlHolder_getAdaptiveExtension_noExtension.
@Test
public void test_urlHolder_getAdaptiveExtension_noExtension() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
URL url = new URL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Fail to get extension("));
}
url = url.addParameter("ext2", "XXX");
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("No such extension"));
}
}
use of com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided.
@Test
public void test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
URL url = new URL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
try {
ext.echo(holder, "impl1");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Fail to get extension("));
}
url = url.addParameter("key1", "impl1");
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Fail to get extension(com.alibaba.dubbo.common.extensionloader.ext2.Ext2) name from url"));
}
}
use of com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_urlHolder_getAdaptiveExtension_UrlNpe.
@Test
public void test_urlHolder_getAdaptiveExtension_UrlNpe() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
try {
ext.echo(null, "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder argument == null", e.getMessage());
}
try {
ext.echo(new UrlHolder(), "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder argument getUrl() == null", e.getMessage());
}
}
use of com.alibaba.dubbo.common.extensionloader.ext2.UrlHolder in project dubbo by alibaba.
the class ExtensionLoader_Adaptive_Test method test_urlHolder_getAdaptiveExtension.
@Test
public void test_urlHolder_getAdaptiveExtension() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
map.put("ext2", "impl1");
URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
String echo = ext.echo(holder, "haha");
assertEquals("Ext2Impl1-echo", echo);
}
Aggregations