This closes #673

This commit is contained in:
Clebert Suconic 2016-07-27 12:55:52 -04:00
commit 53c56efca9
4 changed files with 20 additions and 22 deletions

View File

@ -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();

View File

@ -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]);

View File

@ -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));

View File

@ -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