summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-02-11 07:41:20 (EST)
committer sefftinge2009-02-11 07:41:20 (EST)
commitd0d9d4eb127bf4135d1701c4ce668c3f7af13079 (patch)
treea4ac6f145a3144f9d3f454df988a849a2eea246d
parentba8eee6d9b3e5198d58e4ec3e53c36c0d77e95c7 (diff)
downloadorg.eclipse.xtext-d0d9d4eb127bf4135d1701c4ce668c3f7af13079.zip
org.eclipse.xtext-d0d9d4eb127bf4135d1701c4ce668c3f7af13079.tar.gz
org.eclipse.xtext-d0d9d4eb127bf4135d1701c4ce668c3f7af13079.tar.bz2
Fixed test
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/LinkingErrorTest.java23
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java26
2 files changed, 25 insertions, 24 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/LinkingErrorTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/LinkingErrorTest.java
index 6bc628e..0383113 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/LinkingErrorTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/LinkingErrorTest.java
@@ -12,7 +12,7 @@ import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.diagnostics.Diagnostic;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.tests.AbstractGeneratorTest;
@@ -23,13 +23,13 @@ import org.eclipse.xtext.tests.AbstractGeneratorTest;
public class LinkingErrorTest extends AbstractGeneratorTest {
private static final Logger logger = Logger.getLogger(CrossRefTest.class);
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
with(LangATestLanguageStandaloneSetup.class);
}
-
+
public void testNoErrors() throws Exception {
XtextResource resource = getResourceFromString(" type A extends B \n type B extends A");
EObject model = getModel(resource);
@@ -38,7 +38,7 @@ public class LinkingErrorTest extends AbstractGeneratorTest {
assertEquals(0, resource.getErrors().size());
assertEquals(0, resource.getWarnings().size());
}
-
+
public void testLinkError() throws Exception {
XtextResource resource = getResourceFromString(" type A extends B \n type B extends C");
EObject model = getModel(resource);
@@ -46,15 +46,14 @@ public class LinkingErrorTest extends AbstractGeneratorTest {
assertWithXtend("2", "types.size", model);
assertEquals(1, resource.getErrors().size());
assertEquals(0, resource.getWarnings().size());
-
+
Diagnostic error = (Diagnostic) resource.getErrors().get(0);
assertEquals(2, error.getLine());
- assertTrue(error instanceof Diagnostic);
- Diagnostic verboseError = (Diagnostic)error;
+ Diagnostic verboseError = error;
assertEquals(35, verboseError.getOffset());
assertEquals(1, verboseError.getLength());
}
-
+
private int getTreeIteratorContentSize(TreeIterator<Object> iterator) {
int result = 0;
while(iterator.hasNext()) {
@@ -64,22 +63,22 @@ public class LinkingErrorTest extends AbstractGeneratorTest {
}
return result;
}
-
+
private int getContentSize(EObject model) {
Resource resource = model.eResource();
assertNotNull(resource);
ResourceSet resourceSet = resource.getResourceSet();
assertNotNull(resourceSet);
- TreeIterator<Object> iterator = EcoreUtil2.getAllProperContents(resourceSet, true);
+ TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(resourceSet, true);
return getTreeIteratorContentSize(iterator);
}
-
+
public void testReparse() throws Exception {
String modelText = " type A extends B \n type B extends C";
XtextResource resource = getResourceFromString(modelText);
EObject model = getModel(resource);
logger.debug(invokeWithXtend("types.collect(e|e.name+'->'+e.extends.name).toString(',')", model));
-
+
assertWithXtend("2", "types.size", model);
assertEquals(4, getContentSize(model));
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
index 6d4f6f4..efb4b03 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
@@ -14,8 +14,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.crossref.IScope;
import org.eclipse.xtext.crossref.IScopeProvider;
-import org.eclipse.xtext.crossref.impl.DefaultScopeProvider;
import org.eclipse.xtext.crossref.impl.DefaultLinkingService;
+import org.eclipse.xtext.crossref.impl.DefaultScopeProvider;
import org.eclipse.xtext.crossref.internal.Linker;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.testlanguages.ReferenceGrammarTestLanguageStandaloneSetup;
@@ -27,7 +27,7 @@ import org.eclipse.xtext.tests.AbstractGeneratorTest;
public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeProvider {
private boolean doFakeScope;
-
+
private EObject context;
private EObject model;
@@ -40,17 +40,18 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
private EReference reference;
+ @Override
protected void setUp() throws Exception {
super.setUp();
with(ReferenceGrammarTestLanguageStandaloneSetup.class);
scopeProvider = new DefaultScopeProvider();
- modelAsText =
- "spielplatz 1 {\n" +
- " kind( Bommel1 1)\n" +
- " kind( Bommel2 2)\n" +
+ modelAsText =
+ "spielplatz 1 {\n" +
+ " kind( Bommel1 1)\n" +
+ " kind( Bommel2 2)\n" +
" kind( Bommel3 3)\n" +
- " erwachsener( Bob 4)\n" +
- " erwachsener( Joe 5)\n" +
+ " erwachsener( Bob 4)\n" +
+ " erwachsener( Joe 5)\n" +
" familie( Familienname Bob Joe Bommel2 )\n" +
"}";
resource = getResourceFromString(modelAsText);
@@ -65,7 +66,7 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
}
reference = (EReference) context.eClass().getEStructuralFeature("kinder");
}
-
+
/**
* We try to emulate a changed scope after a partial parsing so we mock the ScopeService.
*/
@@ -82,7 +83,7 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
EList<EObject> content = (EList<EObject>) context.eGet(reference);
assertEquals(1, content.size());
}
-
+
@SuppressWarnings("unchecked")
public void testPartialLinkingTwice() {
int idx = modelAsText.indexOf("Bommel2 2");
@@ -98,13 +99,13 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
assertTrue(resource.getErrors().isEmpty());
int idx = modelAsText.indexOf("Bommel2 2");
resource.update(idx + 1, 1, "o");
- doFakeScope = true;;
+ doFakeScope = true;
resource.update(idx + 1, 1, "o");
EList<EObject> content = (EList<EObject>) context.eGet(reference);
assertEquals(0, content.size());
assertEquals(1, resource.getErrors().size());
}
-
+
@SuppressWarnings("unchecked")
public void testLinking() {
EList<EObject> content = (EList<EObject>) context.eGet(reference);
@@ -115,6 +116,7 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
Linker linker = new Linker();
DefaultLinkingService linkingService = new DefaultLinkingService();
linkingService.setScopeProvider(this);
+ linkingService.setValueConverter(getValueConverterService());
linker.setLinkingService(linkingService);
resource.setLinker(linker);
}