}
@Test
public void test() throws Exception {
Instance instance = new MockInstance();
Connector connector = instance.getConnector("root", new PasswordToken(""));
BatchWriter bw = connector.createBatchWriter("!METADATA", new BatchWriterConfig());
// Create a fake METADATA table with these splits
String splits[] = {"a", "e", "j", "o", "t", "z"};
// create metadata for a table "t" with the splits above
Text tableId = new Text("t");
Text pr = null;
for (String s : splits) {
Text split = new Text(s);
Mutation prevRow = KeyExtent.getPrevRowUpdateMutation(new KeyExtent(tableId, split, pr));
prevRow.put(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY, new Text("123456"), new Value("127.0.0.1:1234".getBytes()));
Constants.METADATA_CHOPPED_COLUMN.put(prevRow, new Value("junk".getBytes()));
bw.addMutation(prevRow);
pr = split;
}
// Add the default tablet
Mutation defaultTablet = KeyExtent.getPrevRowUpdateMutation(new KeyExtent(tableId, null, pr));
defaultTablet.put(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY, new Text("123456"), new Value("127.0.0.1:1234".getBytes()));
bw.addMutation(defaultTablet);
bw.close();
// Read out the TabletLocationStates
MockCurrentState state = new MockCurrentState(new MergeInfo(new KeyExtent(tableId, new Text("p"), new Text("e")), MergeInfo.Operation.MERGE));
TCredentials auths = CredentialHelper.create("root", new PasswordToken(new byte[0]), "instance");
// Verify the tablet state: hosted, and count
MetaDataStateStore metaDataStateStore = new MetaDataStateStore(instance, auths, state);
int count = 0;
for (TabletLocationState tss : metaDataStateStore) {