Examples of EofFilterInputStream


Examples of com.google.enterprise.connector.util.EofFilterInputStream

  public BinaryValue(InputStreamFactory inputStreamFactory) {
    this.factory = inputStreamFactory;
  }

  public BinaryValue(InputStream inputStream) {
    this.binaryValue = new EofFilterInputStream(inputStream);
  }
View Full Code Here

Examples of com.google.enterprise.connector.util.EofFilterInputStream

  }

  public InputStream getInputStream() throws RepositoryDocumentException {
    if (factory != null) {
      try {
        return new EofFilterInputStream(factory.getInputStream());
      } catch (IOException e) {
        throw new RepositoryDocumentException("Failed to get InputStream", e);
      }
    } else {
      return binaryValue;
View Full Code Here

Examples of com.google.enterprise.connector.util.EofFilterInputStream

    // We are only detecting empty content here, not large documents.
    // TODO: Figure out how to handle CONTENT morphing document filters.
    return
        new AlternateContentFilterInputStream(
            new BigEmptyDocumentFilterInputStream(
                (in == null) ? in : new EofFilterInputStream(in),
                Long.MAX_VALUE),
            null);
  }
View Full Code Here

Examples of com.google.enterprise.connector.util.EofFilterInputStream

   * This tests that the EofFilterInputStream restores the traditional
   * expected behavior when reading while at EOF on an AutoClosed stream.
   */
  public void testAutoCloseProtection() throws IOException {
    InputStream in =
        new EofFilterInputStream(new AutoCloseInputStream(
            new ClosableInputStream(new ByteArrayInputStream(bytes))));

    int rtn = in.read(buffer);
    assertEquals(3, rtn);

    // We should keep hitting EOF now.
    rtn = in.read(buffer);
    assertEquals(-1, rtn);

    rtn = in.read(buffer, 0, buffer.length);
    assertEquals(-1, rtn);

    rtn = in.read();
    assertEquals(-1, rtn);

    rtn = in.read(buffer);
    assertEquals(-1, rtn);

    rtn = in.read(buffer, 0, buffer.length);
    assertEquals(-1, rtn);

    rtn = in.read();
    assertEquals(-1, rtn);

    // Now explicitly close the stream.  Further access should be denied.
    in.close();
    try {
      rtn = in.read(buffer);
      fail("IOException was not thrown on access to closed stream.");
    } catch (IOException ioe) {
      assertEquals(errorMsg, ioe.getMessage());
    }
  }
View Full Code Here

Examples of com.google.enterprise.connector.util.EofFilterInputStream

   * EofFilterInputStream can't protect againt mark()/reset() on an
   * AutoClosed stream, because the underlying resource is no longer available.
   */
  public void testAutoCloseProtection2() throws IOException {
    InputStream in =
        new EofFilterInputStream(new AutoCloseInputStream(
            new ClosableInputStream(new ByteArrayInputStream(bytes))));

    int rtn = in.read(buffer);
    assertEquals(3, rtn);

    // We should keep hitting EOF now.
    rtn = in.read(buffer);
    assertEquals(-1, rtn);

    rtn = in.read(buffer);
    assertEquals(-1, rtn);

    // Attempts to rewind should fail because the shielded resource is
    // actually no longer available.
    try {
      in.reset();
      fail("IOException was not thrown on reset of closed stream.");
    } catch (IOException ioe) {
      assertEquals(errorMsg, ioe.getMessage());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.