コード例 #1
0
  @Test
  public void testSession() {
    String password = Credentials.getPassword();
    assertFalse("Password can be an empty string", password.equals(""));

    for (int i = 0; i < 10; i++) {
      Session session = context.getSession();

      assertTrue("Notes Session could not be retrieved at the iteration " + i, session.isOpen());
      assertFalse(
          "There's a problem with the Session at the iteration "
              + i
              + ". I can't retrieve the current user name.",
          session.getUserName().equals(""));

      context.closeSession();
    }
  }
コード例 #2
0
  @Test
  public void testCreateAndRemoveDatabase() {
    Session session = context.getSession();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    String name = "DB_" + sdf.format(new Date()) + ".nsf";
    Database db = session.createDatabase(context.getTestDatabaseServer(), name);
    assertTrue("There was a problem creating a new database.", db != null && db.isOpen());

    db.delete();

    assertFalse("There was a problem deleting the new database.", db.isOpen());

    db = session.getDatabase(context.getTestDatabaseServer(), name);

    assertFalse("The last database created was not deleted.", db.isOpen());

    context.closeSession();
  }
コード例 #3
0
  @Test
  public void testSessionObjectId() {
    Session session = context.getSession();

    assertTrue("Notes Session could not be retrieved", session.isOpen());

    String uuid1 = session.getObjectId();

    Database database =
        session.getDatabase(
            DefaultDatabase.class, context.getTestDatabaseServer(), context.getTestDatabasePath());

    String uuid2 = database.getSession().getObjectId();

    assertTrue(
        "It was retrieved differents UUID from the first session and the session object from the database",
        uuid1.equals(uuid2));

    context.closeSession();
  }