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

Jean-Noël Rouvignac
17.11.2015 14f94c13789b8ace4eae258b5f1d64494518f9c3
opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
@@ -26,8 +26,8 @@
 */
package org.opends.server.tools.makeldif;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -37,6 +37,7 @@
import org.opends.server.tasks.LdifFileWriter;
import org.opends.server.tools.ToolsTestCase;
import org.opends.server.types.*;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
@@ -45,7 +46,6 @@
import static org.testng.Assert.*;
import static org.opends.messages.ToolMessages.*;
/**
 * A set of test cases for the MakeLDIF tool.
 */
@@ -324,14 +324,7 @@
    LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);
    Entry top = reader.readEntry();
    Entry e = reader.readEntry();
    reader.close();
    assertNotNull(top);
    Entry e = readEntry(outLdifFilePath);
    assertNotNull(e);
    List<Attribute> attrs = e.getAttribute(attrName);
    assertFalse(attrs.isEmpty());
@@ -340,6 +333,17 @@
    assertEquals(a, expectedRes);
  }
  private Entry readEntry(String outLdifFilePath) throws IOException, LDIFException
  {
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    try (LDIFReader reader = new LDIFReader(ldifConfig))
    {
      assertNotNull(reader.readEntry());
      return reader.readEntry();
    }
  }
  /**
   * Test for escaped characters in templates, check LDIF output when
   * the templates combines escaped characters and variables.
@@ -370,14 +374,7 @@
    LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);
    Entry top = reader.readEntry();
    Entry e = reader.readEntry();
    reader.close();
    assertNotNull(top);
    Entry e = readEntry(outLdifFilePath);
    assertNotNull(e);
    List<Attribute> attrs = e.getAttribute("cn");
    assertFalse(attrs.isEmpty());
@@ -386,4 +383,3 @@
        "cn value doesn't match the expected value");
  }
}