@@ -0,0 +1,2163 @@
+/*******************************************************************************%0A * Copyright (c) 2012 itemis AG (http://www.itemis.eu) and others.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *******************************************************************************/%0Apackage org.eclipse.xtext.generator.grammarAccess;%0A%0Aimport org.eclipse.emf.common.util.URI;%0Aimport org.eclipse.emf.ecore.EPackage;%0Aimport org.eclipse.emf.ecore.resource.Resource;%0Aimport org.eclipse.emf.ecore.util.EcoreUtil;%0Aimport org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;%0Aimport org.eclipse.xtext.Grammar;%0Aimport org.eclipse.xtext.XtextStandaloneSetup;%0Aimport org.eclipse.xtext.junit4.AbstractXtextTests;%0Aimport org.eclipse.xtext.resource.XtextResourceSet;%0Aimport org.junit.Test;%0A%0A/**%0A * @author Jan Koehnlein - Initial contribution and API%0A */%0Apublic class Bug378261Test extends AbstractXtextTests %7B%0A%0A%09@Override%0A%09public void setUp() throws Exception %7B%0A%09%09super.setUp();%0A%09%09with(XtextStandaloneSetup.class);%0A%09%7D%0A%09%0A%09private GrammarAccessFragment fragment = new GrammarAccessFragment(); %0A%09%0A%09@Test public void testReplaceResourceURIs() %7B%0A%09%09XtextResourceSet xtextResourceSet = get(XtextResourceSet.class);%0A%09%09xtextResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(%22ecore%22, new EcoreResourceFactoryImpl());%0A%09%09xtextResourceSet.setClasspathURIContext(this);%0A%09%09Resource grammarResource = xtextResourceSet.getResource(URI.createURI(%22classpath:/org/eclipse/xtext/generator/grammarAccess/GrammarAccessTestLanguage.xtext%22), true);%0A%09%09EcoreUtil.resolveAll(grammarResource);%0A%09%09Grammar grammar = (Grammar) grammarResource.getContents().get(0);%0A%09%09EPackage ePackage = grammar.getMetamodelDeclarations().get(0).getEPackage();%0A%09%09assertFalse(ePackage.eResource().getURI().equals(URI.createURI(ePackage.getNsURI())));%0A%09%09fragment.replaceResourceURIsWithNsURIs(grammar, xtextResourceSet);%0A%09%09assertEquals(ePackage.eResource().getURI(), URI.createURI(ePackage.getNsURI()));%0A%09%7D%0A%7D%0A

Test for URI conversion in XMI grammar https://bugs.eclipse.org/bugs/show_bug.cgi?id=378261