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

Jean-Noël Rouvignac
01.42.2016 bd8fcc5a7de0344027c44027bbb70f58c0a472c5
ServerState: removed reload() (only used by tests)
2 files modified
61 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/common/ServerState.java 27 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/common/ServerStateTest.java 34 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/common/ServerState.java
@@ -12,7 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.replication.common;
@@ -41,7 +41,6 @@
 */
public class ServerState implements Iterable<CSN>
{
  /** Associates a serverId with a CSN. */
  private final ConcurrentMap<Integer, CSN> serverIdToCSN = new ConcurrentSkipListMap<>();
  /**
@@ -50,9 +49,7 @@
   */
  private volatile boolean saved = true;
  /**
   * Creates a new empty ServerState.
   */
  /** Creates a new empty ServerState. */
  public ServerState()
  {
    super();
@@ -161,22 +158,6 @@
  }
  /**
   * Replace the Server State with another ServerState.
   *
   * @param serverState The ServerState.
   *
   * @return a boolean indicating if the update was meaningful.
   */
  public boolean reload(ServerState serverState) {
    if (serverState == null) {
      return false;
    }
    clear();
    return update(serverState);
  }
  /**
   * Return a Set of String usable as a textual representation of
   * a Server state.
   * format : time seqnum id
@@ -214,8 +195,6 @@
    return values;
  }
  /**
   * Encodes this server state to the provided ASN1 writer.
   *
@@ -315,7 +294,6 @@
    return new HashMap<>(serverIdToCSN);
  }
  /** {@inheritDoc} */
  @Override
  public Iterator<CSN> iterator()
  {
@@ -436,5 +414,4 @@
  {
    return saved;
  }
}
opendj-server-legacy/src/test/java/org/opends/server/replication/common/ServerStateTest.java
@@ -12,7 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2013-2015 ForgeRock AS.
 * Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.replication.common;
@@ -25,16 +25,11 @@
import static org.testng.Assert.*;
/**
 * Test the ServerState.
 */
/** Test the ServerState. */
@SuppressWarnings("javadoc")
public class ServerStateTest extends ReplicationTestCase
{
  /**
   * Create CSN Data.
   */
  /** Create CSN Data. */
  @DataProvider(name = "csnData")
  public Object[][] createCSNData()
  {
@@ -44,9 +39,7 @@
    };
  }
  /**
   * Create a new ServerState object.
   */
  /** Create a new ServerState object. */
  @Test(dataProvider = "csnData")
  public void serverStateTest(CSN csn) throws Exception
  {
@@ -85,25 +78,6 @@
    assertTrue(stringRep.contains(csn3.toString()));
  }
  /**
   * Create a new ServerState object.
   */
  @Test(dataProvider = "csnData")
  public void serverStateReloadTest(CSN csn) throws Exception
  {
    CSN csn1 = new CSN(csn.getTime() + 1, csn.getSeqnum(), csn.getServerId());
    CSN csn3 = new CSN(csn1.getTime(), csn1.getSeqnum(), (csn1.getServerId() + 1));
    ServerState state1 = new ServerState();
    state1.update(csn1);
    state1.update(csn3);
    ServerState state2 = new ServerState();
    state2.reload(state1);
    assertEquals(state1.toString(), state2.toString()) ;
  }
  @Test
  public void testCover() throws Exception
  {