Update code in the org.opends.server.util package to use the
Validator.ensureNotNull method for arguments that are not allowed to be null,
and also update the javadoc for the corresponding @param tags to indicate this.
Also, update the ModifyDNChangeRecordEntry class to rearrange the order of the
constructor arguments to be more consistent with the rest of the codebase, as
well as the standard definitions in LDAP and LDIF.
Reviewed by davidely.
| | |
| | | |
| | | import static org.opends.server.loggers.Debug.debugConstructor; |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | * Creates a new entry with the provided information. |
| | | * |
| | | * @param dn |
| | | * The distinguished name for this entry. |
| | | * The distinguished name for this entry. It must not be |
| | | * <CODE>null</CODE>. |
| | | * @param attributes |
| | | * The entry attributes for this operation. |
| | | * The entry attributes for this operation. It must not be |
| | | * <CODE>null</CODE>. |
| | | */ |
| | | public AddChangeRecordEntry(DN dn, |
| | | Map<AttributeType,List<Attribute>> attributes) |
| | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(dn), |
| | | String.valueOf(attributes)); |
| | | |
| | | ensureNotNull(attributes); |
| | | |
| | | |
| | | this.attributes = new ArrayList<Attribute>(attributes.size()); |
| | | for (List<Attribute> list : attributes.values()) |
| | |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.nio.ByteBuffer; |
| | | import java.text.ParseException; |
| | |
| | | /** |
| | | * Encodes the provided raw data using base64. |
| | | * |
| | | * @param rawData The raw data to encode. |
| | | * @param rawData The raw data to encode. It must not be <CODE>null</CODE>. |
| | | * |
| | | * @return The base64-encoded representation of the provided raw data. |
| | | */ |
| | |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encode", String.valueOf(rawData)); |
| | | |
| | | ensureNotNull(rawData); |
| | | |
| | | |
| | | StringBuilder buffer = new StringBuilder(4 * rawData.length / 3); |
| | | |
| | |
| | | /** |
| | | * Decodes the provided set of base64-encoded data. |
| | | * |
| | | * @param encodedData The base64-encoded data to decode. |
| | | * @param encodedData The base64-encoded data to decode. It must not be |
| | | * <CODE>null</CODE>. |
| | | * |
| | | * @return The decoded raw data. |
| | | * |
| | |
| | | { |
| | | assert debugEnter(CLASS_NAME, "decode", String.valueOf(encodedData)); |
| | | |
| | | ensureNotNull(encodedData); |
| | | |
| | | |
| | | // The encoded value must have length that is a multiple of four bytes. |
| | | int length = encodedData.length(); |
| | |
| | | |
| | | import static org.opends.server.loggers.Debug.debugConstructor; |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import org.opends.server.types.DN; |
| | | |
| | |
| | | /** |
| | | * Creates a new change record entry with the provided information. |
| | | * |
| | | * @param dn The distinguished name for this change record entry. |
| | | * @param dn The distinguished name for this change record entry. It must |
| | | * not be <CODE>null</CODE>. |
| | | */ |
| | | protected ChangeRecordEntry(DN dn) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(dn)); |
| | | |
| | | if (dn == null) |
| | | { |
| | | this.dn = new DN(); |
| | | } |
| | | else |
| | | { |
| | | this.dn = dn; |
| | | } |
| | | ensureNotNull(dn); |
| | | this.dn = dn; |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Creates a new entry with the provided information. |
| | | * |
| | | * @param dn The distinguished name for this entry. |
| | | * @param dn The distinguished name for this entry. It must not be |
| | | * <CODE>null</CODE>. |
| | | */ |
| | | public DeleteChangeRecordEntry(DN dn) |
| | | { |
| | |
| | | * This class defines an exception that may be thrown while attempting to parse |
| | | * LDIF content. |
| | | */ |
| | | public class LDIFException |
| | | public final class LDIFException |
| | | extends Exception |
| | | { |
| | | /** |
| | |
| | | |
| | | // Indicates whether this exception is severe enough that it is no longer |
| | | // possible to keep reading. |
| | | private boolean canContinueReading; |
| | | private final boolean canContinueReading; |
| | | |
| | | // The line number of the last line read from the LDIF source. |
| | | private long lineNumber; |
| | | private final long lineNumber; |
| | | |
| | | // The unique message ID for the associated message. |
| | | private int messageID; |
| | | private final int messageID; |
| | | |
| | | |
| | | |
| | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.StaticUtils.toLowerCase; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | |
| | | * Creates a new LDIF reader that will read information from the specified |
| | | * file. |
| | | * |
| | | * @param importConfig The import configuration for this LDIF reader. |
| | | * @param importConfig The import configuration for this LDIF reader. It |
| | | * must not be <CODE>null</CODE>. |
| | | * |
| | | * @throws IOException If a problem occurs while opening the LDIF file for |
| | | * reading. |
| | |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(importConfig)); |
| | | |
| | | ensureNotNull(importConfig); |
| | | this.importConfig = importConfig; |
| | | |
| | | reader = importConfig.getReader(); |
| | |
| | | { |
| | | try |
| | | { |
| | | rejectWriter.write("# "); |
| | | rejectWriter.write(message); |
| | | rejectWriter.newLine(); |
| | | if ((message != null) && (message.length() > 0)) |
| | | { |
| | | rejectWriter.write("# "); |
| | | rejectWriter.write(message); |
| | | rejectWriter.newLine(); |
| | | } |
| | | |
| | | for (StringBuilder sb : lastEntryHeaderLines) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return new ModifyDNChangeRecordEntry(entryDN, newSuperiorDN, |
| | | newRDN, deleteOldRDN); |
| | | return new ModifyDNChangeRecordEntry(entryDN, newRDN, deleteOldRDN, |
| | | newSuperiorDN); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * Creates a new LDIF writer with the provided configuration. |
| | | * |
| | | * @param exportConfig The configuration to use for the export. |
| | | * @param exportConfig The configuration to use for the export. It must not |
| | | * be <CODE>null</CODE>. |
| | | * |
| | | * @throws IOException If a problem occurs while opening the writer. |
| | | */ |
| | |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(exportConfig)); |
| | | |
| | | ensureNotNull(exportConfig); |
| | | this.exportConfig = exportConfig; |
| | | |
| | | writer = exportConfig.getWriter(); |
| | |
| | | * |
| | | * @param comment The comment to be written. Any line breaks that it |
| | | * contains will be honored, and potentially new line |
| | | * breaks may be introduced by the wrapping process. |
| | | * breaks may be introduced by the wrapping process. It |
| | | * must not be <CODE>null</CODE>. |
| | | * @param wrapColumn The column at which long lines should be wrapped, or |
| | | * -1 to indicate that no additional wrapping should be |
| | | * added. This will override the wrap column setting |
| | |
| | | assert debugEnter(CLASS_NAME, "writeComment", String.valueOf(comment), |
| | | String.valueOf(wrapColumn)); |
| | | |
| | | ensureNotNull(comment); |
| | | |
| | | |
| | | // First, break up the comment into multiple lines to preserve the original |
| | | // spacing that it contained. |
| | |
| | | /** |
| | | * Writes the provided entry to LDIF. |
| | | * |
| | | * @param entry The entry to be written. |
| | | * @param entry The entry to be written. It must not be <CODE>null</CODE>. |
| | | * |
| | | * @return <CODE>true</CODE> if the entry was actually written, or |
| | | * <CODE>false</CODE> if it was not because of the export |
| | |
| | | { |
| | | assert debugEnter(CLASS_NAME, "writeEntry", String.valueOf(entry)); |
| | | |
| | | ensureNotNull(entry); |
| | | return entry.toLDIF(exportConfig); |
| | | } |
| | | |
| | |
| | | * performed for this entry, nor will any export plugins be invoked. Further, |
| | | * only the user attributes will be included. |
| | | * |
| | | * @param entry The entry to include in the add change record. |
| | | * @param entry The entry to include in the add change record. It must not |
| | | * be <CODE>null</CODE>. |
| | | * |
| | | * @throws IOException If a problem occurs while writing the add record. |
| | | */ |
| | |
| | | assert debugEnter(CLASS_NAME, "writeAddChangeRecord", |
| | | String.valueOf(entry)); |
| | | |
| | | ensureNotNull(entry); |
| | | |
| | | |
| | | // Get the information necessary to write the LDIF. |
| | | BufferedWriter writer = exportConfig.getWriter(); |
| | | int wrapColumn = exportConfig.getWrapColumn(); |
| | |
| | | * this entry, nor will any export plugins be invoked. Further, only the user |
| | | * attributes will be included. |
| | | * |
| | | * @param entry The entry to include in the delete change record. |
| | | * @param entry The entry to include in the delete change record. It |
| | | * must not be <CODE>null</CODE>. |
| | | * @param commentEntry Indicates whether to include a comment with the |
| | | * contents of the entry. |
| | | * |
| | |
| | | assert debugEnter(CLASS_NAME, "writeDeleteChangeRecord", |
| | | String.valueOf(entry), String.valueOf(commentEntry)); |
| | | |
| | | ensureNotNull(entry); |
| | | |
| | | // Get the information necessary to write the LDIF. |
| | | BufferedWriter writer = exportConfig.getWriter(); |
| | | int wrapColumn = exportConfig.getWrapColumn(); |
| | |
| | | * Writes a modify change record with the provided information. No filtering |
| | | * will be performed, nor will any export plugins be invoked. |
| | | * |
| | | * @param dn The DN of the entry being modified. |
| | | * @param dn The DN of the entry being modified. It must not be |
| | | * <CODE>null</CODE>. |
| | | * @param modifications The set of modifications to include in the change |
| | | * record. |
| | | * record. It must not be <CODE>null</CODE>. |
| | | * |
| | | * @throws IOException If a problem occurs while writing the modify record. |
| | | */ |
| | |
| | | assert debugEnter(CLASS_NAME, "writeModifyChangeRecord", String.valueOf(dn), |
| | | String.valueOf(modifications)); |
| | | |
| | | ensureNotNull(dn, modifications); |
| | | |
| | | // If there aren't any modifications, then there's nothing to do. |
| | | if (modifications.isEmpty()) |
| | | { |
| | |
| | | * Writes a modify DN change record with the provided information. No |
| | | * filtering will be performed, nor will any export plugins be invoked. |
| | | * |
| | | * @param dn The DN of the entry before the rename. |
| | | * @param newRDN The new RDN for the entry. |
| | | * @param dn The DN of the entry before the rename. It must not |
| | | * be <CODE>null</CODE>. |
| | | * @param newRDN The new RDN for the entry. It must not be |
| | | * <CODE>null</CODE>. |
| | | * @param deleteOldRDN Indicates whether the old RDN value should be removed |
| | | * from the entry. |
| | | * @param newSuperior The new superior DN for the entry, or |
| | |
| | | String.valueOf(deleteOldRDN), |
| | | String.valueOf(newSuperior)); |
| | | |
| | | ensureNotNull(dn, newRDN); |
| | | |
| | | |
| | | // Get the information necessary to write the LDIF. |
| | | BufferedWriter writer = exportConfig.getWriter(); |
| | |
| | | * space, and a base64-encoded form of the value will be appended. |
| | | * |
| | | * @param buffer The buffer to which the information should be |
| | | * appended. |
| | | * @param valueBytes The value to append to the buffer. |
| | | * appended. It must not be <CODE>null</CODE>. |
| | | * @param valueBytes The value to append to the buffer. It must not be |
| | | * <CODE>null</CODE>. |
| | | */ |
| | | public static void appendLDIFSeparatorAndValue(StringBuilder buffer, |
| | | byte[] valueBytes) |
| | |
| | | "java.lang.StringBuilder", |
| | | String.valueOf(valueBytes)); |
| | | |
| | | ensureNotNull(buffer, valueBytes); |
| | | |
| | | |
| | | // If the value is empty, then just append a single colon and a single |
| | | // space. |
| | |
| | | /** |
| | | * Writes the provided line to LDIF using the provided information. |
| | | * |
| | | * @param line The line of information to write. |
| | | * @param writer The writer to which the data should be written. |
| | | * @param line The line of information to write. It must not be |
| | | * <CODE>null</CODE>. |
| | | * @param writer The writer to which the data should be written. It |
| | | * must not be <CODE>null</CODE>. |
| | | * @param wrapLines Indicates whether to wrap long lines. |
| | | * @param wrapColumn The column at which long lines should be wrapped. |
| | | * |
| | |
| | | String.valueOf(writer), String.valueOf(wrapLines), |
| | | String.valueOf(wrapColumn)); |
| | | |
| | | ensureNotNull(line, writer); |
| | | |
| | | int length = line.length(); |
| | | if (wrapLines && (length > wrapColumn)) |
| | | { |
| | |
| | | |
| | | import static org.opends.server.loggers.Debug.debugConstructor; |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | /** |
| | | * Creates a new entry with the provided information. |
| | | * |
| | | * @param dn The distinguished name for this entry. |
| | | * @param modifications The modifications for this change record. |
| | | * @param dn The distinguished name for this entry. It must not |
| | | * be <CODE>null</CODE>. |
| | | * @param modifications The modifications for this change record. It must |
| | | * not be <CODE>null</CODE>. |
| | | */ |
| | | public ModifyChangeRecordEntry(DN dn, |
| | | Collection<LDAPModification> modifications) |
| | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(dn), |
| | | String.valueOf(modifications)); |
| | | |
| | | ensureNotNull(modifications); |
| | | |
| | | this.modifications = new ArrayList<LDAPModification>(modifications); |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.loggers.Debug.debugConstructor; |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * Creates a new entry with the provided information. |
| | | * |
| | | * @param dn |
| | | * The distinguished name for this entry. |
| | | * @param newSuperiorDN |
| | | * The new superior DN. |
| | | * The distinguished name for this entry. It must not be |
| | | * <CODE>null</CODE>. |
| | | * @param newRDN |
| | | * The new RDN. |
| | | * The new RDN. It must not be <CODE>null</CODE>. |
| | | * @param deleteOldRDN |
| | | * Delete the old RDN? |
| | | * @param newSuperiorDN |
| | | * The new superior DN. It may be <CODE>null</CODE> if the entry is |
| | | * not to be moved below a new parent. |
| | | */ |
| | | public ModifyDNChangeRecordEntry(DN dn, DN newSuperiorDN, |
| | | RDN newRDN, boolean deleteOldRDN) |
| | | public ModifyDNChangeRecordEntry(DN dn, RDN newRDN, boolean deleteOldRDN, |
| | | DN newSuperiorDN) |
| | | { |
| | | super(dn); |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(dn), |
| | |
| | | String.valueOf(newRDN), |
| | | String.valueOf(deleteOldRDN)); |
| | | |
| | | ensureNotNull(newRDN); |
| | | |
| | | this.newSuperiorDN = newSuperiorDN; |
| | | this.newRDN = newRDN; |
| | | this.deleteOldRDN = deleteOldRDN; |
| | |
| | | /** |
| | | * Get the new superior DN for the requested modify DN operation. |
| | | * |
| | | * @return the new superior DN. |
| | | * @return the new superior DN, or <CODE>null</CODE> if there is none. |
| | | * |
| | | */ |
| | | public DN getNewSuperiorDN() |
| | |
| | | * debugging will be performed in this class due to the frequency with which it |
| | | * will be called. |
| | | */ |
| | | public class TimeThread |
| | | public final class TimeThread |
| | | extends DirectoryThread |
| | | { |
| | | /** |
| | |
| | | |
| | | /** |
| | | * Once-only initialization. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurred. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | @Test(expectedExceptions = { NullPointerException.class, |
| | | AssertionError.class }) |
| | | public void testConstructorNullDN() throws Exception { |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(null, attributes); |
| | | |
| | | Assert.assertEquals(entry.getDN(), new DN()); |
| | | } |
| | | |
| | | /** |
| | | * Tests the constructor with empty DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with non-null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the change operation type is correct. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testChangeOperationType() throws Exception { |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(null, attributes); |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(new DN(), attributes); |
| | | |
| | | Assert.assertEquals(entry.getChangeOperationType(), |
| | | ChangeOperationType.ADD); |
| | |
| | | |
| | | /** |
| | | * Tests getAttributes method for empty modifications. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetAttributesEmpty() throws Exception { |
| | | Map<AttributeType, List<Attribute>> empty = Collections.emptyMap(); |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(null, empty); |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(new DN(), empty); |
| | | |
| | | List<Attribute> attrs = entry.getAttributes(); |
| | | Assert.assertEquals(attrs.size(), 0); |
| | |
| | | |
| | | /** |
| | | * Tests getAttributes method for non-empty modifications. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetAttributesNonEmpty() throws Exception { |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(null, attributes); |
| | | AddChangeRecordEntry entry = new AddChangeRecordEntry(new DN(), attributes); |
| | | |
| | | List<Attribute> attrs = entry.getAttributes(); |
| | | Assert.assertEquals(attrs.size(), 1); |
| | |
| | | |
| | | /** |
| | | * Create a new test record. |
| | | * |
| | | * |
| | | * @param dn |
| | | * The test record's DN. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Once-only initialization. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurred. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | @Test(expectedExceptions = { NullPointerException.class, |
| | | AssertionError.class }) |
| | | 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. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with non-null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | public final class TestDeleteChangeRecordEntry extends UtilTestCase { |
| | | /** |
| | | * Once-only initialization. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurred. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | @Test(expectedExceptions = { NullPointerException.class, |
| | | AssertionError.class }) |
| | | public void testConstructorNullDN() throws Exception { |
| | | DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(null); |
| | | |
| | | Assert.assertEquals(entry.getDN(), new DN()); |
| | | } |
| | | |
| | | /** |
| | | * Tests the constructor with empty DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with non-null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 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); |
| | | DeleteChangeRecordEntry entry = new DeleteChangeRecordEntry(new DN()); |
| | | |
| | | Assert.assertEquals(entry.getChangeOperationType(), |
| | | ChangeOperationType.DELETE); |
| | |
| | | |
| | | /** |
| | | * Once-only initialization. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurred. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | @Test(expectedExceptions = { NullPointerException.class, |
| | | AssertionError.class }) |
| | | public void testConstructorNullDN() throws Exception { |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(null, |
| | | modifications); |
| | | |
| | | Assert.assertEquals(entry.getDN(), new DN()); |
| | | } |
| | | |
| | | /** |
| | | * Tests the constructor with empty DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with non-null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 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, |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(new DN(), |
| | | modifications); |
| | | |
| | | Assert.assertEquals(entry.getChangeOperationType(), |
| | |
| | | |
| | | /** |
| | | * Tests getModifications method for empty modifications. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetModificationsEmpty() throws Exception { |
| | | List<LDAPModification> empty = Collections.emptyList(); |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(null, empty); |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(new DN(), |
| | | empty); |
| | | |
| | | List<LDAPModification> mods = entry.getModifications(); |
| | | Assert.assertEquals(mods.size(), 0); |
| | |
| | | |
| | | /** |
| | | * Tests getModifications method for non-empty modifications. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetModificationsNonEmpty() throws Exception { |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(null, |
| | | ModifyChangeRecordEntry entry = new ModifyChangeRecordEntry(new DN(), |
| | | modifications); |
| | | |
| | | List<LDAPModification> mods = entry.getModifications(); |
| | |
| | | |
| | | /** |
| | | * Once-only initialization. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurred. |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Tests the constructor with null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | @Test(expectedExceptions = { NullPointerException.class, |
| | | AssertionError.class }) |
| | | public void testConstructorNullDN() throws Exception { |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null, |
| | | newSuperiorDN, newRDN, false); |
| | | |
| | | Assert.assertEquals(entry.getDN(), new DN()); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(null, newRDN, false, newSuperiorDN); |
| | | } |
| | | |
| | | /** |
| | | * 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(), newSuperiorDN, newRDN, false); |
| | | new DN(), newRDN, false, newSuperiorDN); |
| | | |
| | | Assert.assertEquals(entry.getDN(), new DN()); |
| | | } |
| | | |
| | | /** |
| | | * Tests the constructor with non-null DN. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | |
| | | DN testDN2 = DN.decode("dc=hello, dc=world"); |
| | | |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry( |
| | | testDN1, newSuperiorDN, newRDN, false); |
| | | testDN1, newRDN, false, newSuperiorDN); |
| | | |
| | | 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, |
| | | newSuperiorDN, newRDN, false); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(new DN(), newRDN, false, newSuperiorDN); |
| | | |
| | | Assert.assertEquals(entry.getChangeOperationType(), |
| | | ChangeOperationType.MODIFY_DN); |
| | |
| | | |
| | | /** |
| | | * Tests getNewRDN method. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetNewRDN() throws Exception { |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null, |
| | | newSuperiorDN, newRDN, false); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(new DN(), newRDN, false, newSuperiorDN); |
| | | |
| | | Assert.assertEquals(entry.getNewRDN(), newRDN.duplicate()); |
| | | } |
| | | |
| | | /** |
| | | * Tests getNewSuperiorDN method. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testGetNewSuperiorDN() throws Exception { |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null, |
| | | newSuperiorDN, newRDN, false); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(new DN(), newRDN, false, newSuperiorDN); |
| | | |
| | | Assert |
| | | .assertEquals(entry.getNewSuperiorDN(), newSuperiorDN.duplicate()); |
| | |
| | | |
| | | /** |
| | | * Tests deleteOldRDN method when false. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testDeleteOldRDNFalse() throws Exception { |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null, |
| | | newSuperiorDN, newRDN, false); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(new DN(), newRDN, false, newSuperiorDN); |
| | | |
| | | Assert.assertEquals(entry.deleteOldRDN(), false); |
| | | } |
| | | |
| | | /** |
| | | * Tests deleteOldRDN method. |
| | | * |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testDeleteOldRDNTrue() throws Exception { |
| | | ModifyDNChangeRecordEntry entry = new ModifyDNChangeRecordEntry(null, |
| | | newSuperiorDN, newRDN, true); |
| | | ModifyDNChangeRecordEntry entry = |
| | | new ModifyDNChangeRecordEntry(new DN(), newRDN, true, newSuperiorDN); |
| | | |
| | | Assert.assertEquals(entry.deleteOldRDN(), true); |
| | | } |