コード例 #1
0
  @Test
  public void valueIsNull() throws Exception {
    final Exception expected = new NullPointerException();

    startupIndex();

    try {
      index.addEntry(2, null);
    } catch (Exception occurred) {
      assertExceptions(occurred, expected);
    }
    closeDatabase(index);
  }
コード例 #2
0
  @Test
  public void transactionManagerThrowsException() throws Exception {
    final Exception expected =
        new HGException(
            "Failed to add entry to index 'sample_index': java.lang.IllegalStateException: This exception is thrown by fake transaction manager.");

    startupIndexWithFakeTransactionManager();

    try {
      index.addEntry(2, "two");
    } catch (Exception occurred) {
      assertExceptions(occurred, expected);
    } finally {
      index.close();
    }
  }
コード例 #3
0
  @Test
  public void transactionManagerThrowsException() throws Exception {
    final Exception expected =
        new HGException(
            "Failed to lookup index 'sample_index': java.lang.IllegalStateException: Transaction manager is fake.");

    startupIndexWithFakeTransactionManager();

    try {
      indexImpl.findByValue("yellow");
    } catch (Exception occurred) {
      assertExceptions(occurred, expected);
    } finally {
      indexImpl.close();
    }
  }
コード例 #4
0
  @Test
  public void indexIsNotOpened() throws Exception {
    final Exception expected =
        new HGException(
            "Attempting to operate on index 'sample_index' while the index is being closed.");

    PowerMock.replayAll();
    index =
        new DefaultIndexImpl(
            INDEX_NAME, storage, transactionManager, keyConverter, valueConverter, comparator);

    try {
      index.addEntry(1, "one");
    } catch (Exception occurred) {
      assertExceptions(occurred, expected);
    }
  }
コード例 #5
0
  @Test
  public void indexIsNotOpened() throws Exception {
    final Exception expected =
        new HGException("Attempting to lookup index 'sample_index' while it is closed.");

    PowerMock.replayAll();
    indexImpl =
        new DefaultBiIndexImpl<Integer, String>(
            INDEX_NAME, storage, transactionManager, keyConverter, valueConverter, comparator);

    try {
      indexImpl.findByValue("some value");
    } catch (Exception occurred) {
      assertExceptions(occurred, expected);
    } finally {
      indexImpl.close();
    }
  }