diff --git a/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.xtend b/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.xtend index dcf99d75c..57bf91cc6 100644 --- a/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.xtend +++ b/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.xtend @@ -47,7 +47,23 @@ class RequestManagerTest { } @Test(timeout = 1000) - def void testLogException() { + def void testRunWriteLogExceptionNonCancellable() { + val logResult = LoggingTester.captureLogging(Level.ALL, RequestManager, [ + val future = requestManager.runWrite([], [ + throw new RuntimeException(); + ]) + + // join future to assert log later + try { + future.join + } catch (Exception e) {} + ]) + + logResult.assertLogEntry("Error during request:") + } + + @Test(timeout = 1000) + def void testRunWriteLogExceptionCancellable() { val logResult = LoggingTester.captureLogging(Level.ALL, RequestManager, [ val future = requestManager.runWrite([ throw new RuntimeException(); @@ -55,7 +71,7 @@ class RequestManagerTest { // join future to assert log later try { - future.get + future.join } catch (Exception e) {} ]) @@ -63,7 +79,7 @@ class RequestManagerTest { } @Test(timeout = 1000, expected = ExecutionException) - def void testCatchException() { + def void testRunWriteCatchException() { LoggingTester.captureLogging(Level.ALL, RequestManager, [ val future = requestManager.runWrite([ throw new RuntimeException() @@ -75,6 +91,35 @@ class RequestManagerTest { Assert.fail } + @Test(timeout = 1000) + def void testRunReadLogException() { + val logResult = LoggingTester.captureLogging(Level.ALL, RequestManager, [ + val future = requestManager.runRead([ + throw new RuntimeException(); + ]) + + // join future to assert log later + try { + future.join + } catch (Exception e) {} + ]) + + logResult.assertLogEntry("Error during request:") + } + + @Test(timeout = 1000, expected = ExecutionException) + def void testRunReadCatchException() { + LoggingTester.captureLogging(Level.ALL, RequestManager, [ + val future = requestManager.runRead([ + throw new RuntimeException() + ]) + + assertEquals('Foo', future.get) + ]) + + Assert.fail + } + @Test(timeout = 1000) def void testRunRead() { val future = requestManager.runRead [ diff --git a/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.java b/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.java index 6ffde591d..0093f5474 100644 --- a/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.java +++ b/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/concurrent/RequestManagerTest.java @@ -53,7 +53,30 @@ public class RequestManagerTest { } @Test(timeout = 1000) - public void testLogException() { + public void testRunWriteLogExceptionNonCancellable() { + final Runnable _function = () -> { + final Function0 _function_1 = () -> { + return null; + }; + final Function2 _function_2 = (CancelIndicator $0, Object $1) -> { + throw new RuntimeException(); + }; + final CompletableFuture future = this.requestManager.runWrite(_function_1, _function_2); + try { + future.join(); + } catch (final Throwable _t) { + if (_t instanceof Exception) { + } else { + throw Exceptions.sneakyThrow(_t); + } + } + }; + final LoggingTester.LogCapture logResult = LoggingTester.captureLogging(Level.ALL, RequestManager.class, _function); + logResult.assertLogEntry("Error during request:"); + } + + @Test(timeout = 1000) + public void testRunWriteLogExceptionCancellable() { final Runnable _function = () -> { final Function0 _function_1 = () -> { throw new RuntimeException(); @@ -63,7 +86,7 @@ public class RequestManagerTest { }; final CompletableFuture future = this.requestManager.runWrite(_function_1, _function_2); try { - future.get(); + future.join(); } catch (final Throwable _t) { if (_t instanceof Exception) { } else { @@ -76,7 +99,7 @@ public class RequestManagerTest { } @Test(timeout = 1000, expected = ExecutionException.class) - public void testCatchException() { + public void testRunWriteCatchException() { final Runnable _function = () -> { try { final Function0 _function_1 = () -> { @@ -95,6 +118,43 @@ public class RequestManagerTest { Assert.fail(); } + @Test(timeout = 1000) + public void testRunReadLogException() { + final Runnable _function = () -> { + final Function1 _function_1 = (CancelIndicator it) -> { + throw new RuntimeException(); + }; + final CompletableFuture future = this.requestManager.runRead(_function_1); + try { + future.join(); + } catch (final Throwable _t) { + if (_t instanceof Exception) { + } else { + throw Exceptions.sneakyThrow(_t); + } + } + }; + final LoggingTester.LogCapture logResult = LoggingTester.captureLogging(Level.ALL, RequestManager.class, _function); + logResult.assertLogEntry("Error during request:"); + } + + @Test(timeout = 1000, expected = ExecutionException.class) + public void testRunReadCatchException() { + final Runnable _function = () -> { + try { + final Function1 _function_1 = (CancelIndicator it) -> { + throw new RuntimeException(); + }; + final CompletableFuture future = this.requestManager.runRead(_function_1); + Assert.assertEquals("Foo", future.get()); + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + }; + LoggingTester.captureLogging(Level.ALL, RequestManager.class, _function); + Assert.fail(); + } + @Test(timeout = 1000) public void testRunRead() { try {