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%2Fjmx%2FObjectNameUtilTest.java;h=e69ff921ccc4975994d8c542a738d84f33f96c34;hb=e316a0ef36279a72767703d190f38a39d7d49395;hp=d3d8469dfba7b0409a0c7738be2b43ca76f4a57b;hpb=596901e767e8c988dbb88d4efb3f64c0d6676b54;p=controller.git diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java index d3d8469dfb..e69ff921cc 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java @@ -7,16 +7,15 @@ */ package org.opendaylight.controller.config.api.jmx; -import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - +import static org.junit.Assert.fail; import com.google.common.base.Throwables; import com.google.common.collect.Maps; +import java.util.HashMap; import java.util.Map; import javax.management.ObjectName; -import junit.framework.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.config.api.ModuleIdentifier; @@ -82,7 +81,7 @@ public class ObjectNameUtilTest { assertPattern(on, pattern); } - private void assertPattern(ObjectName test, ObjectName pattern) { + private void assertPattern(final ObjectName test, final ObjectName pattern) { assertTrue(pattern.isPattern()); assertTrue(pattern.apply(test)); } @@ -148,15 +147,26 @@ public class ObjectNameUtilTest { }, IllegalArgumentException.class); } - private void assertFailure(Runnable test, Class ex) { + private void assertFailure(final Runnable test, final Class ex) { try { test.run(); } catch(Exception e) { - Assert.assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e), + assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e), e.getClass().isAssignableFrom(ex)); return; } fail(test + " should have failed on " + ex); } + + @Test(expected = IllegalArgumentException.class) + public void testCreateON() throws Exception { + ObjectNameUtil.createON(">}+!#"); + } + + @Test(expected = IllegalArgumentException.class) + public void testCreateON2() throws Exception { + Map map = new HashMap<>(); + ObjectNameUtil.createON(">}+!#", map); + } }