use of com.ctrip.framework.dal.cluster.client.shard.read.ReadCurrentZoneSlavesFirstStrategyTest.produceHostSpec in project dal by ctripcorp.
the class ReadCurrentZoneSlavesOnlyStrategyTest method pickCurrentZoneSlaveOnly.
@Test
public void pickCurrentZoneSlaveOnly() {
ReadCurrentZoneSlavesOnlyStrategy strategy = new ReadCurrentZoneSlavesOnlyStrategy();
strategy.init(ReadCurrentZoneSlavesFirstStrategyTest.produceHostSpec(), null);
strategy.currentZone = "shaoy";
HostSpec hostSpec = strategy.pickRead(new DalHints());
assertEquals(strategy.currentZone, hostSpec.getTrimLowerCaseZone());
strategy.currentZone = "";
try {
hostSpec = strategy.pickRead(new DalHints());
fail();
} catch (Throwable t) {
assertEquals(true, t instanceof DalMetadataException);
assertEquals(" has no database in ", t.getMessage());
}
strategy.currentZone = "shaxy";
try {
hostSpec = strategy.pickRead(new DalHints());
fail();
} catch (Throwable t) {
assertEquals(true, t instanceof DalMetadataException);
assertEquals(" has no database in " + strategy.currentZone, t.getMessage());
}
}
Aggregations