### Question:
DestinationActionPermissionResolver implements ActionPermissionResolver { @Override public Collection<Permission> getPermissions(Action action) { if (!(action instanceof DestinationAction)) { throw new IllegalArgumentException("Action argument must be a " + DestinationAction.class.getName() + " instance."); } DestinationAction da = (DestinationAction) action; return getPermissions(da); }  String getPermissionStringPrefix(); void setPermissionStringPrefix(String permissionStringPrefix); boolean isPermissionStringCaseSensitive(); void setPermissionStringCaseSensitive(boolean permissionStringCaseSensitive); @Override Collection<Permission> getPermissions(Action action);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testGetPermissionsWithNonDestinationActionInstance() { resolver.getPermissions(new Action() { @Override public String toString() { return "foo"; } }); }
@Test(expected = IllegalArgumentException.class) public void testGetPermissionsWithNullArgument() { resolver.getPermissions((Action)null); }
@Test public void testGetPermissionsWithTopic() { ActiveMQTopic topic = new ActiveMQTopic("myTopic"); DestinationAction action = new DestinationAction(new ConnectionContext(), topic, "create"); Collection<Permission> perms = resolver.getPermissions(action); assertPermString("topic:myTopic:create", perms); }
@Test public void testGetPermissionsWithTemporaryTopic() { ActiveMQTempTopic topic = new ActiveMQTempTopic("myTempTopic"); DestinationAction action = new DestinationAction(new ConnectionContext(), topic, "remove"); Collection<Permission> perms = resolver.getPermissions(action); assertPermString("temp-topic:myTempTopic:remove", perms); }
@Test public void testGetPermissionsWithQueue() { ActiveMQQueue queue = new ActiveMQQueue("myQueue"); DestinationAction action = new DestinationAction(new ConnectionContext(), queue, "write"); Collection<Permission> perms = resolver.getPermissions(action); assertPermString("queue:myQueue:write", perms); }
@Test public void testGetPermissionsWithTemporaryQueue() { ActiveMQTempQueue queue = new ActiveMQTempQueue("myTempQueue"); DestinationAction action = new DestinationAction(new ConnectionContext(), queue, "read"); Collection<Permission> perms = resolver.getPermissions(action); assertPermString("temp-queue:myTempQueue:read", perms); }