コード例 #1
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 public void testNullPollNak() throws Exception {
   V3LcapMessage src = this.makePollAckMessage(null);
   InputStream srcStream = src.getInputStream();
   V3LcapMessage copy = new V3LcapMessage(srcStream, tempDir, theDaemon);
   assertEqualMessages(src, copy);
   assertNull(src.getNak());
   assertNull(copy.getNak());
 }
コード例 #2
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 public void testPollDuration() throws Exception {
   TimeBase.setSimulated(TimeBase.nowMs());
   V3LcapMessage src = this.makePollMessage(6 * Constants.WEEK);
   InputStream srcStream = src.getInputStream();
   V3LcapMessage copy = new V3LcapMessage(srcStream, tempDir, theDaemon);
   assertEqualMessages(src, copy);
   assertEquals(6 * Constants.WEEK, copy.getDuration());
 }
コード例 #3
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 public void testNonNullPollNak1() throws Exception {
   V3LcapMessage src = this.makePollAckMessage(V3LcapMessage.PollNak.NAK_GROUP_MISMATCH);
   InputStream srcStream = src.getInputStream();
   V3LcapMessage copy = new V3LcapMessage(srcStream, tempDir, theDaemon);
   assertEqualMessages(src, copy);
   assertNotNull(src.getNak());
   assertNotNull(copy.getNak());
   assertEquals(V3LcapMessage.PollNak.NAK_GROUP_MISMATCH, src.getNak());
   assertEquals(V3LcapMessage.PollNak.NAK_GROUP_MISMATCH, copy.getNak());
 }
コード例 #4
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 public void testDiskBasedStreamEncodingTest() throws Exception {
   // Make a list of vote blocks large enough to trigger on-disk
   // vote message creation.
   List testVoteBlocks = V3TestUtils.makeVoteBlockList(21);
   V3LcapMessage testMsg = makeTestVoteMessage(testVoteBlocks);
   assertTrue(testMsg.m_voteBlocks instanceof DiskVoteBlocks);
   // Encode the test message.
   InputStream is = testMsg.getInputStream();
   V3LcapMessage decodedMsg = new V3LcapMessage(is, tempDir, theDaemon);
   // Ensure that the decoded message matches the test message.
   assertEqualMessages(testMsg, decodedMsg);
 }
コード例 #5
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 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());
 }
コード例 #6
0
ファイル: TestV3LcapMessage.java プロジェクト: ravn/lockss
 public void testDiskRepairMessage() throws Exception {
   int len = 100 * 1024;
   byte[] repairData = ByteArray.makeRandomBytes(len);
   V3LcapMessage src = makeRepairMessage(repairData);
   assertEquals(len, src.getRepairDataLength());
   assertEquals(V3LcapMessage.EST_ENCODED_HEADER_LENGTH + len, src.getEstimatedEncodedLength());
   InputStream srcStream = src.getInputStream();
   V3LcapMessage copy = new V3LcapMessage(srcStream, tempDir, theDaemon);
   assertEqualMessages(src, copy);
   assertEquals(len, copy.getRepairDataLength());
   assertEquals(V3LcapMessage.EST_ENCODED_HEADER_LENGTH + len, src.getEstimatedEncodedLength());
   InputStream in = copy.getRepairDataInputStream();
   assertTrue(in + "", in instanceof FileInputStream);
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   StreamUtil.copy(in, out);
   byte[] repairCopy = out.toByteArray();
   assertEquals(repairData, repairCopy);
   // ensure that repeated delete doesn't cause error
   copy.delete();
   copy.delete();
 }