Exemple #1
0
 /** @see org.melati.poem.CachedCount#CachedCount */
 public void testCachedCountPersistentBooleanBoolean() {
   int queries = getDb().getQueryCount();
   User u = (User) getDb().getUserTable().newPersistent();
   u.setName("guest");
   CachedCount cc = new CachedCount(u, false, true);
   int queries2 = getDb().getQueryCount();
   assertEquals(queries, queries2);
   assertEquals(1, cc.count());
   int queries3 = getDb().getQueryCount();
   assertEquals(queries2 + 1, queries3);
   assertEquals(1, cc.count());
   int queries4 = getDb().getQueryCount();
   assertEquals(queries3, queries4);
 }
Exemple #2
0
  /** @see org.melati.poem.Database#hasCapability(User, Capability) */
  public void testHasCapability() {
    assertTrue(
        getDb()
            .hasCapability(getDb().getUserTable().administratorUser(), getDb().getCanAdminister()));
    assertTrue(getDb().hasCapability(getDb().getUserTable().guestUser(), null));

    getDb().setCanAdminister();
    // This is only true for a db that that never had its administration set
    assertFalse(
        getDb().hasCapability(getDb().getUserTable().guestUser(), getDb().getCanAdminister()));
    User u = (User) getDb().getUserTable().newPersistent();
    u.setName("test");
    u.setLogin("test");
    u.setPassword("test");
    u.makePersistent();
    assertFalse(getDb().hasCapability(u, getDb().getCanAdminister()));
    u.delete();
  }
Exemple #3
0
 /** @see org.melati.poem.UserTable#administratorUser() */
 public final void testAdministratorUser() {
   User u = getDb().getUserTable().administratorUser();
   assertEquals(u.getPassword(), "FIXME");
 }
Exemple #4
0
 /** @see org.melati.poem.UserTable#guestUser() */
 public final void testGuestUser() {
   User u = getDb().getUserTable().guestUser();
   assertEquals(u.getLogin(), "_guest_");
 }