@Before public void setUpRepository() throws Exception { repo = createRepository(); }
@Override public void tearDownRepository() throws Exception { server.stop(); super.tearDownRepository(); }
@Test public void testSubjectConfigs() { String testKey = "test.key"; String testVal = "test.val"; String testVal2 = "test.val2"; SubjectConfig conf = new SubjectConfig.Builder().set(testKey, testVal).build(); SubjectConfig conf2 = new SubjectConfig.Builder().set(testKey, testVal2).build(); // lookup a subject that does not exist, when none do Subject none = repo.lookup(CONF); Assert.assertNull("non-existent subject lookup should return null", none); // register a subject Subject sub = repo.register(CONF, conf); Assert.assertNotNull("failed to register subject: " + CONF, sub); // a duplicate register is idempotent; the result is the same Subject sub2 = repo.register(CONF, conf2); Assert.assertNotNull("failed to re-register subject: " + SUB, sub2); validateSubject(sub, sub2); // lookup subject that was just registered Subject sub3 = repo.lookup(CONF); validateSubject(sub, sub3); // lookup something that is not there Subject sub4 = repo.lookup(NOCONF); Assert.assertNull("subject should not exist", sub4); }
validateSchemaEntry(FOO, foo); Assert.assertEquals("duplicate schema registration must be idempotent", foo, foo2); validateSchemaEntry(FOO, foo2); validateSchemaEntry(BAR, bar); validateSchemaEntry(BAZ, baz);