本文整理匯總了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);
}
}