提交 c6d1c6e7 编写于 作者: C cherrylzhao

Add NewInstanceServiceLoaderTest.assertRegisterService().

上级 1cac1d56
......@@ -18,9 +18,12 @@
package io.shardingsphere.spi;
import io.shardingsphere.spi.transaction.xa.DataSourceMapConverter;
import lombok.SneakyThrows;
import org.junit.Test;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
......@@ -34,4 +37,15 @@ public class NewInstanceServiceLoaderTest {
assertThat(collections.size(), is(1));
assertThat(collections.iterator().next(), instanceOf(DataSourceMapConverter.class));
}
@Test
@SneakyThrows
@SuppressWarnings("unchecked")
public void assertRegisterService() {
NewInstanceServiceLoader.register(DataSourceMapConverter.class);
Field field = NewInstanceServiceLoader.class.getDeclaredField("SERVICE_MAP");
field.setAccessible(true);
Map<Class, Collection<Class<?>>> map = (Map<Class, Collection<Class<?>>>) field.get(null);
assertThat(map.get(DataSourceMapConverter.class).size(), is(1));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册