コード例 #1
0
ファイル: FileManagerTest.java プロジェクト: nologic/nabs
  protected void tearDown() throws IOException, DatabaseException {

    if (fileManager != null) {
      fileManager.clear();
      fileManager.close();
    }
    TestUtils.removeFiles("TearDown", envHome, FileManager.JE_SUFFIX);
  }
コード例 #2
0
ファイル: FileManagerTest.java プロジェクト: nologic/nabs
  public void testFlipFile() throws Throwable {

    /*
     * The setUp() method opens a standalone FileManager, but in this test
     * case we need a regular Environment.  On Windows, we can't lock the
     * file range twice in FileManager.lockEnvironment, so we must close
     * the standalone FileManager here before opening a regular
     * environment.
     */
    fileManager.clear();
    fileManager.close();
    fileManager = null;

    EnvironmentConfig envConfig = TestUtils.initEnvConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(true);
    Environment env = new Environment(envHome, envConfig);
    EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
    FileManager fileManager = envImpl.getFileManager();

    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setAllowCreate(true);
    Database exampleDb = env.openDatabase(null, "simpleDb", dbConfig);

    assertEquals("Should have 0 as current file", 0L, fileManager.getCurrentFileNum());
    long flipLsn = envImpl.forceLogFileFlip();
    assertEquals("LSN should be 1 post-flip", 1L, DbLsn.getFileNumber(flipLsn));
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    key.setData("key".getBytes());
    data.setData("data".getBytes());
    exampleDb.put(null, key, data);
    assertEquals("Should have 1 as last file", 1L, fileManager.getCurrentFileNum());
    exampleDb.close();
    env.close();
  }