use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class OnChangeEvictingCacheAdapterTest method testCacheSurvivesChangesToAdapters.
@Test
public void testCacheSurvivesChangesToAdapters() throws Exception {
EcoreFactory factory = EcoreFactory.eINSTANCE;
EClass eClass = factory.createEClass();
Resource resource = new ResourceImpl();
resource.getContents().add(eClass);
CacheAdapter ca = new OnChangeEvictingCache().getOrCreate(resource);
setValue(ca);
List<Adapter> adapters = resource.eAdapters();
assertIsSet(ca);
AdapterImpl adapter = new AdapterImpl();
adapters.add(adapter);
assertIsSet(ca);
adapters.remove(adapter);
assertIsSet(ca);
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class LazyLinkerTest method testManyValuedResolveProxiesReference.
@Test
public void testManyValuedResolveProxiesReference() throws Exception {
final EObject foo = newEObject("Foo");
final List<EObject> bars = Lists.newArrayList(newEObject("Bar"), newEObject("Bar"));
final Iterator<EObject> barsIterator = bars.iterator();
final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {
@Override
public EObject getEObject(String uriFragment) {
return barsIterator.next();
}
};
resourceSet.getResources().add(resource);
resource.getContents().add(foo);
final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("many");
assertFalse(eReference.isResolveProxies());
final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
final INode leafNode2 = newCrossReferenceAssignmentNode(eReference.getName());
final ICompositeNode adapter = newSimpleNodeAdapter(leafNode, leafNode2);
foo.eAdapters().add((Adapter) adapter);
linker.linkModel(foo, new ListBasedDiagnosticConsumer());
assertEquals(bars, foo.eGet(eReference, false));
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class LazyLinkerTest method testSingleValuedResolveProxiesReference.
@Test
public void testSingleValuedResolveProxiesReference() throws Exception {
final EObject foo = newEObject("Foo");
final EObject bar = newEObject("Bar");
final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {
@Override
public EObject getEObject(String uriFragment) {
return bar;
}
};
resourceSet.getResources().add(resource);
resource.getContents().add(foo);
final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("single");
assertFalse(eReference.isResolveProxies());
final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
final ICompositeNode adapter = newSimpleNodeAdapter(leafNode);
foo.eAdapters().add((Adapter) adapter);
linker.linkModel(foo, new ListBasedDiagnosticConsumer());
assertEquals(bar, foo.eGet(eReference, false));
}
Aggregations