Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does StringObservableTest.testFromReaderWillUnsubscribeBeforeCallingNextRead() test? #42

Open
suchafreak opened this issue Jul 13, 2016 · 1 comment

Comments

@suchafreak
Copy link

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?

@davidmoten
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants