| | |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006 Brighton Consulting, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tasks.LdifFileWriter; |
| | | import org.opends.server.tools.ToolsTestCase; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the MakeLDIF tool. |
| | | */ |
| | | public class MakeLDIFTestCase |
| | | extends ToolsTestCase |
| | | /** A set of test cases for the MakeLDIF tool. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class MakeLDIFTestCase extends ToolsTestCase |
| | | { |
| | | private String resourcePath; |
| | | |
| | |
| | | // Test must show "missingVar" missing on line 1. |
| | | // Previous behaviour showed "missingVar" on line 5. |
| | | |
| | | TemplateFile templateFile = new TemplateFile(resourcePath); |
| | | TemplateFile templateFile = new TemplateFile(resourcePath, new Random()); |
| | | List<LocalizableMessage> warns = new ArrayList<>(); |
| | | |
| | | try |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test for parsing escaped character in templates. |
| | | */ |
| | | /** Test for parsing escaped character in templates. */ |
| | | @Test(dataProvider = "validTemplates") |
| | | public void testParsingEscapeCharInTemplate(String testName, String[] lines) |
| | | throws Exception |
| | | { |
| | | TemplateFile templateFile = new TemplateFile(resourcePath); |
| | | TemplateFile templateFile = new TemplateFile(resourcePath, new Random()); |
| | | List<LocalizableMessage> warns = new ArrayList<>(); |
| | | templateFile.parse(lines, warns); |
| | | assertTrue(warns.isEmpty(),"Warnings in parsing test template " + testName ); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test for escaped characters in templates, check LDIF output. |
| | | */ |
| | | @Test(dataProvider="templatesToTestLDIFOutput", dependsOnMethods = { "testParsingEscapeCharInTemplate"}) |
| | | /** Test for escaped characters in templates, check LDIF output. */ |
| | | @Test(dataProvider = "templatesToTestLDIFOutput", dependsOnMethods = "testParsingEscapeCharInTemplate") |
| | | public void testLDIFOutputFromTemplate(String testName, String[] lines, |
| | | String attrName, String expectedValue) throws Exception |
| | | { |
| | |
| | | * Test for escaped characters in templates, check LDIF output when |
| | | * the templates combines escaped characters and variables. |
| | | */ |
| | | @Test(dependsOnMethods = { "testParsingEscapeCharInTemplate"}) |
| | | @Test(dependsOnMethods = "testParsingEscapeCharInTemplate") |
| | | public void testOutputCombineEscapeCharInTemplate() throws Exception |
| | | { |
| | | String[] lines = |
| | |
| | | "", |
| | | }; |
| | | |
| | | |
| | | File tmpFile = File.createTempFile("combineEscapeChar", "out.ldif"); |
| | | tmpFile.deleteOnExit(); |
| | | String outLdifFilePath = tmpFile.getAbsolutePath(); |