Esempio n. 1
0
  public void testNoOpMessageCreation() throws Exception {
    // Without voterNonce2
    V3LcapMessage noopMsg =
        V3LcapMessage.makeNoOpMsg(m_testID, m_testBytes, m_testBytes, theDaemon);
    // With voterNonce2
    V3LcapMessage noopMsg2 =
        V3LcapMessage.makeNoOpMsg(m_testID, m_testBytes, m_testBytes, m_testBytes, theDaemon);

    // now check the fields we expect to be valid
    assertEquals(V3LcapMessage.MSG_NO_OP, noopMsg.getOpcode());
    assertTrue(m_testID == noopMsg.getOriginatorId());
    assertEquals(m_testBytes, noopMsg.getPollerNonce());
    assertEquals(m_testBytes, noopMsg.getVoterNonce());
    assertEquals(null, noopMsg.getVoterNonce2());
    assertEquals(null, noopMsg.getVoteBlocks());
    assertEquals(V3LcapMessage.EST_ENCODED_HEADER_LENGTH, noopMsg.getEstimatedEncodedLength());

    // Same for msg with voterNonce2
    assertEquals(V3LcapMessage.MSG_NO_OP, noopMsg2.getOpcode());
    assertTrue(m_testID == noopMsg2.getOriginatorId());
    assertEquals(m_testBytes, noopMsg2.getPollerNonce());
    assertEquals(m_testBytes, noopMsg2.getVoterNonce());
    assertEquals(m_testBytes, noopMsg2.getVoterNonce2());
    assertEquals(null, noopMsg2.getVoteBlocks());
    assertEquals(V3LcapMessage.EST_ENCODED_HEADER_LENGTH, noopMsg2.getEstimatedEncodedLength());
  }
Esempio n. 2
0
  public void testRandomNoOpMessageCreation() throws Exception {
    V3LcapMessage noopMsg1 = V3LcapMessage.makeNoOpMsg(m_testID, theDaemon);
    V3LcapMessage noopMsg2 = V3LcapMessage.makeNoOpMsg(m_testID, theDaemon);

    // now check the fields we expect to be valid
    assertEquals(V3LcapMessage.MSG_NO_OP, noopMsg1.getOpcode());
    assertEquals(V3LcapMessage.MSG_NO_OP, noopMsg2.getOpcode());
    assertTrue(noopMsg1.getOriginatorId() == m_testID);
    assertTrue(noopMsg1.getOriginatorId() == noopMsg2.getOriginatorId());
    assertFalse(noopMsg1.getPollerNonce() == noopMsg2.getPollerNonce());
    assertFalse(noopMsg1.getVoterNonce() == noopMsg2.getVoterNonce());
    assertEquals(null, noopMsg1.getVoterNonce2());
    assertEquals(null, noopMsg2.getVoterNonce2());
    assertEquals(null, noopMsg1.getVoteBlocks());
    assertEquals(null, noopMsg2.getVoteBlocks());
  }
Esempio n. 3
0
 public void testNoOpEncoding() throws Exception {
   V3LcapMessage noopMsg =
       V3LcapMessage.makeNoOpMsg(m_testID, m_testBytes, m_testBytes, theDaemon);
   InputStream fromMsg = noopMsg.getInputStream();
   V3LcapMessage msg = new V3LcapMessage(fromMsg, tempDir, theDaemon);
   // now test to see if we got back what we started with
   assertTrue(m_testID == msg.getOriginatorId());
   assertEquals(V3LcapMessage.MSG_NO_OP, msg.getOpcode());
   assertEquals(m_testBytes, msg.getPollerNonce());
   assertEquals(m_testBytes, msg.getVoterNonce());
   assertEquals(null, msg.getVoterNonce2());
 }
Esempio n. 4
0
 public void testNoOpMessageToString() throws IOException {
   V3LcapMessage noopMsg =
       V3LcapMessage.makeNoOpMsg(m_testID, m_testBytes, m_testBytes, theDaemon);
   String expectedResult = "[V3LcapMessage: from " + m_testID.toString() + ", NoOp]";
   assertEquals(expectedResult, noopMsg.toString());
 }