| | |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | 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; |
| | |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the MakeLDIF tool. |
| | | */ |
| | |
| | | |
| | | 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()); |
| | |
| | | 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. |
| | |
| | | |
| | | 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()); |
| | |
| | | "cn value doesn't match the expected value"); |
| | | } |
| | | } |
| | | |