Java Code Examples for org.eclipse.xtext.testing.logging.LoggingTester#LogCapture

The following examples show how to use org.eclipse.xtext.testing.logging.LoggingTester#LogCapture . 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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 4
Source File: TestBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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 5
Source File: TestBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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 6
Source File: TestBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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 7
Source File: JvmTypesBuilderTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected void expectErrorLogging(final int numberOfloggings, final Runnable block) {
  final LoggingTester.LogCapture loggings = LoggingTester.captureLogging(Level.ERROR, JvmTypesBuilder.class, block);
  loggings.assertNumberOfLogEntries(numberOfloggings);
}