コード例 #1
0
  @Test
  public void testGetXmlOneUserNoRoles() {
    DataSourceAclModel model = new DataSourceAclModel();
    model.addUser("testUser");
    String xml = model.toXml();

    assertTrue(
        xml.contains(
            "  <aces>    <recipient>testUser</recipient>    <recipientType>0</recipientType>"
                + "    <permissions>4</permissions>    <modifiable>false</modifiable>  </aces>"));
  }
コード例 #2
0
  @Test
  public void testGetXmlMultipleRolesNoUsers() {
    DataSourceAclModel model = new DataSourceAclModel();
    model.addRole("testRole");
    model.addRole("testRole2");
    String xml = model.toXml();

    assertTrue(
        xml.contains(
            "  <aces>    <recipient>testRole</recipient>    <recipientType>1</recipientType>"
                + "    <permissions>4</permissions>    <modifiable>false</modifiable>  </aces>"));
    assertTrue(
        xml.contains(
            "  <aces>    <recipient>testRole2</recipient>    <recipientType>1</recipientType>"
                + "    <permissions>4</permissions>    <modifiable>false</modifiable>  </aces>"));
  }
コード例 #3
0
 @Test
 public void testGetXmlNoUsersOrRoles() {
   DataSourceAclModel model = new DataSourceAclModel();
   assertNull(model.toXml());
 }
コード例 #4
0
  @Test
  public void testCreateAndAddUserRoles() {
    DataSourceAclModel model = new DataSourceAclModel();
    assertNull(model.getRoles());
    assertNull(model.getUsers());
    model.addRole("testRole");
    model.addUser("testUser");
    assertEquals("testRole", model.getRoles().get(0));
    assertEquals("testUser", model.getUsers().get(0));

    model.setUsers(Arrays.asList("otherTestUser"));
    model.setRoles(Arrays.asList("otherTestRole"));

    assertEquals("otherTestRole", model.getRoles().get(0));
    assertEquals("otherTestUser", model.getUsers().get(0));
  }