@Test()
public void testGetInstanceForAllStateUnits() {
List<InstanceConfig> instancesList;
Set<InstanceConfig> instancesSet;
InstanceConfig instancesArray[];
RoutingTableProvider routingTable = new RoutingTableProvider();
List<ExternalView> externalViewList = new ArrayList<ExternalView>();
ZNRecord record = new ZNRecord("TESTDB");
// one master
add(record, "TESTDB_0", "localhost_8900", "MASTER");
add(record, "TESTDB_1", "localhost_8900", "MASTER");
add(record, "TESTDB_2", "localhost_8900", "MASTER");
add(record, "TESTDB_3", "localhost_8900", "SLAVE");
add(record, "TESTDB_4", "localhost_8900", "SLAVE");
add(record, "TESTDB_5", "localhost_8900", "SLAVE");
add(record, "TESTDB_0", "localhost_8901", "SLAVE");
add(record, "TESTDB_1", "localhost_8901", "SLAVE");
add(record, "TESTDB_2", "localhost_8901", "SLAVE");
add(record, "TESTDB_3", "localhost_8901", "MASTER");
add(record, "TESTDB_4", "localhost_8901", "MASTER");
add(record, "TESTDB_5", "localhost_8901", "MASTER");
externalViewList.add(new ExternalView(record));
routingTable.onExternalViewChange(externalViewList, changeContext);
instancesList = routingTable.getInstances("TESTDB", "TESTDB_0", "MASTER");
AssertJUnit.assertNotNull(instancesList);
AssertJUnit.assertEquals(instancesList.size(), 1);
instancesSet = routingTable.getInstances("TESTDB", "MASTER");
AssertJUnit.assertNotNull(instancesSet);
AssertJUnit.assertEquals(instancesSet.size(), 2);
instancesSet = routingTable.getInstances("TESTDB", "SLAVE");
AssertJUnit.assertNotNull(instancesSet);
AssertJUnit.assertEquals(instancesSet.size(), 2);
instancesArray = new InstanceConfig[instancesSet.size()];
instancesSet.toArray(instancesArray);
AssertJUnit.assertEquals(instancesArray[0].getHostName(), "localhost");