!"false".equals(reader.getAttribute(ATTR_ENABLED))); } else if (ELEM_SECURE_PORT.equals(nodeName)) { builder.setSecurePort(Integer.valueOf(reader.getValue()) .intValue());
case PORT: if (jsonToken == JsonToken.FIELD_NAME) jp.nextToken(); builder.setSecurePort(jp.getValueAsInt()); break; case ENABLED:
@Test public void testHealthCheckSetContainsValidUrlEntries() throws Exception { Builder builder = newBuilder() .setAppName("test") .setNamespace("eureka.") .setHostName("localhost") .setPort(80) .setSecurePort(443) .enablePort(PortType.SECURE, true); // No health check URLs InstanceInfo noHealtcheckInstanceInfo = builder.build(); assertThat(noHealtcheckInstanceInfo.getHealthCheckUrls().size(), is(equalTo(0))); // Now when health check is defined InstanceInfo instanceInfo = builder .setHealthCheckUrls("/healthcheck", "http://${eureka.hostname}/healthcheck", "https://${eureka.hostname}/healthcheck") .build(); assertThat(instanceInfo.getHealthCheckUrls().size(), is(equalTo(2))); }
case PORT: if (jsonToken == JsonToken.FIELD_NAME) jp.nextToken(); builder.setSecurePort(jp.getValueAsInt()); break; case ENABLED:
.setIPAddr(publicIp) .setPort(8080) .setSecurePort(8081) .enablePort(PortType.SECURE, true) .setHealthCheckUrls("/healthcheck", unsecureURL + "/healthcheck", secureURL + "/healthcheck")
.setPort(config.getNonSecurePort()) .enablePort(PortType.UNSECURE, config.isNonSecurePortEnabled()) .setSecurePort(config.getSecurePort()) .enablePort(PortType.SECURE, config.getSecurePortEnabled()) .setVIPAddress(config.getVirtualHostName())
!"false".equals(reader.getAttribute(ATTR_ENABLED))); } else if (ELEM_SECURE_PORT.equals(nodeName)) { builder.setSecurePort(Integer.valueOf(reader.getValue()) .intValue());
.enablePort(InstanceInfo.PortType.UNSECURE, config.isNonSecurePortEnabled()) .setSecurePort(config.getSecurePort()) .enablePort(InstanceInfo.PortType.SECURE, config.getSecurePortEnabled()) .setVIPAddress(config.getVirtualHostName())
ii = new InstanceInfo.Builder(copy).setSecurePort(overridePort).build(); }else{ ii = new InstanceInfo.Builder(copy).setPort(overridePort).build();
.setIPAddr(publicIp) .setPort(8080) .setSecurePort(8081) .enablePort(PortType.SECURE, true) .setHealthCheckUrls("/healthcheck", unsecureURL + "/healthcheck", secureURL + "/healthcheck")
.setPort(config.getNonSecurePort()) .enablePort(PortType.UNSECURE, config.isNonSecurePortEnabled()) .setSecurePort(config.getSecurePort()) .enablePort(PortType.SECURE, config.getSecurePortEnabled()) .setVIPAddress(config.getVirtualHostName())
@Test public void testInfoDetailApplications(){ DataCenterInfo myDCI = new DataCenterInfo() { public DataCenterInfo.Name getName() { return DataCenterInfo.Name.MyOwn; } }; InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setInstanceId("test.id") .setAppName("test") .setHostName("test.hostname") .setStatus(InstanceStatus.UP) .setIPAddr("test.testip:1") .setPort(8080) .setSecurePort(443) .setDataCenterInfo(myDCI) .build(); Application application = new Application("Test App"); application.addInstance(instanceInfo); Applications applications = new Applications(); applications.addApplication(application); List<InstanceInfo> instanceInfos = application.getInstances(); Assert.assertEquals(1, instanceInfos.size()); Assert.assertTrue(instanceInfos.contains(instanceInfo)); List<Application> appsList = applications.getRegisteredApplications(); Assert.assertEquals(1, appsList.size()); Assert.assertTrue(appsList.contains(application)); Assert.assertEquals(application, applications.getRegisteredApplications(application.getName())); }
@Test public void testCopyConstructor() { DataCenterInfo myDCI = new DataCenterInfo() { public DataCenterInfo.Name getName() { return DataCenterInfo.Name.MyOwn; } }; InstanceInfo smallII1 = newBuilder().setAppName("test").setDataCenterInfo(myDCI).build(); InstanceInfo smallII2 = new InstanceInfo(smallII1); assertNotSame(smallII1, smallII2); Assert.assertEquals(smallII1, smallII2); InstanceInfo fullII1 = newBuilder().setMetadata(null) .setOverriddenStatus(InstanceInfo.InstanceStatus.UNKNOWN) .setHostName("localhost") .setSecureVIPAddress("testSecureVIP:22") .setStatus(InstanceInfo.InstanceStatus.UNKNOWN) .setStatusPageUrl("relative", "explicit/relative") .setVIPAddress("testVIP:21") .setAppName("test").setASGName("testASG").setDataCenterInfo(myDCI) .setHealthCheckUrls("relative", "explicit/relative", "secureExplicit/relative") .setHomePageUrl("relativeHP", "explicitHP/relativeHP") .setIPAddr("127.0.0.1") .setPort(21).setSecurePort(22).build(); InstanceInfo fullII2 = new InstanceInfo(fullII1); assertNotSame(fullII1, fullII2); Assert.assertEquals(fullII1, fullII2); }