コード例 #1
0
 @Test
 public void testThatMessagesCanBeRemovedFromTheQueue() {
   addMessageToQueue(queue, validMessage);
   assertThat(queue.getSize(), equalTo(1));
   queue.remove(validMessage);
   assertThat(queue.getSize(), equalTo(0));
 }
コード例 #2
0
 @Test
 public void testThatMessagesAreReturnedInPriorityOrder() {
   addMessageToQueue(queue, validMessageLowPriority);
   addMessageToQueue(queue, validMessage);
   addMessageToQueue(queue, validMessageMidPriority);
   addMessageToQueue(queue, validMessage);
   assertThat(queue.poll().getInstructionType(), equalTo(10));
   assertThat(queue.poll().getInstructionType(), equalTo(10));
   assertThat(queue.poll().getInstructionType(), equalTo(50));
   assertThat(queue.poll().getInstructionType(), equalTo(99));
 }
コード例 #3
0
 /*
  * Test Utils to save code duplication
  */
 private boolean addMessageToQueue(InstructionQueue queue, InstructionMessage message) {
   try {
     return queue.add(message);
   } catch (InvalidMessageException ime) {
     return false;
   }
 }
コード例 #4
0
 @Test
 public void testThatTheHighestPriorityMessageIsReturnedFromTheQueue() {
   addMessageToQueue(queue, validMessage);
   addMessageToQueue(queue, validMessageMidPriority);
   addMessageToQueue(queue, validMessageLowPriority);
   assertThat(queue.poll().getInstructionType(), equalTo(10));
 }
コード例 #5
0
 @Test(expected = InvalidMessageException.class)
 public void testThatInvalidMessagesCanNotBeAddedToAQueue() throws InvalidMessageException {
   try {
     queue.add(invalidMessage);
   } catch (InvalidMessageException ime) {
     throw ime;
   }
 }
コード例 #6
0
 @Test
 public void testThatMessagesCanBeRetrievedFromTheQueue() {
   addMessageToQueue(queue, validMessage);
   InstructionMessage polledMessage = queue.poll();
   assertThat(validMessage.getInstructionType(), equalTo(polledMessage.getInstructionType()));
 }
コード例 #7
0
 @Test
 public void testThatMultipleMessagesCanBeAddedToAQueue() {
   addMessageToQueue(queue, validMessage);
   addMessageToQueue(queue, validMessageMidPriority);
   assertThat(queue.getSize(), equalTo(2));
 }
コード例 #8
0
 @Test
 public void testThatMessagesCanBeAddedToAQueue() {
   assert (addMessageToQueue(queue, validMessage));
   assertThat(queue.getSize(), equalTo(1));
 }
コード例 #9
0
 @Test
 public void testThatQueueRespondsCorrectlyWhenEmpty() {
   assert (queue.isEmpty());
 }
コード例 #10
0
 @Test
 public void testThatQueueStartsEmpty() {
   assertThat(queue.getSize(), equalTo(0));
 }