Repository: incubator-ranger Updated Branches: refs/heads/ranger-0.5 3c11aee92 -> 4b6b64100
RANGER-841 Remove deprecated junit.framework dependencies Signed-off-by: Alok Lal <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/4b6b6410 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/4b6b6410 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/4b6b6410 Branch: refs/heads/ranger-0.5 Commit: 4b6b641008feca7834d5f2a97cd954aa31065298 Parents: 3c11aee Author: Colm O hEigeartaigh <[email protected]> Authored: Thu Feb 11 10:53:31 2016 -0800 Committer: Alok Lal <[email protected]> Committed: Thu Feb 11 11:09:12 2016 -0800 ---------------------------------------------------------------------- .../plugin/errors/TestValidationErrorCode.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4b6b6410/agents-common/src/test/java/org/apache/ranger/plugin/errors/TestValidationErrorCode.java ---------------------------------------------------------------------- diff --git a/agents-common/src/test/java/org/apache/ranger/plugin/errors/TestValidationErrorCode.java b/agents-common/src/test/java/org/apache/ranger/plugin/errors/TestValidationErrorCode.java index 46b1966..9336377 100644 --- a/agents-common/src/test/java/org/apache/ranger/plugin/errors/TestValidationErrorCode.java +++ b/agents-common/src/test/java/org/apache/ranger/plugin/errors/TestValidationErrorCode.java @@ -20,8 +20,9 @@ package org.apache.ranger.plugin.errors; import com.google.common.collect.ImmutableSet; -import junit.framework.TestCase; import org.apache.ranger.plugin.model.validation.ValidationFailureDetails; +import org.junit.Assert; +import org.junit.Test; import java.util.HashSet; import java.util.Set; @@ -29,14 +30,14 @@ import java.util.Set; /** * Created by alal on 7/30/15. */ -public class TestValidationErrorCode extends TestCase { - +public class TestValidationErrorCode { + @Test public void testUserMessage() throws Exception { ValidationErrorCode errorCode = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; String aParameter = "FOO"; String expected = errorCode._template.replace("{0}", aParameter); - assertEquals(expected, errorCode.getMessage(aParameter)); + Assert.assertEquals(expected, errorCode.getMessage(aParameter)); } /** @@ -46,6 +47,7 @@ public class TestValidationErrorCode extends TestCase { * This check is far from perfect. It may give false alarms if the message itself contains strings of the form {1} * which have been escaped using single quotes. If that happens we would have to make this test smarter. */ + @Test public void testTemplates() { // we check up to 5 substitution variables. If there are more than 5 then you probably have a different set of problems @@ -65,7 +67,7 @@ public class TestValidationErrorCode extends TestCase { } // check for incorrectly numbers substition variable placeholders for (ValidationErrorCode anEnum : mustNot) { - assertFalse(anEnum.toString() + ": contains " + token + ". Check for wongly numberd substition variable placeholders.", + Assert.assertFalse(anEnum.toString() + ": contains " + token + ". Check for wongly numberd substition variable placeholders.", anEnum._template.contains(token)); } } @@ -74,12 +76,13 @@ public class TestValidationErrorCode extends TestCase { /** * Test if the values assigned to the validation error code are unique or not. */ + @Test public void testValidationErrorCodesUnique() { Set<Integer> errorCodes = new HashSet<>(); for (ValidationErrorCode anEnum : ValidationErrorCode.values()) { int errorCode = anEnum.getErrorCode(); // errorCode that we see must not have been seen so far. - assertFalse("ValidationErrorCode: error code [" + errorCode + "] used multiple times!", errorCodes.contains(errorCode)); + Assert.assertFalse("ValidationErrorCode: error code [" + errorCode + "] used multiple times!", errorCodes.contains(errorCode)); errorCodes.add(errorCode); } }
