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

matthew_swift
06.32.2006 88992b173c274afd27c4bfaddeeeeeea620b1f92
Add remaining ChangeRecordEntry test classes.

Perform minor clean-up on tested classes:

* change constructors in abstract ChangeRecordEntry to protected
* change non-overridable methods in ChangeRecordEntry to final
* make classes derived from ChangeRecordEntry final
* cleanup import declarations
* rename method getNewSuperiorRDN in ModifyDNChangeRecordEntry
to getNewSuperiorDN and fix references.

Reviewed by: Daniel.
4 files added
7 files modified
711 ■■■■■ changed files
opends/src/server/org/opends/server/tools/LDAPModify.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/AddChangeRecordEntry.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/ChangeRecordEntry.java 17 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/DeleteChangeRecordEntry.java 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/ModifyChangeRecordEntry.java 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/ModifyDNChangeRecordEntry.java 21 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestAddChangeRecordEntry.java 21 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestChangeRecordEntry.java 152 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestDeleteChangeRecordEntry.java 145 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestModifyChangeRecordEntry.java 146 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestModifyDNChangeRecordEntry.java 181 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -265,13 +265,13 @@
          operationType = "MODIFY DN";
          ModifyDNChangeRecordEntry modDNEntry =
            (ModifyDNChangeRecordEntry) entry;
          if(modDNEntry.getNewSuperiorRDN() != null)
          if(modDNEntry.getNewSuperiorDN() != null)
          {
            protocolOp = new ModifyDNRequestProtocolOp(asn1OctetStr,
                 new ASN1OctetString(modDNEntry.getNewRDN().toString()),
                 modDNEntry.deleteOldRDN(),
                 new ASN1OctetString(
                          modDNEntry.getNewSuperiorRDN().toString()));
                          modDNEntry.getNewSuperiorDN().toString()));
          } else
          {
            protocolOp = new ModifyDNRequestProtocolOp(asn1OctetStr,
opends/src/server/org/opends/server/util/AddChangeRecordEntry.java
@@ -46,7 +46,7 @@
 * an add operation.  It includes a DN and a set of attributes, as well as
 * methods to decode the entry.
 */
public class AddChangeRecordEntry extends ChangeRecordEntry
public final class AddChangeRecordEntry extends ChangeRecordEntry
{
  /**
   * The fully-qualified name of this class for debugging purposes.
opends/src/server/org/opends/server/util/ChangeRecordEntry.java
@@ -28,18 +28,15 @@
import static org.opends.server.loggers.Debug.debugConstructor;
import static org.opends.server.loggers.Debug.debugEnter;
import java.util.ArrayList;
import java.util.LinkedList;
import org.opends.server.types.DN;
import org.opends.server.types.RDN;
import static org.opends.server.loggers.Debug.*;
import static org.opends.server.messages.CoreMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -66,7 +63,7 @@
   * @param  dn      The distinguished name for this entry.
   * @param  reader  The LDIF reader.
   */
  public ChangeRecordEntry(DN dn, LDIFReader reader)
  protected ChangeRecordEntry(DN dn, LDIFReader reader)
  {
    assert debugConstructor(CLASS_NAME, String.valueOf(dn),
                            String.valueOf(reader));
@@ -89,7 +86,7 @@
   *
   * @param  dn  The distinguished name for this change record entry.
   */
  public ChangeRecordEntry(DN dn)
  protected ChangeRecordEntry(DN dn)
  {
    assert debugConstructor(CLASS_NAME, String.valueOf(dn));
@@ -109,7 +106,7 @@
   *
   * @return  The distinguished name for this entry.
   */
  public DN getDN()
  public final DN getDN()
  {
    assert debugEnter(CLASS_NAME, "getDN");
@@ -123,7 +120,7 @@
   *
   * @param  dn  The distinguished name for this entry.
   */
  public void setDN(DN dn)
  public final void setDN(DN dn)
  {
    assert debugEnter(CLASS_NAME, "setDN", String.valueOf(dn));
opends/src/server/org/opends/server/util/DeleteChangeRecordEntry.java
@@ -28,15 +28,15 @@
import static org.opends.server.loggers.Debug.debugConstructor;
import static org.opends.server.loggers.Debug.debugEnter;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.UtilityMessages.*;
import java.util.LinkedList;
import org.opends.server.types.DN;
import static org.opends.server.loggers.Debug.*;
import static org.opends.server.messages.CoreMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.messages.UtilityMessages.*;
@@ -45,7 +45,7 @@
 * an delete operation.  It includes a DN and a set of attributes, as well as
 * methods to decode the entry.
 */
public class DeleteChangeRecordEntry extends ChangeRecordEntry
public final class DeleteChangeRecordEntry extends ChangeRecordEntry
{
  /**
   * The fully-qualified name of this class for debugging purposes.
opends/src/server/org/opends/server/util/ModifyChangeRecordEntry.java
@@ -28,6 +28,10 @@
import static org.opends.server.loggers.Debug.debugEnter;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.UtilityMessages.*;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -39,10 +43,6 @@
import org.opends.server.types.DN;
import org.opends.server.types.ModificationType;
import static org.opends.server.loggers.Debug.*;
import static org.opends.server.messages.UtilityMessages.*;
import static org.opends.server.messages.MessageHandler.*;
/**
@@ -50,7 +50,7 @@
 * an modify operation.  It includes a DN and a set of attributes, as well as
 * methods to decode the entry.
 */
public class ModifyChangeRecordEntry extends ChangeRecordEntry
public final class ModifyChangeRecordEntry extends ChangeRecordEntry
{
  /**
   * The fully-qualified name of this class for debugging purposes.
opends/src/server/org/opends/server/util/ModifyDNChangeRecordEntry.java
@@ -28,6 +28,12 @@
import static org.opends.server.loggers.Debug.debugConstructor;
import static org.opends.server.loggers.Debug.debugEnter;
import static org.opends.server.loggers.Debug.debugException;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.UtilityMessages.*;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -37,11 +43,6 @@
import org.opends.server.types.DN;
import org.opends.server.types.RDN;
import static org.opends.server.loggers.Debug.*;
import static org.opends.server.messages.UtilityMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -49,7 +50,7 @@
 * an modifyDN operation.  It includes a DN and a set of attributes, as well as
 * methods to decode the entry.
 */
public class ModifyDNChangeRecordEntry extends ChangeRecordEntry
public final class ModifyDNChangeRecordEntry extends ChangeRecordEntry
{
  /**
   * The fully-qualified name of this class for debugging purposes.
@@ -100,14 +101,14 @@
  /**
   * Get the new superior RDN for the requested modify DN operation.
   * Get the new superior DN for the requested modify DN operation.
   *
   * @return the new superior RDN.
   * @return the new superior DN.
   *
   */
  public DN getNewSuperiorRDN()
  public DN getNewSuperiorDN()
  {
    assert debugEnter(CLASS_NAME, "getNewSuperiorRDN");
    assert debugEnter(CLASS_NAME, "getNewSuperiorDN");
    return newSuperiorDN;
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestAddChangeRecordEntry.java
@@ -27,9 +27,9 @@
package org.opends.server.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.DN;
import org.opends.server.types.LDIFImportConfig;
import org.testng.Assert;
@@ -39,6 +39,10 @@
/**
 * This class defines a set of tests for the
 * {@link org.opends.server.util.AddChangeRecordEntry} class.
 * <p>
 * Note that we test shared behaviour with the abstract
 * {@link org.opends.server.util.ChangeRecordEntry} class in case it has
 * been overridden.
 */
public final class TestAddChangeRecordEntry extends UtilTestCase {
  // An empty LDIF reader.
@@ -47,11 +51,15 @@
  /**
   * Once-only initialization.
   * 
   * @throws IOException
   *           If an I/O error occurred.
   * @throws Exception
   *           If an unexpected error occurred.
   */
  @BeforeClass
  public void setUp() throws IOException {
  public void setUp() throws Exception {
    // This test suite depends on having the schema available, so we'll
    // start the server.
    TestCaseUtils.startServer();
    InputStream stream = new ByteArrayInputStream(new byte[0]);
    LDIFImportConfig config = new LDIFImportConfig(stream);
    emptyReader = new LDIFReader(config);
@@ -129,9 +137,8 @@
   */
  @Test(enabled = false)
  public void testGetAttributes() throws Exception {
    // FIXME: Due to tight coupling between the parse() method and the
    // LDIFReader it is not easy to test the getAttributes() method.
    // Instead, we'll test that in the LDIFReader test suite.
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestChangeRecordEntry.java
New file
@@ -0,0 +1,152 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.util;
import java.util.LinkedList;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.DN;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
 * This class defines a set of tests for the abstract
 * {@link org.opends.server.util.ChangeRecordEntry} class.
 * <p>
 * Since the class is abstract and cannot be abstract, this test suite
 * will run tests against a derived inner class.
 */
public final class TestChangeRecordEntry extends UtilTestCase {
  /**
   * Perform tests against this inner class.
   */
  private static final class MyChangeRecordEntry extends ChangeRecordEntry {
    /**
     * Create a new test record.
     *
     * @param dn
     *          The test record's DN.
     */
    public MyChangeRecordEntry(DN dn) {
      super(dn);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ChangeOperationType getChangeOperationType() {
      // Will not use.
      return null;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void parse(LinkedList<StringBuilder> lines, long lineNumber)
        throws LDIFException {
      // Will not use.
    }
  }
  /**
   * Once-only initialization.
   *
   * @throws Exception
   *           If an unexpected error occurred.
   */
  @BeforeClass
  public void setUp() throws Exception {
    // This test suite depends on having the schema available, so we'll
    // start the server.
    TestCaseUtils.startServer();
  }
  /**
   * Tests the constructor with null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNullDN() throws Exception {
    MyChangeRecordEntry entry = new MyChangeRecordEntry(null);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with empty DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorEmptyDN() throws Exception {
    MyChangeRecordEntry entry = new MyChangeRecordEntry(new DN());
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with non-null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNonNullDN() throws Exception {
    DN testDN1 = DN.decode("dc=hello, dc=world");
    DN testDN2 = DN.decode("dc=hello, dc=world");
    MyChangeRecordEntry entry = new MyChangeRecordEntry(testDN1);
    Assert.assertEquals(entry.getDN(), testDN2);
  }
  /**
   * Tests the set DN method.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(dependsOnMethods = { "testConstructorNonNullDN" })
  public void testSetDN() throws Exception {
    DN testDN1 = DN.decode("dc=hello, dc=world");
    DN testDN2 = DN.decode("dc=goodbye, dc=world");
    DN testDN3 = DN.decode("dc=goodbye, dc=world");
    MyChangeRecordEntry entry = new MyChangeRecordEntry(testDN1);
    entry.setDN(testDN2);
    Assert.assertEquals(entry.getDN(), testDN3);
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestDeleteChangeRecordEntry.java
New file
@@ -0,0 +1,145 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.util;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.DN;
import org.opends.server.types.LDIFImportConfig;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
 * This class defines a set of tests for the
 * {@link org.opends.server.util.DeleteChangeRecordEntry} class.
 * <p>
 * Note that we test shared behaviour with the abstract
 * {@link org.opends.server.util.ChangeRecordEntry} class in case it has
 * been overridden.
 */
public final class TestDeleteChangeRecordEntry extends UtilTestCase {
  // An empty LDIF reader.
  private LDIFReader emptyReader;
  /**
   * Once-only initialization.
   *
   * @throws Exception
   *           If an unexpected error occurred.
   */
  @BeforeClass
  public void setUp() throws Exception {
    // This test suite depends on having the schema available, so we'll
    // start the server.
    TestCaseUtils.startServer();
    InputStream stream = new ByteArrayInputStream(new byte[0]);
    LDIFImportConfig config = new LDIFImportConfig(stream);
    emptyReader = new LDIFReader(config);
  }
  /**
   * Tests the constructor with null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNullDN() throws Exception {
    DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with empty DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorEmptyDN() throws Exception {
    DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(new DN(),
        emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with non-null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNonNullDN() throws Exception {
    DN testDN1 = DN.decode("dc=hello, dc=world");
    DN testDN2 = DN.decode("dc=hello, dc=world");
    DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(testDN1,
        emptyReader);
    Assert.assertEquals(entry.getDN(), testDN2);
  }
  /**
   * Tests the change operation type is correct.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testChangeOperationType() throws Exception {
    DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getChangeOperationType(),
        ChangeOperationType.DELETE);
  }
  /**
   * Tests parse method.
   * <p>
   * Due to tight coupling between the
   * {@link DeleteChangeRecordEntry#parse(java.util.LinkedList, long)}
   * method and the {@link LDIFReader} class we'll test this method in
   * the {@link LDIFReader} test suite.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(enabled = false)
  public void testParse() throws Exception {
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestModifyChangeRecordEntry.java
New file
@@ -0,0 +1,146 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.util;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.DN;
import org.opends.server.types.LDIFImportConfig;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
 * This class defines a set of tests for the
 * {@link org.opends.server.util.ModifyChangeRecordEntry} class.
 * <p>
 * Note that we test shared behaviour with the abstract
 * {@link org.opends.server.util.ChangeRecordEntry} class in case it has
 * been overridden.
 */
public final class TestModifyChangeRecordEntry extends UtilTestCase {
  // An empty LDIF reader.
  private LDIFReader emptyReader;
  /**
   * Once-only initialization.
   *
   * @throws Exception
   *           If an unexpected error occurred.
   */
  @BeforeClass
  public void setUp() throws Exception {
    // This test suite depends on having the schema available, so we'll
    // start the server.
    TestCaseUtils.startServer();
    InputStream stream = new ByteArrayInputStream(new byte[0]);
    LDIFImportConfig config = new LDIFImportConfig(stream);
    emptyReader = new LDIFReader(config);
  }
  /**
   * Tests the constructor with null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNullDN() throws Exception {
    ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with empty DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorEmptyDN() throws Exception {
    ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(new DN(),
        emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with non-null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNonNullDN() throws Exception {
    DN testDN1 = DN.decode("dc=hello, dc=world");
    DN testDN2 = DN.decode("dc=hello, dc=world");
    ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(testDN1,
        emptyReader);
    Assert.assertEquals(entry.getDN(), testDN2);
  }
  /**
   * Tests the change operation type is correct.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testChangeOperationType() throws Exception {
    ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getChangeOperationType(),
        ChangeOperationType.MODIFY);
  }
  /**
   * Tests parse and getAttributes methods.
   * <p>
   * Due to tight coupling between the
   * {@link ModifyChangeRecordEntry#parse(java.util.LinkedList, long)}
   * method and the {@link LDIFReader} class it is not easy to test the
   * {@link ModifyChangeRecordEntry#getModifications()} method. Instead,
   * we'll test that in the {@link LDIFReader} test suite.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(enabled = false)
  public void testGetModifications() throws Exception {
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/util/TestModifyDNChangeRecordEntry.java
New file
@@ -0,0 +1,181 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.util;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.DN;
import org.opends.server.types.LDIFImportConfig;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
 * This class defines a set of tests for the
 * {@link org.opends.server.util.ModifyDNChangeRecordEntry} class.
 * <p>
 * Note that we test shared behaviour with the abstract
 * {@link org.opends.server.util.ChangeRecordEntry} class in case it has
 * been overridden.
 */
public final class TestModifyDNChangeRecordEntry extends UtilTestCase {
  // An empty LDIF reader.
  private LDIFReader emptyReader;
  /**
   * Once-only initialization.
   *
   * @throws Exception
   *           If an unexpected error occurred.
   */
  @BeforeClass
  public void setUp() throws Exception {
    // This test suite depends on having the schema available, so we'll
    // start the server.
    TestCaseUtils.startServer();
    InputStream stream = new ByteArrayInputStream(new byte[0]);
    LDIFImportConfig config = new LDIFImportConfig(stream);
    emptyReader = new LDIFReader(config);
  }
  /**
   * Tests the constructor with null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNullDN() throws Exception {
    ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with empty DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorEmptyDN() throws Exception {
    ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(
        new DN(), emptyReader);
    Assert.assertEquals(entry.getDN(), new DN());
  }
  /**
   * Tests the constructor with non-null DN.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testConstructorNonNullDN() throws Exception {
    DN testDN1 = DN.decode("dc=hello, dc=world");
    DN testDN2 = DN.decode("dc=hello, dc=world");
    ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(
        testDN1, emptyReader);
    Assert.assertEquals(entry.getDN(), testDN2);
  }
  /**
   * Tests the change operation type is correct.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testChangeOperationType() throws Exception {
    ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null,
        emptyReader);
    Assert.assertEquals(entry.getChangeOperationType(),
        ChangeOperationType.MODIFY_DN);
  }
  /**
   * Tests parse and getNewRDN methods.
   * <p>
   * Due to tight coupling between the
   * {@link ModifyDNChangeRecordEntry#parse(java.util.LinkedList, long)}
   * method and the {@link LDIFReader} class it is not easy to test the
   * {@link ModifyDNChangeRecordEntry#getNewRDN()} method. Instead,
   * we'll test that in the {@link LDIFReader} test suite.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(enabled = false)
  public void testGetNewRDN() throws Exception {
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
  /**
   * Tests parse and getNewSuperiorDN methods.
   * <p>
   * Due to tight coupling between the
   * {@link ModifyDNChangeRecordEntry#parse(java.util.LinkedList, long)}
   * method and the {@link LDIFReader} class it is not easy to test the
   * {@link ModifyDNChangeRecordEntry#getNewSuperiorDN()} method.
   * Instead, we'll test that in the {@link LDIFReader} test suite.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(enabled = false)
  public void testGetNewSuperiorDN() throws Exception {
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
  /**
   * Tests parse and deleteOldRDN methods.
   * <p>
   * Due to tight coupling between the
   * {@link ModifyDNChangeRecordEntry#parse(java.util.LinkedList, long)}
   * method and the {@link LDIFReader} class it is not easy to test the
   * {@link ModifyDNChangeRecordEntry#deleteOldRDN()} method. Instead,
   * we'll test that in the {@link LDIFReader} test suite.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(enabled = false)
  public void testDeleteOldRDN() throws Exception {
    // FIXME: fix tight-coupling between parse() and LDIFReader.
    Assert.assertTrue(false);
  }
}