@Test
public void testAddAvroSchema() throws Exception {
// backwards incompatible schema should fail
try {
logger.info("Now inserting stores with non backward compatible schema. Should see exception");
adminClient.storeMgmtOps.addStore(new StoreDefinitionsMapper().readStore(new StringReader(storeXmlWithBackwardIncompatibleSchema)));
Assert.fail("Did not throw exception");
} catch(VoldemortException e) {
}
// invalid key schema should fail
try {
logger.info("Now inserting stores with int32 avro key. Should see exception");
adminClient.storeMgmtOps.addStore(new StoreDefinitionsMapper().readStore(new StringReader(storeXmlWithInvalidAvroKeySchema)));
Assert.fail("Did not throw exception for invalid key schema");
} catch(VoldemortException e) {
logger.error("As expected", e);
}
// invalid value schema should fail
try {
logger.info("Now inserting stores with html characters in avro value schema");
adminClient.storeMgmtOps.addStore(new StoreDefinitionsMapper().readStore(new StringReader(storeXmlWithInvalidAvroValueSchema)));
Assert.fail("Did not throw exception for invalid value schema");
} catch(VoldemortException e) {
logger.error("As expected", e);
}
for(VoldemortServer vs: vservers.values()) {
assertNull(vs.getStoreRepository().getLocalStore("test"));
}
logger.info("Now inserting stores with backward compatible schema. Should not see exception");
adminClient.storeMgmtOps.addStore(new StoreDefinitionsMapper().readStore(new StringReader(storeXmlWithBackwardCompatibleSchema)));
for(VoldemortServer vs: vservers.values()) {
assertNotNull(vs.getStoreRepository().getLocalStore("test"));
}
}