Example usage for org.apache.commons.io.output TeeOutputStream close

List of usage examples for org.apache.commons.io.output TeeOutputStream close

Introduction

In this page you can find the example usage for org.apache.commons.io.output TeeOutputStream close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes both streams.

Usage

From source file:org.paxle.core.doc.impl.BasicDocumentFactoryTest.java

public void testMarshalUnmarshalBasicCommand() throws IOException, ParseException {
    // creating a test command
    final ICommand cmd1 = this.createTestCommand();

    // marshal command
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final TeeOutputStream out = new TeeOutputStream(System.out, bout);
    final Map<String, DataHandler> attachments = this.docFactory.marshal(cmd1, out);
    out.close();

    // unmarshal command
    final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    final ICommand cmd2 = this.docFactory.unmarshal(bin, attachments);

    // check if the commands are equal
    assertNotSame(cmd1, cmd2);//w  ww .  j a v  a2  s  . co m
    assertEquals(cmd1, cmd2);
}

From source file:org.paxle.core.doc.impl.BasicDocumentFactoryTest.java

public void testMarshalUnmarshalBasicCrawlerDocument() throws IOException, ParseException {
    final ICrawlerDocument expected = this.createTestCDoc(BasicCrawlerDocument.class,
            URI.create("http://www.paxle.net"));
    assertNotNull(expected);//w ww. j a va2 s  .  com

    // marshal crawler-document
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final TeeOutputStream out = new TeeOutputStream(System.out, bout);
    final Map<String, DataHandler> attachments = this.docFactory.marshal(expected, out);
    out.close();

    // unmarshal crawler-document
    final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    final ICrawlerDocument actual = this.docFactory.unmarshal(bin, attachments);

    assertEquals(expected, actual);
}

From source file:org.paxle.core.doc.impl.BasicDocumentFactoryTest.java

public void testMarshalUnmarshalBasicParserDocument() throws IOException {
    final IParserDocument expected = this.createTestPDoc(BasicParserDocument.class);
    assertNotNull(expected);/*  w w w. j  a  v  a  2 s  . co  m*/

    // marshal parser-document
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final TeeOutputStream out = new TeeOutputStream(System.out, bout);
    final Map<String, DataHandler> attachments = this.docFactory.marshal(expected, out);
    out.close();

    // unmarshal crawler-document
    final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    final IParserDocument actual = this.docFactory.unmarshal(bin, attachments);

    assertEquals(expected, actual);
}

From source file:org.paxle.core.doc.impl.BasicDocumentFactoryTest.java

public void testMarshalUnmarshalCachedParserDocument() throws IOException {
    final IParserDocument expected = this.createTestPDoc(CachedParserDocument.class);
    assertNotNull(expected);//from ww w.  j av  a  2  s .  c om

    // marshal parser-document
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final TeeOutputStream out = new TeeOutputStream(System.out, bout);
    final Map<String, DataHandler> attachments = this.docFactory.marshal(expected, out);
    out.close();

    // unmarshal crawler-document
    final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    final IParserDocument actual = this.docFactory.unmarshal(bin, attachments);

    assertEquals(expected, actual);
}

From source file:org.paxle.core.doc.impl.BasicDocumentFactoryTest.java

public void testMarshalUnmarshalBasicIndexerDocument() throws IOException {
    final IIndexerDocument expected = this.createTestIDoc(BasicIndexerDocument.class);
    assertNotNull(expected);//from   w w  w.  j  a  va2 s .  c  o  m

    // marshal parser-document
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final TeeOutputStream out = new TeeOutputStream(System.out, bout);
    final Map<String, DataHandler> attachments = this.docFactory.marshal(expected, out);
    out.close();

    // unmarshal crawler-document
    final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    final IIndexerDocument actual = this.docFactory.unmarshal(bin, attachments);

    assertEquals(expected, actual);
}