/** * Test that Constraints are properly enabled, disabled, and removed * * @throws Exception */ @SuppressWarnings("unchecked") @Test public void testEnableDisableRemove() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); // check general enabling/disabling of constraints // first add a constraint Constraints.add(desc, AllPassConstraint.class); // make sure everything is enabled assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); assertTrue(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // check disabling Constraints.disable(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // make sure the added constraints are still present assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); // check just removing the single constraint Constraints.remove(desc, AllPassConstraint.class); assertFalse(Constraints.has(desc, AllPassConstraint.class)); // Add back the single constraint Constraints.add(desc, AllPassConstraint.class); // and now check that when we remove constraints, all are gone Constraints.remove(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); assertFalse(Constraints.has(desc, AllPassConstraint.class)); }
/** * Test that Constraints are properly enabled, disabled, and removed * * @throws Exception */ @SuppressWarnings("unchecked") @Test public void testEnableDisableRemove() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); // check general enabling/disabling of constraints // first add a constraint Constraints.add(desc, AllPassConstraint.class); // make sure everything is enabled assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); assertTrue(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // check disabling Constraints.disable(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // make sure the added constraints are still present assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); // check just removing the single constraint Constraints.remove(desc, AllPassConstraint.class); assertFalse(Constraints.has(desc, AllPassConstraint.class)); // Add back the single constraint Constraints.add(desc, AllPassConstraint.class); // and now check that when we remove constraints, all are gone Constraints.remove(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); assertFalse(Constraints.has(desc, AllPassConstraint.class)); }