ManagementExceptionHandlingTest.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:activemq-artemis 作者:
@Test
@BMRules(
        rules = {@BMRule(
                name = "checking ActiveMQServerControl methods",
                targetClass = "org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl",
                targetMethod = "route(org.apache.activemq.artemis.api.core.Message, boolean)",
                targetLocation = "ENTRY",
                action = "throw new org.apache.activemq.artemis.api.core.ActiveMQException(\"gotcha\")")})
public void testAddressControl() throws Exception {
   server.getActiveMQServerControl().createAddress("test.address", "ANYCAST");
   MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   System.out.println("server is " + mbs);
   ObjectName objectName = new ObjectName("org.apache.activemq.artemis:broker=\"localhost\",component=addresses,address=\"test.address\"");
   Object[] params = new Object[] {new HashMap(), 3, "aGVsbG8=", true, null, null};
   String[] signature = new String[] {"java.util.Map", "int", "java.lang.String", "boolean", "java.lang.String", "java.lang.String"};
   try {
      mbs.invoke(objectName, "sendMessage", params, signature);
      fail("test should have gotten an exception!");
   } catch (RuntimeMBeanException ex) {
      assertTrue(ex.getCause() instanceof IllegalStateException);
      IllegalStateException e = (IllegalStateException) ex.getCause();
      assertEquals("gotcha", e.getMessage());
   }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号