diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java index 9ea40819b2..739f4d1ee6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java @@ -146,7 +146,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro for (Role role : roles) { json.add(role.toJson()); } - return json.toString(); + return json.build().toString(); } finally { blockOnIO(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java index 83aeb1c9f9..9ccb832c22 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java @@ -136,7 +136,7 @@ public class AddressControlUsingCoreTest extends ManagementTestBase { newRoles.add(role); server.getSecurityRepository().addMatch(address.toString(), newRoles); - roles = (Object[]) proxy.retrieveAttributeValue("roles"); + roles = (Object[]) proxy.retrieveAttributeValue("roles", String.class); Assert.assertEquals(1, roles.length); Object[] r = (Object[]) roles[0]; Assert.assertEquals(role.getName(), r[0]); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java index e9168a25f0..c519b7f645 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java @@ -73,12 +73,16 @@ public class CoreMessagingProxy { } public Object invokeOperation(final String operationName, final Object... args) throws Exception { + return invokeOperation(null, operationName, args); + } + + public Object invokeOperation(final Class desiredType, final String operationName, final Object... args) throws Exception { ClientMessage m = session.createMessage(false); ManagementHelper.putOperationInvocation(m, resourceName, operationName, args); ClientMessage reply = requestor.request(m); if (reply != null) { if (ManagementHelper.hasOperationSucceeded(reply)) { - return ManagementHelper.getResult(reply); + return ManagementHelper.getResult(reply, desiredType); } else { throw new Exception((String) ManagementHelper.getResult(reply)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java index f27eaf1328..230941fce6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java @@ -62,7 +62,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public long countMessages(final String filter) throws Exception { - return ((Number) proxy.invokeOperation("countMessages", filter)).longValue(); + return (Long) proxy.invokeOperation(Long.class, "countMessages", filter); } @Override @@ -72,7 +72,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public int expireMessages(final String filter) throws Exception { - return (Integer) proxy.invokeOperation("expireMessages", filter); + return (Integer) proxy.invokeOperation(Integer.class, "expireMessages", filter); } @Override @@ -82,7 +82,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public int getConsumerCount() { - return (Integer) proxy.retrieveAttributeValue("consumerCount"); + return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class); } @Override @@ -92,7 +92,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public int getDeliveringCount() { - return (Integer) proxy.retrieveAttributeValue("deliveringCount"); + return (Integer) proxy.retrieveAttributeValue("deliveringCount", Integer.class); } @Override @@ -107,22 +107,22 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public long getMessageCount() { - return ((Number) proxy.retrieveAttributeValue("messageCount")).longValue(); + return (Long) proxy.retrieveAttributeValue("messageCount", Long.class); } @Override public long getMessagesAdded() { - return (Integer) proxy.retrieveAttributeValue("messagesAdded"); + return (Integer) proxy.retrieveAttributeValue("messagesAdded", Integer.class); } @Override public long getMessagesAcknowledged() { - return (Integer) proxy.retrieveAttributeValue("messagesAcknowledged"); + return (Integer) proxy.retrieveAttributeValue("messagesAcknowledged", Integer.class); } @Override public long getMessagesExpired() { - return ((Number) proxy.retrieveAttributeValue("messagesExpired")).longValue(); + return (Long) proxy.retrieveAttributeValue("messagesExpired", Long.class); } @Override @@ -201,13 +201,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { */ @Override public Long getFirstMessageAge() throws Exception { - Object value = proxy.invokeOperation("getFirstMessageAge"); - - if (value instanceof Integer) { - return ((Integer) value).longValue(); - } - - return (Long) value; + return (Long) proxy.invokeOperation(Long.class, "getFirstMessageAge"); } @Override @@ -247,7 +241,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public int moveMessages(final String filter, final String otherQueueName) throws Exception { - return (Integer) proxy.invokeOperation("moveMessages", filter, otherQueueName); + return (Integer) proxy.invokeOperation(Integer.class, "moveMessages", filter, otherQueueName); } @Override @@ -284,17 +278,17 @@ public class QueueControlUsingCoreTest extends QueueControlTest { @Override public int retryMessages() throws Exception { - return (Integer) proxy.invokeOperation("retryMessages"); + return (Integer) proxy.invokeOperation(Integer.class, "retryMessages"); } @Override public int removeMessages(final String filter) throws Exception { - return (Integer) proxy.invokeOperation("removeMessages", filter); + return (Integer) proxy.invokeOperation(Integer.class, "removeMessages", filter); } @Override public int removeMessages(final int limit, final String filter) throws Exception { - return (Integer) proxy.invokeOperation("removeMessages", limit, filter); + return (Integer) proxy.invokeOperation(Integer.class, "removeMessages", limit, filter); } @Override