summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-08-04 02:42:27 (EDT)
committerEd Merks2011-08-04 02:42:27 (EDT)
commitbd2877894dc7763e19ec05596bdb6295033b3d5b (patch)
tree3599b612acdcd99b572774d663d9a983dc6ec867
parent6ec4b41a9c19c8d22ca05a73e8235ee0f469188e (diff)
downloadorg.eclipse.emf-bd2877894dc7763e19ec05596bdb6295033b3d5b.zip
org.eclipse.emf-bd2877894dc7763e19ec05596bdb6295033b3d5b.tar.gz
org.eclipse.emf-bd2877894dc7763e19ec05596bdb6295033b3d5b.tar.bz2
added testing of isFullyInitialized flag
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/scoping/LazyGenmodelInferenceTest.java49
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/XcoreResource.java2
2 files changed, 29 insertions, 22 deletions
diff --git a/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/scoping/LazyGenmodelInferenceTest.java b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/scoping/LazyGenmodelInferenceTest.java
index 3f593ee..9529883 100644
--- a/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/scoping/LazyGenmodelInferenceTest.java
+++ b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/scoping/LazyGenmodelInferenceTest.java
@@ -40,11 +40,11 @@ public class LazyGenmodelInferenceTest {
@Inject
private Provider<XtextResourceSet> resourceSetProvider;
-
+
public static class MyXcoreInjectorProvider extends XcoreInjectorProvider {
-
+
private Injector injector;
-
+
@Override
public Injector getInjector() {
if (injector == null) {
@@ -61,7 +61,7 @@ public class LazyGenmodelInferenceTest {
}
return injector;
}
-
+
@Override
public void setupRegistry() {
super.setupRegistry();
@@ -70,52 +70,58 @@ public class LazyGenmodelInferenceTest {
}
}
}
-
+
public static class InspectableXcoreResource extends XcoreResource {
-
+
public EList<EObject> getContentsUnsafe() {
return contents;
}
+ public boolean isFullyInitialized() {
+ return fullyInitialized;
+ }
+
}
-
+
@Test
public void testSetup() {
XtextResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
assertTrue(resource.toString(), resource instanceof InspectableXcoreResource);
- assertNull(((InspectableXcoreResource)resource).getContentsUnsafe());
+ assertNull(((InspectableXcoreResource) resource).getContentsUnsafe());
+ assertFalse(((InspectableXcoreResource) resource).isFullyInitialized());
}
-
+
@Test
public void testContentsWithoutDerived() throws IOException {
XtextResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
- assertEquals(1, ((InspectableXcoreResource)resource).getContentsUnsafe().size());
+ assertEquals(1, ((InspectableXcoreResource) resource).getContentsUnsafe().size());
+ assertFalse(((InspectableXcoreResource) resource).isFullyInitialized());
}
-
+
@Test
public void testContentsWithDerived() throws IOException {
XtextResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
assertTrue(1 < resource.getContents().size());
+ assertTrue(((InspectableXcoreResource) resource).isFullyInitialized());
}
-
+
public void testResourceDescriptionManagerDoesNotResolve() throws IOException {
XtextResourceSet resourceSet = resourceSetProvider.get();
InspectableXcoreResource resource = (InspectableXcoreResource) resourceSet.createResource(URI.createURI("foo.xcore"));
resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
Manager manager = resource.getResourceServiceProvider().getResourceDescriptionManager();
IResourceDescription resourceDescription = manager.getResourceDescription(resource);
-
- Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS)
- .iterator();
- Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(
- GenModelPackage.Literals.GEN_CLASS).iterator();
- Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(
- TypesPackage.Literals.JVM_GENERIC_TYPE).iterator();
+
+ Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator();
+ Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(GenModelPackage.Literals.GEN_CLASS)
+ .iterator();
+ Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(TypesPackage.Literals.JVM_GENERIC_TYPE)
+ .iterator();
final String expected = "foo.bar.Baz";
assertEquals(expected, eclass.next().getName().toString());
assertFalse(eclass.hasNext());
@@ -124,8 +130,9 @@ public class LazyGenmodelInferenceTest {
assertEquals(expected, jvmTypes.next().getName().toString());
assertEquals(expected + "Impl", jvmTypes.next().getName().toString());
assertFalse(genclass.hasNext());
-
+
assertEquals(1, resource.getContentsUnsafe().size());
+ assertFalse(((InspectableXcoreResource) resource).isFullyInitialized());
}
-
+
}
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/XcoreResource.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/XcoreResource.java
index 9b2bc5e..b256a41 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/XcoreResource.java
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/XcoreResource.java
@@ -32,7 +32,7 @@ public class XcoreResource extends XbaseResource {
@Inject
private IQualifiedNameProvider nameProvider;
- private boolean fullyInitialized = false;
+ protected boolean fullyInitialized = false;
@Override
public EList<EObject> getContents() {