use of com.tencent.polaris.api.plugin.Supplier in project polaris-java by polarismesh.
the class APIFactoryTest method testInitContextByConfig.
@Test
public void testInitContextByConfig() {
SDKContext sdkContext = null;
try {
sdkContext = APIFactory.initContextByConfig(TestUtils.createSimpleConfiguration(8888));
Supplier plugins = sdkContext.getPlugins();
Plugin plugin = plugins.getPlugin(PluginTypes.LOAD_BALANCER.getBaseType(), LoadBalanceConfig.LOAD_BALANCE_WEIGHTED_RANDOM);
Assert.assertNotNull(plugin);
} catch (PolarisException e) {
Assert.fail(e.getMessage());
} finally {
if (null != sdkContext) {
sdkContext.destroy();
}
}
}
use of com.tencent.polaris.api.plugin.Supplier in project polaris-java by polarismesh.
the class APIFactoryTest method testInitContextByFile.
@Test
public void testInitContextByFile() {
InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("conf/default.yaml");
SDKContext sdkContext = null;
try {
sdkContext = APIFactory.initContextByFile(resourceAsStream);
Supplier plugins = sdkContext.getPlugins();
Plugin plugin = plugins.getPlugin(PluginTypes.CIRCUIT_BREAKER.getBaseType(), DefaultPlugins.CIRCUIT_BREAKER_ERROR_COUNT);
Assert.assertNotNull(plugin);
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
if (null != sdkContext) {
sdkContext.destroy();
}
}
}
Aggregations