PermissionAdmin implements PermissionAdminMBean { public void setPermissions(String location, String[] encodedPermissions) throws IOException { if (location == null) { throw new IOException("Location cannot be null"); } PermissionInfo[] permissions = toPermissionInfo(encodedPermissions); permAdmin.setPermissions(location, permissions); } PermissionAdmin(org.osgi.service.permissionadmin.PermissionAdmin permAdmin); String[] getPermissions(String location); String[] listDefaultPermissions(); String[] listLocations(); void setDefaultPermissions(String[] encodedPermissions); void setPermissions(String location, String[] encodedPermissions);  }
@Test public void testSetPermissions() throws IOException { PermissionInfo info1 = new PermissionInfo("Admin", "test", "set"); PermissionInfo info2 = new PermissionInfo("Admin", "test2", "set"); PermissionInfo[] permInfos = new PermissionInfo[] { info1, info2 }; String[] encodedPermissions = new String[2]; int i = 0; for (PermissionInfo info : permInfos) { encodedPermissions[i++] = info.getEncoded(); } mbean.setPermissions("test", encodedPermissions); Mockito.verify(permAdmin).setPermissions("test", permInfos); }