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

Jean-Noel Rouvignac
16.57.2015 a41662c1136b2bb4a4198df89e0e87d2be3ef099
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 */
package org.opends.server.tools;
 
 
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
 
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
 
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.testng.Assert.*;
 
 
 
/**
 * A set of test cases for the LDIFDiff tool.
 */
public class LDIFDiffTestCase
       extends ToolsTestCase
{
  /**
   * The path to the file that will be used if there are no differences between
   * the source and target LDIF data sets.
   */
  private String noDiffsFile =
       System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT) + File.separator +
       "tests" + File.separator + "unit-tests-testng" + File.separator +
       "resource" + File.separator + "ldif-diff" + File.separator +
       "diff-nochanges.ldif";
 
 
 
  /**
   * Make sure that the server is running, since we need it for schema
   * handling.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
  }
 
 
  /** Calculates the checksum of a file. */
  private long calcChecksum(String filename) throws Exception
  {
    return calcChecksum(new File(filename));
  }
 
  private long calcChecksum(File file) throws Exception
  {
    long checksum = 0L;
    BufferedReader reader = new BufferedReader(new FileReader(file));
    String line = null;
    while ((line =reader.readLine()) != null)
    {
      checksum += line.hashCode();
    }
    reader.close();
    return checksum;
  }
 
 
  /**
   * Tests the LDIFDiff tool with an argument that will simply cause it to
   * display usage information.
   */
  @Test
  public void testUsage()
  {
    String[] args = { "--help" };
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
 
    args = new String[] { "-H" };
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
 
    args = new String[] { "-?" };
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
  }
 
 
 
  /**
   * Tests the LDIFDiff tool with an invalid set of arguments.
   */
  @Test
  public void testInvalidArguments()
  {
    String[] args =
    {
      "--invalid"
    };
 
    assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
  }
 
 
 
  /**
   * Retrieves the names of the files that should be used when testing the
   * ldif-diff tool.  Each element of the outer array should be an array
   * containing the following elements:
   * <OL>
   *   <LI>The path to the source LDIF file</LI>
   *   <LI>The path to the target LDIF file</LI>
   *   <LI>The path to the diff file, or {@code null} if the diff is supposed
   *       to fail</LI>
   * </OL>
   */
  @DataProvider(name = "testdata")
  public Object[][] getTestData()
  {
    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
    String ldifRoot  = buildRoot + File.separator + "tests" + File.separator +
                       "unit-tests-testng" + File.separator + "resource" +
                       File.separator + "ldif-diff" + File.separator;
 
    return new Object[][]
    {
      // Both files are empty.
      new Object[] { ldifRoot + "source-empty.ldif",
                     ldifRoot + "target-empty.ldif",
                     noDiffsFile, noDiffsFile,
                     COMPARE_TRUE },
 
      // Both files are the single-entry source.
      new Object[] { ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "source-singleentry.ldif",
                     noDiffsFile, noDiffsFile,
                     COMPARE_TRUE },
 
      // Both files are the single-entry target.
      new Object[] { ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "target-singleentry.ldif",
                     noDiffsFile, noDiffsFile,
                     COMPARE_TRUE },
 
      // Both files are the multiple-entry source.
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "source-multipleentries.ldif",
                     noDiffsFile, noDiffsFile,
                     COMPARE_TRUE },
 
      // Both files are the multiple-entry target.
      new Object[] { ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     noDiffsFile, noDiffsFile,
                     COMPARE_TRUE },
 
      // The source is empty but the target has a single entry.
      new Object[] { ldifRoot + "source-empty.ldif",
                     ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "diff-emptytosingle.ldif",
                     ldifRoot + "diff-emptytosingle.ldif",
                     COMPARE_FALSE },
 
      // The source has a single entry but the target is empty.
      new Object[] { ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "target-empty.ldif",
                     ldifRoot + "diff-singletoempty.ldif",
                     ldifRoot + "diff-singletoempty.ldif",
                     COMPARE_FALSE },
 
      // Make a change to only a single entry in the source->target direction.
      new Object[] { ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "diff-singleentry.ldif",
                     ldifRoot + "diff-singleentry.ldif",
                     COMPARE_FALSE },
 
      // Make a change to only a single entry in the target->source direction.
      new Object[] { ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "diff-singleentry-reverse.ldif",
                     ldifRoot + "diff-singleentry-reverse.ldif",
                     COMPARE_FALSE },
 
      // Make changes to multiple entries in the source->target direction.
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "diff-multipleentries.ldif",
                     ldifRoot + "diff-multipleentries-singlevalue.ldif",
                     COMPARE_FALSE },
 
      // Make changes to multiple entries in the target->source direction.
      new Object[] { ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "diff-multipleentries-reverse.ldif",
                     ldifRoot +
                          "diff-multipleentries-reverse-singlevalue.ldif",
                     COMPARE_FALSE },
 
      // Go from one entry to multiple in the source->target direction.
      new Object[] { ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "diff-singletomultiple.ldif",
                     ldifRoot + "diff-singletomultiple-singlevalue.ldif",
                     COMPARE_FALSE },
 
      // Go from one entry to multiple in the target->source direction.
      new Object[] { ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "diff-singletomultiple-reverse.ldif",
                     ldifRoot + "diff-singletomultiple-reverse.ldif",
                     COMPARE_FALSE },
 
      // Go from multiple entries to one in the source->target direction.
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-singleentry.ldif",
                     ldifRoot + "diff-multipletosingle.ldif",
                     ldifRoot + "diff-multipletosingle.ldif",
                     COMPARE_FALSE },
 
      // Go from multiple entries to one in the target->source direction.
      new Object[] { ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "diff-multipletosingle-reverse.ldif",
                     ldifRoot +
                          "diff-multipletosingle-reverse-singlevalue.ldif",
                     COMPARE_FALSE },
 
      // The source file doesn't exist.
      new Object[] { ldifRoot + "source-notfound.ldif",
                     ldifRoot + "target-singleentry.ldif",
                     null, null,
                     COMPARE_FALSE },
 
      // The target file doesn't exist.
      new Object[] { ldifRoot + "source-singleentry.ldif",
                     ldifRoot + "target-notfound.ldif",
                     null, null,
                     COMPARE_FALSE }
    };
  }
 
 
  /**
   * Tests the LDIFDiff tool with the provided information to ensure that the
   * normal mode of operation works as expected.  This is a bit tricky because
   * the attributes and values will be written in an indeterminate order, so we
   * can't just use string equality.  We'll have to use a crude checksum
   * mechanism to test whether they are equal.  Combined with other methods in
   * this class, this should be good enough.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @param  singleValueDiffFile  The path to the file containing the expected
   *                              diff in "single-value" form, where each
   *                              attribute-level change results in a separate
   *                              entry per attribute value.
   * @param resultCode            The result code that should be returned with
   *                              --useCompareResultCode flag
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testdata")
  public void testVerifyNormal(String sourceFile, String targetFile,
      String normalDiffFile, String singleValueDiffFile, int resultCode)
      throws Exception
  {
    File outputFile = File.createTempFile("difftest", "ldif");
    outputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-o", outputFile.getAbsolutePath(),
      "-O"
    };
    String[] argsUseCompare =
    {
      "-s", sourceFile,
      "-t", targetFile,
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    if (normalDiffFile == null)
    {
      // We expect this to fail, so just make sure that it does.
      assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
      outputFile.delete();
      return;
    }
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(outputFile), calcChecksum(normalDiffFile));
 
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), resultCode);
    outputFile.delete();
  }
 
 
 
 
  /**
   * Tests the LDIFDiff tool with the provided information to ensure that the
   * single value changes mode of operation works as expected.  This is a bit
   * tricky because the attributes and values will be written in an
   * indeterminate order, so we can't just use string equality.  We'll have to
   * use a crude checksum mechanism to test whether they are equal.  Combined
   * with other methods in this class, this should be good enough.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @param  singleValueDiffFile  The path to the file containing the expected
   *                              diff in "single-value" form, where each
   *                              attribute-level change results in a separate
   *                              entry per attribute value.
   * @param resultCode            The result code that should be returned with
   *                              --useCompareResultCode flag
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testdata")
  public void testVerifySingleValue(String sourceFile, String targetFile,
      String normalDiffFile, String singleValueDiffFile, int resultCode)
      throws Exception
  {
    File outputFile = File.createTempFile("difftest", "ldif");
    outputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-o", outputFile.getAbsolutePath(),
      "-O",
      "-S"
    };
    String[] argsUseCompare =
    {
      "-s", sourceFile,
      "-t", targetFile,
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    if (singleValueDiffFile == null)
    {
      // We expect this to fail, so just make sure that it does.
      assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
      outputFile.delete();
      return;
    }
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(outputFile), calcChecksum(singleValueDiffFile));
 
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), resultCode);
    outputFile.delete();
  }
 
 
 
  /**
   * Tests the LDIFDiff tool by first identifying the differences between the
   * source and the target and then using the LDIFModify tool to apply the
   * identified changes to the source LDIF and verify that it matches the
   * target.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @param  singleValueDiffFile  The path to the file containing the expected
   *                              diff in "single-value" form, where each
   *                              attribute-level change results in a separate
   *                              entry per attribute value.
   * @param resultCode            The result code that should be returned with
   *                              --useCompareResultCode flag
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testdata")
  public void testReconstructNormal(String sourceFile, String targetFile,
      String normalDiffFile, String singleValueDiffFile, int resultCode)
      throws Exception
  {
    // If the command is expected to fail, or if there aren't any differences,
    // then bail out now.
    if (normalDiffFile == null || normalDiffFile.equals(noDiffsFile))
    {
      return;
    }
 
 
    // Generate the diff file.
    File diffOutputFile = File.createTempFile("difftest", "ldif");
    diffOutputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-o", diffOutputFile.getAbsolutePath()
    };
    String[] argsUseCompare =
    {
      "-s", sourceFile,
      "-t", targetFile,
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), resultCode);
 
 
    // Use LDIFModify to generate a new target file.
    File newTargetFile = File.createTempFile("difftest", "newtarget.ldif");
    newTargetFile.deleteOnExit();
 
    DirectoryServer.getInstance();
    args = new String[]
    {
      "-c", DirectoryServer.getConfigFile(),
      "-s", sourceFile,
      "-m", diffOutputFile.getAbsolutePath(),
      "-t", newTargetFile.getAbsolutePath()
    };
 
    assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err),
                 0);
 
 
    // Use LDIFDiff again to verify that there are effectively no differences
    // between the original target and the new target.
    File newDiffFile = File.createTempFile("difftest", "newdiff.ldif");
    newDiffFile.deleteOnExit();
 
    args = new String[]
    {
      "-s", targetFile,
      "-t", newTargetFile.getAbsolutePath(),
      "-o", newDiffFile.getAbsolutePath()
    };
    argsUseCompare = new String[]
    {
      "-s", targetFile,
      "-t", newTargetFile.getAbsolutePath(),
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(newDiffFile), calcChecksum(noDiffsFile));
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), COMPARE_TRUE);
 
    diffOutputFile.delete();
    newTargetFile.delete();
    newDiffFile.delete();
  }
 
 
 
  /**
   * Tests the LDIFDiff tool by first identifying the differences between the
   * source and the target (using the single-value format) and then using the
   * LDIFModify tool to apply the identified changes to the source LDIF and
   * verify that it matches the target.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @param  singleValueDiffFile  The path to the file containing the expected
   *                              diff in "single-value" form, where each
   *                              attribute-level change results in a separate
   *                              entry per attribute value.
   * @param resultCode            The result code that should be returned with
   *                              --useCompareResultCode flag
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testdata")
  public void testReconstructSingleValue(String sourceFile, String targetFile,
      String normalDiffFile, String singleValueDiffFile, int resultCode)
      throws Exception
  {
    // If the command is expected to fail, or if there aren't any differences,
    // then bail out now.
    if (normalDiffFile == null || singleValueDiffFile.equals(noDiffsFile))
    {
      return;
    }
 
 
    // Generate the diff file.
    File diffOutputFile = File.createTempFile("difftest", "ldif");
    diffOutputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-o", diffOutputFile.getAbsolutePath(),
      "-S"
    };
    String[] argsUseCompare =
    {
      "-s", sourceFile,
      "-t", targetFile,
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), resultCode);
 
 
    // Use LDIFModify to generate a new target file.
    File newTargetFile = File.createTempFile("difftest", "newtarget.ldif");
    newTargetFile.deleteOnExit();
 
    DirectoryServer.getInstance();
    args = new String[]
    {
      "-c", DirectoryServer.getConfigFile(),
      "-s", sourceFile,
      "-m", diffOutputFile.getAbsolutePath(),
      "-t", newTargetFile.getAbsolutePath()
    };
 
    assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err),
                 0);
 
 
    // Use LDIFDiff again to verify that there are effectively no differences
    // between the original target and the new target.
    File newDiffFile = File.createTempFile("difftest", "newdiff.ldif");
    newDiffFile.deleteOnExit();
 
    args = new String[]
    {
      "-s", targetFile,
      "-t", newTargetFile.getAbsolutePath(),
      "-o", newDiffFile.getAbsolutePath()
    };
    argsUseCompare = new String[]
    {
      "-s", targetFile,
      "-t", newTargetFile.getAbsolutePath(),
      // No need to write to the outputFile
      "--useCompareResultCode"
    };
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(newDiffFile), calcChecksum(noDiffsFile));
    assertEquals(LDIFDiff
        .mainDiff(argsUseCompare, true, System.out, System.err), COMPARE_TRUE);
 
    diffOutputFile.delete();
    newTargetFile.delete();
    newDiffFile.delete();
  }
 
 
  /**
   * Retrieves the names of the files that should be used when testing the
   * ldif-diff tool.  Each element of the outer array should be an array
   * containing the following elements:
   * <OL>
   *   <LI>The path to the source LDIF file</LI>
   *   <LI>The path to the target LDIF file</LI>
   *   <LI>The path to the file with attributes to be ignored</LI>
   *   <LI>The path to the diff file</LI>
   * </OL>
   */
  @DataProvider(name = "ignoreattributesdata")
  public Object[][] getIATestData()
  {
    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
    String ldifRoot  = buildRoot + File.separator + "tests" + File.separator +
                       "unit-tests-testng" + File.separator + "resource" +
                       File.separator + "ldif-diff" + File.separator;
 
    return new Object[][]
    {
      // Make changes to multiple entries in the target->source direction.
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "ignore-attributes",
                     ldifRoot + "diff-multipleentries-ignore-attributes.ldif" },
 
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "does-not-exist",
                     ldifRoot + "diff-multipleentries-ignore-attributes.ldif" }
    };
 
  }
 
 
 
  /**
   * Tests the LDIFDiff tool with the provided information to ensure that the
   * normal mode of operation works as expected.  This is a bit tricky because
   * the attributes and values will be written in an indeterminate order, so we
   * can't just use string equality.  We'll have to use a crude checksum
   * mechanism to test whether they are equal.  Combined with other methods in
   * this class, this should be good enough.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "ignoreattributesdata")
  public void testVerifyIgnoreAttributes(String sourceFile, String targetFile,
                               String ignoreAttributesFile,
                               String normalDiffFile)
         throws Exception
  {
    File outputFile = File.createTempFile("difftest", "ldif");
    outputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-a", ignoreAttributesFile,
      "-o", outputFile.getAbsolutePath(),
      "-O"
    };
 
    if (ignoreAttributesFile.endsWith("does-not-exist"))
    {
      // We expect this to fail, so just make sure that it does.
      assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 1);
      return;
    }
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(outputFile), calcChecksum(normalDiffFile));
 
    outputFile.delete();
  }
 
 
  /**
   * Retrieves the names of the files that should be used when testing the
   * ldif-diff tool.  Each element of the outer array should be an array
   * containing the following elements:
   * <OL>
   *   <LI>The path to the source LDIF file</LI>
   *   <LI>The path to the target LDIF file</LI>
   *   <LI>The path to the file with entries to be ignored</LI>
   *   <LI>The path to the diff file</LI>
   * </OL>
   */
  @DataProvider(name = "ignoreentriesdata")
  public Object[][] getIETestData()
  {
    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
    String ldifRoot  = buildRoot + File.separator + "tests" + File.separator +
                       "unit-tests-testng" + File.separator + "resource" +
                       File.separator + "ldif-diff" + File.separator;
 
    return new Object[][]
    {
      // Make changes to multiple entries in the target->source direction.
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "ignore-entries",
                     ldifRoot + "diff-multipleentries-ignore-entries.ldif" },
 
      new Object[] { ldifRoot + "source-multipleentries.ldif",
                     ldifRoot + "target-multipleentries.ldif",
                     ldifRoot + "does-not-exist",
                     ldifRoot + "diff-multipleentries-ignore-entries.ldif" }
    };
 
  }
 
 
 
  /**
   * Tests the LDIFDiff tool with the provided information to ensure that the
   * normal mode of operation works as expected.  This is a bit tricky because
   * the attributes and values will be written in an indeterminate order, so we
   * can't just use string equality.  We'll have to use a crude checksum
   * mechanism to test whether they are equal.  Combined with other methods in
   * this class, this should be good enough.
   *
   * @param  sourceFile           The path to the file containing the source
   *                              data set.
   * @param  targetFile           The path to the file containing the target
   *                              data set.
   * @param  normalDiffFile       The path to the file containing the expected
   *                              diff in "normal" form (at most one record per
   *                              entry), or {@code null} if the diff is
   *                              supposed to fail.
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "ignoreentriesdata")
  public void testVerifyIgnoreEntries(String sourceFile, String targetFile,
                               String ignoreEntriesFile,
                               String normalDiffFile)
         throws Exception
  {
    File outputFile = File.createTempFile("difftest", "ldif");
    outputFile.deleteOnExit();
 
    String[] args =
    {
      "-s", sourceFile,
      "-t", targetFile,
      "-e", ignoreEntriesFile,
      "-o", outputFile.getAbsolutePath(),
      "-O"
    };
 
    if (ignoreEntriesFile.endsWith("does-not-exist"))
    {
      // We expect this to fail, so just make sure that it does.
      assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 1);
      return;
    }
 
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    assertEquals(calcChecksum(outputFile), calcChecksum(normalDiffFile));
 
    outputFile.delete();
  }
}