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