use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AddressManagerTest method addressIPV6Test.
@Test
public void addressIPV6Test() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("rest://[2008::7:957f:b2d6:1af4:a1f8]:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", new ArrayList<>());
addressManager1 = new AddressManager(addresses, EventManager.getEventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "SERVICECENTER");
addressManager1.refreshEndpoint(event, "SERVICECENTER");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("[2008::7:957f:b2d6:1af4:a1f8]:30100", availableZone.get(0));
IpPort ipPort = addressManager1.getAvailableIpPort();
Assert.assertEquals("[2008::7:957f:b2d6:1af4:a1f8]", ipPort.getHostOrIp());
Assert.assertEquals(30100, ipPort.getPort());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AddressManagerTest 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("https://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
addressManager1 = new AddressManager(addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "SERVICECENTER");
addressManager1.refreshEndpoint(event, "SERVICECENTER");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("127.0.0.3:30100", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("127.0.0.4:30100", availableRegion.get(0));
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AddressManagerTest 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 AddressManager("project", addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "SERVICECENTER");
addressManager1.refreshEndpoint(event, "SERVICECENTER");
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));
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AddressManagerTest 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 AddressManager("project", addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "CseConfigCenter");
addressManager1.refreshEndpoint(event, "CseConfigCenter");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("http://127.0.0.3:30100/v3/project", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("http://127.0.0.4:30100/v3/project", availableRegion.get(0));
Assert.assertEquals("http://127.0.0.3:30100/v3/project", addressManager1.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project incubator-servicecomb-java-chassis by apache.
the class AddressManagerTest 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 AddressManager(addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "CseMonitoring");
addressManager1.refreshEndpoint(event, "CseMonitoring");
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