use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ClassloaderClasspathUriResolverTest method normalizeUriAndLoadResource.
private void normalizeUriAndLoadResource(URI classpathUri, String expectedUri) {
URI normalizedUri = _resolver.resolve(getClass().getClassLoader(), classpathUri);
assertEquals(expectedUri, normalizedUri.toString());
ResourceSet resourceSet = new ResourceSetImpl();
System.out.println(normalizedUri);
Resource resource = resourceSet.getResource(normalizedUri, true);
assertNotNull("Classpth URI ot registered", resource);
assertTrue("Resource not loaded", resource.isLoaded());
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ConcurrentAccessTest method testMultiThreadedUnitOfWork.
@Ignore
@Test
public void testMultiThreadedUnitOfWork() throws InterruptedException {
ResourceSet resourceSet = new XtextResourceSet();
resourceSet.getResources().add(resource);
boolean wasOk = resolveAllReferencesStateAccess((EPackage) resource.getContents().get(0));
if (wasOk)
assertFalse(101 == resourceSet.getResources().size());
assertFalse("unresolvedProxy", wasOk);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ConcurrentAccessTest method setUp.
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
ResourceSet resourceSet = new ResourceSetImpl();
resource = new XtextResource(URI.createFileURI("something.ecore"));
resourceSet.getResources().add(resource);
EPackage start = EcoreFactory.eINSTANCE.createEPackage();
resource.getContents().add(start);
for (int i = 0; i < 100; i++) {
File tempFile = temporaryFolder.createTempFile("Package" + i, ".ecore");
URI fileURI = URI.createFileURI(tempFile.getAbsolutePath());
Resource toBeProxified = resourceSet.createResource(fileURI);
EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
ePackage.setNsURI("http://www.test.me/" + i);
toBeProxified.getContents().add(ePackage);
for (int j = 0; j < 100; j++) {
EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
annotation.setSource("Source" + j);
start.getEAnnotations().add(annotation);
EClass superClass = EcoreFactory.eINSTANCE.createEClass();
superClass.setName("SuperClass" + j);
ePackage.getEClassifiers().add(superClass);
annotation.getReferences().add(superClass);
}
toBeProxified.save(null);
}
EcoreUtil.resolveAll(resourceSet);
for (int i = 100; i >= 1; i--) {
Resource toBeProxified = resourceSet.getResources().get(i);
toBeProxified.unload();
resourceSet.getResources().remove(toBeProxified);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class AbstractLiveContainerTest method testGlobalScope.
@Test
public void testGlobalScope() throws Exception {
EReference ref = createRefToRoot();
ResourceSet resourceSet = new XtextResourceSet();
Resource res = parse("local", resourceSet).eResource();
parse("other", resourceSet);
assertEquals("other", format(scopeProvider.getScope(res, ref).getAllElements()));
Resource foo = parse("foo", resourceSet).eResource();
assertEquals("foo, other", format(scopeProvider.getScope(res, ref).getAllElements()));
resourceSet.getResources().remove(foo);
assertEquals("other", format(scopeProvider.getScope(res, ref).getAllElements()));
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class AbstractLiveContainerTest method testContainerLoadUnload.
@Test
public void testContainerLoadUnload() throws Exception {
ResourceSet resourceSet = new XtextResourceSet();
Resource res = parse("local", resourceSet).eResource();
Resource foo = resourceSet.createResource(computeUnusedUri(resourceSet));
IResourceDescription resourceDescription = descriptionManager.getResourceDescription(res);
IResourceDescriptions resourceDescriptions = descriptionsProvider.getResourceDescriptions(res);
List<IContainer> containers = containerManager.getVisibleContainers(resourceDescription, resourceDescriptions);
assertEquals(1, containers.size());
IContainer container = containers.get(0);
// assertEquals("local", format(container.getExportedObjects()));
foo.load(new StringInputStream("foo"), null);
assertEquals("foo, local", format(container.getExportedObjects()));
// foo.unload();
// assertEquals("local", format(container.getExportedObjects()));
}
Aggregations