@After
 public void tearDown() {
   pse.tearDown();
   pss.tearDown();
   mtf.tearDown();
   JMSConnectionFactory.getInstance().removeListener(Channels.getTheIndexServer(), listener);
   mjms.tearDown();
   rs.tearDown();
 }
  /** Test that download of a small file succeeds. */
  @Test
  public void testMain() {
    String[] args = new String[] {"-tDEDUP", "-l1"};

    TestInfo.CACHE_TEMP_DIR.mkdirs(); // FIXME: Should not be missing.
    ZipUtils.gzipFiles(TestInfo.CACHE_TEMP_DIR, TestInfo.CACHE_OUTPUT_DIR);

    pss.tearDown();
    CreateIndex.main(args);
  }
 @After
 public void tearDown() {
   marc.tearDown();
   pse.tearDown();
   pss.tearDown();
   mtf.tearDown();
   mjms.tearDown();
   ulrf.tearDown();
   RememberNotifications.resetSingleton();
   rs.tearDown();
 }
 @Before
 public void setUp() {
   rs.setUp();
   ulrf.setUp();
   mjms.setUp();
   mtf.setUp();
   pss.setUp();
   pse.setUp();
   marc.setUp();
   Settings.set(CommonSettings.NOTIFICATIONS_CLASS, RememberNotifications.class.getName());
 }
 @Before
 public void setUp() {
   rs.setUp();
   mjms.setUp();
   listener = new CreateIndexListener();
   JMSConnectionFactory.getInstance().setListener(Channels.getTheIndexServer(), listener);
   Settings.set(
       CommonSettings.REMOTE_FILE_CLASS, "dk.netarkivet.common.distribute.NullRemoteFile");
   Settings.set(CommonSettings.CACHE_DIR, TestInfo.CACHE_DIR.getPath());
   mtf.setUp();
   pss.setUp();
   pse.setUp();
 }
  @Test
  public void testBadArguments4() {
    String[] args = new String[] {"-tMYINDEX", "-l1"};
    String expectedMsg = "Unknown indextype 'MYINDEX' requested.";

    try {
      CreateIndex.main(args);
      fail("It should not be allowed to call CreateIndex with bad arguments");
    } catch (SecurityException e) {
      // expected
    }

    String errMsg = pss.getErr();
    int exitCode = pse.getExitValue();

    assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode);
    assertTrue(
        "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.",
        errMsg.contains(expectedMsg));
  }
  @Test
  public void testBadArguments1() {
    String[] args = new String[] {"-asdf"};
    String expectedMsg = "Parsing of parameters failed: Unrecognized option: -a";

    try {
      CreateIndex.main(args);
      fail("It should not be allowed to call CreateIndex with bad arguments");
    } catch (SecurityException e) {
      // expected
    }

    String errMsg = pss.getErr();
    int exitCode = pse.getExitValue();

    assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode);
    assertTrue(
        "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.",
        errMsg.contains(expectedMsg));
  }
  @Test
  public void testBadArguments3() {
    String[] args = new String[] {"-l1"};
    // String expectedMsg =
    // "Some of the required parameters are missing: -t";
    String expectedMsg = "Some of the required parameters are missing: Missing required option: t";

    try {
      CreateIndex.main(args);
      fail("It should not be allowed to call CreateIndex with bad arguments");
    } catch (SecurityException e) {
      // expected
    }

    String errMsg = pss.getErr();
    int exitCode = pse.getExitValue();

    assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode);
    assertTrue(
        "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.",
        errMsg.contains(expectedMsg));
  }