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) { for (Role role : roles) {
json.add(role.toJson()); json.add(role.toJson());
} }
return json.toString(); return json.build().toString();
} }
finally { finally {
blockOnIO(); blockOnIO();

View File

@ -136,7 +136,7 @@ public class AddressControlUsingCoreTest extends ManagementTestBase {
newRoles.add(role); newRoles.add(role);
server.getSecurityRepository().addMatch(address.toString(), newRoles); server.getSecurityRepository().addMatch(address.toString(), newRoles);
roles = (Object[]) proxy.retrieveAttributeValue("roles"); roles = (Object[]) proxy.retrieveAttributeValue("roles", String.class);
Assert.assertEquals(1, roles.length); Assert.assertEquals(1, roles.length);
Object[] r = (Object[]) roles[0]; Object[] r = (Object[]) roles[0];
Assert.assertEquals(role.getName(), r[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 { 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); ClientMessage m = session.createMessage(false);
ManagementHelper.putOperationInvocation(m, resourceName, operationName, args); ManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
ClientMessage reply = requestor.request(m); ClientMessage reply = requestor.request(m);
if (reply != null) { if (reply != null) {
if (ManagementHelper.hasOperationSucceeded(reply)) { if (ManagementHelper.hasOperationSucceeded(reply)) {
return ManagementHelper.getResult(reply); return ManagementHelper.getResult(reply, desiredType);
} }
else { else {
throw new Exception((String) ManagementHelper.getResult(reply)); throw new Exception((String) ManagementHelper.getResult(reply));

View File

@ -62,7 +62,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public long countMessages(final String filter) throws Exception { public long countMessages(final String filter) throws Exception {
return ((Number) proxy.invokeOperation("countMessages", filter)).longValue(); return (Long) proxy.invokeOperation(Long.class, "countMessages", filter);
} }
@Override @Override
@ -72,7 +72,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public int expireMessages(final String filter) throws Exception { public int expireMessages(final String filter) throws Exception {
return (Integer) proxy.invokeOperation("expireMessages", filter); return (Integer) proxy.invokeOperation(Integer.class, "expireMessages", filter);
} }
@Override @Override
@ -82,7 +82,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public int getConsumerCount() { public int getConsumerCount() {
return (Integer) proxy.retrieveAttributeValue("consumerCount"); return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class);
} }
@Override @Override
@ -92,7 +92,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public int getDeliveringCount() { public int getDeliveringCount() {
return (Integer) proxy.retrieveAttributeValue("deliveringCount"); return (Integer) proxy.retrieveAttributeValue("deliveringCount", Integer.class);
} }
@Override @Override
@ -107,22 +107,22 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public long getMessageCount() { public long getMessageCount() {
return ((Number) proxy.retrieveAttributeValue("messageCount")).longValue(); return (Long) proxy.retrieveAttributeValue("messageCount", Long.class);
} }
@Override @Override
public long getMessagesAdded() { public long getMessagesAdded() {
return (Integer) proxy.retrieveAttributeValue("messagesAdded"); return (Integer) proxy.retrieveAttributeValue("messagesAdded", Integer.class);
} }
@Override @Override
public long getMessagesAcknowledged() { public long getMessagesAcknowledged() {
return (Integer) proxy.retrieveAttributeValue("messagesAcknowledged"); return (Integer) proxy.retrieveAttributeValue("messagesAcknowledged", Integer.class);
} }
@Override @Override
public long getMessagesExpired() { public long getMessagesExpired() {
return ((Number) proxy.retrieveAttributeValue("messagesExpired")).longValue(); return (Long) proxy.retrieveAttributeValue("messagesExpired", Long.class);
} }
@Override @Override
@ -201,13 +201,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
*/ */
@Override @Override
public Long getFirstMessageAge() throws Exception { public Long getFirstMessageAge() throws Exception {
Object value = proxy.invokeOperation("getFirstMessageAge"); return (Long) proxy.invokeOperation(Long.class, "getFirstMessageAge");
if (value instanceof Integer) {
return ((Integer) value).longValue();
}
return (Long) value;
} }
@Override @Override
@ -247,7 +241,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public int moveMessages(final String filter, final String otherQueueName) throws Exception { 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 @Override
@ -284,17 +278,17 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
@Override @Override
public int retryMessages() throws Exception { public int retryMessages() throws Exception {
return (Integer) proxy.invokeOperation("retryMessages"); return (Integer) proxy.invokeOperation(Integer.class, "retryMessages");
} }
@Override @Override
public int removeMessages(final String filter) throws Exception { public int removeMessages(final String filter) throws Exception {
return (Integer) proxy.invokeOperation("removeMessages", filter); return (Integer) proxy.invokeOperation(Integer.class, "removeMessages", filter);
} }
@Override @Override
public int removeMessages(final int limit, final String filter) throws Exception { 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 @Override