summaryrefslogtreecommitdiffstats
path: root/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java')
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
new file mode 100644
index 00000000000..c234e524774
--- /dev/null
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
@@ -0,0 +1,38 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.http.client.core.communication;
+
+import com.yahoo.vespa.http.client.core.Document;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+public class CloseableQTestCase {
+ @Test
+ public void requestThatPutIsInterruptedOnClose() throws InterruptedException {
+ final DocumentQueue q = new DocumentQueue(1);
+ q.put(new Document("id", "data", null /* context */));
+ Thread t = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+
+ }
+ q.close();
+ q.clear();
+ }
+ });
+ t.start();
+ try {
+ q.put(new Document("id2", "data2", null /* context */));
+ fail("This shouldn't have worked.");
+ } catch (IllegalStateException ise) {
+ // ok!
+ }
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ }
+ }
+}