Search in sources :

Example 1 with AddExt1

use of com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1 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)!"));
    }
}
Also used : SimpleExt(com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt) AddExt1(com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1) Test(org.junit.Test)

Example 2 with AddExt1

use of com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1 in project dubbo by alibaba.

the class ExtensionLoaderTest method test_AddExtension.

@Test
public void test_AddExtension() throws Exception {
    try {
        ExtensionLoader.getExtensionLoader(AddExt1.class).getExtension("Manual1");
        fail();
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("No such extension com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1 by name Manual"));
    }
    ExtensionLoader.getExtensionLoader(AddExt1.class).addExtension("Manual1", AddExt1_ManualAdd1.class);
    AddExt1 ext = ExtensionLoader.getExtensionLoader(AddExt1.class).getExtension("Manual1");
    assertThat(ext, instanceOf(AddExt1_ManualAdd1.class));
    assertEquals("Manual1", ExtensionLoader.getExtensionLoader(AddExt1.class).getExtensionName(AddExt1_ManualAdd1.class));
}
Also used : AddExt1_ManualAdd1(com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt1_ManualAdd1) AddExt1(com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1) Test(org.junit.Test)

Example 3 with AddExt1

use of com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1 in project dubbo by alibaba.

the class ExtensionLoaderTest method test_replaceExtension_ExceptionWhenNotExistedExtension.

@Test
public void test_replaceExtension_ExceptionWhenNotExistedExtension() throws Exception {
    AddExt1 ext = ExtensionLoader.getExtensionLoader(AddExt1.class).getExtension("impl1");
    try {
        ExtensionLoader.getExtensionLoader(AddExt1.class).replaceExtension("NotExistedExtension", AddExt1_ManualAdd1.class);
        fail();
    } catch (IllegalStateException expected) {
        assertThat(expected.getMessage(), containsString("Extension name NotExistedExtension not existed(Extension interface com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1)"));
    }
}
Also used : AddExt1(com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1) Test(org.junit.Test)

Aggregations

AddExt1 (com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1)3 Test (org.junit.Test)3 SimpleExt (com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt)1 AddExt1_ManualAdd1 (com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt1_ManualAdd1)1