use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AbstractAddressManagerTest method addressForAzAndRegionTest.
@Test
public void addressForAzAndRegionTest() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("rest://127.0.0.1:30100?sslEnabled=true");
addressAZ.add("https://127.0.0.2:30100");
List<String> addressRG = new ArrayList<>();
addressRG.add("rest://127.0.0.3:30100?sslEnabled=true");
addressRG.add("https://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "TEST");
addressManager1.refreshEndpoint(event, "TEST");
Assert.assertEquals("https://127.0.0.2:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.1:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.2:30100", addressManager1.address());
addressManager1.removeAddress("https://127.0.0.2:30100");
addressManager1.removeAddress("https://127.0.0.1:30100");
Assert.assertEquals("https://127.0.0.3:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.4:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.3:30100", addressManager1.address());
addressManager1.removeAddress("https://127.0.0.4:30100");
addressManager1.removeAddress("https://127.0.0.3:30100");
Assert.assertEquals("https://127.0.0.2:30103", addressManager1.address());
Assert.assertEquals("http://127.0.0.1:30103", addressManager1.address());
Assert.assertEquals("https://127.0.0.2:30103", addressManager1.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AbstractAddressManagerTest method refreshEndpointTest.
@Test
public void refreshEndpointTest() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("rest://127.0.0.1:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", new ArrayList<>());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "TEST");
addressManager1.refreshEndpoint(event, "KIE");
Assert.assertEquals("https://127.0.0.2:30103", addressManager1.address());
Assert.assertEquals("http://127.0.0.1:30103", addressManager1.address());
Assert.assertEquals("https://127.0.0.2:30103", addressManager1.address());
addressManager2.refreshEndpoint(event, "TEST");
Assert.assertEquals("http://127.0.0.1:30100", addressManager2.address());
Assert.assertEquals("http://127.0.0.1:30100", addressManager2.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AbstractAddressManagerTest method addressForOnlyRegionTest.
@Test
public void addressForOnlyRegionTest() {
List<String> addressRG = new ArrayList<>();
addressRG.add("rest://127.0.0.5:30100?sslEnabled=true");
addressRG.add("rest://127.0.0.6:30100");
addressRG.add("http://127.0.0.7:30100");
addressRG.add("https://127.0.0.8:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", new ArrayList<>());
zoneAndRegion.put("sameRegion", addressRG);
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "TEST");
addressManager1.refreshEndpoint(event, "TEST");
Assert.assertEquals("http://127.0.0.6:30100", addressManager1.address());
Assert.assertEquals("http://127.0.0.7:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.8:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.5:30100", addressManager1.address());
Assert.assertEquals("http://127.0.0.6:30100", addressManager1.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AbstractAddressManagerTest method addressForOnlyAzTest.
@Test
public void addressForOnlyAzTest() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("http://127.0.0.1:30100");
addressAZ.add("https://127.0.0.2:30100");
addressAZ.add("rest://127.0.0.1:30100?sslEnabled=true");
addressAZ.add("rest://127.0.0.2:30100?sslEnabled=false");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", new ArrayList<>());
RefreshEndpointEvent event1 = new RefreshEndpointEvent(zoneAndRegion, "TEST");
addressManager1.refreshEndpoint(event1, "TEST");
Assert.assertEquals("https://127.0.0.2:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.1:30100", addressManager1.address());
Assert.assertEquals("http://127.0.0.2:30100", addressManager1.address());
Assert.assertEquals("http://127.0.0.1:30100", addressManager1.address());
Assert.assertEquals("https://127.0.0.2:30100", addressManager1.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class KieAddressManagerTest method onRefreshEndpointEvent.
@Test
public void onRefreshEndpointEvent() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("http://127.0.0.3:30100");
List<String> addressRG = new ArrayList<>();
addressRG.add("http://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
addressManager1 = new KieAddressManager(addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "KIE");
addressManager1.refreshEndpoint(event, "KIE");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("http://127.0.0.3:30100", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("http://127.0.0.4:30100", availableRegion.get(0));
}
Aggregations