本文整理汇总了Java中com.netflix.appinfo.MyDataCenterInstanceConfig类的典型用法代码示例。如果您正苦于以下问题:Java MyDataCenterInstanceConfig类的具体用法?Java MyDataCenterInstanceConfig怎么用?Java MyDataCenterInstanceConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyDataCenterInstanceConfig类属于com.netflix.appinfo包,在下文中一共展示了MyDataCenterInstanceConfig类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doReturn
import com.netflix.appinfo.MyDataCenterInstanceConfig; //导入依赖的package包/类
@DataProvider(value = {
"null",
"MyOwn",
"not-a-real-datacenter-type"
})
@Test
public void createEurekaInstanceConfig_returns_MyDataCenterInstanceConfig_when_datacenterType_is_null_or_MyOwn_or_invalid(
String datacenterType
) {
// given
doReturn(datacenterType).when(datacenterTypePropertySupplierMock).get();
// when
EurekaInstanceConfig instanceConfig = handlerSpy.createEurekaInstanceConfig();
// then
assertThat(instanceConfig).isInstanceOf(MyDataCenterInstanceConfig.class);
assertThat(Whitebox.getInternalState(instanceConfig, "namespace")).isEqualTo(handlerSpy.eurekaClientNamespace);
}
示例2: buildInstanceConfig
import com.netflix.appinfo.MyDataCenterInstanceConfig; //导入依赖的package包/类
private EurekaInstanceConfig buildInstanceConfig(DiscoveryNode localNode) {
try {
String configProperty = DynamicPropertyFactory
.getInstance()
.getStringProperty("eureka.client.props", "eureka-client")
.get();
String eurekaPropertyFile = String.format("%s.properties", configProperty);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
URL url = loader.getResource(eurekaPropertyFile);
if (url == null) {
throw new IllegalStateException("Cannot locate " + eurekaPropertyFile + " as a classpath resource.");
}
Properties props = new Properties();
props.load(url.openStream());
String key = String.format("%s.datacenter", this.namespace);
String value = props.getProperty(key, "");
if ("cloud".equals(value.trim().toLowerCase())) {
return new DelegatingInstanceConfig(new CloudInstanceConfig(this.namespace), localNode);
}
return new DelegatingInstanceConfig(new MyDataCenterInstanceConfig(this.namespace), localNode);
} catch (IOException e) {
throw new IllegalStateException("Cannot build EurekaInstanceInfo", e);
}
}