Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 250268 Details for
Bug 458151
Unstability on resource reload
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
JUnit test corresponding to comment 3
EMFUnloadWithStrangeProxyURITests.java (text/x-java), 4.82 KB, created by
Laurent Redor
on 2015-01-27 09:34:06 EST
(
hide
)
Description:
JUnit test corresponding to comment 3
Filename:
MIME Type:
Creator:
Laurent Redor
Created:
2015-01-27 09:34:06 EST
Size:
4.82 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2015 THALES GLOBAL SERVICES. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * Obeo - initial API and implementation > *******************************************************************************/ >package org.eclipse.sirius.tests.unit.common; > >import java.io.File; >import java.io.IOException; > >import junit.framework.TestCase; > >import org.eclipse.emf.common.util.URI; >import org.eclipse.emf.ecore.EClass; >import org.eclipse.emf.ecore.EPackage; >import org.eclipse.emf.ecore.EcoreFactory; >import org.eclipse.emf.ecore.resource.Resource; >import org.eclipse.emf.ecore.resource.ResourceSet; >import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >import org.eclipse.emf.ecore.util.EcoreUtil; >import org.eclipse.emf.edit.command.AddCommand; >import org.eclipse.emf.edit.command.RemoveCommand; >import org.eclipse.emf.transaction.RecordingCommand; >import org.eclipse.emf.transaction.TransactionalEditingDomain; >import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.FactoryImpl; > >/** > * Class containing some tests to reveal the "problem" with URI after a unload > * of fragmented resource. > * > * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> > */ >public class EMFUnloadWithStrangeProxyURITests extends TestCase { > > private TransactionalEditingDomain editingDomain; > > public void testURIAfterUnloadWithoutFragment() { > System.out.println("EMFUnloadWithStrangeProxyURITests.testURIAfterUnloadWithoutFragment()"); > init(false); > > } > > public void testURIAfterUnloadWithFragment() { > System.out.println("EMFUnloadWithStrangeProxyURITests.testURIAfterUnloadWithFragment()"); > init(true); > } > > protected Resource init(boolean control) { > /* create a resource set . */ > ResourceSet rset = new ResourceSetImpl(); > /* create an editing domain */ > editingDomain = FactoryImpl.INSTANCE.createEditingDomain(rset); > > /* Initialize the model B */ > final EPackage ePackageB = EcoreFactory.eINSTANCE.createEPackage(); > ePackageB.setName("RootB"); > final EPackage ePackageB1 = EcoreFactory.eINSTANCE.createEPackage(); > ePackageB1.setName("b1"); > ePackageB.getESubpackages().add(ePackageB1); > final EPackage ePackageB2 = EcoreFactory.eINSTANCE.createEPackage(); > ePackageB2.setName("b2"); > ePackageB1.getESubpackages().add(ePackageB2); > final EClass eClassB = EcoreFactory.eINSTANCE.createEClass(); > eClassB.setName("ClassB"); > ePackageB2.getEClassifiers().add(eClassB); > > /* create resource and and add it initialized model */ > final URI fileBUri = URI.createFileURI(new File("B.ecore").getAbsolutePath()); > final Resource rsB = rset.createResource(fileBUri); > editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { > > @Override > protected void doExecute() { > rsB.getContents().add(ePackageB); > } > > }); > try { > rsB.save(null); > } catch (IOException e) { > e.printStackTrace(); > } > > Resource rsB1 = null; > if (control) { > // Control ePackageB1 > final URI fileB1Uri = URI.createFileURI(new File("B1.ecore").getAbsolutePath()); > rsB1 = rset.createResource(fileB1Uri); > EcoreUtil.resolveAll(rset); > editingDomain.getCommandStack().execute(new RemoveCommand(editingDomain, rsB.getContents(), ePackageB1)); > editingDomain.getCommandStack().execute(new AddCommand(editingDomain, rsB1.getContents(), ePackageB1)); > try { > rsB.save(null); > rsB1.save(null); > } catch (IOException e) { > e.printStackTrace(); > } > } > > Resource resourceToUnloadAndReload = rsB; > if (control) { > resourceToUnloadAndReload = rsB1; > } > // Unload and reload the resource B > try { > URI beforeUnload = EcoreUtil.getURI(eClassB); > System.out.println("URI before the unload: " + beforeUnload); > resourceToUnloadAndReload.unload(); > URI afterUnload = EcoreUtil.getURI(eClassB); > System.out.println("URI after the unload : " + afterUnload); > assertEquals("URI should be the same before unload and after unload of the resource.", beforeUnload, afterUnload); > resourceToUnloadAndReload.load(null); > } catch (IOException e) { > fail("Unload/reload of resource B.ecore failed: " + e.getMessage()); > } > return null; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 458151
:
250148
|
250189
|
250265
| 250268