Пример #1
0
 @Test
 public void testAccept() {
   BeforeTimePredicate predicate = new BeforeTimePredicate(sixDaysBefore);
   assertTrue(predicate.accept(sevenDaysBefore, sixDaysBefore));
   assertFalse(predicate.accept(sixDaysBefore, fiveDaysBefore));
   predicate = new BeforeTimePredicate(fiveDaysBefore);
   assertTrue(predicate.accept(sevenDaysBefore, sixDaysBefore));
   assertTrue(predicate.accept(sixDaysBefore, fiveDaysBefore));
 }
Пример #2
0
 @Test
 public void testWriteRead() throws IOException {
   BeforeTimePredicate predicate = new BeforeTimePredicate(sevenDaysBefore);
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   DataOutputStream out = new DataOutputStream(baos);
   predicate.write(out);
   ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
   DataInputStream in = new DataInputStream(bais);
   BeforeTimePredicate read = new BeforeTimePredicate();
   read.readFields(in);
   assertEquals(predicate, read);
 }