Пример #1
0
  /**
   * Test for {@link IOStreams#fromObjects(java.io.ObjectInput)}
   *
   * @throws IOException
   */
  @Test
  public void testReadObjects() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream objectOutput = new ObjectOutputStream(out);

    objectOutput.writeObject(Range.from(10, 90));
    objectOutput.writeObject(Range.from(8, 40));
    objectOutput.writeObject(Range.from(9, 10));
    objectOutput.writeObject(Range.from(9, 12));

    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());

    assertEquals(
        "[Range(10, 90), Range(8, 40), Range(9, 10), Range(9, 12)]",
        IOStreams.<Range<Integer>>fromObjects(new ObjectInputStream(in)).printString());
  }
Пример #2
0
 @Test
 public void testReadWords() {
   assertEquals(
       "this|is|line|1|this|is|line|2|this|is|line|three",
       IOStreams.fromWords(readable).joinStrings("|"));
 }
Пример #3
0
 @Test
 public void testReadLines() {
   assertEquals(
       "this is line 1| this is line 2 | this is line three",
       IOStreams.fromLines(readable).joinStrings("|"));
 }