assertTrue(ExtensionLoader.getExtensionLoader(Ext1.class).getExtension("impl2") instanceof Ext1Impl2);
}
@Test
public void test_getExtension_WithWrapper() throws Exception {
Ext5NoAdaptiveMethod impl1 = ExtensionLoader.getExtensionLoader(Ext5NoAdaptiveMethod.class).getExtension("impl1");
assertThat(impl1, anyOf(instanceOf(Ext5Wrapper1.class), instanceOf(Ext5Wrapper2.class)));
Ext5NoAdaptiveMethod impl2 = ExtensionLoader.getExtensionLoader(Ext5NoAdaptiveMethod.class).getExtension("impl2") ;
assertThat(impl2, anyOf(instanceOf(Ext5Wrapper1.class), instanceOf(Ext5Wrapper2.class)));
Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");
int echoCount1 = Ext5Wrapper1.echoCount.get();
int echoCount2 = Ext5Wrapper2.echoCount.get();
int yellCount1 = Ext5Wrapper1.yellCount.get();
int yellCount2 = Ext5Wrapper2.yellCount.get();
assertEquals("Ext5Impl1-echo", impl1.echo(config, "ha"));
assertEquals(echoCount1 + 1, Ext5Wrapper1.echoCount.get());
assertEquals(echoCount2 + 1, Ext5Wrapper2.echoCount.get());
assertEquals(yellCount1, Ext5Wrapper1.yellCount.get());
assertEquals(yellCount2, Ext5Wrapper2.yellCount.get());
assertEquals("Ext5Impl2-yell", impl2.yell(config, "ha"));
assertEquals(echoCount1 + 1, Ext5Wrapper1.echoCount.get());
assertEquals(echoCount2 + 1, Ext5Wrapper2.echoCount.get());
assertEquals(yellCount1 + 1, Ext5Wrapper1.yellCount.get());
assertEquals(yellCount2 + 1, Ext5Wrapper2.yellCount.get());
}