mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
add tests for runRead, etc.
Signed-off-by: mmews <marcus.mews@numberfour.eu>
This commit is contained in:
parent
3102556c4e
commit
df3b967105
2 changed files with 111 additions and 6 deletions
|
@ -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 [
|
||||
|
|
|
@ -53,7 +53,30 @@ public class RequestManagerTest {
|
|||
}
|
||||
|
||||
@Test(timeout = 1000)
|
||||
public void testLogException() {
|
||||
public void testRunWriteLogExceptionNonCancellable() {
|
||||
final Runnable _function = () -> {
|
||||
final Function0<Object> _function_1 = () -> {
|
||||
return null;
|
||||
};
|
||||
final Function2<CancelIndicator, Object, Object> _function_2 = (CancelIndicator $0, Object $1) -> {
|
||||
throw new RuntimeException();
|
||||
};
|
||||
final CompletableFuture<Object> future = this.requestManager.<Object, Object>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<Object> _function_1 = () -> {
|
||||
throw new RuntimeException();
|
||||
|
@ -63,7 +86,7 @@ public class RequestManagerTest {
|
|||
};
|
||||
final CompletableFuture<Object> future = this.requestManager.<Object, Object>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<Object> _function_1 = () -> {
|
||||
|
@ -95,6 +118,43 @@ public class RequestManagerTest {
|
|||
Assert.fail();
|
||||
}
|
||||
|
||||
@Test(timeout = 1000)
|
||||
public void testRunReadLogException() {
|
||||
final Runnable _function = () -> {
|
||||
final Function1<CancelIndicator, Object> _function_1 = (CancelIndicator it) -> {
|
||||
throw new RuntimeException();
|
||||
};
|
||||
final CompletableFuture<Object> future = this.requestManager.<Object>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<CancelIndicator, Object> _function_1 = (CancelIndicator it) -> {
|
||||
throw new RuntimeException();
|
||||
};
|
||||
final CompletableFuture<Object> future = this.requestManager.<Object>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 {
|
||||
|
|
Loading…
Reference in a new issue