Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.Group


        }
        User user = getUser(username);
        if (user == null) {
            throw new UserNotFoundException(username);
        }
        Group group = getGroup(user);
        group.removeMember(user);
        m_useradmin.removeRole(user.getName());
    }
View Full Code Here


    private volatile UserAdmin m_userAdmin;

    public void GetUserBroken() {
        User newUser = null;
        Role newRole = m_userAdmin.createRole((String) "Testuser", Role.USER);
        Group group = (Group) m_userAdmin.getRole(TEST_GROUP);
        if (newRole != null && group != null) {
            newUser = (User) newRole;
            newUser.getProperties().put("username", "u");
            newUser.getCredentials().put("password", "p");
            group.addMember(newUser);
        }
        assertEquals("Testuser", m_userEditor.getUser("u").getName());
    }
View Full Code Here

    public void testGetGroupByUser() {
        Role newRole = m_userAdmin.createRole((String) "Testuser", Role.USER);
        assertNotNull(newRole);

        Group group = (Group) m_userAdmin.getRole(TEST_GROUP);
        assertNotNull(group);

        User newUser = (User) newRole;
        newUser.getProperties().put("username", "u");
        newUser.getCredentials().put("password", "p");
        group.addMember(newUser);

        Group userGroup = m_userEditor.getGroup(newUser);
        assertNotNull(userGroup);
        assertEquals(group.getName(), userGroup.getName());
    }
View Full Code Here

        assertEquals(1, m_userEditor.getData().size());
    }

    @Override
    protected void configureAdditionalServices() throws Exception {
        Group group = (Group) m_userAdmin.createRole(TEST_GROUP, Role.GROUP);
        group.getProperties().put("type", "userGroup");

        User user = (User) m_userAdmin.createRole("TestUser", Role.USER);
        user.getProperties().put("email", "testUser@apache.org");
        user.getCredentials().put("password", "swordfish");
        user.getCredentials().put("certificate", "42".getBytes());

        group.addMember(user);
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testAddMember() throws IOException {
        Group group1 = Mockito.mock(Group.class);
        User user1 = Mockito.mock(User.class);
        Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
        Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.addMember(user1)).thenReturn(true);
        boolean isAdded = mbean.addMember("group1", "user1");
        Assert.assertTrue(isAdded);
        Mockito.verify(group1).addMember(user1);
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testAddRequiredMember() throws IOException {
        Group group1 = Mockito.mock(Group.class);
        User user1 = Mockito.mock(User.class);
        Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
        Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.addRequiredMember(user1)).thenReturn(true);
        boolean isAdded = mbean.addRequiredMember("group1", "user1");
        Assert.assertTrue(isAdded);
        Mockito.verify(group1).addRequiredMember(user1);
    }
View Full Code Here

     *
     * @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);
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testGetGroups() throws Exception {
        Group group1 = Mockito.mock(Group.class);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.getName()).thenReturn("group1");
        Mockito.when(userAdmin.getRoles("name=group1")).thenReturn(new Role[] { group1 });
        String[] groups = mbean.getGroups("name=group1");
        Assert.assertArrayEquals(new String[] { "group1" }, groups);
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testGetMembers() throws IOException {
        Group group1 = Mockito.mock(Group.class);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.getName()).thenReturn("group1");
        User user1 = Mockito.mock(Group.class);
        Mockito.when(user1.getName()).thenReturn("user1");
        Mockito.when(group1.getMembers()).thenReturn(new Role[] { user1 });
        Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
        String[] members = mbean.getMembers("group1");
        Assert.assertArrayEquals(new String[] { "user1" }, members);
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testGetRequiredMembers() throws IOException {
        Group group1 = Mockito.mock(Group.class);
        Mockito.when(group1.getType()).thenReturn(Role.GROUP);
        Mockito.when(group1.getName()).thenReturn("group1");
        User user1 = Mockito.mock(Group.class);
        Mockito.when(user1.getName()).thenReturn("user1");
        Mockito.when(group1.getRequiredMembers()).thenReturn(new Role[] { user1 });
        Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
        String[] members = mbean.getRequiredMembers("group1");
        Assert.assertArrayEquals(new String[] { "user1" }, members);
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.useradmin.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.