opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/EntryGenerator.java
File was renamed from opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/MakeLDIFEntryReader.java @@ -50,10 +50,11 @@ import com.forgerock.opendj.util.Validator; /** * This reader generates entries from a template file, which can be provided * as a file, a list of lines, an array of lines, or an input stream. * Generator of entries based on a {@code TemplateFile template file}, which can * be provided as a file, a list of lines, an array of lines, or an input * stream. */ public final class MakeLDIFEntryReader implements EntryReader { public final class EntryGenerator implements EntryReader { private static final TemplateEntry POISON_ENTRY = TemplateFile.TemplateEntry.NULL_TEMPLATE_ENTRY; @@ -90,7 +91,7 @@ * used to hold generated entries and block generation until * entries are read */ private MakeLDIFEntryReader(TemplateFile templateFile, LinkedList<LocalizableMessage> warnings, private EntryGenerator(TemplateFile templateFile, LinkedList<LocalizableMessage> warnings, BlockingQueue<TemplateEntry> entryQueue) { this.templateFile = templateFile; this.warnings = warnings; @@ -146,19 +147,19 @@ } /** * Builder of {@code MakeLDIFEntryReader readers}. * Builder of {@code EntryGenerator readers}. * <p> * * To build a reader with all default values: * <pre> * {@code reader = MakeLDIFEntryReader.newReader(...).build() } * {@code reader = EntryGenerator.newReader(...).build() } * </pre> * <p> * * To build a reader with some custom values, using the * <code>set</code> methods: * <pre> * {@code reader = MakeLDIFEntryReader.newReader(...). * {@code reader = EntryGenerator.newReader(...). * setResourcePath(path). * setSchema(schema). * build() } @@ -198,7 +199,7 @@ * * @param max * capacity of the queue that holds generated entries * @return A reference to this {@code MakeLDIFEntryReader.Builder}. * @return A reference to this {@code EntryGenerator.Builder}. */ public Builder setMaxNumberOfEntriesInQueue(final int max) { Validator.ensureTrue(max > 0, "queue capacity must be strictly superior to zero"); @@ -211,7 +212,7 @@ * * @param seed * seed to use * @return A reference to this {@code MakeLDIFEntryReader.Builder}. * @return A reference to this {@code EntryGenerator.Builder}. */ public Builder setRandomSeed(final int seed) { randomSeed = seed; @@ -224,7 +225,7 @@ * * @param path * resource path * @return A reference to this {@code MakeLDIFEntryReader.Builder}. * @return A reference to this {@code EntryGenerator.Builder}. */ public Builder setResourcePath(final String path) { Validator.ensureNotNull(path); @@ -238,7 +239,7 @@ * * @param schema * The schema which should be used for generating entries. * @return A reference to this {@code MakeLDIFEntryReader.Builder}. * @return A reference to this {@code EntryGenerator.Builder}. */ public Builder setSchema(final Schema schema) { this.schema = schema; @@ -258,7 +259,7 @@ * @param policy * The schema validation which should be used when generating * entries. * @return A reference to this {@code MakeLDIFEntryReader.Builder}. * @return A reference to this {@code EntryGenerator.Builder}. */ public Builder setSchemaValidationPolicy(final SchemaValidationPolicy policy) { this.schemaValidationPolicy = SchemaValidationPolicy.copyOf(policy); @@ -274,7 +275,7 @@ * @throws DecodeException * If some other problem occurs during initialization */ public MakeLDIFEntryReader build() throws IOException, DecodeException { public EntryGenerator build() throws IOException, DecodeException { if (schema == null) { schema = Schema.getDefaultSchema(); } @@ -293,14 +294,14 @@ templateFile.parse(templateStream, warnings); } else { // this should never happen throw DecodeException.fatalError(ERR_MAKELDIF_MISSING_TEMPLATE_FILE.get()); throw DecodeException.fatalError(ERR_ENTRY_GENERATOR_MISSING_TEMPLATE_FILE.get()); } } catch (IOException e) { throw e; } catch (Exception e) { throw DecodeException.fatalError(ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage()), e); throw DecodeException.fatalError(ERR_ENTRY_GENERATOR_EXCEPTION_DURING_PARSE.get(e.getMessage()), e); } MakeLDIFEntryReader reader = new MakeLDIFEntryReader(templateFile, EntryGenerator reader = new EntryGenerator(templateFile, warnings, new LinkedBlockingQueue<TemplateEntry>(maxNumberOfEntriesInQueue)); reader.startEntriesGeneration(); return reader; opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java
@@ -85,7 +85,7 @@ * A template file allow to generate entries from a collection of constant * definitions, branches, and templates. * * @see MakeLDIFEntryReader * @see EntryGenerator */ class TemplateFile { /** @@ -247,7 +247,7 @@ try { c = Class.forName(tagClass); } catch (Exception e) { final LocalizableMessage message = ERR_MAKELDIF_CANNOT_LOAD_TAG_CLASS.get(tagClass); final LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_LOAD_TAG_CLASS.get(tagClass); throw DecodeException.fatalError(message, e); } @@ -255,13 +255,13 @@ try { t = (TemplateTag) c.newInstance(); } catch (Exception e) { final LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG.get(tagClass); final LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_TAG.get(tagClass); throw DecodeException.fatalError(message, e); } String lowerName = t.getName().toLowerCase(); if (registeredTags.containsKey(lowerName)) { final LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TAG_NAME.get(tagClass, t.getName()); final LocalizableMessage message = ERR_ENTRY_GENERATOR_CONFLICTING_TAG_NAME.get(tagClass, t.getName()); throw DecodeException.fatalError(message); } else { registeredTags.put(lowerName, t); @@ -284,7 +284,7 @@ registeredTags.put(t.getName().toLowerCase(), t); } catch (Exception e) { // this should never happen StaticUtils.DEFAULT_LOG.error(ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG.get(c.getName()).toString()); StaticUtils.DEFAULT_LOG.error(ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_TAG.get(c.getName()).toString()); } } } @@ -544,7 +544,7 @@ templatePath = null; File f = getFile(filename); if ((f == null) || (!f.exists())) { LocalizableMessage message = ERR_MAKELDIF_COULD_NOT_FIND_TEMPLATE_FILE.get(filename); LocalizableMessage message = ERR_ENTRY_GENERATOR_COULD_NOT_FIND_TEMPLATE_FILE.get(filename); throw new IOException(message.toString()); } else { templatePath = f.getParentFile().getAbsolutePath(); @@ -581,8 +581,7 @@ * @throws DecodeException * If any other problem occurs while parsing the template. */ public void parse(InputStream inputStream, List<LocalizableMessage> warnings) throws IOException, DecodeException { public void parse(InputStream inputStream, List<LocalizableMessage> warnings) throws IOException, DecodeException { ArrayList<String> fileLines = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); @@ -640,7 +639,7 @@ try { tagClass = Class.forName(className); } catch (Exception e) { LocalizableMessage message = ERR_MAKELDIF_CANNOT_LOAD_TAG_CLASS.get(className); LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_LOAD_TAG_CLASS.get(className); throw DecodeException.fatalError(message, e); } @@ -648,13 +647,13 @@ try { tag = (TemplateTag) tagClass.newInstance(); } catch (Exception e) { LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG.get(className); LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_TAG.get(className); throw DecodeException.fatalError(message, e); } String lowerName = tag.getName().toLowerCase(); if (registeredTags.containsKey(lowerName) || templateFileIncludeTags.containsKey(lowerName)) { LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TAG_NAME.get(className, tag.getName()); LocalizableMessage message = ERR_ENTRY_GENERATOR_CONFLICTING_TAG_NAME.get(className, tag.getName()); throw DecodeException.fatalError(message); } @@ -666,25 +665,25 @@ // value. int equalPos = line.indexOf('=', 7); if (equalPos < 0) { LocalizableMessage message = ERR_MAKELDIF_DEFINE_MISSING_EQUALS.get(lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_DEFINE_MISSING_EQUALS.get(lineNumber); throw DecodeException.fatalError(message); } String name = line.substring(7, equalPos).trim(); if (name.length() == 0) { LocalizableMessage message = ERR_MAKELDIF_DEFINE_NAME_EMPTY.get(lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_DEFINE_NAME_EMPTY.get(lineNumber); throw DecodeException.fatalError(message); } String lowerName = name.toLowerCase(); if (templateFileConstants.containsKey(lowerName)) { LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_CONSTANT_NAME.get(name, lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_CONFLICTING_CONSTANT_NAME.get(name, lineNumber); throw DecodeException.fatalError(message); } String value = line.substring(equalPos + 1); if (value.length() == 0) { LocalizableMessage message = ERR_MAKELDIF_WARNING_DEFINE_VALUE_EMPTY.get(name, lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_WARNING_DEFINE_VALUE_EMPTY.get(name, lineNumber); warnings.add(message); } @@ -714,8 +713,8 @@ Branch b = parseBranchDefinition(branchLines, lineNumber, templateFileIncludeTags, warnings); DN branchDN = b.getBranchDN(); if (templateFileBranches.containsKey(branchDN)) { LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_BRANCH_DN.get(String.valueOf(branchDN), startLineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_CONFLICTING_BRANCH_DN.get( String.valueOf(branchDN), startLineNumber); throw DecodeException.fatalError(message); } else { templateFileBranches.put(branchDN, b); @@ -746,14 +745,14 @@ templateFileTemplates, warnings); String lowerName = t.getName().toLowerCase(); if (templateFileTemplates.containsKey(lowerName)) { LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TEMPLATE_NAME.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_CONFLICTING_TEMPLATE_NAME.get( String.valueOf(t.getName()), startLineNumber); throw DecodeException.fatalError(message); } else { templateFileTemplates.put(lowerName, t); } } else { LocalizableMessage message = ERR_MAKELDIF_UNEXPECTED_TEMPLATE_FILE_LINE.get(line, lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_UNEXPECTED_TEMPLATE_FILE_LINE.get(line, lineNumber); throw DecodeException.fatalError(message); } } @@ -808,7 +807,7 @@ String constantName = line.substring(openPos + 1, closePos).toLowerCase(); String constantValue = constants.get(constantName); if (constantValue == null) { LocalizableMessage message = WARN_MAKELDIF_WARNING_UNDEFINED_CONSTANT.get(constantName, LocalizableMessage message = WARN_ENTRY_GENERATOR_WARNING_UNDEFINED_CONSTANT.get(constantName, lineNumber); warnings.add(message); } else { @@ -853,7 +852,7 @@ try { branchDN = DN.valueOf(dnString, schema); } catch (Exception e) { LocalizableMessage message = ERR_MAKELDIF_CANNOT_DECODE_BRANCH_DN.get(dnString, startLineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_DECODE_BRANCH_DN.get(dnString, startLineNumber); throw DecodeException.fatalError(message); } @@ -874,8 +873,8 @@ // number of entries. int colonPos = line.indexOf(':', 21); if (colonPos <= 21) { LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_TEMPLATE_NO_COLON.get(lineNumber, dnString); LocalizableMessage message = ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_TEMPLATE_NO_COLON.get( lineNumber, dnString); throw DecodeException.fatalError(message); } @@ -885,18 +884,18 @@ try { numEntries = Integer.parseInt(line.substring(colonPos + 1).trim()); if (numEntries < 0) { LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_INVALID_NUM_ENTRIES.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_INVALID_NUM_ENTRIES.get( lineNumber, dnString, numEntries, templateName); throw DecodeException.fatalError(message); } else if (numEntries == 0) { LocalizableMessage message = WARN_MAKELDIF_BRANCH_SUBORDINATE_ZERO_ENTRIES.get(lineNumber, dnString, templateName); LocalizableMessage message = WARN_ENTRY_GENERATOR_BRANCH_SUBORDINATE_ZERO_ENTRIES.get( lineNumber, dnString, templateName); warnings.add(message); } branch.addSubordinateTemplate(templateName, numEntries); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_CANT_PARSE_NUMENTRIES.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_CANT_PARSE_NUMENTRIES.get( templateName, lineNumber, dnString); throw DecodeException.fatalError(message); } @@ -958,8 +957,8 @@ String parentTemplateName = line.substring(9).trim(); parentTemplate = definedTemplates.get(parentTemplateName.toLowerCase()); if (parentTemplate == null) { LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_INVALID_PARENT_TEMPLATE.get(parentTemplateName, lineNumber, templateName); LocalizableMessage message = ERR_ENTRY_GENERATOR_TEMPLATE_INVALID_PARENT_TEMPLATE.get( parentTemplateName, lineNumber, templateName); throw DecodeException.fatalError(message); } } else if (lowerLine.startsWith("rdnattr: ")) { @@ -981,8 +980,8 @@ // number of entries. int colonPos = line.indexOf(':', 21); if (colonPos <= 21) { LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_TEMPLATE_NO_COLON.get(lineNumber, templateName); LocalizableMessage message = ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_TEMPLATE_NO_COLON.get( lineNumber, templateName); throw DecodeException.fatalError(message); } @@ -992,19 +991,19 @@ try { numEntries = Integer.parseInt(line.substring(colonPos + 1).trim()); if (numEntries < 0) { LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_INVALID_NUM_ENTRIES.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_INVALID_NUM_ENTRIES.get( lineNumber, templateName, numEntries, subTemplateName); throw DecodeException.fatalError(message); } else if (numEntries == 0) { LocalizableMessage message = WARN_MAKELDIF_TEMPLATE_SUBORDINATE_ZERO_ENTRIES.get(lineNumber, templateName, subTemplateName); LocalizableMessage message = WARN_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_ZERO_ENTRIES.get( lineNumber, templateName, subTemplateName); warnings.add(message); } subTemplateNames.add(subTemplateName); entriesPerTemplate.add(numEntries); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_CANT_PARSE_NUMENTRIES.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_CANT_PARSE_NUMENTRIES.get( subTemplateName, lineNumber, templateName); throw DecodeException.fatalError(message); } @@ -1091,19 +1090,21 @@ int colonPos = lowerLine.indexOf(':'); if (colonPos < 0) { if (branch == null) { LocalizableMessage message = ERR_MAKELDIF_NO_COLON_IN_TEMPLATE_LINE.get(lineNumber, template.getName()); LocalizableMessage message = ERR_ENTRY_GENERATOR_NO_COLON_IN_TEMPLATE_LINE.get(lineNumber, template.getName()); throw DecodeException.fatalError(message); } else { LocalizableMessage message = ERR_MAKELDIF_NO_COLON_IN_BRANCH_EXTRA_LINE.get(lineNumber, LocalizableMessage message = ERR_ENTRY_GENERATOR_NO_COLON_IN_BRANCH_EXTRA_LINE.get(lineNumber, String.valueOf(branch.getBranchDN())); throw DecodeException.fatalError(message); } } else if (colonPos == 0) { if (branch == null) { LocalizableMessage message = ERR_MAKELDIF_NO_ATTR_IN_TEMPLATE_LINE.get(lineNumber, template.getName()); LocalizableMessage message = ERR_ENTRY_GENERATOR_NO_ATTR_IN_TEMPLATE_LINE.get(lineNumber, template.getName()); throw DecodeException.fatalError(message); } else { LocalizableMessage message = ERR_MAKELDIF_NO_ATTR_IN_BRANCH_EXTRA_LINE.get(lineNumber, LocalizableMessage message = ERR_ENTRY_GENERATOR_NO_ATTR_IN_BRANCH_EXTRA_LINE.get(lineNumber, String.valueOf(branch.getBranchDN())); throw DecodeException.fatalError(message); } @@ -1135,11 +1136,11 @@ // add a // warning. if (branch == null) { LocalizableMessage message = WARN_MAKELDIF_NO_VALUE_IN_TEMPLATE_LINE .get(lineNumber, template.getName()); LocalizableMessage message = WARN_ENTRY_GENERATOR_NO_VALUE_IN_TEMPLATE_LINE.get(lineNumber, template.getName()); warnings.add(message); } else { LocalizableMessage message = WARN_MAKELDIF_NO_VALUE_IN_BRANCH_EXTRA_LINE.get(lineNumber, LocalizableMessage message = WARN_ENTRY_GENERATOR_NO_VALUE_IN_BRANCH_EXTRA_LINE.get(lineNumber, String.valueOf(branch.getBranchDN())); warnings.add(message); } @@ -1241,7 +1242,7 @@ tagList.add(t); } } else { LocalizableMessage message = ERR_MAKELDIF_INCOMPLETE_TAG.get(lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_INCOMPLETE_TAG.get(lineNumber); throw DecodeException.fatalError(message); } @@ -1286,7 +1287,7 @@ if (t == null) { t = tags.get(lowerTagName); if (t == null) { LocalizableMessage message = ERR_MAKELDIF_NO_SUCH_TAG.get(tagName, lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_NO_SUCH_TAG.get(tagName, lineNumber); throw DecodeException.fatalError(message); } } @@ -1303,7 +1304,7 @@ try { newTag = t.getClass().newInstance(); } catch (Exception e) { LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_NEW_TAG.get(tagName, lineNumber, LocalizableMessage message = ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_NEW_TAG.get(tagName, lineNumber, String.valueOf(e)); throw DecodeException.fatalError(message, e); } @@ -1314,7 +1315,8 @@ if (newTag.allowedInBranch()) { newTag.initializeForBranch(schema, this, branch, args, lineNumber, warnings); } else { LocalizableMessage message = ERR_MAKELDIF_TAG_NOT_ALLOWED_IN_BRANCH.get(newTag.getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_NOT_ALLOWED_IN_BRANCH.get(newTag.getName(), lineNumber); throw DecodeException.fatalError(message); } } @@ -1604,7 +1606,8 @@ TemplateTag[] tags = new TemplateTag[1]; tags[0] = new StaticTextTag(); tags[0].initializeForBranch(schema, templateFile, this, valueStrings, 0, warnings); lineList.add(new TemplateLine(attribute.getAttributeDescription().getAttributeType(), 0, tags)); lineList.add( new TemplateLine(attribute.getAttributeDescription().getAttributeType(), 0, tags)); } catch (Exception e) { // This should never happen. e.printStackTrace(); @@ -1637,8 +1640,8 @@ for (int i = 0; i < subordinateTemplates.length; i++) { subordinateTemplates[i] = templates.get(subordinateTemplateNames[i].toLowerCase()); if (subordinateTemplates[i] == null) { LocalizableMessage message = ERR_MAKELDIF_UNDEFINED_BRANCH_SUBORDINATE.get(branchDN.toString(), subordinateTemplateNames[i]); LocalizableMessage message = ERR_ENTRY_GENERATOR_UNDEFINED_BRANCH_SUBORDINATE.get( branchDN.toString(), subordinateTemplateNames[i]); throw DecodeException.fatalError(message); } } @@ -1821,8 +1824,8 @@ */ static class Template { /** * The attribute types that are used in the RDN for entries generated using * this template. * The attribute types that are used in the RDN for entries generated * using this template. */ private org.forgerock.opendj.ldap.schema.AttributeType[] rdnAttributes; @@ -1927,7 +1930,7 @@ for (int i = 0; i < subordinateTemplates.length; i++) { subordinateTemplates[i] = templates.get(subordinateTemplateNames[i].toLowerCase()); if (subordinateTemplates[i] == null) { LocalizableMessage message = ERR_MAKELDIF_UNDEFINED_TEMPLATE_SUBORDINATE.get( LocalizableMessage message = ERR_ENTRY_GENERATOR_UNDEFINED_TEMPLATE_SUBORDINATE.get( subordinateTemplateNames[i], name); throw DecodeException.fatalError(message); } @@ -1950,7 +1953,7 @@ if (!rdnAttrs.isEmpty()) { AttributeType t = rdnAttrs.iterator().next(); LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_MISSING_RDN_ATTR.get(name, t.getNameOrOID()); LocalizableMessage message = ERR_ENTRY_GENERATOR_TEMPLATE_MISSING_RDN_ATTR.get(name, t.getNameOrOID()); throw DecodeException.fatalError(message); } } @@ -2090,7 +2093,8 @@ numEntriesPerTemplate[j]); if (!(r.keepProcessingParent() && r.keepProcessingTemplateFile())) { if (r.keepProcessingTemplateFile()) { // We don't want to propagate a "stop processing parent" // We don't want to propagate a // "stop processing parent" // all the way up the chain. return TagResult.SUCCESS_RESULT; } opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
@@ -50,7 +50,7 @@ * It can be used to generate content. * * @see TemplateFile * @see MakeLDIFEntryReader * @see EntryGenerator */ abstract class TemplateTag { @@ -318,15 +318,15 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); attributeType = schema.getAttributeType(lowerName); if (!branch.hasAttribute(attributeType)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -334,13 +334,13 @@ try { numCharacters = Integer.parseInt(arguments[1]); if (numCharacters < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(numCharacters, 0, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get( numCharacters, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message); } } else { @@ -369,15 +369,15 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); attributeType = schema.getAttributeType(lowerName); if (!template.hasAttribute(attributeType)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -385,13 +385,13 @@ try { numCharacters = Integer.parseInt(arguments[1]); if (numCharacters < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(numCharacters, 0, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get( numCharacters, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message); } } else { @@ -535,13 +535,13 @@ try { numComponents = Integer.parseInt(arguments[0]); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 1, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 1, arguments.length); throw DecodeException.fatalError(message); } } @@ -710,20 +710,22 @@ // There must be at least one argument, and possibly two. if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } // The first argument should be the path to the file. dataFile = templateFile.getFile(arguments[0]); if ((dataFile == null) || (!dataFile.exists())) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_FIND_FILE.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_FIND_FILE.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } // If there is a second argument, then it should be either // "sequential" or "random". If there isn't one, then we should assume "random". // "sequential" or "random". If there isn't one, then we should // assume "random". if (arguments.length == 2) { if (arguments[1].equalsIgnoreCase("sequential")) { sequential = true; @@ -731,8 +733,8 @@ } else if (arguments[1].equalsIgnoreCase("random")) { sequential = false; } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message); } } else { @@ -744,8 +746,8 @@ try { fileLines = templateFile.getFileLines(dataFile); } catch (IOException ioe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_READ_FILE.get(arguments[0], getName(), lineNumber, String.valueOf(ioe)); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_READ_FILE.get(arguments[0], getName(), lineNumber, String.valueOf(ioe)); throw DecodeException.fatalError(message, ioe); } } @@ -833,8 +835,8 @@ this.templateFile = templateFile; if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -909,8 +911,8 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -936,8 +938,8 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -1019,15 +1021,15 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); AttributeType t = schema.getAttributeType(lowerName); if (!branch.hasAttribute(t)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -1059,15 +1061,15 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); attributeType = schema.getAttributeType(lowerName); if (!template.hasAttribute(attributeType)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -1169,15 +1171,15 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); AttributeType t = schema.getAttributeType(lowerName); if (!branch.hasAttribute(t)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -1209,15 +1211,15 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if ((arguments.length < 1) || (arguments.length > 2)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, arguments.length); throw DecodeException.fatalError(message); } String lowerName = arguments[0].toLowerCase(); attributeType = schema.getAttributeType(lowerName); if (!template.hasAttribute(attributeType)) { LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber); throw DecodeException.fatalError(message); } @@ -1317,8 +1319,8 @@ this.templateFile = templateFile; if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -1456,7 +1458,7 @@ private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length == 0) { throw DecodeException.fatalError(ERR_MAKELDIF_TAG_LIST_NO_ARGUMENTS.get(lineNumber)); throw DecodeException.fatalError(ERR_ENTRY_GENERATOR_TAG_LIST_NO_ARGUMENTS.get(lineNumber)); } valueStrings = new String[arguments.length]; @@ -1474,7 +1476,7 @@ weight = Integer.parseInt(s.substring(semicolonPos + 1)); s = s.substring(0, semicolonPos); } catch (Exception e) { warnings.add(WARN_MAKELDIF_TAG_LIST_INVALID_WEIGHT.get(lineNumber, s)); warnings.add(WARN_ENTRY_GENERATOR_TAG_LIST_INVALID_WEIGHT.get(lineNumber, s)); } } @@ -1561,8 +1563,8 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -1693,8 +1695,8 @@ random = templateFile.getRandom(); if (arguments.length != 1) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); throw DecodeException.fatalError(message); } @@ -1702,17 +1704,17 @@ percentage = Integer.parseInt(arguments[0]); if (percentage < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(percentage, 0, LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get(percentage, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } else if (percentage > 100) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_ABOVE_UPPER_BOUND.get(percentage, 100, LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_ABOVE_UPPER_BOUND.get(percentage, 100, getName(), lineNumber); throw DecodeException.fatalError(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } } @@ -1813,7 +1815,7 @@ * The character set that will be used for base64 characters. */ public static final char[] BASE64_CHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "01234567890+/").toCharArray(); + "01234567890+/").toCharArray(); /** * The set of month names that will be used. @@ -1960,7 +1962,7 @@ // There must be at least one argument, to specify the type of // random value to generate. if ((arguments == null) || (arguments.length == 0)) { LocalizableMessage message = ERR_MAKELDIF_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber); throw DecodeException.fatalError(message); } @@ -1979,15 +1981,15 @@ minLength = Integer.parseInt(arguments[1]); if (minLength < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get( minLength, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } else if (minLength == 0) { LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber); LocalizableMessage message = WARN_ENTRY_GENERATOR_TAG_WARNING_EMPTY_VALUE.get(lineNumber); warnings.add(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } @@ -1998,8 +2000,8 @@ try { decimalFormat = new DecimalFormat(arguments[3]); } catch (Exception e) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_FORMAT_STRING.get(arguments[3], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_FORMAT_STRING.get( arguments[3], getName(), lineNumber); throw DecodeException.fatalError(message, e); } } else { @@ -2009,7 +2011,7 @@ try { minValue = Long.parseLong(arguments[1]); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } @@ -2017,19 +2019,19 @@ try { maxValue = Long.parseLong(arguments[2]); if (maxValue < minValue) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxValue, minValue, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get( maxValue, minValue, getName(), lineNumber); throw DecodeException.fatalError(message); } valueRange = maxValue - minValue + 1; } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[2], LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[2], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 2, 4, numArgs); throw DecodeException.fatalError(message); } @@ -2038,7 +2040,7 @@ decodeLength(arguments, 1, lineNumber, warnings); } else if (randomTypeString.equals("chars")) { if ((numArgs < 3) || (numArgs > 4)) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 3, 4, numArgs); throw DecodeException.fatalError(message); } @@ -2060,24 +2062,25 @@ try { maxLength = Integer.parseInt(arguments[1]); if (maxLength <= 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxLength, 1, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get( maxLength, 1, getName(), lineNumber); throw DecodeException.fatalError(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 1, 2, numArgs); throw DecodeException.fatalError(message); } } else if (randomTypeString.equals("telephone")) { randomType = RANDOM_TYPE_TELEPHONE; } else { LocalizableMessage message = ERR_MAKELDIF_TAG_UNKNOWN_RANDOM_TYPE.get(lineNumber, randomTypeString); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNKNOWN_RANDOM_TYPE.get(lineNumber, randomTypeString); throw DecodeException.fatalError(message); } } @@ -2111,16 +2114,16 @@ minLength = Integer.parseInt(arguments[startPos]); if (minLength < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } else if (minLength == 0) { LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber); LocalizableMessage message = WARN_ENTRY_GENERATOR_TAG_WARNING_EMPTY_VALUE.get(lineNumber); warnings.add(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get( arguments[startPos], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } } else if (numArgs == 3) { @@ -2131,13 +2134,13 @@ minLength = Integer.parseInt(arguments[startPos]); if (minLength < 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0, getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0, getName(), lineNumber); throw DecodeException.fatalError(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get( arguments[startPos], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } @@ -2146,21 +2149,21 @@ lengthRange = maxLength - minLength + 1; if (maxLength < minLength) { LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxLength, LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxLength, minLength, getName(), lineNumber); throw DecodeException.fatalError(message); } else if (maxLength == 0) { LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber); LocalizableMessage message = WARN_ENTRY_GENERATOR_TAG_WARNING_EMPTY_VALUE.get(lineNumber); warnings.add(message); } } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos + 1], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get( arguments[startPos + 1], getName(), lineNumber); throw DecodeException.fatalError(message, nfe); } } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, startPos + 1, startPos + 2, numArgs); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, startPos + 1, startPos + 2, numArgs); throw DecodeException.fatalError(message); } } @@ -2282,8 +2285,8 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -2309,8 +2312,8 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } @@ -2450,8 +2453,8 @@ try { initialValue = Integer.parseInt(arguments[0]); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } @@ -2462,8 +2465,8 @@ try { initialValue = Integer.parseInt(arguments[0]); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } @@ -2472,16 +2475,16 @@ } else if (arguments[1].equalsIgnoreCase("false")) { resetOnNewParents = false; } else { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_BOOLEAN.get(arguments[1], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_BOOLEAN.get(arguments[1], getName(), lineNumber); throw DecodeException.fatalError(message); } nextValue = initialValue; break; default: LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 2, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 2, arguments.length); throw DecodeException.fatalError(message); } } @@ -2573,8 +2576,8 @@ public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 1) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); throw DecodeException.fatalError(message); } @@ -2602,8 +2605,8 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 1) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1, arguments.length); throw DecodeException.fatalError(message); } @@ -2730,13 +2733,13 @@ try { numComponents = Integer.parseInt(arguments[0]); } catch (NumberFormatException nfe) { LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(), lineNumber); throw DecodeException.fatalError(message); } } else { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 1, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber, 0, 1, arguments.length); throw DecodeException.fatalError(message); } } @@ -2839,13 +2842,12 @@ public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template, String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException { if (arguments.length != 0) { LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0, arguments.length); throw DecodeException.fatalError(message); } } /** * Generates the content for this tag by appending it to the provided * tag. opendj3/opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties
@@ -1417,139 +1417,139 @@ HBCF_CONNECTION_CLOSED_BY_CLIENT=Connection closed by client HBCF_HEARTBEAT_FAILED=Heartbeat failed HBCF_HEARTBEAT_TIMEOUT=Heartbeat timed out after %d ms ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT=Invalid number of arguments \ ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_COUNT=Invalid number of arguments \ provided for tag %s on line number %d of the template file: expected %d, got \ %d ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT=Invalid number of \ ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT=Invalid number of \ arguments provided for tag %s on line number %d of the template file: \ expected between %d and %d, got %d ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE=Undefined attribute %s \ ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE=Undefined attribute %s \ referenced on line %d of the template file ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND=Value %d is below the \ ERR_ENTRY_GENERATOR_TAG_INTEGER_BELOW_LOWER_BOUND=Value %d is below the \ lowest allowed value of %d for tag %s on line %d of the template file ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER=Cannot parse value "%s" as \ ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_INTEGER=Cannot parse value "%s" as \ an integer for tag %s on line %d of the template file ERR_MAKELDIF_TAG_INTEGER_ABOVE_UPPER_BOUND=Value %d is above the \ ERR_ENTRY_GENERATOR_TAG_INTEGER_ABOVE_UPPER_BOUND=Value %d is above the \ largest allowed value of %d for tag %s on line %d of the template file ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_BOOLEAN=Cannot parse value "%s" as \ ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_BOOLEAN=Cannot parse value "%s" as \ a Boolean value for tag %s on line %d of the template file. The value must \ be either 'true' or 'false' ERR_MAKELDIF_UNDEFINED_BRANCH_SUBORDINATE=The branch with entry DN \ ERR_ENTRY_GENERATOR_UNDEFINED_BRANCH_SUBORDINATE=The branch with entry DN \ '%s' references a subordinate template named '%s' which is not defined in the \ template file ERR_MAKELDIF_CANNOT_LOAD_TAG_CLASS=Unable to load class %s for use \ ERR_ENTRY_GENERATOR_CANNOT_LOAD_TAG_CLASS=Unable to load class %s for use \ as a MakeLDIF tag ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG=Cannot instantiate class %s as a \ ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_TAG=Cannot instantiate class %s as a \ MakeLDIF tag ERR_MAKELDIF_CONFLICTING_TAG_NAME=Cannot register the tag defined in \ ERR_ENTRY_GENERATOR_CONFLICTING_TAG_NAME=Cannot register the tag defined in \ class %s because the tag name %s conflicts with the name of another tag that \ has already been registered WARN_MAKELDIF_WARNING_UNDEFINED_CONSTANT=Possible reference to an \ WARN_ENTRY_GENERATOR_WARNING_UNDEFINED_CONSTANT=Possible reference to an \ undefined constant %s on line %d ERR_MAKELDIF_DEFINE_MISSING_EQUALS=The constant definition on line \ ERR_ENTRY_GENERATOR_DEFINE_MISSING_EQUALS=The constant definition on line \ %d is missing an equal sign to delimit the constant name from the value ERR_MAKELDIF_DEFINE_NAME_EMPTY=The constant definition on line %d \ ERR_ENTRY_GENERATOR_DEFINE_NAME_EMPTY=The constant definition on line %d \ does not include a name for the constant ERR_MAKELDIF_CONFLICTING_CONSTANT_NAME=The definition for constant \ ERR_ENTRY_GENERATOR_CONFLICTING_CONSTANT_NAME=The definition for constant \ %s on line %d conflicts with an earlier constant definition included in the \ template ERR_MAKELDIF_WARNING_DEFINE_VALUE_EMPTY=Constant %s defined on line \ ERR_ENTRY_GENERATOR_WARNING_DEFINE_VALUE_EMPTY=Constant %s defined on line \ %d has not been assigned a value ERR_MAKELDIF_CONFLICTING_BRANCH_DN=The branch definition %s starting \ ERR_ENTRY_GENERATOR_CONFLICTING_BRANCH_DN=The branch definition %s starting \ on line %d conflicts with an earlier branch definition contained in the \ template file ERR_MAKELDIF_CONFLICTING_TEMPLATE_NAME=The template definition %s \ ERR_ENTRY_GENERATOR_CONFLICTING_TEMPLATE_NAME=The template definition %s \ starting on line %d conflicts with an earlier template definition contained \ in the template file ERR_MAKELDIF_UNEXPECTED_TEMPLATE_FILE_LINE=Unexpected template line \ ERR_ENTRY_GENERATOR_UNEXPECTED_TEMPLATE_FILE_LINE=Unexpected template line \ "%s" encountered on line %d of the template file ERR_MAKELDIF_UNDEFINED_TEMPLATE_SUBORDINATE=The template named %s \ ERR_ENTRY_GENERATOR_UNDEFINED_TEMPLATE_SUBORDINATE=The template named %s \ references a subordinate template named %s which is not defined in the \ template file ERR_MAKELDIF_CANNOT_DECODE_BRANCH_DN=Unable to decode branch DN "%s" \ ERR_ENTRY_GENERATOR_CANNOT_DECODE_BRANCH_DN=Unable to decode branch DN "%s" \ on line %d of the template file ERR_MAKELDIF_BRANCH_SUBORDINATE_TEMPLATE_NO_COLON=Subordinate \ ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_TEMPLATE_NO_COLON=Subordinate \ template definition on line %d for branch %s is missing a colon to separate \ the template name from the number of entries ERR_MAKELDIF_BRANCH_SUBORDINATE_INVALID_NUM_ENTRIES=Subordinate \ ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_INVALID_NUM_ENTRIES=Subordinate \ template definition on line %d for branch %s specified invalid number of \ entries %d for template %s WARN_MAKELDIF_BRANCH_SUBORDINATE_ZERO_ENTRIES=Subordinate template \ WARN_ENTRY_GENERATOR_BRANCH_SUBORDINATE_ZERO_ENTRIES=Subordinate template \ definition on line %d for branch %s specifies that zero entries of type %s \ should be generated ERR_MAKELDIF_BRANCH_SUBORDINATE_CANT_PARSE_NUMENTRIES=Unable to \ ERR_ENTRY_GENERATOR_BRANCH_SUBORDINATE_CANT_PARSE_NUMENTRIES=Unable to \ parse the number of entries for template %s as an integer for the subordinate \ template definition on line %d for branch %s ERR_MAKELDIF_TEMPLATE_SUBORDINATE_TEMPLATE_NO_COLON=Subordinate \ ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_TEMPLATE_NO_COLON=Subordinate \ template definition on line %d for template %s is missing a colon to separate \ the template name from the number of entries ERR_MAKELDIF_TEMPLATE_SUBORDINATE_INVALID_NUM_ENTRIES=Subordinate \ ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_INVALID_NUM_ENTRIES=Subordinate \ template definition on line %d for template %s specified invalid number of \ entries %d for subordinate template %s WARN_MAKELDIF_TEMPLATE_SUBORDINATE_ZERO_ENTRIES=Subordinate template \ WARN_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_ZERO_ENTRIES=Subordinate template \ definition on line %d for template %s specifies that zero entries of type %s \ should be generated ERR_MAKELDIF_TEMPLATE_SUBORDINATE_CANT_PARSE_NUMENTRIES=Unable to \ ERR_ENTRY_GENERATOR_TEMPLATE_SUBORDINATE_CANT_PARSE_NUMENTRIES=Unable to \ parse the number of entries for template %s as an integer for the subordinate \ template definition on line %d for template %s ERR_MAKELDIF_TEMPLATE_MISSING_RDN_ATTR=The template named %s \ ERR_ENTRY_GENERATOR_TEMPLATE_MISSING_RDN_ATTR=The template named %s \ includes RDN attribute %s that is not assigned a value in that template ERR_MAKELDIF_NO_COLON_IN_BRANCH_EXTRA_LINE=There is no colon to \ ERR_ENTRY_GENERATOR_NO_COLON_IN_BRANCH_EXTRA_LINE=There is no colon to \ separate the attribute name from the value pattern on line %d of the template \ file in the definition for branch %s ERR_MAKELDIF_NO_ATTR_IN_BRANCH_EXTRA_LINE=There is no attribute name \ ERR_ENTRY_GENERATOR_NO_ATTR_IN_BRANCH_EXTRA_LINE=There is no attribute name \ before the colon on line %d of the template file in the definition for branch \ %s WARN_MAKELDIF_NO_VALUE_IN_BRANCH_EXTRA_LINE=The value pattern for \ WARN_ENTRY_GENERATOR_NO_VALUE_IN_BRANCH_EXTRA_LINE=The value pattern for \ line %d of the template file in the definition for branch %s is empty ERR_MAKELDIF_NO_COLON_IN_TEMPLATE_LINE=There is no colon to separate \ ERR_ENTRY_GENERATOR_NO_COLON_IN_TEMPLATE_LINE=There is no colon to separate \ the attribute name from the value pattern on line %d of the template file in \ the definition for template %s ERR_MAKELDIF_NO_ATTR_IN_TEMPLATE_LINE=There is no attribute name \ ERR_ENTRY_GENERATOR_NO_ATTR_IN_TEMPLATE_LINE=There is no attribute name \ before the colon on line %d of the template file in the definition for \ template %s WARN_MAKELDIF_NO_VALUE_IN_TEMPLATE_LINE=The value pattern for line \ WARN_ENTRY_GENERATOR_NO_VALUE_IN_TEMPLATE_LINE=The value pattern for line \ %d of the template file in the definition for template %s is empty ERR_MAKELDIF_NO_SUCH_TAG=An undefined tag %s is referenced on line \ ERR_ENTRY_GENERATOR_NO_SUCH_TAG=An undefined tag %s is referenced on line \ %d of the template file ERR_MAKELDIF_CANNOT_INSTANTIATE_NEW_TAG=An unexpected error occurred \ ERR_ENTRY_GENERATOR_CANNOT_INSTANTIATE_NEW_TAG=An unexpected error occurred \ while trying to create a new instance of tag %s referenced on line %d of the \ template file: %s ERR_MAKELDIF_TAG_INVALID_FORMAT_STRING=Cannot parse value "%s" as an \ ERR_ENTRY_GENERATOR_TAG_INVALID_FORMAT_STRING=Cannot parse value "%s" as an \ valid format string for tag %s on line %d of the template file ERR_MAKELDIF_TAG_NO_RANDOM_TYPE_ARGUMENT=The random tag on line %d \ ERR_ENTRY_GENERATOR_TAG_NO_RANDOM_TYPE_ARGUMENT=The random tag on line %d \ of the template file does not include an argument to specify the type of \ random value that should be generated WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE=The value generated from the \ WARN_ENTRY_GENERATOR_TAG_WARNING_EMPTY_VALUE=The value generated from the \ random tag on line %d of the template file will always be an empty string ERR_MAKELDIF_TAG_UNKNOWN_RANDOM_TYPE=The random tag on line %d of \ ERR_ENTRY_GENERATOR_TAG_UNKNOWN_RANDOM_TYPE=The random tag on line %d of \ the template file references an unknown random type of %s ERR_MAKELDIF_COULD_NOT_FIND_TEMPLATE_FILE=Could not find template \ ERR_ENTRY_GENERATOR_COULD_NOT_FIND_TEMPLATE_FILE=Could not find template \ file %s ERR_MAKELDIF_TAG_CANNOT_FIND_FILE=Cannot find file %s referenced by \ ERR_ENTRY_GENERATOR_TAG_CANNOT_FIND_FILE=Cannot find file %s referenced by \ tag %s on line %d of the template file ERR_MAKELDIF_TAG_INVALID_FILE_ACCESS_MODE=Invalid file access mode \ ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE=Invalid file access mode \ %s for tag %s on line %d of the template file. It must be either \ "sequential" or "random" ERR_MAKELDIF_TAG_CANNOT_READ_FILE=An error occurred while trying to \ ERR_ENTRY_GENERATOR_TAG_CANNOT_READ_FILE=An error occurred while trying to \ read file %s referenced by tag %s on line %d of the template file: %s ERR_MAKELDIF_INCOMPLETE_TAG=Line %d of the template file contains an \ ERR_ENTRY_GENERATOR_INCOMPLETE_TAG=Line %d of the template file contains an \ incomplete tag that starts with either '<' or '{' but does get closed ERR_MAKELDIF_TAG_NOT_ALLOWED_IN_BRANCH=Tag %s referenced on line %d \ ERR_ENTRY_GENERATOR_TAG_NOT_ALLOWED_IN_BRANCH=Tag %s referenced on line %d \ of the template file is not allowed for use in branch definitions ERR_MAKELDIF_TEMPLATE_INVALID_PARENT_TEMPLATE=The parent template %s \ ERR_ENTRY_GENERATOR_TEMPLATE_INVALID_PARENT_TEMPLATE=The parent template %s \ referenced on line %d for template %s is invalid because the referenced \ parent template is not defined before the template that extends it ERR_MAKELDIF_TAG_LIST_NO_ARGUMENTS=The list tag on line %d of the \ ERR_ENTRY_GENERATOR_TAG_LIST_NO_ARGUMENTS=The list tag on line %d of the \ template file does not contain any arguments to specify the list values. At \ least one list value must be provided WARN_MAKELDIF_TAG_LIST_INVALID_WEIGHT=The list tag on line %d of \ WARN_ENTRY_GENERATOR_TAG_LIST_INVALID_WEIGHT=The list tag on line %d of \ the template file contains item '%s' that includes a semicolon but that \ semicolon is not followed by an integer. The semicolon will be assumed to be \ part of the value and not a delimiter to separate the value from its relative \ weight ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE=An error occurred while \ ERR_ENTRY_GENERATOR_IOEXCEPTION_DURING_PARSE=An error occurred while \ attempting to read the template file: %s ERR_MAKELDIF_EXCEPTION_DURING_PARSE=An error occurred while \ ERR_ENTRY_GENERATOR_EXCEPTION_DURING_PARSE=An error occurred while \ attempting to parse the template file: %s ERR_MAKELDIF_MISSING_TEMPLATE_FILE=Unexpected error when initializing config : no template file provided as input ERR_ENTRY_GENERATOR_MISSING_TEMPLATE_FILE=Unexpected error when initializing config : no template file provided as input opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/EntryGeneratorTestCase.java
File was renamed from opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/MakeLDIFEntryReaderTestCase.java @@ -29,7 +29,7 @@ import static org.fest.assertions.Assertions.*; import static org.forgerock.opendj.ldap.TestCaseUtils.getTestFilePath; import static org.forgerock.opendj.ldif.MakeLDIFEntryReader.*; import static org.forgerock.opendj.ldif.EntryGenerator.*; import java.io.File; import java.io.FileInputStream; @@ -48,7 +48,7 @@ import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class MakeLDIFEntryReaderTestCase extends SdkTestCase { public class EntryGeneratorTestCase extends SdkTestCase { private static final String TEMPLATE_FILE_PATH = "MakeLDIF/example.template"; private String resourcePath; @@ -63,7 +63,7 @@ @Test public void testReaderWithTemplateFile() throws Exception { String templatePath = getTestFilePath(TEMPLATE_FILE_PATH); MakeLDIFEntryReader reader = newReader(templatePath).setResourcePath(resourcePath).build(); EntryGenerator reader = newReader(templatePath).setResourcePath(resourcePath).build(); checkReader(reader); reader.close(); @@ -73,7 +73,7 @@ public void testReaderWithTemplateStream() throws Exception { InputStream stream = new FileInputStream( new File(getTestFilePath(TEMPLATE_FILE_PATH))); MakeLDIFEntryReader reader = newReader(stream).setResourcePath(resourcePath).build(); EntryGenerator reader = newReader(stream).setResourcePath(resourcePath).build(); checkReader(reader); reader.close(); @@ -82,7 +82,7 @@ @Test public void testReaderWithTemplateLines() throws Exception { MakeLDIFEntryReader reader = newReader( EntryGenerator reader = newReader( "define suffix=dc=example,dc=com", "define maildomain=example.com", "define numusers=2", @@ -126,7 +126,7 @@ * Check the content of the reader for basic case. * Expecting 4 entries with 2 users. */ private void checkReader(MakeLDIFEntryReader reader) throws Exception { private void checkReader(EntryGenerator reader) throws Exception { assertThat(reader.hasNext()).isTrue(); assertThat(reader.readEntry().getName().toString()).isEqualTo("dc=example,dc=com"); assertThat(reader.hasNext()).isTrue(); @@ -175,7 +175,7 @@ templateFile.parse(lines, warns); failWasExpected(DecodeException.class); } catch (DecodeException e) { LocalizableMessage expected = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get("missingVar", 1); LocalizableMessage expected = ERR_ENTRY_GENERATOR_TAG_UNDEFINED_ATTRIBUTE.get("missingVar", 1); assertThat(e.getMessage()).isEqualTo(expected.toString()); } } @@ -363,7 +363,7 @@ @Test(dataProvider = "templatesToTestEscapeChars", dependsOnMethods = { "testParsingEscapeCharInTemplate" }) public void testEscapeCharsFromTemplate(String testName, String[] lines, String attrName, String expectedValue) throws Exception { MakeLDIFEntryReader reader = newReader(lines).setResourcePath(resourcePath).build(); EntryGenerator reader = newReader(lines).setResourcePath(resourcePath).build(); Entry topEntry = reader.readEntry(); Entry entry = reader.readEntry(); reader.close(); @@ -392,7 +392,7 @@ // from [A-Z]. "cn: Foo \\<<random:chars:ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>\\>\\{1\\}{sn}", "", }; MakeLDIFEntryReader reader = newReader(lines).setResourcePath(resourcePath).build(); EntryGenerator reader = newReader(lines).setResourcePath(resourcePath).build(); Entry topEntry = reader.readEntry(); Entry entry = reader.readEntry(); reader.close();