Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian W. Damus2013-09-25 10:24:15 -0400
committerChristian W. Damus2013-09-25 10:25:19 -0400
commitae18c252a2edd65f2d5883799e8e273cd5330e51 (patch)
treeccd882fbdfa82b712852aa660f10dae63bee4a72 /tests
parent8590852becaab9c4b24004e9fed686b0f4dfaefb (diff)
downloadorg.eclipse.papyrus-ae18c252a2edd65f2d5883799e8e273cd5330e51.tar.gz
org.eclipse.papyrus-ae18c252a2edd65f2d5883799e8e273cd5330e51.tar.xz
org.eclipse.papyrus-ae18c252a2edd65f2d5883799e8e273cd5330e51.zip
415373: [CDO] Ensure proper cleanup of repositories in tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415373 Fix test failures on "repository already exists" condition caused by the repository registry being saved when a repository is connected, to remember its UUID for the next Eclipse session. Also ensure that repositories have access (through the managed container) to the factory that created them, for this saving of the registry and other purposes.
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java3
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java11
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
index 01fd56634d4..73f3b43018a 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
@@ -109,6 +109,9 @@ public abstract class AbstractPapyrusCDOTest {
repository.disconnect();
PapyrusRepositoryManager.INSTANCE.removeRepository(repository);
repository = null;
+
+ // persist the removal (the new new repository saved its UUID when opened)
+ PapyrusRepositoryManager.INSTANCE.saveRepositories();
}
LifecycleUtil.deactivate(container);
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
index b940e0a1056..655f9fac00b 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
@@ -178,6 +178,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.NONE;
@@ -207,6 +208,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.SAVE;
@@ -237,6 +239,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+ @Override
public DisposeAction disposalRequested(IPapyrusRepository repository, Collection<ResourceSet> resourceSets) {
return DisposeAction.CLOSE;
@@ -270,13 +273,12 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
@Before
public void createRepositoryManager() throws Exception {
-
- fixture = new PapyrusRepositoryManager();
+ // make sure that any saves are ephemeral
+ fixture = new PapyrusRepositoryManager(new StringStorage());
}
@After
public void disposeRepositoryManager() throws Exception {
-
if(fixture != null) {
fixture.dispose();
fixture = null;
@@ -379,6 +381,7 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
return result;
}
+ @Override
public void notifyEvent(IEvent event) {
if(event instanceof CDOTransactionFinishedEvent) {
committed = true;
@@ -390,11 +393,13 @@ public class PapyrusRepositoryManagerTest extends AbstractPapyrusCDOTest {
String storage = null;
+ @Override
public InputStream createInputStream() throws IOException {
return (storage == null ? null : new ByteArrayInputStream(storage.getBytes("UTF-8")));
}
+ @Override
public OutputStream createOutputStream() throws IOException {
return new ByteArrayOutputStream() {

Back to the top