@Before
  public void setUp() throws Exception {
    rs.setUp();
    mtf.setUp();
    JMSConnectionMockupMQ.useJMSConnectionMockupMQ();

    Settings.set(ArchiveSettings.DIRS_ARCREPOSITORY_ADMIN, TestInfo.WORKING_DIR.getAbsolutePath());

    if (!Replica.isKnownReplicaId("TWO") || !Replica.isKnownReplicaId("ONE")) {
      List<String> knownIds = new ArrayList<String>();

      fail(
          "These tests assume, that ONE and TWO are known replica ids. Only known replicas are: "
              + StringUtils.conjoin(", ", knownIds.toArray(Replica.getKnownIds())));
    }
    // super.setUp();
  }
  public void setUp() throws Exception {
    ChannelsTester.resetChannels();
    rs.setUp();
    mtf.setUp();
    utrf.setUp();

    JMSConnectionMockupMQ.useJMSConnectionMockupMQ();

    DatabaseTestUtils.takeDatabase(TestInfo.DATABASE_FILE, TestInfo.DATABASE_DIR);

    // define the settings for accessing the database
    Settings.set(ArchiveSettings.BASEURL_ARCREPOSITORY_ADMIN_DATABASE, TestInfo.DATABASE_URL);
    Settings.set(ArchiveSettings.MACHINE_ARCREPOSITORY_ADMIN_DATABASE, "");
    Settings.set(ArchiveSettings.PORT_ARCREPOSITORY_ADMIN_DATABASE, "");
    Settings.set(ArchiveSettings.DIR_ARCREPOSITORY_ADMIN_DATABASE, "");

    Settings.set(CommonSettings.NOTIFICATIONS_CLASS, PrintNotifications.class.getName());
  }
  /** Disabled, fails on Jenkins */
  public void failingTestArcRepositoryCalls() {
    DatabaseAdmin da = DatabaseAdmin.getInstance();

    assertFalse("Should not contain NON-EXISTING-FILE", da.hasEntry("NON-EXISTING-FILE"));
    assertFalse(
        "Should not contain StoreMessage for NON-EXISTING-FILE",
        da.hasReplyInfo("NON-EXISTING-FILE"));

    StoreMessage storeMsg1 = new StoreMessage(Channels.getError(), TestInfo.TEST_FILE_1);
    JMSConnectionMockupMQ.updateMsgID(storeMsg1, "store1");

    da.addEntry(TestInfo.TEST_FILE_1.getName(), storeMsg1, "1234567890");

    // make sure that the test instance can now be found.
    assertTrue(
        "Should contain " + TestInfo.TEST_FILE_1.getName(),
        da.hasEntry(TestInfo.TEST_FILE_1.getName()));
    assertTrue(
        "Should have replyInfo for " + TestInfo.TEST_FILE_1.getName(),
        da.hasReplyInfo(TestInfo.TEST_FILE_1.getName()));
    assertEquals(
        "Should have the given checksum",
        "1234567890",
        da.getCheckSum(TestInfo.TEST_FILE_1.getName()));

    // Test the hasState.
    assertFalse(
        "Should not yet have a acceptable state",
        da.hasState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()));
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        ONE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_STARTED);
    assertTrue(
        "Should now have a acceptable state",
        da.hasState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()));
    assertEquals(
        "Should have the same state",
        da.getState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()),
        ReplicaStoreState.UPLOAD_STARTED);

    StoreMessage storeMsg2 = new StoreMessage(Channels.getError(), TestInfo.TEST_FILE_1);
    JMSConnectionMockupMQ.updateMsgID(storeMsg2, "store2");

    da.setReplyInfo(storeMsg2.getArcfileName(), storeMsg2);

    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        ONE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        TWO.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        THREE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);

    StoreMessage retrievedMsg = da.removeReplyInfo(TestInfo.TEST_FILE_1.getName());

    assertEquals("The message should have the new ID.", "store2", retrievedMsg.getID());

    try {
      da.setCheckSum(TestInfo.TEST_FILE_1.getName(), "0987654321");
      fail("An illegal state exception should be thrown here.");
    } catch (IllegalState e) {
      // expected
    }

    Set<String> filenames = da.getAllFileNames();
    assertTrue(
        "Should contain the file '" + TestInfo.TEST_FILE_1.getName() + "' but was '" + filenames,
        filenames.contains(TestInfo.TEST_FILE_1.getName()));

    filenames = da.getAllFileNames(THREE, ReplicaStoreState.UPLOAD_FAILED);
    assertTrue(
        "The list of files with state UPLOAD_FAILED for replica "
            + "THREE should be empty, but it was: "
            + filenames,
        filenames.isEmpty());

    filenames = da.getAllFileNames(THREE, ReplicaStoreState.UPLOAD_COMPLETED);
    assertTrue(
        "The list of files with state UPLOAD_COMPLETED for replica "
            + "THREE should contain the file: '"
            + TestInfo.TEST_FILE_1.getName()
            + "', but it contained: "
            + filenames,
        filenames.contains(TestInfo.TEST_FILE_1.getName()));
  }
 public void tearDown() {
   JMSConnectionMockupMQ.clearTestQueues();
   utrf.setUp();
   mtf.tearDown();
   rs.tearDown();
 }
 public void cleanup() {
   JMSConnectionMockupMQ.useJMSConnectionMockupMQ();
   super.cleanup();
 }