Esempio n. 1
0
 /**
  * tearDown method for test case
  *
  * @throws Exception if removePoll failed
  */
 public void tearDown() throws Exception {
   pollmanager.stopService();
   theDaemon.getLockssRepository(testau).stopService();
   theDaemon.getHashService().stopService();
   theDaemon.getDatagramRouterManager().stopService();
   theDaemon.getRouterManager().stopService();
   theDaemon.getSystemMetrics().stopService();
   TimeBase.setReal();
   for (int i = 0; i < testV1msg.length; i++) {
     if (testV1msg[i] != null) pollmanager.removePoll(testV1msg[i].getKey());
   }
   super.tearDown();
 }
Esempio n. 2
0
 private void initTestPolls() throws Exception {
   testV1polls = new V1Poll[testV1msg.length];
   for (int i = 0; i < testV1polls.length; i++) {
     log.debug3("initTestPolls: V1 " + i);
     BasePoll p = pollmanager.makePoll(testV1msg[i]);
     assertNotNull(p);
     assertNotNull(p.getMessage());
     log.debug("initTestPolls: V1 " + i + " returns " + p);
     assertTrue(p instanceof V1Poll);
     switch (i) {
       case 0:
         assertTrue(p instanceof V1NamePoll);
         break;
       case 1:
         assertTrue(p instanceof V1ContentPoll);
         break;
       case 2:
         assertTrue(p instanceof V1VerifyPoll);
         break;
     }
     testV1polls[i] = (V1Poll) p;
     assertNotNull(testV1polls[i]);
     log.debug3("initTestPolls: " + i + " " + p.toString());
   }
 }
Esempio n. 3
0
  private void initRequiredServices() {
    theDaemon = getMockLockssDaemon();
    pollmanager = new LocalPollManager();
    pollmanager.initService(theDaemon);
    theDaemon.setPollManager(pollmanager);

    theDaemon.getPluginManager();
    testau = PollTestPlugin.PTArchivalUnit.createFromListOfRootUrls(rootV1urls);
    PluginTestUtil.registerArchivalUnit(testau);

    String tempDirPath = null;
    try {
      tempDirPath = getTempDir().getAbsolutePath() + File.separator;
    } catch (IOException ex) {
      fail("unable to create a temporary directory");
    }

    Properties p = new Properties();
    p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb");
    p.setProperty(LockssRepositoryImpl.PARAM_CACHE_LOCATION, tempDirPath);
    p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1");
    p.setProperty(ConfigManager.PARAM_NEW_SCHEDULER, "false");
    // XXX we need to disable verification of votes because the
    // voter isn't really there
    p.setProperty(V1Poll.PARAM_AGREE_VERIFY, "0");
    p.setProperty(V1Poll.PARAM_DISAGREE_VERIFY, "0");
    ConfigurationUtil.setCurrentConfigFromProps(p);
    idmgr = theDaemon.getIdentityManager();
    idmgr.startService();
    // theDaemon.getSchedService().startService();
    theDaemon.getHashService().startService();
    theDaemon.getDatagramRouterManager().startService();
    theDaemon.getRouterManager().startService();
    theDaemon.getSystemMetrics().startService();
    theDaemon.getActivityRegulator(testau).startService();
    theDaemon.setNodeManager(new MockNodeManager(), testau);
    pollmanager.startService();
  }
Esempio n. 4
0
  private void initTestMsg() throws Exception {
    testV1msg = new V1LcapMessage[3];
    int[] pollType = {
      Poll.V1_NAME_POLL, Poll.V1_CONTENT_POLL, Poll.V1_VERIFY_POLL,
    };
    PollFactory ppf = pollmanager.getPollFactory(1);
    assertNotNull("PollFactory should not be null", ppf);
    // XXX V1 support mandatory
    assertTrue(ppf instanceof V1PollFactory);
    V1PollFactory pf = (V1PollFactory) ppf;

    for (int i = 0; i < testV1msg.length; i++) {
      PollSpec spec = new MockPollSpec(testau, rootV1urls[i], lwrbnd, uprbnd, pollType[i]);
      log.debug("Created poll spec: " + spec);
      ((MockCachedUrlSet) spec.getCachedUrlSet()).setHasContent(false);
      int opcode = V1LcapMessage.NAME_POLL_REQ + (i * 2);
      long duration = -1;
      //  NB calcDuration is not applied to Verify polls.
      switch (opcode) {
        case V1LcapMessage.NAME_POLL_REQ:
        case V1LcapMessage.CONTENT_POLL_REQ:
          // this will attempt to schedule and can return -1
          duration = Math.max(pf.calcDuration(spec, pollmanager), 1000);
          break;
        case V1LcapMessage.VERIFY_POLL_REQ:
        case V1LcapMessage.VERIFY_POLL_REP:
          duration = 100000; // Arbitrary
          break;
        default:
          fail("Bad opcode " + opcode);
          break;
      }

      testV1msg[i] =
          V1LcapMessage.makeRequestMsg(
              spec,
              agree_entries,
              pf.makeVerifier(100000),
              pf.makeVerifier(100000),
              opcode,
              duration,
              testID);
      assertNotNull(testV1msg[i]);
    }
  }