package com.netflix.discovery;
import java.util.UUID;
import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.DataCenterInfo;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.appinfo.MyDataCenterInstanceConfig;
import com.netflix.config.ConfigurationManager;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author Nitesh Kant
*/
public class DiscoveryClientDisableRegistryTest {
private EurekaClient client;
private MockRemoteEurekaServer mockLocalEurekaServer;
@Before
public void setUp() throws Exception {
mockLocalEurekaServer = new MockRemoteEurekaServer();
mockLocalEurekaServer.start();
ConfigurationManager.getConfigInstance().setProperty("eureka.registration.enabled", "false");
ConfigurationManager.getConfigInstance().setProperty("eureka.shouldFetchRegistry", "false");
ConfigurationManager.getConfigInstance().setProperty("eureka.serviceUrl.default",
"http://localhost:" + mockLocalEurekaServer.getPort() +
MockRemoteEurekaServer.EUREKA_API_BASE_PATH);
InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
builder.setIPAddr("10.10.101.00");
builder.setHostName("Hosttt");
builder.setAppName("EurekaTestApp-" + UUID.randomUUID());
builder.setDataCenterInfo(new DataCenterInfo() {
@Override
public Name getName() {
return Name.MyOwn;
}
});
ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), builder.build());
client = new DiscoveryClient(applicationInfoManager, new DefaultEurekaClientConfig());
}
@Test
public void testDisableFetchRegistry() throws Exception {
Assert.assertFalse("Registry fetch disabled but eureka server recieved a registry fetch.",
mockLocalEurekaServer.isSentRegistry());
}
}