-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EMF driver: use adapters to keep cached allContents/allInstances up t…
…o date (fixes #508075)
- Loading branch information
1 parent
9bd80dd
commit 699896d
Showing
5 changed files
with
153 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...pse.epsilon.emc.emf.test/src/org/eclipse/epsilon/emc/emf/EmfModelCachedContentsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.eclipse.epsilon.emc.emf; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.eclipse.emf.ecore.EClass; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.EcorePackage; | ||
import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException; | ||
import org.junit.Test; | ||
|
||
public class EmfModelCachedContentsTests { | ||
|
||
protected EmfModel createEmptyModel() throws EolModelLoadingException { | ||
final EmfModel model = new EmfModel(); | ||
model.setModelFile("dummy.xmi"); | ||
model.setMetamodelUri(EcorePackage.eINSTANCE.getNsURI()); | ||
model.setReadOnLoad(false); | ||
model.setStoredOnDisposal(false); | ||
model.load(); | ||
return model; | ||
} | ||
|
||
@Test | ||
public void emptyModel() throws Exception { | ||
final EmfModel model = createEmptyModel(); | ||
assertEquals(0, model.allContents().size()); | ||
} | ||
|
||
@Test | ||
public void manageThroughModel() throws Exception { | ||
final EmfModel model = createEmptyModel(); | ||
assertEquals(0, model.allContents().size()); | ||
final EObject eClass = model.createInstance("EClass"); | ||
assertEquals(1, model.allContents().size()); | ||
model.deleteElement(eClass); | ||
assertEquals(0, model.allContents().size()); | ||
} | ||
|
||
@Test | ||
public void manageExternally() throws Exception { | ||
final EmfModel model = createEmptyModel(); | ||
assertEquals(0, model.allContents().size()); | ||
|
||
final EClass eClass = EcorePackage.eINSTANCE.getEcoreFactory().createEClass(); | ||
model.getResource().getContents().add(eClass); | ||
assertEquals(1, model.allContents().size()); | ||
|
||
model.getResource().getContents().remove(eClass); | ||
assertEquals(0, model.allContents().size()); | ||
} | ||
|
||
} |