summaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/test/java/com/yahoo/jdisc/handler
diff options
context:
space:
mode:
Diffstat (limited to 'jdisc_core/src/test/java/com/yahoo/jdisc/handler')
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java26
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java20
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java10
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java22
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java36
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java8
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java6
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java8
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java16
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java48
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java22
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java30
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java20
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java12
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java54
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java10
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java30
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java32
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java32
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java57
20 files changed, 262 insertions, 237 deletions
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java
index 4951ff72ffd..7578e3213dd 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -11,8 +11,8 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -21,15 +21,15 @@ import static org.junit.Assert.assertTrue;
public class AbstractContentOutputStreamTestCase {
@Test
- public void requireThatStreamCanBeWrittenTo() throws IOException {
+ void requireThatStreamCanBeWrittenTo() throws IOException {
MyOutputStream out = new MyOutputStream();
int len = 2 * AbstractContentOutputStream.BUFFERSIZE;
for (int i = 0; i < len; ++i) {
out.write(69);
- out.write(new byte[] { });
- out.write(new byte[] { 6, 9 });
- out.write(new byte[] { 6, 69, 9 }, 1, 0); // zero length
- out.write(new byte[] { 6, 69, 9 }, 1, 1);
+ out.write(new byte[]{});
+ out.write(new byte[]{6, 9});
+ out.write(new byte[]{6, 69, 9}, 1, 0); // zero length
+ out.write(new byte[]{6, 69, 9}, 1, 1);
}
out.close();
@@ -45,7 +45,7 @@ public class AbstractContentOutputStreamTestCase {
}
@Test
- public void requireThatBigBuffersAreWrittenInOrder() throws IOException {
+ void requireThatBigBuffersAreWrittenInOrder() throws IOException {
MyOutputStream out = new MyOutputStream();
out.write(6);
out.write(new byte[2 * AbstractContentOutputStream.BUFFERSIZE]);
@@ -62,7 +62,7 @@ public class AbstractContentOutputStreamTestCase {
}
@Test
- public void requireThatEmptyBuffersAreNotFlushed() throws Exception {
+ void requireThatEmptyBuffersAreNotFlushed() throws Exception {
MyOutputStream out = new MyOutputStream();
out.close();
assertTrue(out.writes.isEmpty());
@@ -70,9 +70,9 @@ public class AbstractContentOutputStreamTestCase {
}
@Test
- public void requireThatNoExcessiveBytesAreWritten() throws Exception {
+ void requireThatNoExcessiveBytesAreWritten() throws Exception {
MyOutputStream out = new MyOutputStream();
- out.write(new byte[] { 6, 9 });
+ out.write(new byte[]{6, 9});
out.close();
InputStream in = out.toInputStream();
@@ -85,7 +85,7 @@ public class AbstractContentOutputStreamTestCase {
}
@Test
- public void requireThatWrittenArraysAreCopied() throws Exception {
+ void requireThatWrittenArraysAreCopied() throws Exception {
MyOutputStream out = new MyOutputStream();
byte[] buf = new byte[1];
for (byte b = 0; b < 127; ++b) {
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java
index 6b5382b8bba..14ff6d87555 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java
@@ -6,18 +6,18 @@ import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.test.NonWorkingRequest;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -28,7 +28,7 @@ public class AbstractRequestHandlerTestCase {
private static final int NUM_REQUESTS = 666;
@Test
- public void requireThatHandleTimeoutIsImplemented() throws Exception {
+ void requireThatHandleTimeoutIsImplemented() throws Exception {
FutureResponse handler = new FutureResponse();
new AbstractRequestHandler() {
@@ -43,7 +43,7 @@ public class AbstractRequestHandlerTestCase {
}
@Test
- public void requireThatHelloWorldWorks() throws InterruptedException {
+ void requireThatHelloWorldWorks() throws InterruptedException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new HelloWorldHandler());
@@ -62,7 +62,7 @@ public class AbstractRequestHandlerTestCase {
}
@Test
- public void requireThatEchoWorks() throws InterruptedException {
+ void requireThatEchoWorks() throws InterruptedException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new EchoHandler());
@@ -83,7 +83,7 @@ public class AbstractRequestHandlerTestCase {
}
@Test
- public void requireThatForwardWorks() throws InterruptedException {
+ void requireThatForwardWorks() throws InterruptedException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new ForwardHandler());
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java
index 7d76e9de7e2..03fd4368be9 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java
@@ -4,12 +4,12 @@ package com.yahoo.jdisc.handler;
import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -18,14 +18,14 @@ import static org.junit.Assert.fail;
public class BindingNotFoundTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
URI uri = URI.create("http://host/path");
BindingNotFoundException e = new BindingNotFoundException(uri);
assertEquals(uri, e.uri());
}
@Test
- public void requireThatBindingNotFoundIsThrown() {
+ void requireThatBindingNotFoundIsThrown() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
driver.activateContainer(driver.newContainerBuilder());
Request request = new Request(driver, URI.create("http://host/path"));
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java
index 651c24648a1..96c6edbdcf5 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java
@@ -1,15 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.concurrent.*;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertTrue;
public class BlockingContentWriterTestCase {
@Test
- public void requireThatContentChannelIsNotNull() {
+ void requireThatContentChannelIsNotNull() {
try {
new BlockingContentWriter(null);
fail();
@@ -27,7 +27,7 @@ public class BlockingContentWriterTestCase {
}
@Test
- public void requireThatWriteDeliversBuffer() throws InterruptedException {
+ void requireThatWriteDeliversBuffer() throws InterruptedException {
MyContent content = MyContent.newNonBlockingContent();
BlockingContentWriter writer = new BlockingContentWriter(content);
ByteBuffer buf = ByteBuffer.allocate(69);
@@ -36,7 +36,7 @@ public class BlockingContentWriterTestCase {
}
@Test
- public void requireThatWriteIsBlocking() throws Exception {
+ void requireThatWriteIsBlocking() throws Exception {
MyContent content = MyContent.newBlockingContent();
BlockingContentWriter writer = new BlockingContentWriter(content);
FutureTask<Boolean> task = new FutureTask<>(new WriteTask(writer, ByteBuffer.allocate(69)));
@@ -53,7 +53,7 @@ public class BlockingContentWriterTestCase {
}
@Test
- public void requireThatWriteExceptionIsThrown() throws Exception {
+ void requireThatWriteExceptionIsThrown() throws Exception {
Throwable throwMe = new RuntimeException();
try {
new BlockingContentWriter(MyContent.newFailedContent(throwMe)).write(ByteBuffer.allocate(69));
@@ -76,7 +76,7 @@ public class BlockingContentWriterTestCase {
}
@Test
- public void requireThatCloseIsBlocking() throws Exception {
+ void requireThatCloseIsBlocking() throws Exception {
MyContent content = MyContent.newBlockingContent();
BlockingContentWriter writer = new BlockingContentWriter(content);
FutureTask<Boolean> task = new FutureTask<>(new CloseTask(writer));
@@ -93,7 +93,7 @@ public class BlockingContentWriterTestCase {
}
@Test
- public void requireThatCloseExceptionIsThrown() throws Exception {
+ void requireThatCloseExceptionIsThrown() throws Exception {
Throwable throwMe = new RuntimeException();
try {
new BlockingContentWriter(MyContent.newFailedContent(throwMe)).close();
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java
index 705d6d008b0..3824c0eb928 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.LinkedList;
@@ -9,11 +9,11 @@ import java.util.List;
import java.util.Random;
import java.util.concurrent.*;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
public class BufferedContentChannelTestCase {
@Test
- public void requireThatIsConnectedWorks() {
+ void requireThatIsConnectedWorks() {
MyContent target = new MyContent();
BufferedContentChannel content = new BufferedContentChannel();
assertFalse(content.isConnected());
@@ -30,7 +30,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatConnectToNullThrowsException() {
+ void requireThatConnectToNullThrowsException() {
BufferedContentChannel content = new BufferedContentChannel();
try {
content.connectTo(null);
@@ -41,7 +41,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatWriteAfterCloseThrowsException() {
+ void requireThatWriteAfterCloseThrowsException() {
BufferedContentChannel content = new BufferedContentChannel();
content.close(null);
try {
@@ -53,7 +53,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatCloseAfterCloseThrowsException() {
+ void requireThatCloseAfterCloseThrowsException() {
BufferedContentChannel content = new BufferedContentChannel();
content.close(null);
try {
@@ -65,7 +65,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatConnecToAfterConnecToThrowsException() {
+ void requireThatConnecToAfterConnecToThrowsException() {
BufferedContentChannel content = new BufferedContentChannel();
content.connectTo(new MyContent());
try {
@@ -77,7 +77,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatWriteBeforeConnectToWritesToTarget() {
+ void requireThatWriteBeforeConnectToWritesToTarget() {
BufferedContentChannel content = new BufferedContentChannel();
ByteBuffer buf = ByteBuffer.allocate(69);
MyCompletion completion = new MyCompletion();
@@ -89,7 +89,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatWriteAfterConnectToWritesToTarget() {
+ void requireThatWriteAfterConnectToWritesToTarget() {
MyContent target = new MyContent();
BufferedContentChannel content = new BufferedContentChannel();
content.connectTo(target);
@@ -101,7 +101,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatCloseBeforeConnectToClosesTarget() {
+ void requireThatCloseBeforeConnectToClosesTarget() {
BufferedContentChannel content = new BufferedContentChannel();
MyCompletion completion = new MyCompletion();
content.close(completion);
@@ -112,7 +112,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatCloseAfterConnectToClosesTarget() {
+ void requireThatCloseAfterConnectToClosesTarget() {
MyContent target = new MyContent();
BufferedContentChannel content = new BufferedContentChannel();
content.connectTo(target);
@@ -123,7 +123,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatIsConnectedIsTrueWhenConnectedBeforeClose() {
+ void requireThatIsConnectedIsTrueWhenConnectedBeforeClose() {
BufferedContentChannel content = new BufferedContentChannel();
assertFalse(content.isConnected());
content.connectTo(new MyContent());
@@ -133,7 +133,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatIsConnectedIsTrueWhenClosedBeforeConnected() {
+ void requireThatIsConnectedIsTrueWhenClosedBeforeConnected() {
BufferedContentChannel content = new BufferedContentChannel();
assertFalse(content.isConnected());
content.close(null);
@@ -143,7 +143,7 @@ public class BufferedContentChannelTestCase {
}
@Test
- public void requireThatContentIsThreadSafe() throws Exception {
+ void requireThatContentIsThreadSafe() throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(101);
for (int run = 0; run < 69; ++run) {
List<ByteBuffer> bufs = new LinkedList<>();
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java
index b11afacb518..6e5ad50f447 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java
@@ -5,12 +5,12 @@ import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue;
public class CallableRequestDispatchTestCase {
@Test
- public void requireThatDispatchIsCalled() throws Exception {
+ void requireThatDispatchIsCalled() throws Exception {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java
index bb17bb9bc41..ff953fe0384 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java
@@ -2,11 +2,11 @@
package com.yahoo.jdisc.handler;
import com.yahoo.jdisc.Response;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
@@ -15,7 +15,7 @@ import static org.junit.Assert.assertSame;
public class CallableResponseDispatchTestCase {
@Test
- public void requireThatDispatchIsCalled() throws Exception {
+ void requireThatDispatchIsCalled() throws Exception {
final Response response = new Response(Response.Status.OK);
FutureResponse handler = new FutureResponse();
new CallableResponseDispatch(handler) {
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java
index f90251bc16e..30169699077 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Future;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -14,13 +14,13 @@ import static org.junit.Assert.assertTrue;
public class ContentInputStreamTestCase {
@Test
- public void requireThatContentInputStreamExtendsUnsafeContentInputStream() {
+ void requireThatContentInputStreamExtendsUnsafeContentInputStream() {
assertTrue(UnsafeContentInputStream.class.isAssignableFrom(ContentInputStream.class));
}
@Test
@SuppressWarnings("FinalizeCalledExplicitly")
- public void requireThatFinalizerClosesStream() throws Throwable {
+ void requireThatFinalizerClosesStream() throws Throwable {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("foo");
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java
index 2cdc0e1256f..3f97fe014e6 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java
@@ -1,15 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.nio.ByteBuffer;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -18,15 +18,15 @@ import static org.junit.Assert.fail;
public class FastContentOutputStreamTestCase {
@Test
- public void requireThatNullConstructorArgumentThrows() {
+ void requireThatNullConstructorArgumentThrows() {
try {
- new FastContentOutputStream((ContentChannel)null);
+ new FastContentOutputStream((ContentChannel) null);
fail();
} catch (NullPointerException e) {
assertEquals("out", e.getMessage());
}
try {
- new FastContentOutputStream((FastContentWriter)null);
+ new FastContentOutputStream((FastContentWriter) null);
fail();
} catch (NullPointerException e) {
assertEquals("out", e.getMessage());
@@ -34,11 +34,11 @@ public class FastContentOutputStreamTestCase {
}
@Test
- public void requireThatAllMethodsDelegateToWriter() throws Exception {
+ void requireThatAllMethodsDelegateToWriter() throws Exception {
FastContentWriter writer = Mockito.mock(FastContentWriter.class);
FastContentOutputStream out = new FastContentOutputStream(writer);
- out.write(new byte[] { 6, 9 });
+ out.write(new byte[]{6, 9});
out.flush();
Mockito.verify(writer).write(Mockito.any(ByteBuffer.class));
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java
index 45bc230896f..4e0b989db74 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.nio.ByteBuffer;
@@ -15,14 +15,14 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertArrayEquals;
public class FastContentWriterTestCase {
@Test
- public void requireThatContentCanBeWritten() throws ExecutionException, InterruptedException {
+ void requireThatContentCanBeWritten() throws ExecutionException, InterruptedException {
ReadableContentChannel content = new ReadableContentChannel();
FastContentWriter out = new FastContentWriter(content);
@@ -50,7 +50,7 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatStringsAreUtf8Encoded() {
+ void requireThatStringsAreUtf8Encoded() {
ReadableContentChannel content = new ReadableContentChannel();
FastContentWriter out = new FastContentWriter(content);
@@ -65,7 +65,7 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatCancelThrowsUnsupportedOperation() {
+ void requireThatCancelThrowsUnsupportedOperation() {
try {
new FastContentWriter(Mockito.mock(ContentChannel.class)).cancel(true);
fail();
@@ -75,7 +75,7 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatCancelIsAlwaysFalse() {
+ void requireThatCancelIsAlwaysFalse() {
FastContentWriter writer = new FastContentWriter(Mockito.mock(ContentChannel.class));
assertFalse(writer.isCancelled());
try {
@@ -88,11 +88,11 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatGetThrowsTimeoutUntilCloseCompletionHandlerIsCalled() throws Exception {
+ void requireThatGetThrowsTimeoutUntilCloseCompletionHandlerIsCalled() throws Exception {
ReadableContentChannel buf = new ReadableContentChannel();
FastContentWriter out = new FastContentWriter(buf);
- out.write(new byte[] { 6, 9 });
+ out.write(new byte[]{6, 9});
assertFalse(out.isDone());
try {
out.get(100, TimeUnit.MILLISECONDS);
@@ -126,11 +126,11 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatSyncWriteExceptionFailsFuture() throws InterruptedException {
+ void requireThatSyncWriteExceptionFailsFuture() throws InterruptedException {
IllegalStateException expected = new IllegalStateException();
ContentChannel content = Mockito.mock(ContentChannel.class);
Mockito.doThrow(expected)
- .when(content).write(Mockito.any(ByteBuffer.class), Mockito.any(CompletionHandler.class));
+ .when(content).write(Mockito.any(ByteBuffer.class), Mockito.any(CompletionHandler.class));
FastContentWriter out = new FastContentWriter(content);
try {
out.write("foo");
@@ -147,11 +147,11 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatSyncCloseExceptionFailsFuture() throws InterruptedException {
+ void requireThatSyncCloseExceptionFailsFuture() throws InterruptedException {
IllegalStateException expected = new IllegalStateException();
ContentChannel content = Mockito.mock(ContentChannel.class);
Mockito.doThrow(expected)
- .when(content).close(Mockito.any(CompletionHandler.class));
+ .when(content).close(Mockito.any(CompletionHandler.class));
FastContentWriter out = new FastContentWriter(content);
try {
out.close();
@@ -168,7 +168,7 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatAsyncExceptionFailsFuture() throws InterruptedException {
+ void requireThatAsyncExceptionFailsFuture() throws InterruptedException {
IllegalStateException expected = new IllegalStateException();
ReadableContentChannel content = new ReadableContentChannel();
FastContentWriter out = new FastContentWriter(content);
@@ -183,13 +183,13 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatWriterCanBeListenedTo() throws InterruptedException {
+ void requireThatWriterCanBeListenedTo() throws InterruptedException {
ReadableContentChannel buf = new ReadableContentChannel();
FastContentWriter out = new FastContentWriter(buf);
RunnableLatch listener = new RunnableLatch();
out.addListener(listener, Runnable::run);
- out.write(new byte[] { 6, 9 });
+ out.write(new byte[]{6, 9});
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
assertNotNull(buf.read());
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
@@ -200,7 +200,7 @@ public class FastContentWriterTestCase {
}
@Test
- public void requireThatWriterIsThreadSafe() throws Exception {
+ void requireThatWriterIsThreadSafe() throws Exception {
final CountDownLatch latch = new CountDownLatch(2);
final ReadableContentChannel content = new ReadableContentChannel();
Future<Integer> read = Executors.newSingleThreadExecutor().submit(new Callable<Integer>() {
@@ -235,6 +235,6 @@ public class FastContentWriterTestCase {
}
});
assertEquals(read.get(600, TimeUnit.SECONDS),
- write.get(600, TimeUnit.SECONDS));
+ write.get(600, TimeUnit.SECONDS));
}
}
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java
index ef63b200b5f..fe4b329ba9d 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java
@@ -1,16 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertSame;
public class FutureCompletionTestCase {
@Test
- public void requireThatCancelIsUnsupported() {
+ void requireThatCancelIsUnsupported() {
FutureCompletion future = new FutureCompletion();
assertFalse(future.isCancelled());
try {
@@ -38,7 +38,7 @@ public class FutureCompletionTestCase {
}
@Test
- public void requireThatCompletedReturnsTrue() throws Exception {
+ void requireThatCompletedReturnsTrue() throws Exception {
FutureCompletion future = new FutureCompletion();
try {
future.get(0, TimeUnit.MILLISECONDS);
@@ -52,7 +52,7 @@ public class FutureCompletionTestCase {
}
@Test
- public void requireThatCompletionIsDoneWhenCompleted() {
+ void requireThatCompletionIsDoneWhenCompleted() {
FutureCompletion future = new FutureCompletion();
assertFalse(future.isDone());
future.completed();
@@ -60,7 +60,7 @@ public class FutureCompletionTestCase {
}
@Test
- public void requireThatCompletionIsDoneWhenFailed() {
+ void requireThatCompletionIsDoneWhenFailed() {
FutureCompletion future = new FutureCompletion();
assertFalse(future.isDone());
future.failed(new Throwable());
@@ -68,7 +68,7 @@ public class FutureCompletionTestCase {
}
@Test
- public void requireThatFailedCauseIsRethrown() throws Exception {
+ void requireThatFailedCauseIsRethrown() throws Exception {
FutureCompletion future = new FutureCompletion();
Throwable t = new Throwable();
future.failed(t);
@@ -87,7 +87,7 @@ public class FutureCompletionTestCase {
}
@Test
- public void requireThatCompletionCanBeListenedTo() throws InterruptedException {
+ void requireThatCompletionCanBeListenedTo() throws InterruptedException {
FutureCompletion completion = new FutureCompletion();
RunnableLatch listener = new RunnableLatch();
completion.addListener(listener, Runnable::run);
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java
index 1aa78a16dfc..16c6b394426 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
@@ -10,10 +10,10 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -23,13 +23,17 @@ public class FutureConjunctionTestCase {
private final ExecutorService executor = Executors.newCachedThreadPool();
@Test
- public void requireThatAllFuturesAreWaitedFor() throws Exception {
+ void requireThatAllFuturesAreWaitedFor() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
FutureConjunction future = new FutureConjunction();
CompletableFuture<Boolean> cf = new CompletableFuture<>();
cf.completeAsync(() -> {
- try { return latch.await(600, TimeUnit.SECONDS); }
- catch (InterruptedException e) { return false; }
+ try {
+ return latch.await(600, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e) {
+ return false;
+ }
}, executor);
future.addOperand(cf);
try {
@@ -43,7 +47,7 @@ public class FutureConjunctionTestCase {
}
@Test
- public void requireThatGetReturnValueIsAConjunction() throws Exception {
+ void requireThatGetReturnValueIsAConjunction() throws Exception {
assertTrue(tryGet(true));
assertTrue(tryGet(true, true));
assertTrue(tryGet(true, true, true));
@@ -60,7 +64,7 @@ public class FutureConjunctionTestCase {
}
@Test
- public void requireThatIsDoneReturnValueIsAConjunction() {
+ void requireThatIsDoneReturnValueIsAConjunction() {
assertTrue(tryIsDone(true));
assertTrue(tryIsDone(true, true));
assertTrue(tryIsDone(true, true, true));
@@ -77,7 +81,7 @@ public class FutureConjunctionTestCase {
}
@Test
- public void requireThatCancelReturnValueIsAConjuction() {
+ void requireThatCancelReturnValueIsAConjuction() {
assertTrue(tryCancel(true));
assertTrue(tryCancel(true, true));
assertTrue(tryCancel(true, true, true));
@@ -94,7 +98,7 @@ public class FutureConjunctionTestCase {
}
@Test
- public void requireThatIsCancelledReturnValueIsAConjuction() {
+ void requireThatIsCancelledReturnValueIsAConjuction() {
assertTrue(tryIsCancelled(true));
assertTrue(tryIsCancelled(true, true));
assertTrue(tryIsCancelled(true, true, true));
@@ -111,7 +115,7 @@ public class FutureConjunctionTestCase {
}
@Test
- public void requireThatConjunctionCanBeListenedTo() throws InterruptedException {
+ void requireThatConjunctionCanBeListenedTo() throws InterruptedException {
FutureConjunction conjunction = new FutureConjunction();
RunnableLatch listener = new RunnableLatch();
conjunction.addListener(listener, Runnable::run);
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java
index 398f288e307..09f6db882fb 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java
@@ -3,15 +3,15 @@ package com.yahoo.jdisc.handler;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.test.NonWorkingContentChannel;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertSame;
public class FutureResponseTestCase {
@Test
- public void requireThatCancelIsUnsupported() {
+ void requireThatCancelIsUnsupported() {
FutureResponse future = new FutureResponse();
assertFalse(future.isCancelled());
try {
@@ -39,7 +39,7 @@ public class FutureResponseTestCase {
}
@Test
- public void requireThatCompletionIsDoneWhenHandlerIsCalled() {
+ void requireThatCompletionIsDoneWhenHandlerIsCalled() {
FutureResponse future = new FutureResponse();
assertFalse(future.isDone());
future.handleResponse(new Response(69));
@@ -47,7 +47,7 @@ public class FutureResponseTestCase {
}
@Test
- public void requireThatResponseBecomesAvailable() throws Exception {
+ void requireThatResponseBecomesAvailable() throws Exception {
FutureResponse future = new FutureResponse();
try {
future.get(0, TimeUnit.MILLISECONDS);
@@ -61,7 +61,7 @@ public class FutureResponseTestCase {
}
@Test
- public void requireThatResponseContentIsReturnedToCaller() throws Exception {
+ void requireThatResponseContentIsReturnedToCaller() throws Exception {
ContentChannel content = new NonWorkingContentChannel();
FutureResponse future = new FutureResponse(content);
Response response = new Response(Response.Status.OK);
@@ -69,7 +69,7 @@ public class FutureResponseTestCase {
}
@Test
- public void requireThatResponseCanBeListenedTo() throws InterruptedException {
+ void requireThatResponseCanBeListenedTo() throws InterruptedException {
FutureResponse response = new FutureResponse();
RunnableLatch listener = new RunnableLatch();
response.addListener(listener, Runnable::run);
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java
index 598d21b94ea..8e18ab01ae3 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.nio.ByteBuffer;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -14,7 +14,7 @@ import static org.junit.Assert.fail;
public class NullContentTestCase {
@Test
- public void requireThatWriteThrowsException() {
+ void requireThatWriteThrowsException() {
CompletionHandler completion = Mockito.mock(CompletionHandler.class);
try {
NullContent.INSTANCE.write(ByteBuffer.allocate(69), completion);
@@ -26,7 +26,7 @@ public class NullContentTestCase {
}
@Test
- public void requireThatWriteEmptyDoesNotThrowException() {
+ void requireThatWriteEmptyDoesNotThrowException() {
CompletionHandler completion = Mockito.mock(CompletionHandler.class);
NullContent.INSTANCE.write(ByteBuffer.allocate(0), completion);
Mockito.verify(completion).completed();
@@ -34,7 +34,7 @@ public class NullContentTestCase {
}
@Test
- public void requireThatCloseCallsCompletion() {
+ void requireThatCloseCallsCompletion() {
CompletionHandler completion = Mockito.mock(CompletionHandler.class);
NullContent.INSTANCE.close(completion);
Mockito.verify(completion).completed();
@@ -42,7 +42,7 @@ public class NullContentTestCase {
}
@Test
- public void requireThatCloseWithoutCompletionDoesNotThrow() {
+ void requireThatCloseWithoutCompletionDoesNotThrow() {
NullContent.INSTANCE.close(null);
}
}
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java
index 385cd4015b9..77da00bfa89 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.Iterator;
@@ -10,12 +10,12 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.*;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author Simon Thoresen Hult
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertSame;
public class ReadableContentChannelTestCase {
@Test
- public void requireThatWriteNullThrowsException() {
+ void requireThatWriteNullThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
try {
content.write(null, new MyCompletion());
@@ -34,7 +34,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatWriteAfterCloseThrowsException() {
+ void requireThatWriteAfterCloseThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
content.close(null);
try {
@@ -46,7 +46,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatWriteAfterFailedThrowsException() {
+ void requireThatWriteAfterFailedThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
content.failed(new RuntimeException());
try {
@@ -58,7 +58,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatCloseAfterCloseThrowsException() {
+ void requireThatCloseAfterCloseThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
content.close(null);
try {
@@ -70,7 +70,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatCloseAfterFailedThrowsException() {
+ void requireThatCloseAfterFailedThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
content.failed(new RuntimeException());
try {
@@ -82,7 +82,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatFailedAfterFailedThrowsException() {
+ void requireThatFailedAfterFailedThrowsException() {
ReadableContentChannel content = new ReadableContentChannel();
content.failed(new RuntimeException());
try {
@@ -94,7 +94,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatIteratorDoesNotSupportRemove() {
+ void requireThatIteratorDoesNotSupportRemove() {
try {
new ReadableContentChannel().iterator().remove();
fail();
@@ -104,7 +104,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatWrittenBufferCanBeRead() {
+ void requireThatWrittenBufferCanBeRead() {
ReadableContentChannel content = new ReadableContentChannel();
ByteBuffer buf = ByteBuffer.allocate(69);
content.write(buf, null);
@@ -112,7 +112,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatWrittenBuffersAreReadInOrder() {
+ void requireThatWrittenBuffersAreReadInOrder() {
ReadableContentChannel content = new ReadableContentChannel();
ByteBuffer foo = ByteBuffer.allocate(69);
content.write(foo, null);
@@ -124,7 +124,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatReadAfterCloseIsNull() {
+ void requireThatReadAfterCloseIsNull() {
ReadableContentChannel content = new ReadableContentChannel();
content.close(null);
assertNull(content.read());
@@ -132,7 +132,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatWrittenBufferCanBeReadByIterator() {
+ void requireThatWrittenBufferCanBeReadByIterator() {
ReadableContentChannel content = new ReadableContentChannel();
ByteBuffer foo = ByteBuffer.allocate(69);
content.write(foo, null);
@@ -155,7 +155,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatReadAfterFailedIsNull() {
+ void requireThatReadAfterFailedIsNull() {
ReadableContentChannel content = new ReadableContentChannel();
content.failed(new RuntimeException());
assertNull(content.read());
@@ -163,7 +163,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatReadCallsCompletion() {
+ void requireThatReadCallsCompletion() {
ReadableContentChannel content = new ReadableContentChannel();
ByteBuffer buf = ByteBuffer.allocate(69);
MyCompletion completion = new MyCompletion();
@@ -180,7 +180,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatReadWaitsForWrite() throws Exception {
+ void requireThatReadWaitsForWrite() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
ReadableContentChannel content = new ReadableContentChannel();
Future<ByteBuffer> readBuf = executor.submit(new ReadTask(content));
@@ -196,7 +196,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatCloseNotifiesRead() throws Exception {
+ void requireThatCloseNotifiesRead() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
ReadableContentChannel content = new ReadableContentChannel();
Future<ByteBuffer> buf = executor.submit(new ReadTask(content));
@@ -211,7 +211,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatFailedNotifiesRead() throws Exception {
+ void requireThatFailedNotifiesRead() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
ReadableContentChannel content = new ReadableContentChannel();
Future<ByteBuffer> buf = executor.submit(new ReadTask(content));
@@ -226,7 +226,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatFailedCallsPendingCompletions() {
+ void requireThatFailedCallsPendingCompletions() {
MyCompletion foo = new MyCompletion();
MyCompletion bar = new MyCompletion();
ReadableContentChannel content = new ReadableContentChannel();
@@ -239,10 +239,10 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatAvailableIsNotBlocking() {
+ void requireThatAvailableIsNotBlocking() {
ReadableContentChannel content = new ReadableContentChannel();
assertEquals(0, content.available());
- ByteBuffer buf = ByteBuffer.wrap(new byte[] { 6, 9 });
+ ByteBuffer buf = ByteBuffer.wrap(new byte[]{6, 9});
content.write(buf, null);
assertTrue(content.available() > 0);
assertSame(buf, content.read());
@@ -253,7 +253,7 @@ public class ReadableContentChannelTestCase {
}
@Test
- public void requireThatContentIsThreadSafe() {
+ void requireThatContentIsThreadSafe() {
ExecutorService executor = Executors.newFixedThreadPool(100);
for (int run = 0; run < 69; ++run) {
List<ByteBuffer> bufs = new LinkedList<>();
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java
index 01634498bf3..724125e9c5e 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java
@@ -6,12 +6,12 @@ import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertSame;
public class RequestDeniedTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
driver.activateContainer(driver.newContainerBuilder());
Request request = new Request(driver, URI.create("http://host/path"));
@@ -30,7 +30,7 @@ public class RequestDeniedTestCase {
}
@Test
- public void requireThatRequestDeniedIsThrown() {
+ void requireThatRequestDeniedIsThrown() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
RequestHandler requestHandler = new MyRequestHandler();
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java
index 6ec78f01733..fdae7e8e701 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java
@@ -5,7 +5,7 @@ import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -16,12 +16,12 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -29,7 +29,7 @@ import static org.junit.Assert.fail;
public class RequestDispatchTestCase {
@Test
- public void requireThatRequestCanBeDispatched() throws Exception {
+ void requireThatRequestCanBeDispatched() throws Exception {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9));
ReadableContentChannel receivedContent = new ReadableContentChannel();
@@ -62,7 +62,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatStreamCanBeConnected() throws IOException {
+ void requireThatStreamCanBeConnected() throws IOException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
ReadableContentChannel content = new ReadableContentChannel();
@@ -84,7 +84,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatCancelIsUnsupported() {
+ void requireThatCancelIsUnsupported() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
RequestDispatch dispatch = driver.newRequestDispatch("http://localhost/", new FutureResponse());
assertFalse(dispatch.isCancelled());
@@ -106,7 +106,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatDispatchHandlesConnectException() {
+ void requireThatDispatchHandlesConnectException() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new AbstractRequestHandler() {
@@ -127,7 +127,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatDispatchHandlesWriteException() {
+ void requireThatDispatchHandlesWriteException() {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
@@ -165,7 +165,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatDispatchHandlesCloseException() {
+ void requireThatDispatchHandlesCloseException() {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
@@ -203,7 +203,7 @@ public class RequestDispatchTestCase {
}
@Test
- public void requireThatDispatchCanBeListenedTo() throws InterruptedException {
+ void requireThatDispatchCanBeListenedTo() throws InterruptedException {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
ReadableContentChannel requestContent = new ReadableContentChannel();
@@ -220,7 +220,7 @@ public class RequestDispatchTestCase {
}.dispatch().whenComplete((__, ___) -> listener.run());
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
ContentChannel responseContent = ResponseDispatch.newInstance(Response.Status.OK)
- .connect(requestHandler.responseHandler);
+ .connect(requestHandler.responseHandler);
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
assertNull(requestContent.read());
assertTrue(listener.await(600, TimeUnit.SECONDS));
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java
index 4006ab072cb..2c00689c3f4 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.jdisc.handler;
import com.yahoo.jdisc.Response;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -13,13 +13,13 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -27,7 +27,7 @@ import static org.junit.Assert.fail;
public class ResponseDispatchTestCase {
@Test
- public void requireThatFactoryMethodsWork() throws Exception {
+ void requireThatFactoryMethodsWork() throws Exception {
{
FutureResponse handler = new FutureResponse();
ResponseDispatch.newInstance(69).dispatch(handler);
@@ -78,7 +78,7 @@ public class ResponseDispatchTestCase {
}
@Test
- public void requireThatResponseCanBeDispatched() throws Exception {
+ void requireThatResponseCanBeDispatched() throws Exception {
final Response response = new Response(Response.Status.OK);
final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9));
ResponseDispatch dispatch = new ResponseDispatch() {
@@ -109,7 +109,7 @@ public class ResponseDispatchTestCase {
}
@Test
- public void requireThatStreamCanBeConnected() throws IOException {
+ void requireThatStreamCanBeConnected() throws IOException {
ReadableContentChannel responseContent = new ReadableContentChannel();
OutputStream out = new FastContentOutputStream(new ResponseDispatch() {
@@ -129,7 +129,7 @@ public class ResponseDispatchTestCase {
}
@Test
- public void requireThatCancelIsUnsupported() {
+ void requireThatCancelIsUnsupported() {
ResponseDispatch dispatch = ResponseDispatch.newInstance(69);
assertFalse(dispatch.isCancelled());
try {
@@ -149,7 +149,7 @@ public class ResponseDispatchTestCase {
}
@Test
- public void requireThatDispatchClosesContentIfWriteThrowsException() {
+ void requireThatDispatchClosesContentIfWriteThrowsException() {
final AtomicBoolean closed = new AtomicBoolean(false);
try {
ResponseDispatch.newInstance(6, ByteBuffer.allocate(9)).dispatch(
@@ -173,12 +173,12 @@ public class ResponseDispatchTestCase {
}
@Test
- public void requireThatDispatchCanBeListenedTo() throws InterruptedException {
+ void requireThatDispatchCanBeListenedTo() throws InterruptedException {
RunnableLatch listener = new RunnableLatch();
ReadableContentChannel responseContent = new ReadableContentChannel();
ResponseDispatch.newInstance(6, ByteBuffer.allocate(9))
- .dispatch(new MyResponseHandler(responseContent))
- .whenComplete((__, ___) -> listener.run());
+ .dispatch(new MyResponseHandler(responseContent))
+ .whenComplete((__, ___) -> listener.run());
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
assertNotNull(responseContent.read());
assertFalse(listener.await(100, TimeUnit.MILLISECONDS));
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java
index f639877b87b..63a6d310208 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java
@@ -6,7 +6,7 @@ import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.service.CurrentContainer;
import com.yahoo.jdisc.test.TestDriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URI;
import java.nio.ByteBuffer;
@@ -18,12 +18,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -31,7 +31,7 @@ import static org.junit.Assert.fail;
public class ThreadedRequestHandlerTestCase {
@Test
- public void requireThatNullExecutorThrowsException() {
+ void requireThatNullExecutorThrowsException() {
try {
new ThreadedRequestHandler(null) {
@@ -47,7 +47,7 @@ public class ThreadedRequestHandlerTestCase {
}
@Test
- public void requireThatAccessorWork() {
+ void requireThatAccessorWork() {
MyRequestHandler requestHandler = new MyRequestHandler(newExecutor());
requestHandler.setTimeout(1000, TimeUnit.MILLISECONDS);
assertEquals(1000, requestHandler.getTimeout(TimeUnit.MILLISECONDS));
@@ -55,7 +55,7 @@ public class ThreadedRequestHandlerTestCase {
}
@Test
- public void requireThatHandlerSetsRequestTimeout() throws InterruptedException {
+ void requireThatHandlerSetsRequestTimeout() throws InterruptedException {
MyRequestHandler requestHandler = new MyRequestHandler(newExecutor());
requestHandler.setTimeout(600, TimeUnit.SECONDS);
TestDriver driver = newTestDriver("http://localhost/", requestHandler);
@@ -74,7 +74,7 @@ public class ThreadedRequestHandlerTestCase {
}
@Test
- public void requireThatRequestAndResponseReachHandlers() throws InterruptedException {
+ void requireThatRequestAndResponseReachHandlers() throws InterruptedException {
MyRequestHandler requestHandler = new MyRequestHandler(newExecutor());
TestDriver driver = newTestDriver("http://localhost/", requestHandler);
@@ -99,18 +99,18 @@ public class ThreadedRequestHandlerTestCase {
}
@Test
- public void requireThatNotImplementedHandlerDoesNotPreventShutdown() throws Exception {
+ void requireThatNotImplementedHandlerDoesNotPreventShutdown() throws Exception {
TestDriver driver = newTestDriver("http://localhost/", new ThreadedRequestHandler(newExecutor()) {
});
assertEquals(Response.Status.NOT_IMPLEMENTED,
- dispatchRequest(driver, "http://localhost/", ByteBuffer.wrap(new byte[] { 69 }))
- .get(600, TimeUnit.SECONDS).getStatus());
+ dispatchRequest(driver, "http://localhost/", ByteBuffer.wrap(new byte[]{69}))
+ .get(600, TimeUnit.SECONDS).getStatus());
assertTrue(driver.close());
}
@Test
- public void requireThatThreadedRequestHandlerRetainsTheRequestUntilHandlerIsRun() throws Exception {
+ void requireThatThreadedRequestHandlerRetainsTheRequestUntilHandlerIsRun() throws Exception {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
final AtomicInteger baseRetainCount = new AtomicInteger();
@@ -130,7 +130,7 @@ public class ThreadedRequestHandlerTestCase {
@Override
public void handleRequest(Request request, ReadableContentChannel requestContent,
- ResponseHandler responseHandler) {
+ ResponseHandler responseHandler) {
try {
entryLatch.await(600, TimeUnit.SECONDS);
} catch (InterruptedException e) {
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java
index 864604d76d6..50d695dbb27 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.jdisc.handler;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
@@ -10,10 +10,11 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -21,7 +22,7 @@ import static org.junit.Assert.fail;
public class UnsafeContentInputStreamTestCase {
@Test
- public void requireThatBytesCanBeRead() throws IOException {
+ void requireThatBytesCanBeRead() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("Hello ");
@@ -34,7 +35,7 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void testMark() throws IOException {
+ void testMark() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("Hello ");
@@ -50,6 +51,11 @@ public class UnsafeContentInputStreamTestCase {
stream.read(buf);
assertEquals("ello Wor", Utf8.toString(buf));
stream.reset();
+ stream.mark(8);
+ buf = new byte[8];
+ stream.read(buf);
+ assertEquals("ello Wor", Utf8.toString(buf));
+ stream.reset();
stream.mark(5);
buf = new byte [9];
stream.read(buf);
@@ -65,7 +71,22 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatCompletionsAreCalledWithDeprecatedContentWriter() throws IOException {
+ void requireThatReadAfterResetIncludesDataAfterMark() throws IOException {
+ ReadableContentChannel content = new ReadableContentChannel();
+ UnsafeContentInputStream in = new UnsafeContentInputStream(content);
+ byte[] outBuf = new byte[]{1, 2, 3};
+ content.write(ByteBuffer.wrap(outBuf), null);
+ in.mark(4);
+ assertEquals(3, in.read(new byte[]{101, 102, 103, 104}));
+ in.reset();
+ byte[] inBuf = new byte[4];
+ int read = in.read(inBuf);
+ assertEquals(3, read);
+ assertArrayEquals(new byte[]{1, 2, 3, 0}, inBuf);
+ }
+
+ @Test
+ void requireThatCompletionsAreCalledWithDeprecatedContentWriter() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("foo");
@@ -80,7 +101,7 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatCompletionsAreCalled() throws IOException {
+ void requireThatCompletionsAreCalled() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("foo");
@@ -95,7 +116,7 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatCloseDrainsStreamWithDeprecatedContentWriter() {
+ void requireThatCloseDrainsStreamWithDeprecatedContentWriter() {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("foo");
@@ -106,7 +127,7 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatCloseDrainsStream() {
+ void requireThatCloseDrainsStream() {
BufferedContentChannel channel = new BufferedContentChannel();
FastContentWriter writer = new FastContentWriter(channel);
writer.write("foo");
@@ -117,11 +138,11 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatAvailableIsNotBlocking() throws IOException {
+ void requireThatAvailableIsNotBlocking() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
InputStream stream = asInputStream(channel);
assertEquals(0, stream.available());
- channel.write(ByteBuffer.wrap(new byte[] { 6, 9 }), null);
+ channel.write(ByteBuffer.wrap(new byte[]{6, 9}), null);
assertTrue(stream.available() > 0);
assertEquals(6, stream.read());
assertTrue(stream.available() > 0);
@@ -133,11 +154,11 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatReadLargeArrayIsNotBlocking() throws IOException {
+ void requireThatReadLargeArrayIsNotBlocking() throws IOException {
BufferedContentChannel channel = new BufferedContentChannel();
InputStream stream = asInputStream(channel);
assertEquals(0, stream.available());
- channel.write(ByteBuffer.wrap(new byte[] { 6, 9 }), null);
+ channel.write(ByteBuffer.wrap(new byte[]{6, 9}), null);
assertTrue(stream.available() > 0);
byte[] buf = new byte[69];
assertEquals(2, stream.read(buf));
@@ -150,12 +171,12 @@ public class UnsafeContentInputStreamTestCase {
}
@Test
- public void requireThatAllByteValuesCanBeRead() throws IOException {
+ void requireThatAllByteValuesCanBeRead() throws IOException {
ReadableContentChannel content = new ReadableContentChannel();
InputStream in = new UnsafeContentInputStream(content);
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; ++i) {
- content.write(ByteBuffer.wrap(new byte[] { (byte)i }), null);
- assertEquals(i, (byte)in.read());
+ content.write(ByteBuffer.wrap(new byte[]{(byte) i}), null);
+ assertEquals(i, (byte) in.read());
}
}