From ba8da400c5dff4dd18e06a978e3ebc4520bb1247 Mon Sep 17 00:00:00 2001 From: mmis Date: Thu, 15 Mar 2018 10:59:51 +0000 Subject: Removed checkstyle warnings Removed checkstyle warnings in policy/common/utils-test Issue-ID: POLICY-695 Change-Id: I9962b2f815d2c116f77475944bc17ea1cb0af539 Signed-off-by: mmis --- .../common/utils/test/ThrowablesTesterTest.java | 370 ++++++++++----------- 1 file changed, 184 insertions(+), 186 deletions(-) (limited to 'utils-test/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java') diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java index cb8c0ef6..4d289c6a 100644 --- a/utils-test/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java +++ b/utils-test/src/test/java/org/onap/policy/common/utils/test/ThrowablesTesterTest.java @@ -26,191 +26,189 @@ import org.junit.Test; public class ThrowablesTesterTest { - @Test - public void test() { - assertEquals(2, new ThrowablesTester().testAllThrowable(SimpleThrowable.class)); - assertEquals(5, new ThrowablesTester().testAllThrowable(StaticThrowable.class)); - } - - @Test - public void testNoConstructorsThrowable() { - // this will not throw an error, but it should return 0, as there are - // no matching constructors - assertEquals(0, new ThrowablesTester().testAllThrowable(NoConstructorsThrowable.class)); - } - - @Test(expected = AssertionError.class) - public void testIgnoreMessageThrowable() { - new ThrowablesTester().testAllThrowable(IgnoreMessageThrowable.class); - } - - @Test(expected = AssertionError.class) - public void testIgnoreCauseThrowable() { - new ThrowablesTester().testAllThrowable(IgnoreCauseThrowable.class); - } - - @Test(expected = AssertionError.class) - public void testAlwaysSuppressThrowable() { - new ThrowablesTester().testAllThrowable(AlwaysSuppressThrowable.class); - } - - @Test(expected = AssertionError.class) - public void testNeverSuppressThrowable() { - new ThrowablesTester().testAllThrowable(NeverSuppressThrowable.class); - } - - @Test(expected = AssertionError.class) - public void testAlwaysWritableThrowable() { - new ThrowablesTester().testAllThrowable(AlwaysWritableThrowable.class); - } - - @Test(expected = AssertionError.class) - public void testNeverWritableThrowable() { - new ThrowablesTester().testAllThrowable(NeverWritableThrowable.class); - } - - @Test(expected = ConstructionError.class) - public void testThrowInstantiationException() { - new ThrowablesTester().testAllThrowable(ThrowInstantiationException.class); - } - - /** - * Used to test a failure case - message text is ignored. - */ - public static class IgnoreMessageThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public IgnoreMessageThrowable(String message) { - super("bogus"); - } - } - - /** - * Used to test a failure case - cause is ignored. - */ - public static class IgnoreCauseThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public IgnoreCauseThrowable(Throwable cause) { - super(new Throwable("another cause")); - } - } - - /** - * Used to test a failure case - this has no standard constructors. The only - * constructor it has takes an "int", thus it is not one of the standard - * constructors. - */ - public static class NoConstructorsThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public NoConstructorsThrowable(int value) { - super(); - } - } - - /** - * Used to test a failure case - always suppresses. - */ - public static class AlwaysSuppressThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public AlwaysSuppressThrowable(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, true, writableStackTrace); - } - } - - /** - * Used to test a failure case - never suppresses. - */ - public static class NeverSuppressThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public NeverSuppressThrowable(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, false, writableStackTrace); - } - } - - /** - * Used to test a failure case - always allows stack writes. - */ - public static class AlwaysWritableThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public AlwaysWritableThrowable(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, enableSuppression, true); - } - } - - /** - * Used to test a failure case - never allows stack writes. - */ - public static class NeverWritableThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public NeverWritableThrowable(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, enableSuppression, false); - } - } - - /** - * Used to test a failure case - throws InstantiationException when - * constructed. - */ - public static class ThrowInstantiationException extends Throwable { - private static final long serialVersionUID = 1L; - - public ThrowInstantiationException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) throws InstantiationException { - - throw new InstantiationException(ThrowablesTester.EXPECTED_EXCEPTION_MSG); - } - } - - /** - * Used to test a simple success case. - */ - public static class SimpleThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public SimpleThrowable() { - super(); - } - - public SimpleThrowable(String message) { - super(message); - } - } - - /** - * Used to test the exhaustive success case. - */ - public static class StaticThrowable extends Throwable { - private static final long serialVersionUID = 1L; - - public StaticThrowable() { - super(); - } - - public StaticThrowable(String message) { - super(message); - } - - public StaticThrowable(Throwable cause) { - super(cause); - } - - public StaticThrowable(String message, Throwable cause) { - super(message, cause); - } - - public StaticThrowable(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - } + @Test + public void test() { + assertEquals(2, new ThrowablesTester().testAllThrowable(SimpleThrowable.class)); + assertEquals(5, new ThrowablesTester().testAllThrowable(StaticThrowable.class)); + } + + @Test + public void testNoConstructorsThrowable() { + // this will not throw an error, but it should return 0, as there are + // no matching constructors + assertEquals(0, new ThrowablesTester().testAllThrowable(NoConstructorsThrowable.class)); + } + + @Test(expected = AssertionError.class) + public void testIgnoreMessageThrowable() { + new ThrowablesTester().testAllThrowable(IgnoreMessageThrowable.class); + } + + @Test(expected = AssertionError.class) + public void testIgnoreCauseThrowable() { + new ThrowablesTester().testAllThrowable(IgnoreCauseThrowable.class); + } + + @Test(expected = AssertionError.class) + public void testAlwaysSuppressThrowable() { + new ThrowablesTester().testAllThrowable(AlwaysSuppressThrowable.class); + } + + @Test(expected = AssertionError.class) + public void testNeverSuppressThrowable() { + new ThrowablesTester().testAllThrowable(NeverSuppressThrowable.class); + } + + @Test(expected = AssertionError.class) + public void testAlwaysWritableThrowable() { + new ThrowablesTester().testAllThrowable(AlwaysWritableThrowable.class); + } + + @Test(expected = AssertionError.class) + public void testNeverWritableThrowable() { + new ThrowablesTester().testAllThrowable(NeverWritableThrowable.class); + } + + @Test(expected = ConstructionError.class) + public void testThrowInstantiationException() { + new ThrowablesTester().testAllThrowable(ThrowInstantiationException.class); + } + + /** + * Used to test a failure case - message text is ignored. + */ + public static class IgnoreMessageThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public IgnoreMessageThrowable(String message) { + super("bogus"); + } + } + + /** + * Used to test a failure case - cause is ignored. + */ + public static class IgnoreCauseThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public IgnoreCauseThrowable(Throwable cause) { + super(new Throwable("another cause")); + } + } + + /** + * Used to test a failure case - this has no standard constructors. The only constructor it has + * takes an "int", thus it is not one of the standard constructors. + */ + public static class NoConstructorsThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public NoConstructorsThrowable(int value) { + super(); + } + } + + /** + * Used to test a failure case - always suppresses. + */ + public static class AlwaysSuppressThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public AlwaysSuppressThrowable(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, true, writableStackTrace); + } + } + + /** + * Used to test a failure case - never suppresses. + */ + public static class NeverSuppressThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public NeverSuppressThrowable(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, false, writableStackTrace); + } + } + + /** + * Used to test a failure case - always allows stack writes. + */ + public static class AlwaysWritableThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public AlwaysWritableThrowable(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, true); + } + } + + /** + * Used to test a failure case - never allows stack writes. + */ + public static class NeverWritableThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public NeverWritableThrowable(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, false); + } + } + + /** + * Used to test a failure case - throws InstantiationException when constructed. + */ + public static class ThrowInstantiationException extends Throwable { + private static final long serialVersionUID = 1L; + + public ThrowInstantiationException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) throws InstantiationException { + + throw new InstantiationException(ThrowablesTester.EXPECTED_EXCEPTION_MSG); + } + } + + /** + * Used to test a simple success case. + */ + public static class SimpleThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public SimpleThrowable() { + super(); + } + + public SimpleThrowable(String message) { + super(message); + } + } + + /** + * Used to test the exhaustive success case. + */ + public static class StaticThrowable extends Throwable { + private static final long serialVersionUID = 1L; + + public StaticThrowable() { + super(); + } + + public StaticThrowable(String message) { + super(message); + } + + public StaticThrowable(Throwable cause) { + super(cause); + } + + public StaticThrowable(String message, Throwable cause) { + super(message, cause); + } + + public StaticThrowable(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + } } -- cgit 1.2.3-korg