Exemple #1
0
  private V3LcapMessage makeTestVoteMessage(Collection voteBlocks) throws IOException {
    mPollMgr.setStateDir("key", tempDir);
    V3LcapMessage msg =
        new V3LcapMessage(
            "ArchivalID_2",
            "key",
            "Plug42",
            m_testBytes,
            m_testBytes,
            V3LcapMessage.MSG_VOTE,
            987654321,
            m_testID,
            tempDir,
            theDaemon);

    // Set msg vote blocks.
    for (Iterator ix = voteBlocks.iterator(); ix.hasNext(); ) {
      msg.addVoteBlock((VoteBlock) ix.next());
    }

    msg.setHashAlgorithm(LcapMessage.getDefaultHashAlgorithm());
    msg.setArchivalId(m_archivalID);
    msg.setPluginVersion("PlugVer42");
    return msg;
  }
Exemple #2
0
  /** test for method tally(..) */
  public void testTally() {
    V1Poll p = testV1polls[0];
    LcapMessage msg = p.getMessage();
    PeerIdentity id = msg.getOriginatorId();
    p.m_tally.addVote(new Vote(msg, false), id, false);
    p.m_tally.addVote(new Vote(msg, false), id, false);
    p.m_tally.addVote(new Vote(msg, false), id, false);
    assertEquals(0, p.m_tally.numAgree);
    assertEquals(0, p.m_tally.wtAgree);
    assertEquals(3, p.m_tally.numDisagree);
    assertEquals(1500, p.m_tally.wtDisagree);

    p = testV1polls[1];
    msg = p.getMessage();
    p.m_tally.addVote(new Vote(msg, true), id, false);
    p.m_tally.addVote(new Vote(msg, true), id, false);
    p.m_tally.addVote(new Vote(msg, true), id, false);
    assertEquals(3, p.m_tally.numAgree);
    assertEquals(1500, p.m_tally.wtAgree);
    assertEquals(0, p.m_tally.numDisagree);
    assertEquals(0, p.m_tally.wtDisagree);
  }
Exemple #3
0
 private V3LcapMessage makeRepairMessage(byte[] repairData) {
   V3LcapMessage msg =
       new V3LcapMessage(
           "ArchivalID_2",
           "key",
           "Plug42",
           m_testBytes,
           m_testBytes,
           V3LcapMessage.MSG_REPAIR_REP,
           987654321,
           m_testID,
           tempDir,
           theDaemon);
   msg.setHashAlgorithm(LcapMessage.getDefaultHashAlgorithm());
   msg.setTargetUrl(m_url);
   msg.setArchivalId(m_archivalID);
   msg.setPluginVersion("PlugVer42");
   msg.setRepairDataLength(repairData.length);
   msg.setRepairProps(m_repairProps);
   msg.setInputStream(new ByteArrayInputStream(repairData));
   return msg;
 }