Package gabriel

Examples of gabriel.Principal


    super.setUp();
  }

  public void testDoNotModifyPrincipalsIfNotOwner() {
    Mock ownable = mock(Ownable.class);
    ownable.expects(once()).method("getOwner").will(returnValue(new Principal("NotOwner")));

    AccessContext context = new OwnerAccessContext((Ownable) ownable.proxy());
    Set principals = new HashSet();
    principals.add(new Principal("TestOwner"));
    context.modifyPrincipals(principals);
    assertTrue("Owner principal was not added to list.",
        !principals.contains(new Principal("Owner")));
  }
View Full Code Here


        !principals.contains(new Principal("Owner")));
  }

  public void testModifyPrincipalsIfOwner() {
    Mock ownable = mock(Ownable.class);
    ownable.expects(once()).method("getOwner").will(returnValue(new Principal("TestOwner")));


    AccessContext context = new OwnerAccessContext((Ownable) ownable.proxy());
    Set principals = new HashSet();
    principals.add(new Principal("TestOwner"));
    context.modifyPrincipals(principals);
    assertTrue("Owner principal was added to list.",
        principals.contains(new Principal("Owner")));
  }
View Full Code Here

    return new TestSuite(AclEntryTest.class);
  }

  protected void setUp() throws Exception {
    super.setUp();
    principal = new Principal("TestPrincipal");
    entry = new AclEntry(principal);
    permission = new Permission("TestPermission");
  }
View Full Code Here

    entry = new AclEntry(principal);
    permission = new Permission("TestPermission");
  }

  public void testPrincipalProperty() {
    Principal newPrincipal = new Principal("NewPrincipal");
    entry.setPrincipal(newPrincipal);
    assertEquals("New Principal was set.", newPrincipal, entry.getPrincipal());
  }
View Full Code Here

    return new TestSuite(AclTest.class);
  }

  protected void setUp() throws Exception {
    super.setUp();
    owner = new Principal("Owner");
    acl = new Acl(owner, "TestAcl");
  }
View Full Code Here

    assertEquals("Acl name is correct.", "TestAcl", acl.getName());
  }

  public void testSetNameWithWrongOwner() {
    try {
      acl.setName(new Principal("Owner"), "NewTestName");
      fail("Should raise an SecurityException");
    } catch (SecurityException e) {
    }
  }
View Full Code Here

    } catch (SecurityException e) {
    }
  }

  public void testAddAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertTrue("Acl contains added entry.", acl.entries().contains(entry));
  }
View Full Code Here

    acl.addEntry(owner, entry);
    assertTrue("Acl contains added entry.", acl.entries().contains(entry));
  }

  public void testAddOneAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertEquals("Acl contains one entry.", 1, acl.entries().size());
  }
View Full Code Here

    acl.addEntry(owner, entry);
    assertEquals("Acl contains one entry.", 1, acl.entries().size());
  }

  public void testAddEntryWithWrongOwner() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    try {
      acl.addEntry(new Principal("Owner"), entry);
      fail("Should raise an SecurityException");
    } catch (SecurityException e) {
    }
  }
View Full Code Here

    } catch (SecurityException e) {
    }
  }

  public void testRemoveAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertTrue("AclEntry says true to remove.", acl.removeEntry(owner, entry));
    assertTrue("Acl does not contain removed entry.", !acl.entries().contains(entry));
  }
View Full Code Here

TOP

Related Classes of gabriel.Principal

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.