mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
05.41.2014 bf3c24657c1be6d611d01f052e8277bb0b6b2f4e
Avoid unnecessarily creating objects.
3 files modified
23 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/jeb/Index.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVIndex.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java 19 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/Index.java
@@ -152,7 +152,7 @@
    this.state = state;
    this.trusted = state.getIndexTrustState(null, this);
    if(!trusted && entryContainer.getHighestEntryID().equals(new EntryID(0)))
    if (!trusted && entryContainer.getHighestEntryID().longValue() == 0)
    {
      // If there are no entries in the entry container then there
      // is no reason why this index can't be upgraded to trusted.
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVIndex.java
@@ -194,7 +194,7 @@
    this.state = state;
    this.trusted = state.getIndexTrustState(null, this);
    if(!trusted && entryContainer.getHighestEntryID().equals(new EntryID(0)))
    if (!trusted && entryContainer.getHighestEntryID().longValue() == 0)
    {
      // If there are no entries in the entry container then there
      // is no reason why this vlvIndex can't be upgraded to trusted.
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java
@@ -36,12 +36,13 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.*;
import static org.assertj.core.api.Assertions.*;
/**
 * EntryContainer tester.
 * Test class for EntryContainer.
 */
public class TestEntryContainer extends JebTestCase {
  private static final String backendID = "userRoot";
  private BackendImpl be;
@@ -112,7 +113,7 @@
  private List<Entry> entryList;
  private long calculatedHighestID = 0;
  private long calculatedHighestID;
  /**
   * Set up the environment for performing the tests in this suite.
@@ -150,8 +151,8 @@
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test()
  public void test1() throws Exception {
  @Test
  public void testGetHighestEntryID() throws Exception {
    TestCaseUtils.clearJEBackend(backendID);
    be = (BackendImpl) DirectoryServer.getBackend(backendID);
    RootContainer rootContainer = be.getRootContainer();
@@ -162,15 +163,15 @@
    try
    {
      EntryID actualHighestID = entryContainer.getHighestEntryID();
      assertTrue(actualHighestID.equals(new EntryID(0)));
      assertThat(actualHighestID.longValue()).isEqualTo(0);
      for (Entry entry : entryList) {
        entryContainer.addEntry(entry, null);
        Entry afterEntry = entryContainer.getEntry(entry.getName());
        assertTrue(afterEntry != null);
        final Entry afterEntry = entryContainer.getEntry(entry.getName());
        assertThat(afterEntry).as("Entry should have been added").isNotNull();
      }
      actualHighestID = entryContainer.getHighestEntryID();
      assertTrue(actualHighestID.equals(new EntryID(calculatedHighestID)));
      assertThat(actualHighestID.longValue()).isEqualTo(calculatedHighestID);
    }
    finally
    {