}
@Test
public void testMBeanInterface() throws IOException {
PermissionAdminMBean mBean = getMBean(PermissionAdminMBean.OBJECTNAME, PermissionAdminMBean.class);
PermissionAdmin permAdminService = getService(PermissionAdmin.class);
assertNotNull(permAdminService);
String[] serviceLocation = permAdminService.getLocations();
String[] mBeanLocations = mBean.listLocations();
assertArrayEquals(serviceLocation, mBeanLocations);
PermissionInfo defPerm = new PermissionInfo("AllPermission", "*", "*");
permAdminService.setDefaultPermissions(new PermissionInfo[]{defPerm});
PermissionInfo[] permissions = permAdminService.getDefaultPermissions();
assertNotNull(permissions);
String[] encoded = toEncodedPerm(permissions);
String[] mBeanDefPermissions = mBean.listDefaultPermissions();
assertArrayEquals(encoded, mBeanDefPermissions);
Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
assertNotNull(a);
String location = a.getLocation();
PermissionInfo bundleaPerm = new PermissionInfo("ServicePermission", "ServiceA", "GET");
mBean.setPermissions(location, new String[]{bundleaPerm.getEncoded()});
String[] serviceBundleaPerm = toEncodedPerm(permAdminService.getPermissions(location));
String[] mBeanBundleaPerm = mBean.getPermissions(location);
assertNotNull(mBeanBundleaPerm);
assertArrayEquals(serviceBundleaPerm, mBeanBundleaPerm);
PermissionInfo defaultPerm = new PermissionInfo("AllPermission", "*", "GET");
mBean.setDefaultPermissions(new String[]{defaultPerm.getEncoded()});
String[] serviceDefaultPerm = toEncodedPerm(permAdminService.getDefaultPermissions());
String[] mBeanDefaultPerm = mBean.listDefaultPermissions();
assertNotNull(mBeanDefaultPerm);
assertArrayEquals(serviceDefaultPerm, mBeanDefaultPerm);
}