Skip to content

What does StringObservableTest.testFromReaderWillUnsubscribeBeforeCallingNextRead() test? #42

Description

@suchafreak

I looked at the following test:

@Test
public void testFromReaderWillUnsubscribeBeforeCallingNextRead() {
  final byte[] inBytes = "test".getBytes();
  final AtomicInteger numReads = new AtomicInteger(0);
  ByteArrayInputStream is = new ByteArrayInputStream(inBytes) {


    @Override
    public synchronized int read(byte[] b, int off, int len) {
      numReads.incrementAndGet();
      return super.read(b, off, len);
    }
  };
  StringObservable.from(new InputStreamReader(is)).first().toBlocking().single();
  assertEquals(1, numReads.get());
}

Looking at the test code, I don't see how this test is related to unsubscribe handling. All I see is a test that asserts that the overriden read() on the stream is called exactly once.

What am I missing?

Activity

  1. davidmoten commented on Jul 13, 2016

    @davidmoten
    Contributor

    Hi, if I remember correctly this was a sufficient test to isolate the problem described by the test method name. Feel free to submit PR to provide more test coverage and improved naming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions