diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java |
Publish
Diffstat (limited to 'container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java')
-rw-r--r-- | container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java b/container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java new file mode 100644 index 00000000000..1e684b816aa --- /dev/null +++ b/container-core/src/test/java/com/yahoo/processing/rendering/TestContentChannel.java @@ -0,0 +1,42 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.processing.rendering; + +import com.yahoo.jdisc.handler.CompletionHandler; +import com.yahoo.jdisc.handler.ContentChannel; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +/** +* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> +* @since 5.1.9 +*/ +class TestContentChannel implements ContentChannel { + private final List<ByteBuffer> buffers = new ArrayList<>(); + private boolean closed = false; + + @Override + public void write(ByteBuffer buf, CompletionHandler handler) { + buffers.add(buf); + if (handler != null) { + handler.completed(); + } + } + + @Override + public void close(CompletionHandler handler) { + closed = true; + if (handler != null) { + handler.completed(); + } + } + + public List<ByteBuffer> getBuffers() { + return buffers; + } + + public boolean isClosed() { + return closed; + } +} |