X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2FValidationExceptionTest.java;h=bc9a8c71ba0f6605b19785b50dc89447825d2a31;hb=4497e2212e73e13356447b9644bbdc935411949a;hp=1809e458606bd928d7e68ffe83bef287e1736be2;hpb=596901e767e8c988dbb88d4efb3f64c0d6676b54;p=controller.git diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java index 1809e45860..bc9a8c71ba 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java @@ -1,20 +1,21 @@ package org.opendaylight.controller.config.api; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.junit.matchers.JUnitMatchers.containsString; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import com.google.common.collect.Lists; import java.util.Map; +import org.junit.Assert; import org.junit.Test; public class ValidationExceptionTest { - private String instance = "instance"; + private final String instance = "instance"; private final ModuleIdentifier mi = new ModuleIdentifier("module", instance); - private String instance2 = "instance2"; + private final String instance2 = "instance2"; private final ModuleIdentifier mi2 = new ModuleIdentifier("module", instance2); private final String message = "ex message"; private final Exception e = new IllegalStateException(message); @@ -51,4 +52,107 @@ public class ValidationExceptionTest { } fail("Duplicate exception should have failed"); } + + @Test + public void testGetTrace() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + exp.setTrace("trace"); + Assert.assertEquals(exp.getTrace(), "trace"); + } + + @Test + public void testSetMessage() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + exp.setMessage("message"); + Assert.assertEquals(exp.getMessage(), "message"); + } + + @Test + public void testHashCode() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + Assert.assertEquals(exp.hashCode(), new ValidationException.ExceptionMessageWithStackTrace().hashCode()); + } + + @Test + public void testExceptionMessageWithStackTraceConstructor() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertEquals(exp, exp); + } + + @Test + public void testExceptionMessageWithStackTraceConstructor2() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertNotEquals(exp, null); + } + + @Test + public void testExceptionMessageWithStackTraceConstructor3() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertNotEquals(exp, new Exception()); + } + + @Test + public void testExceptionMessageWithStackTraceConstructor4() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertEquals(exp, new ValidationException.ExceptionMessageWithStackTrace("string1", "string2")); + } + + @Test + public void testEqual() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + Assert.assertNotEquals(exp, exp2); + } + + @Test + public void testEqual2() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace("different", "string2"); + Assert.assertNotEquals(exp, exp2); + } + + + @Test + public void testEqual3() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace("string1", null); + Assert.assertNotEquals(exp, exp2); + } + + @Test + public void testEqual4() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace("string1", "different"); + Assert.assertNotEquals(exp, exp2); + } + + @Test + public void testEqual5() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertNotEquals(exp, exp2); + } + + @Test + public void testEqual6() throws Exception { + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace("string1", null); + ValidationException.ExceptionMessageWithStackTrace exp2 = + new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + Assert.assertNotEquals(exp, exp2); + } } \ No newline at end of file