Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-04-16 06:50:35 +0000
committerEike Stepper2010-04-16 06:50:35 +0000
commitddf0ed34964ceaf6bb52a6671dbeb8e50fd01d40 (patch)
tree1fe9d6edc8fc3ce5e61dc0ce627bb9638dbf43e0 /plugins
parentd997013583581556e4bbe725c4cfed7aa4c16ae5 (diff)
downloadcdo-ddf0ed34964ceaf6bb52a6671dbeb8e50fd01d40.tar.gz
cdo-ddf0ed34964ceaf6bb52a6671dbeb8e50fd01d40.tar.xz
cdo-ddf0ed34964ceaf6bb52a6671dbeb8e50fd01d40.zip
[256936] Support for Offline Mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256936
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FailoverTest.java117
2 files changed, 118 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
index 5e6ac51c24..14c15469e0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
@@ -32,8 +32,9 @@ public class AllTestsMEMOffline extends AllTestsAllConfigs
{
// super.initTestClasses(testClasses);
- testClasses.add(OfflineTest.class);
+ // testClasses.add(OfflineTest.class);
// testClasses.add(OfflineSqueezedTest.class);
+ testClasses.add(FailoverTest.class);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FailoverTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FailoverTest.java
index 617a915613..cebdb504a1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FailoverTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FailoverTest.java
@@ -12,14 +12,52 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+
/**
* @author Eike Stepper
*/
public class FailoverTest extends AbstractSyncingTest
{
+ private transient IAcceptor backupAcceptor;
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ stopBackupTransport();
+ }
+
+ protected void startBackupTransport()
+ {
+ if (backupAcceptor == null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("startBackupTransport()");
+ IOUtil.OUT().println();
+ IManagedContainer container = getServerContainer();
+ backupAcceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "jvm", "backup");
+ }
+ }
+
+ protected void stopBackupTransport()
+ {
+ if (backupAcceptor != null)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("stopBackupTransport()");
+ IOUtil.OUT().println();
+ backupAcceptor.close();
+ backupAcceptor = null;
+ }
+ }
+
@Override
protected boolean isSqueezedCommitInfos()
{
@@ -32,7 +70,7 @@ public class FailoverTest extends AbstractSyncingTest
return true;
}
- public void testMasterCommits_ArrivalInClone() throws Exception
+ public void testMasterCommits_ArrivalInBackup() throws Exception
{
CDOSession session = openSession(getRepository().getName() + "_master");
CDOTransaction transaction = session.openTransaction();
@@ -74,4 +112,81 @@ public class FailoverTest extends AbstractSyncingTest
session.close();
}
+
+ public void testMasterCommits_NotificationsFromBackup() throws Exception
+ {
+ CDOSession masterSession = openSession(getRepository().getName() + "_master");
+ CDOTransaction transaction = masterSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ TestListener listener = new TestListener();
+ CDOSession backupSession = openSession();
+ backupSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ long timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 1, 3, 1, 0);
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.setName("Test" + i);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().add(getModel1Factory().createCategory());
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 1, 1, 0);
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ company.getCategories().remove(0);
+ timeStamp = transaction.commit().getTimeStamp();
+ assertEquals(true, backupSession.waitForUpdate(timeStamp, DEFAULT_TIMEOUT));
+ checkEvent(listener, 0, 0, 1, 1);
+ }
+
+ backupSession.close();
+ masterSession.close();
+ }
+
+ public void testClientCommitsToBackupForbidden() throws Exception
+ {
+ InternalRepository backup = getRepository();
+ InternalRepository master = getRepository(backup.getName() + "_master");
+
+ TestListener listener = new TestListener();
+ CDOSession masterSession = openSession(master.getName());
+ masterSession.addListener(listener);
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ CDOSession backupSession = openSession();
+ waitForOnline(backupSession.getRepositoryInfo());
+
+ CDOTransaction transaction = backupSession.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(company);
+
+ try
+ {
+ transaction.commit();
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCESS
+ }
+ }
}

Back to the top