Fixed tests.

This commit is contained in:
Arjen Poutsma 2015-09-10 11:36:14 +02:00
parent df31c94d7f
commit 01ef90f1ca
1 changed files with 10 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package org.springframework.reactive.io;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Test;
@ -77,9 +78,10 @@ public class ByteArrayPublisherInputStreamTests {
FileCopyUtils.copy(is, os);
Publisher<byte[]> publisher = os.toByteArrayPublisher();
List<byte[]> result = new ArrayList<>();
AtomicBoolean complete = new AtomicBoolean();
publisher.subscribe(new Subscriber<byte[]>() {
List<byte[]> result = new ArrayList<>();
@Override
public void onSubscribe(Subscription s) {
@ -98,11 +100,16 @@ public class ByteArrayPublisherInputStreamTests {
@Override
public void onComplete() {
assertArrayEquals(result.get(0), new byte[]{'a', 'b', 'c'});
assertArrayEquals(result.get(0), new byte[]{'d', 'e'});
complete.set(true);
}
});
while (!complete.get()) {
}
assertArrayEquals(result.get(0), new byte[]{'a', 'b', 'c'});
assertArrayEquals(result.get(1), new byte[]{'d', 'e'});
}
}