Spencer Gibb
10 years ago
7 changed files with 83 additions and 8 deletions
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
package org.springframework.cloud.netflix.turbine; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Data |
||||
@ConfigurationProperties("turbine") |
||||
public class TurbineProperties { |
||||
private String clusterNameExpression = "appName"; |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
package org.springframework.cloud.netflix.turbine; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
import com.netflix.appinfo.InstanceInfo; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class EurekaInstanceDiscoveryTest { |
||||
|
||||
|
||||
@Test |
||||
public void testGetClusterName() { |
||||
String appName = "testAppName"; |
||||
EurekaInstanceDiscovery discovery = new EurekaInstanceDiscovery(new TurbineProperties()); |
||||
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() |
||||
.setAppName(appName) |
||||
.build(); |
||||
String clusterName = discovery.getClusterName(instanceInfo); |
||||
assertEquals("clusterName is wrong", appName.toUpperCase(), clusterName); |
||||
} |
||||
|
||||
@Test |
||||
public void testGetClusterNameCustomExpression() { |
||||
TurbineProperties turbineProperties = new TurbineProperties(); |
||||
turbineProperties.setClusterNameExpression("aSGName"); |
||||
EurekaInstanceDiscovery discovery = new EurekaInstanceDiscovery(turbineProperties); |
||||
String asgName = "myAsgName"; |
||||
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() |
||||
.setAppName("testApp") |
||||
.setASGName(asgName) |
||||
.build(); |
||||
String clusterName = discovery.getClusterName(instanceInfo); |
||||
assertEquals("clusterName is wrong", asgName, clusterName); |
||||
} |
||||
} |
Loading…
Reference in new issue