aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-02 11:32:11 (EDT)
committersefftinge2009-04-02 11:32:11 (EDT)
commitdccb28c3727ab15ef107083d305a1ad86ad8f8a9 (patch)
tree55cb74f4ff8171912752c741114c82d4d9d6479c
parent23671920a67378cf15b1a12a461c681f0e37519f (diff)
downloadorg.eclipse.xtext-dccb28c3727ab15ef107083d305a1ad86ad8f8a9.zip
org.eclipse.xtext-dccb28c3727ab15ef107083d305a1ad86ad8f8a9.tar.gz
org.eclipse.xtext-dccb28c3727ab15ef107083d305a1ad86ad8f8a9.tar.bz2
Extracted some common functionality of LazyLinker and Linker
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/BasicLazyLinkingTest.java34
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/URIFragmentEncoderTest.java18
2 files changed, 29 insertions, 23 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/BasicLazyLinkingTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/BasicLazyLinkingTest.java
index d42c379..844406b 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/BasicLazyLinkingTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/BasicLazyLinkingTest.java
@@ -21,11 +21,19 @@ import org.eclipse.xtext.util.StringInputStream;
*
*/
public class BasicLazyLinkingTest extends AbstractXtextTests {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ with(new LazyLinkingTestLanguageStandaloneSetup());
+ }
public void testLazyLinking() throws Exception {
- with(new LazyLinkingTestLanguageStandaloneSetup());
XtextResource resource = getResource(new StringInputStream("type A extends B.id{} type B { A id}"));
-
+ doTest(resource);
+ }
+
+ private void doTest(XtextResource resource) {
assertTrue(resource instanceof LazyLinkingResource);
Model model = (Model) resource.getContents().get(0);
@@ -35,32 +43,16 @@ public class BasicLazyLinkingTest extends AbstractXtextTests {
Property parentId = typeA.getParentId();
assertEquals(typeB.getProperties().get(0),parentId);
}
-
+
public void testRecursion() throws Exception {
- with(new LazyLinkingTestLanguageStandaloneSetup());
XtextResource resource = getResource(new StringInputStream("type A extends B.a { B b } type B extends A.b { A a}"));
- assertTrue(resource instanceof LazyLinkingResource);
-
- Model model = (Model) resource.getContents().get(0);
- Type typeA = model.getTypes().get(0);
- Type typeB = model.getTypes().get(1);
-
- Property parentId = typeA.getParentId();
- assertEquals(typeB.getProperties().get(0),parentId);
+ doTest(resource);
}
public void testBackwardDependency() throws Exception {
- with(new LazyLinkingTestLanguageStandaloneSetup());
XtextResource resource = getResource(new StringInputStream("type A for a in B { B b } type B for b in A { A a}"));
- assertTrue(resource instanceof LazyLinkingResource);
-
- Model model = (Model) resource.getContents().get(0);
- Type typeA = model.getTypes().get(0);
- Type typeB = model.getTypes().get(1);
-
- Property parentId = typeA.getParentId();
- assertEquals(typeB.getProperties().get(0),parentId);
+ doTest(resource);
}
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/URIFragmentEncoderTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/URIFragmentEncoderTest.java
index c4bd144..de16e0c 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/URIFragmentEncoderTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/lazy/URIFragmentEncoderTest.java
@@ -42,10 +42,24 @@ public class URIFragmentEncoderTest extends TestCase {
}
- URIFragmentEncoder encoder = new URIFragmentEncoder();
+ private URIFragmentEncoder encoder;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ encoder = new URIFragmentEncoder();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ encoder = null;
+ super.tearDown();
+ }
private AbstractNode find(AbstractNode parent, AbstractNode toFind) {
- String string = encoder.getRelativePath(parent, toFind).toString();
+ StringBuilder builder = new StringBuilder();
+ encoder.getRelativePath(builder, parent, toFind);
+ String string = builder.toString();
return encoder.getNode(parent, string);
}
}