use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testAdd2.
@Test
public void testAdd2() {
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
Assert.assertTrue("adding alice", m_group.add(u1));
Assert.assertTrue("adding bob", m_group.add(u2));
Assert.assertTrue("Alice", m_group.isMember(u1));
Assert.assertTrue("Bob", m_group.isMember(u2));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testRemove.
@Test
public void testRemove() {
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
Principal u3 = new WikiPrincipal("Bob");
m_group.add(u1);
m_group.add(u2);
m_group.remove(u3);
Assert.assertTrue("Alice", m_group.isMember(u1));
Assert.assertFalse("Bob", m_group.isMember(u2));
Assert.assertFalse("Bob 2", m_group.isMember(u3));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testAdd3.
/**
* Check that different objects match as well.
*/
@Test
public void testAdd3() {
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
Principal u3 = new WikiPrincipal("Bob");
Assert.assertTrue("adding alice", m_group.add(u1));
Assert.assertTrue("adding bob", m_group.add(u2));
Assert.assertTrue("Alice", m_group.isMember(u1));
Assert.assertTrue("Bob", m_group.isMember(u3));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testAdd1.
@Test
public void testAdd1() {
Principal u1 = new WikiPrincipal("Alice");
m_group.add(u1);
Assert.assertTrue(m_group.isMember(u1));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class JDBCGroupDatabaseTest method testResave.
@Test
public void testResave() throws Exception {
// Create a new group with random name & 3 members
String name = "TestGroup" + String.valueOf(System.currentTimeMillis());
Group group = new Group(name, m_wiki);
Principal al = new WikiPrincipal("Al");
Principal bob = new WikiPrincipal("Bob");
Principal cookie = new WikiPrincipal("Cookie");
group.add(al);
group.add(bob);
group.add(cookie);
m_db.save(group, new WikiPrincipal("Tester"));
// Make sure the profile saved successfully
group = backendGroup(name);
Assert.assertEquals(name, group.getName());
// Modify the members by adding the group; re-add Al while we're at it
Principal dave = new WikiPrincipal("Dave");
group.add(al);
group.add(dave);
m_db.save(group, new WikiPrincipal("SecondTester"));
// We should see 4 members and new timestamp info
Principal[] members = group.members();
Assert.assertEquals(4, members.length);
Assert.assertNotNull(group.getCreator());
Assert.assertEquals("Tester", group.getCreator());
Assert.assertNotNull(group.getCreated());
Assert.assertNotNull(group.getModifier());
Assert.assertEquals("SecondTester", group.getModifier());
Assert.assertNotNull(group.getLastModified());
// Check the back-end; We should see the same thing
group = backendGroup(name);
members = group.members();
Assert.assertEquals(4, members.length);
Assert.assertNotNull(group.getCreator());
Assert.assertEquals("Tester", group.getCreator());
Assert.assertNotNull(group.getCreated());
Assert.assertNotNull(group.getModifier());
Assert.assertEquals("SecondTester", group.getModifier());
Assert.assertNotNull(group.getLastModified());
// Remove the group
m_db.delete(group);
}
Aggregations