use of org.eclipse.xtext.testing.logging.LoggingTester.LogCapture in project xtext-xtend by eclipse.
the class JavaClasspathTest method testNoJavaInClasspath.
@Test
public void testNoJavaInClasspath() throws Exception {
LogCapture capturedLogging = LoggingTester.captureLogging(Level.ERROR, AbstractClassMirror.class, new Runnable() {
@Override
public void run() {
LogCapture capturedLogging = LoggingTester.captureLogging(Level.ERROR, JdtTypeMirror.class, new Runnable() {
@Override
public void run() {
try {
IProject project = testHelper.getProject();
IJavaProject javaProject = JavaCore.create(project);
IFile file = project.getFile("src/Foo.xtend");
if (!file.exists())
file.create(new StringInputStream(TEST_CLAZZ), true, null);
IClasspathEntry jrePath = JavaProjectSetupUtil.getJreContainerClasspathEntry(javaProject);
assertNotNull("JRE Lib classpath entry not found.", jrePath);
// remove JRE Lib
JavaProjectSetupUtil.deleteClasspathEntry(javaProject, jrePath.getPath());
IResourcesSetupUtil.waitForBuild();
markerAssert.assertErrorMarker(file, IssueCodes.JDK_NOT_ON_CLASSPATH);
// add JRE back
JavaProjectSetupUtil.addToClasspath(javaProject, jrePath);
IResourcesSetupUtil.waitForBuild();
markerAssert.assertNoErrorMarker(file);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
assertFalse(capturedLogging.getLogEntries().isEmpty());
}
});
assertFalse(capturedLogging.getLogEntries().isEmpty());
}
use of org.eclipse.xtext.testing.logging.LoggingTester.LogCapture in project xtext-core by eclipse.
the class CrossRefTest method testGetMultiValuedLinkText.
@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);
}
use of org.eclipse.xtext.testing.logging.LoggingTester.LogCapture in project xtext-core by eclipse.
the class Bug281990Test method testRecursionErrorMessage.
@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);
}
Aggregations