summaryrefslogtreecommitdiffstats
path: root/sangria-core/src/test
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-07 21:09:20 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-07 21:10:05 -0400
commit505b147bd23e26d21932af2c3336c9f4607bbcce (patch)
treea5e58915ccacd82cb8d4f4b9a9808c318e34573e /sangria-core/src/test
parentdf9dbddd378e6f5adadb3b62279fb80eb92b4a91 (diff)
downloadsangria-505b147bd23e26d21932af2c3336c9f4607bbcce.tar.xz
core: Make DelayedError complain if cancel() is called too late.
Diffstat (limited to 'sangria-core/src/test')
-rw-r--r--sangria-core/src/test/java/com/tavianator/sangria/core/DelayedErrorTest.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/sangria-core/src/test/java/com/tavianator/sangria/core/DelayedErrorTest.java b/sangria-core/src/test/java/com/tavianator/sangria/core/DelayedErrorTest.java
index 349dced..f27aea8 100644
--- a/sangria-core/src/test/java/com/tavianator/sangria/core/DelayedErrorTest.java
+++ b/sangria-core/src/test/java/com/tavianator/sangria/core/DelayedErrorTest.java
@@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.*;
* Tests for {@link DelayedError}.
*
* @author Tavian Barnes (tavianator@tavianator.com)
- * @version 1.0
+ * @version 1.1
* @since 1.0
*/
public class DelayedErrorTest {
@@ -83,4 +83,31 @@ public class DelayedErrorTest {
}
});
}
+
+ @Test
+ public void testCancel() {
+ Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ DelayedError error = DelayedError.create(binder(), "Message");
+ error.cancel();
+ }
+ });
+ }
+
+ @Test
+ public void testLateCancel() {
+ final DelayedError[] errorHolder = new DelayedError[1];
+
+ Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ errorHolder[0] = DelayedError.create(binder(), "Message");
+ errorHolder[0].cancel();
+ }
+ });
+
+ thrown.expect(IllegalStateException.class);
+ errorHolder[0].cancel();
+ }
}