Java Code Examples for org.eclipse.xtext.testing.logging.LoggingTester#captureLogging()
The following examples show how to use
org.eclipse.xtext.testing.logging.LoggingTester#captureLogging() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test(timeout = 1000) 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, WriteRequest.class, _function); logResult.assertLogEntry("Error during request:"); }
Example 2
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test(timeout = 1000) public void testRunWriteLogExceptionCancellable() { final Runnable _function = () -> { final Function0<Object> _function_1 = () -> { throw new RuntimeException(); }; final Function2<CancelIndicator, Object, Object> _function_2 = (CancelIndicator $0, Object $1) -> { return null; }; 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, WriteRequest.class, _function); logResult.assertLogEntry("Error during request:"); }
Example 3
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test(timeout = 1000, expected = ExecutionException.class) public void testRunWriteCatchException() { final Runnable _function = () -> { try { final Function0<Object> _function_1 = () -> { throw new RuntimeException(); }; final Function2<CancelIndicator, Object, Object> _function_2 = (CancelIndicator $0, Object $1) -> { return null; }; final CompletableFuture<Object> future = this.requestManager.<Object, Object>runWrite(_function_1, _function_2); Assert.assertEquals("Foo", future.get()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; LoggingTester.captureLogging(Level.ALL, WriteRequest.class, _function); Assert.fail("unreachable"); }
Example 4
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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, ReadRequest.class, _function); logResult.assertLogEntry("Error during request:"); }
Example 5
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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, ReadRequest.class, _function); Assert.fail(); }
Example 6
Source File: TestBatchCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testInvalidConfiguration() { final Runnable _function = () -> { this.batchCompiler.setSourcePath(TestBatchCompiler.XTEND_SRC_DIRECTORY); this.batchCompiler.setOutputPath((TestBatchCompiler.XTEND_SRC_DIRECTORY + "/xtend-gen")); this.batchCompiler.compile(); }; final LoggingTester.LogCapture log = LoggingTester.captureLogging(Level.ERROR, XtendBatchCompiler.class, _function); log.assertLogEntry("xtend", "cannot be a child"); }
Example 7
Source File: TestBatchCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testInvalidConfiguration_2() { boolean _startsWith = System.getProperty("os.name").startsWith("Windows"); if (_startsWith) { final Runnable _function = () -> { this.batchCompiler.setSourcePath(TestBatchCompiler.XTEND_SRC_DIRECTORY); String _upperCase = TestBatchCompiler.XTEND_SRC_DIRECTORY.toUpperCase(); String _plus = (_upperCase + "/xtend-gen"); this.batchCompiler.setOutputPath(_plus); this.batchCompiler.compile(); }; final LoggingTester.LogCapture log = LoggingTester.captureLogging(Level.ERROR, XtendBatchCompiler.class, _function); log.assertLogEntry("xtend", "cannot be a child"); } }
Example 8
Source File: TestBatchCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testActiveAnnotatons1() { this.batchCompiler.setSourcePath("./batch-compiler-data/activeAnnotations1"); final Runnable _function = () -> { Assert.assertFalse(this.batchCompiler.compile()); }; final LoggingTester.LogCapture logs = LoggingTester.captureLogging(Level.ERROR, XtendBatchCompiler.class, _function); logs.assertNumberOfLogEntries(1); }
Example 9
Source File: Bug281990Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testRecursionErrorMessage() throws Exception { LogCapture loggings = LoggingTester.captureLogging(Level.ERROR, LazyLinkingResource.class, new Runnable() { @Override public void run() { try { EObject model = getModelAndExpect("type Foo extends Foo.bar { Foo foo; }", 2); assertTrue(((Model)model).getTypes().get(0).getParentId().eIsProxy()); assertTrue(model.eResource().getErrors().get(0).getMessage().contains("Couldn't")); } catch (Exception e) { throw Exceptions.sneakyThrow(e); } } }); loggings.assertNumberOfLogEntries(1); }
Example 10
Source File: JvmTypesBuilderTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void expectErrorLogging(final int numberOfloggings, final Runnable block) { final LoggingTester.LogCapture loggings = LoggingTester.captureLogging(Level.ERROR, JvmTypesBuilder.class, block); loggings.assertNumberOfLogEntries(numberOfloggings); }
Example 11
Source File: CrossRefTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testGetMultiValuedLinkText() throws Exception { with(LazyLinkingTestLanguageStandaloneSetup.class); crossRefSerializer = get(ICrossReferenceSerializer.class); final LazyLinkingTestLanguageGrammarAccess g = (LazyLinkingTestLanguageGrammarAccess) get(IGrammarAccess.class); final XtextResource r = CrossRefTest.this.getResourceFromStringAndExpect("type TypeA {} type TypeB { TypeA TypeC TypeB p1; }", 1); LogCapture log = LoggingTester.captureLogging(Level.ERROR, LazyLinkingResource.class, new Runnable() { @Override public void run() { Model model = (Model) r.getContents().get(0); assertEquals(2, model.getTypes().size()); org.eclipse.xtext.linking.lazy.lazyLinking.Type type = model.getTypes().get(1); assertEquals("TypeB", type.getName()); assertEquals(1, type.getProperties().size()); Property prop = type.getProperties().get(0); assertEquals("p1", prop.getName()); assertEquals(3, prop.getType().size()); org.eclipse.xtext.linking.lazy.lazyLinking.Type propType = prop.getType().get(0); assertFalse(propType.eIsProxy()); String linkText = crossRefSerializer.serializeCrossRef(prop,g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null); assertEquals("TypeA", linkText); propType = prop.getType().get(1); assertTrue(propType.eIsProxy()); INode node = getCrossReferenceNode(prop, GrammarUtil.getReference(g.getPropertyAccess().getTypeTypeCrossReference_0_0()), propType); linkText = crossRefSerializer.serializeCrossRef(prop,g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, node); assertEquals("TypeC", linkText); propType = prop.getType().get(2); assertFalse(propType.eIsProxy()); node = getCrossReferenceNode(prop, GrammarUtil.getReference(g.getPropertyAccess().getTypeTypeCrossReference_0_0()), propType); linkText = crossRefSerializer.serializeCrossRef(prop,g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null); assertEquals("TypeB", linkText); Adapter adapter = (Adapter) NodeModelUtils.getNode(prop); prop.eAdapters().remove(adapter); propType = prop.getType().get(1); assertTrue(propType.eIsProxy()); linkText = crossRefSerializer.serializeCrossRef(prop,g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null); assertNull(linkText); } }); log.assertNumberOfLogEntries(2); }