use of javax.management.openmbean.CompositeData in project aries by apache.
the class FrameworkTest method testUninstallBundles.
@Test
public void testUninstallBundles() throws Exception {
Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(context.getBundle(5)).thenReturn(bundle);
CompositeData data = mbean.uninstallBundles(new long[] { 5 });
Mockito.verify(bundle).uninstall();
BatchActionResult batch = BatchActionResult.from(data);
Assert.assertEquals(5, batch.getCompleted()[0]);
Assert.assertTrue(batch.isSuccess());
Assert.assertNull(batch.getError());
Assert.assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.uninstallBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
Assert.assertNull(batch2.getCompleted());
Assert.assertFalse(batch2.isSuccess());
Assert.assertNotNull(batch2.getError());
Assert.assertNull(batch2.getRemainingItems());
}
use of javax.management.openmbean.CompositeData in project aries by apache.
the class UserAdminTest method testGetGroup.
/**
* Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getGroup(java.lang.String)}.
*
* @throws IOException
*/
@Test
public void testGetGroup() throws IOException {
Group group1 = Mockito.mock(Group.class);
Mockito.when(group1.getType()).thenReturn(Role.GROUP);
Mockito.when(group1.getName()).thenReturn("group1");
Role role1 = Mockito.mock(Role.class);
Mockito.when(role1.getName()).thenReturn("role1");
Role role2 = Mockito.mock(Role.class);
Mockito.when(role2.getName()).thenReturn("role2");
Mockito.when(group1.getRequiredMembers()).thenReturn(new Role[] { role1 });
Mockito.when(group1.getMembers()).thenReturn(new Role[] { role2 });
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(group1);
CompositeData data = mbean.getGroup("group1");
Assert.assertNotNull(data);
GroupData group = GroupData.from(data);
Assert.assertNotNull(group);
Assert.assertEquals("group1", group.getName());
Assert.assertEquals(Role.GROUP, group.getType());
Assert.assertArrayEquals(new String[] { "role2" }, group.getMembers());
Assert.assertArrayEquals(new String[] { "role1" }, group.getRequiredMembers());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
use of javax.management.openmbean.CompositeData in project aries by apache.
the class UserAdminTest method testGetUser.
/**
* Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getUser(java.lang.String)}.
*
* @throws IOException
*/
@Test
public void testGetUser() throws IOException {
User user1 = Mockito.mock(User.class);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
CompositeData data = mbean.getUser("user1");
Assert.assertNotNull(data);
UserData user = UserData.from(data);
Assert.assertNotNull(user);
Assert.assertEquals("user1", user.getName());
Assert.assertEquals(Role.USER, user.getType());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
use of javax.management.openmbean.CompositeData in project aries by apache.
the class FrameworkTest method testStartBundles.
@Test
public void testStartBundles() throws Exception {
Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(context.getBundle(5)).thenReturn(bundle);
CompositeData data = mbean.startBundles(new long[] { 5 });
Mockito.verify(bundle).start();
BatchActionResult batch = BatchActionResult.from(data);
Assert.assertEquals(5, batch.getCompleted()[0]);
Assert.assertTrue(batch.isSuccess());
Assert.assertNull(batch.getError());
Assert.assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.startBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
Assert.assertNull(batch2.getCompleted());
Assert.assertFalse(batch2.isSuccess());
Assert.assertNotNull(batch2.getError());
Assert.assertNull(batch2.getRemainingItems());
}
use of javax.management.openmbean.CompositeData in project aries by apache.
the class FrameworkTest method testSetBundleStartLevels.
@Test
public void testSetBundleStartLevels() throws IOException {
Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(context.getBundle(2)).thenReturn(bundle);
CompositeData data = mbean.setBundleStartLevels(new long[] { 2 }, new int[] { 2 });
Mockito.verify(startLevel).setBundleStartLevel(bundle, 2);
BatchActionResult batch = BatchActionResult.from(data);
Assert.assertEquals(2, batch.getCompleted()[0]);
Assert.assertTrue(batch.isSuccess());
Assert.assertNull(batch.getError());
Assert.assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.setBundleStartLevels(new long[] { 2 }, new int[] { 2, 4 });
BatchActionResult batch2 = BatchActionResult.from(data2);
Assert.assertNull(batch2.getCompleted());
Assert.assertFalse(batch2.isSuccess());
Assert.assertNotNull(batch2.getError());
Assert.assertNull(batch2.getRemainingItems());
}
Aggregations