Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-10-07 07:25:57 +0000
committerEike Stepper2012-10-07 07:25:57 +0000
commitf79754573c9fa8fdcb95915b4da730d0f1a0c34f (patch)
tree905fdc5088bc01640831ca0fb76aeccc8c97041b
parent7ef3f185332e130484ddb032f68235e4fa5891cb (diff)
downloadcdo-f79754573c9fa8fdcb95915b4da730d0f1a0c34f.tar.gz
cdo-f79754573c9fa8fdcb95915b4da730d0f1a0c34f.tar.xz
cdo-f79754573c9fa8fdcb95915b4da730d0f1a0c34f.zip
[391309] RepositorySynchronizer silently fails to cast a TimerTask to
Comparable https://bugs.eclipse.org/bugs/show_bug.cgi?id=391309
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java143
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 offline).launch2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysqlOffline.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_312879_Test.java416
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376470_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376566_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376567_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockRawReplicationTest.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java257
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java224
17 files changed, 501 insertions, 630 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
index f676ba76c5..3b66158e2d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
@@ -31,7 +31,8 @@ import org.eclipse.emf.cdo.spi.server.InternalRepositorySynchronizer;
import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.concurrent.QueueRunner;
+import org.eclipse.net4j.util.concurrent.PriorityQueueRunnable;
+import org.eclipse.net4j.util.concurrent.PriorityQueueRunner;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
@@ -46,14 +47,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.PriorityBlockingQueue;
/**
* @author Eike Stepper
* @since 3.0
*/
-public class RepositorySynchronizer extends QueueRunner implements InternalRepositorySynchronizer
+public class RepositorySynchronizer extends PriorityQueueRunner implements InternalRepositorySynchronizer
{
public static final int DEFAULT_RETRY_INTERVAL = 3;
@@ -177,12 +176,6 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
}
@Override
- protected BlockingQueue<Runnable> createQueue()
- {
- return new PriorityBlockingQueue<Runnable>();
- }
-
- @Override
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
@@ -330,20 +323,7 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
/**
* @author Eike Stepper
*/
- private static abstract class QueueRunnable implements Runnable, Comparable<QueueRunnable>
- {
- public int compareTo(QueueRunnable o)
- {
- return getPriority().compareTo(o.getPriority());
- }
-
- protected abstract Integer getPriority();
- }
-
- /**
- * @author Eike Stepper
- */
- private final class ConnectRunnable extends QueueRunnable
+ private final class ConnectRunnable extends PriorityQueueRunnable
{
public ConnectRunnable()
{
@@ -423,7 +403,7 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
/**
* @author Eike Stepper
*/
- private final class ReplicateRunnable extends QueueRunnable
+ private final class ReplicateRunnable extends PriorityQueueRunnable
{
public ReplicateRunnable()
{
@@ -478,7 +458,7 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
/**
* @author Eike Stepper
*/
- private final class BranchRunnable extends QueueRunnable
+ private final class BranchRunnable extends PriorityQueueRunnable
{
private CDOBranch branch;
@@ -500,7 +480,7 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
}
@Override
- public int compareTo(QueueRunnable o)
+ public int compareTo(PriorityQueueRunnable o)
{
int result = super.compareTo(o);
if (result == 0)
@@ -518,58 +498,16 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
}
}
- private final class CommitRunnable extends RetryingRunnable
- {
- private CDOCommitInfo commitInfo;
-
- public CommitRunnable(CDOCommitInfo commitInfo)
- {
- this.commitInfo = commitInfo;
- }
-
- @Override
- protected void doRun()
- {
- localRepository.handleCommitInfo(commitInfo);
- }
-
- @Override
- public int compareTo(QueueRunnable o)
- {
- int result = super.compareTo(o);
- if (result == 0)
- {
- Long timeStamp = commitInfo.getTimeStamp();
- Long timeStamp2 = ((CommitRunnable)o).commitInfo.getTimeStamp();
- result = timeStamp < timeStamp2 ? -1 : timeStamp == timeStamp2 ? 0 : 1;
- }
-
- return result;
- }
-
- @Override
- protected Integer getPriority()
- {
- return COMMIT_PRIORITY;
- }
-
- @Override
- protected String getErrorMessage()
- {
- return "Replication of master commit failed:" + commitInfo;
- }
- }
-
/**
* @author Eike Stepper
*/
- private abstract class RetryingRunnable extends QueueRunnable
+ private abstract class RetryingRunnable extends PriorityQueueRunnable
{
private List<Exception> failedRuns;
- protected abstract void doRun();
-
- protected abstract String getErrorMessage();
+ public RetryingRunnable()
+ {
+ }
public void run()
{
@@ -590,12 +528,13 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
{
if (TRACER.isEnabled())
{
- TRACER.format("Replication of master commit failed. Trying again in {0} seconds...", recommitInterval); //$NON-NLS-1$
+ String simpleName = RetryingRunnable.this.getClass().getSimpleName();
+ TRACER.format(simpleName + " failed. Trying again in {0} seconds...", recommitInterval); //$NON-NLS-1$
}
if (recommitTimer == null)
{
- recommitTimer = new Timer("RecommitTimer-" + RepositorySynchronizer.this);
+ recommitTimer = new Timer("RetryTimer-" + RepositorySynchronizer.this);
}
recommitTimer.schedule(new TimerTask()
@@ -605,11 +544,12 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
{
try
{
- addWork(this);
+ addWork(RetryingRunnable.this);
}
catch (Exception ex)
{
- OM.LOG.error("CommitRunnableTask failed", ex);
+ String simpleName = RetryingRunnable.this.getClass().getSimpleName();
+ OM.LOG.error(simpleName + " failed. Exiting.", ex);
fireThrowable(ex);
}
}
@@ -621,6 +561,55 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
}
}
}
+
+ protected abstract void doRun();
+
+ protected abstract String getErrorMessage();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class CommitRunnable extends RetryingRunnable
+ {
+ private CDOCommitInfo commitInfo;
+
+ public CommitRunnable(CDOCommitInfo commitInfo)
+ {
+ this.commitInfo = commitInfo;
+ }
+
+ @Override
+ protected void doRun()
+ {
+ localRepository.handleCommitInfo(commitInfo);
+ }
+
+ @Override
+ public int compareTo(PriorityQueueRunnable o)
+ {
+ int result = super.compareTo(o);
+ if (result == 0)
+ {
+ Long timeStamp = commitInfo.getTimeStamp();
+ Long timeStamp2 = ((CommitRunnable)o).commitInfo.getTimeStamp();
+ result = timeStamp < timeStamp2 ? -1 : timeStamp == timeStamp2 ? 0 : 1;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected Integer getPriority()
+ {
+ return COMMIT_PRIORITY;
+ }
+
+ @Override
+ protected String getErrorMessage()
+ {
+ return "Replication of master commit failed:" + commitInfo;
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 offline).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 offline).launch
index 9c25d0d342..9f3cd977ab 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 offline).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 offline).launch
@@ -21,5 +21,5 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Offline"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.enableServerBrowser=true"/>
</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index fc06affe14..2f4db98371 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -23,10 +23,8 @@ import org.eclipse.emf.cdo.tests.offline.Bugzilla_376566_Test;
import org.eclipse.emf.cdo.tests.offline.Bugzilla_376567_Test;
import org.eclipse.emf.cdo.tests.offline.FailoverTest;
import org.eclipse.emf.cdo.tests.offline.OfflineDelayedTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockRawReplicationTest;
import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
import org.eclipse.emf.cdo.tests.offline.OfflineTest;
import java.util.List;
@@ -57,11 +55,9 @@ public class AllTestsDBH2Offline extends DBConfigs
{
testClasses.add(FailoverTest.class);
testClasses.add(OfflineTest.class);
- testClasses.add(OfflineRawTest.class);
testClasses.add(OfflineDelayedTest.class);
testClasses.add(OfflineLockingTest.class);
testClasses.add(OfflineLockReplicationTest.class);
- testClasses.add(OfflineLockRawReplicationTest.class);
testClasses.add(Bugzilla_329014_Test.class);
testClasses.add(Bugzilla_328352_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysqlOffline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysqlOffline.java
index 117a24b28e..ea22e3b630 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysqlOffline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysqlOffline.java
@@ -23,10 +23,8 @@ import org.eclipse.emf.cdo.tests.offline.Bugzilla_376566_Test;
import org.eclipse.emf.cdo.tests.offline.Bugzilla_376567_Test;
import org.eclipse.emf.cdo.tests.offline.FailoverTest;
import org.eclipse.emf.cdo.tests.offline.OfflineDelayedTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineLockRawReplicationTest;
import org.eclipse.emf.cdo.tests.offline.OfflineLockReplicationTest;
import org.eclipse.emf.cdo.tests.offline.OfflineLockingTest;
-import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
import org.eclipse.emf.cdo.tests.offline.OfflineTest;
import java.util.List;
@@ -57,11 +55,9 @@ public class AllTestsDBMysqlOffline extends DBConfigs
{
testClasses.add(FailoverTest.class);
testClasses.add(OfflineTest.class);
- testClasses.add(OfflineRawTest.class);
testClasses.add(OfflineDelayedTest.class);
testClasses.add(OfflineLockingTest.class);
testClasses.add(OfflineLockReplicationTest.class);
- testClasses.add(OfflineLockRawReplicationTest.class);
testClasses.add(Bugzilla_329014_Test.class);
testClasses.add(Bugzilla_328352_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
index ab8b9ed518..e9cf28b036 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
@@ -88,7 +88,7 @@ public abstract class AbstractSyncingTest extends AbstractCDOTest
protected boolean isRawReplication()
{
- return false;
+ return true;
}
protected long getTestDelayedCommitHandling()
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_312879_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_312879_Test.java
index 097b81d33d..285c66c674 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_312879_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_312879_Test.java
@@ -1,211 +1,205 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Martin Fl�gge - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
-import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
-import org.eclipse.emf.cdo.tests.model1.Category;
-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 Martin Fl�gge
- */
-public class Bugzilla_312879_Test extends AbstractSyncingTest
-{
- private 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 isFailover()
- {
- return true;
- }
-
- public void testSwitchMasterAndCommit() throws Exception
- {
-
- InternalSynchronizableRepository repo1_master = (InternalSynchronizableRepository)getRepository("master");
- InternalSynchronizableRepository repo1 = getRepository();
-
- InternalSynchronizableRepository master = repo1_master;
- InternalSynchronizableRepository backup = repo1;
-
- CDOSession session = openSession(master.getName());
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("Test");
-
- resource.getContents().add(company);
- transaction.setCommitComment("Company created");
- transaction.commit();
-
- int categoryCount = 10;
- for (int i = 0; i < categoryCount; i++)
- {
- Category category = getModel1Factory().createCategory();
- category.setName("cat" + i);
- company.getCategories().add(category);
- transaction.setCommitComment("Category added " + i);
- transaction.commit();
- }
- sleep(1000);
-
- checkData(company, categoryCount, "cat", "Test");
-
- startBackupTransport();
- repo1.setType(CDOCommonRepository.Type.MASTER);
- repo1_master.setType(CDOCommonRepository.Type.BACKUP);
-
- master = repo1;
- backup = repo1_master;
-
- assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
- assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
-
- // make sure the backup repository is in sync
- waitForOnline(backup);
-
- session.close();
- session = openSession(master.getName());
-
- // make sure we are running the session on the master
- assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
- transaction = session.openTransaction();
-
- resource = transaction.getResource(getResourcePath("/my/resource"));
- company = (Company)resource.getContents().get(0);
-
- checkData(company, categoryCount, "cat", "Test");
-
- int i = 0;
- for (i = 0; i < 10; i++)
- {
- company.setName("AfterFailover-" + i);
- transaction.setCommitComment("Name changed after failover");
- transaction.commit();
- }
-
- int c = 0;
- for (Category category : company.getCategories())
- {
- category.setName("CHANGED" + c++);
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(0, commitInfo.getBranch().getID());
- }
-
- checkData(company, categoryCount, "CHANGED", "AfterFailover-" + (i - 1));
-
- // Switch Master back to master -----------------------------------------
- assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
- stopBackupTransport();
- repo1_master.setType(CDOCommonRepository.Type.MASTER);
- repo1.setType(CDOCommonRepository.Type.BACKUP);
-
- master = repo1_master;
- backup = repo1;
-
- assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
- assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
-
- waitForOnline(backup);
-
- session.close();
-
- session = openSession(master.getName());
- assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
- transaction = session.openTransaction();
-
- resource = transaction.getResource(getResourcePath("/my/resource"));
- company = (Company)resource.getContents().get(0);
-
- checkData(company, categoryCount, "CHANGED", "AfterFailover-" + (i - 1));
-
- for (i = 0; i < 10; i++)
- {
- company.setName("AfterSwitchbackToMaster-" + i);
- transaction.setCommitComment("Name changed after fallback to master");
- transaction.commit();
- }
-
- c = 0;
- for (Category category : company.getCategories())
- {
- category.setName("LASTCHANGE" + c++);
- CDOCommitInfo commitInfo = transaction.commit();
- assertEquals(0, commitInfo.getBranch().getID());
- }
-
- checkData(company, categoryCount, "LASTCHANGE", "AfterSwitchbackToMaster-" + (i - 1));
-
- session.close();
- }
-
- /**
- * checks for the correct naming of Company and it's Categories
- */
- private void checkData(Company company, int categoryCount, String categoryNamePrefix, String companyName)
- {
- assertEquals(companyName, company.getName());
- assertEquals(categoryCount, company.getCategories().size());
- int c = 0;
- for (Category category : company.getCategories())
- {
- assertEquals(categoryNamePrefix + c++, category.getName());
- }
- }
-
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fl�gge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.offline;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+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 Martin Fl�gge
+ */
+public class Bugzilla_312879_Test extends AbstractSyncingTest
+{
+ private 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 isFailover()
+ {
+ return true;
+ }
+
+ public void testSwitchMasterAndCommit() throws Exception
+ {
+
+ InternalSynchronizableRepository repo1_master = (InternalSynchronizableRepository)getRepository("master");
+ InternalSynchronizableRepository repo1 = getRepository();
+
+ InternalSynchronizableRepository master = repo1_master;
+ InternalSynchronizableRepository backup = repo1;
+
+ CDOSession session = openSession(master.getName());
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Test");
+
+ resource.getContents().add(company);
+ transaction.setCommitComment("Company created");
+ transaction.commit();
+
+ int categoryCount = 10;
+ for (int i = 0; i < categoryCount; i++)
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("cat" + i);
+ company.getCategories().add(category);
+ transaction.setCommitComment("Category added " + i);
+ transaction.commit();
+ }
+ sleep(1000);
+
+ checkData(company, categoryCount, "cat", "Test");
+
+ startBackupTransport();
+ repo1.setType(CDOCommonRepository.Type.MASTER);
+ repo1_master.setType(CDOCommonRepository.Type.BACKUP);
+
+ master = repo1;
+ backup = repo1_master;
+
+ assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
+ assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
+
+ // make sure the backup repository is in sync
+ waitForOnline(backup);
+
+ session.close();
+ session = openSession(master.getName());
+
+ // make sure we are running the session on the master
+ assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
+ transaction = session.openTransaction();
+
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ company = (Company)resource.getContents().get(0);
+
+ checkData(company, categoryCount, "cat", "Test");
+
+ int i = 0;
+ for (i = 0; i < 10; i++)
+ {
+ company.setName("AfterFailover-" + i);
+ transaction.setCommitComment("Name changed after failover");
+ transaction.commit();
+ }
+
+ int c = 0;
+ for (Category category : company.getCategories())
+ {
+ category.setName("CHANGED" + c++);
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(0, commitInfo.getBranch().getID());
+ }
+
+ checkData(company, categoryCount, "CHANGED", "AfterFailover-" + (i - 1));
+
+ // Switch Master back to master -----------------------------------------
+ assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
+ stopBackupTransport();
+ repo1_master.setType(CDOCommonRepository.Type.MASTER);
+ repo1.setType(CDOCommonRepository.Type.BACKUP);
+
+ master = repo1_master;
+ backup = repo1;
+
+ assertEquals(CDOCommonRepository.Type.MASTER, master.getType());
+ assertEquals(CDOCommonRepository.Type.BACKUP, backup.getType());
+
+ waitForOnline(backup);
+
+ session.close();
+
+ session = openSession(master.getName());
+ assertEquals(CDOCommonRepository.Type.MASTER, session.getRepositoryInfo().getType());
+ transaction = session.openTransaction();
+
+ resource = transaction.getResource(getResourcePath("/my/resource"));
+ company = (Company)resource.getContents().get(0);
+
+ checkData(company, categoryCount, "CHANGED", "AfterFailover-" + (i - 1));
+
+ for (i = 0; i < 10; i++)
+ {
+ company.setName("AfterSwitchbackToMaster-" + i);
+ transaction.setCommitComment("Name changed after fallback to master");
+ transaction.commit();
+ }
+
+ c = 0;
+ for (Category category : company.getCategories())
+ {
+ category.setName("LASTCHANGE" + c++);
+ CDOCommitInfo commitInfo = transaction.commit();
+ assertEquals(0, commitInfo.getBranch().getID());
+ }
+
+ checkData(company, categoryCount, "LASTCHANGE", "AfterSwitchbackToMaster-" + (i - 1));
+
+ session.close();
+ }
+
+ /**
+ * checks for the correct naming of Company and it's Categories
+ */
+ private void checkData(Company company, int categoryCount, String categoryNamePrefix, String companyName)
+ {
+ assertEquals(companyName, company.getName());
+ assertEquals(categoryCount, company.getCategories().size());
+ int c = 0;
+ for (Category category : company.getCategories())
+ {
+ assertEquals(categoryNamePrefix + c++, category.getName());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
index 5c2dba3dac..32c9f63007 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_319552_Test.java
@@ -24,19 +24,13 @@ import org.eclipse.emf.cdo.util.CDOUtil;
* "Attempt to modify historical revision" on raw replication.
* <p>
* See bug 319552
- *
+ *
* @author Pascal Lehmann
* @since 4.0
*/
@CleanRepositoriesBefore
public class Bugzilla_319552_Test extends AbstractSyncingTest
{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
public void test() throws Exception
{
InternalRepository clone = getRepository();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
index 8e54f4ee76..e29c4da058 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_325097_Test.java
@@ -31,12 +31,6 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
public class Bugzilla_325097_Test extends AbstractSyncingTest
{
@Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
protected boolean isFailover()
{
return true;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
index f14ce4ea43..26bb589398 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_326047_Test.java
@@ -30,19 +30,13 @@ import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
* Revision not revised on rawImport for deleted objects.
* <p>
* See bug 326047
- *
+ *
* @author Pascal Lehmann
* @since 4.0
*/
@CleanRepositoriesBefore
public class Bugzilla_326047_Test extends AbstractSyncingTest
{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
public void test() throws Exception
{
InternalRepository clone = getRepository();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
index 7349e351c6..6750f47bac 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
@@ -26,7 +26,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
* LastUpdateTimestamp of ReplicatorSession not set on local commits.
* <p>
* See bug 329014
- *
+ *
* @author Pascal Lehmann
* @since 4.0
*/
@@ -46,12 +46,6 @@ public class Bugzilla_329014_Test extends AbstractSyncingTest
private CDOSession cloneSession;
@Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
protected void doSetUp() throws Exception
{
super.doSetUp();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
index 0540d8faeb..fe1ec63cfe 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java
@@ -34,7 +34,7 @@ import org.eclipse.emf.common.util.EList;
* Support raw replication in HorizontalBranchingMappingStrategyWithRanges.
* <p>
* See bug 351078
- *
+ *
* @author Eike Stepper
*/
@Requires(IRepositoryConfig.CAPABILITY_OFFLINE)
@@ -42,12 +42,6 @@ import org.eclipse.emf.common.util.EList;
public class Bugzilla_351078_Test extends AbstractSyncingTest
{
@Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
protected void doSetUp() throws Exception
{
OMPlatform.INSTANCE.setDebugging(false);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376470_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376470_Test.java
index 4939565196..aa5101993d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376470_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376470_Test.java
@@ -28,12 +28,6 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
@CleanRepositoriesBefore
public class Bugzilla_376470_Test extends AbstractSyncingTest
{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
public void testRollbackWhileOnline() throws Exception
{
InternalRepository clone = getRepository();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376566_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376566_Test.java
index 188c1f80bf..4d4bc0fe20 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376566_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376566_Test.java
@@ -31,12 +31,6 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
public class Bugzilla_376566_Test extends AbstractSyncingTest
{
@Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
protected boolean isHinderInitialReplication()
{
return true;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376567_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376567_Test.java
index ae41cf6283..12740cefc0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376567_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_376567_Test.java
@@ -26,12 +26,6 @@ import org.eclipse.net4j.signal.RemoteException;
public class Bugzilla_376567_Test extends AbstractSyncingTest
{
@Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- @Override
protected boolean isHinderInitialReplication()
{
return true;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockRawReplicationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockRawReplicationTest.java
deleted file mode 100644
index 2a3f66c69a..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockRawReplicationTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-/**
- * @author Caspar De Groot
- */
-public class OfflineLockRawReplicationTest extends OfflineLockReplicationTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
deleted file mode 100644
index 9992c4c632..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.offline;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
-
-/**
- * @author Eike Stepper
- */
-@CleanRepositoriesBefore
-public class OfflineRawTest extends OfflineTest
-{
- @Override
- protected boolean isRawReplication()
- {
- return true;
- }
-
- public void _testMasterCommits_NotificationsFromClone() throws Exception
- {
- masterCommits_NotificationsFromClone();
- }
-
- /**
- * @since 4.0
- */
- public void _testNotification() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- TestListener sessionListener = new TestListener();
- session.addListener(sessionListener);
-
- TestListener transactionListener = new TestListener();
- transaction.addListener(transactionListener);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterTransaction.close();
- }
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- sleep(1000);
-
- IEvent[] sessionEvents = sessionListener.getEvents();
- assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
-
- int count = 0;
- for (IEvent sessionEvent : sessionEvents)
- {
- if (sessionEvent instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
- assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
- assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
- assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
- ++count;
- }
- }
-
- assertEquals(1, count);
-
- IEvent[] transactionEvents = transactionListener.getEvents();
- assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
-
- CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
- assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
- assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
- assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
-
- CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
- assertEquals(null, delta);
- assertEquals(true, viewInvalidationEvent.getRevisionDeltas().containsKey(resource));
- }
-
- /**
- * @since 4.0
- */
- public void testNotificationAllDeltas() throws Exception
- {
- InternalRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- TestListener sessionListener = new TestListener();
- session.addListener(sessionListener);
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- TestListener transactionListener = new TestListener();
- transaction.addListener(transactionListener);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
-
- masterTransaction.close();
- }
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- sleep(1000);
-
- IEvent[] sessionEvents = sessionListener.getEvents();
- assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
-
- int count = 0;
- for (IEvent sessionEvent : sessionEvents)
- {
- if (sessionEvent instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
- assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
- assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
- assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
- ++count;
- }
- }
-
- assertEquals(1, count);
-
- IEvent[] transactionEvents = transactionListener.getEvents();
- assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
-
- CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
- assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
- assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
- assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
-
- CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
- assertEquals(1, delta.getFeatureDeltas().size());
-
- CDOListFeatureDelta listDelta = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
- assertEquals(2, listDelta.getListChanges().size());
- }
-
- /**
- * @since 4.0
- */
- public void testSyncProgressEvents() throws Exception
- {
- InternalSynchronizableRepository clone = getRepository();
- waitForOnline(clone);
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/my/resource");
-
- resource.getContents().add(getModel1Factory().createCompany());
- transaction.setCommitComment("resource with one company created on clone");
- transaction.commit();
-
- getOfflineConfig().stopMasterTransport();
- waitForOffline(clone);
-
- {
- CDOSession masterSession = openSession("master");
- CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource("/my/resource");
-
- for (int i = 0; i < 100; i++)
- {
- masterResource.getContents().add(getModel1Factory().createCompany());
- masterTransaction.setCommitComment("one company added on master");
- masterTransaction.commit();
- }
-
- masterTransaction.close();
- }
-
- final int[] workPercent = { 0 };
- TestListener listener = new TestListener()
- {
- @Override
- public void notifyEvent(IEvent event)
- {
- super.notifyEvent(event);
- if (event instanceof ProgressEvent)
- {
- ProgressEvent e = (ProgressEvent)event;
- workPercent[0] = (int)e.getWorkPercent();
- msg(e.getTask() + ": " + workPercent[0] + " percent");
- }
- }
- };
-
- clone.getSynchronizer().addListener(listener);
-
- getOfflineConfig().startMasterTransport();
- waitForOnline(clone);
- assertEquals(100, workPercent[0]);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
index 2ccf003808..fd82d1d71e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
@@ -12,15 +12,20 @@ package org.eclipse.emf.cdo.tests.offline;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lob.CDOBlob;
import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.server.syncing.OfflineClone;
import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.bundle.OM;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
@@ -29,9 +34,11 @@ import org.eclipse.emf.cdo.tests.model3.File;
import org.eclipse.emf.cdo.tests.model3.Image;
import org.eclipse.emf.cdo.tests.util.TestListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
@@ -570,4 +577,221 @@ public class OfflineTest extends AbstractSyncingTest
IOUtil.close(fromDisk);
}
}
+
+ public void _testMasterCommits_NotificationsFromClone() throws Exception
+ {
+ masterCommits_NotificationsFromClone();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void _testNotification() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ TestListener sessionListener = new TestListener();
+ session.addListener(sessionListener);
+
+ TestListener transactionListener = new TestListener();
+ transaction.addListener(transactionListener);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterTransaction.close();
+ }
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ sleep(1000);
+
+ IEvent[] sessionEvents = sessionListener.getEvents();
+ assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
+
+ int count = 0;
+ for (IEvent sessionEvent : sessionEvents)
+ {
+ if (sessionEvent instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
+ assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
+ assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
+ assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
+ ++count;
+ }
+ }
+
+ assertEquals(1, count);
+
+ IEvent[] transactionEvents = transactionListener.getEvents();
+ assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
+
+ CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
+ assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
+ assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
+ assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
+
+ CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
+ assertEquals(null, delta);
+ assertEquals(true, viewInvalidationEvent.getRevisionDeltas().containsKey(resource));
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testNotificationAllDeltas() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ TestListener sessionListener = new TestListener();
+ session.addListener(sessionListener);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ TestListener transactionListener = new TestListener();
+ transaction.addListener(transactionListener);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+
+ masterTransaction.close();
+ }
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ sleep(1000);
+
+ IEvent[] sessionEvents = sessionListener.getEvents();
+ assertEquals(4, sessionEvents.length); // 3x repo state change + 1x invalidation
+
+ int count = 0;
+ for (IEvent sessionEvent : sessionEvents)
+ {
+ if (sessionEvent instanceof CDOSessionInvalidationEvent)
+ {
+ CDOSessionInvalidationEvent sessionInvalidationEvent = (CDOSessionInvalidationEvent)sessionEvent;
+ assertEquals(2, sessionInvalidationEvent.getNewObjects().size());
+ assertEquals(1, sessionInvalidationEvent.getChangedObjects().size());
+ assertEquals(0, sessionInvalidationEvent.getDetachedObjects().size());
+ ++count;
+ }
+ }
+
+ assertEquals(1, count);
+
+ IEvent[] transactionEvents = transactionListener.getEvents();
+ assertEquals(2, transactionEvents.length); // 1x invalidation + 1x adapters notified
+
+ CDOViewInvalidationEvent viewInvalidationEvent = (CDOViewInvalidationEvent)transactionEvents[0];
+ assertEquals(1, viewInvalidationEvent.getDirtyObjects().size());
+ assertEquals(1, viewInvalidationEvent.getRevisionDeltas().size());
+ assertEquals(0, viewInvalidationEvent.getDetachedObjects().size());
+
+ CDORevisionDelta delta = viewInvalidationEvent.getRevisionDeltas().get(resource);
+ assertEquals(1, delta.getFeatureDeltas().size());
+
+ CDOListFeatureDelta listDelta = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
+ assertEquals(2, listDelta.getListChanges().size());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void testSyncProgressEvents() throws Exception
+ {
+ InternalSynchronizableRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ {
+ CDOSession masterSession = openSession("master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ for (int i = 0; i < 100; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ }
+
+ final int[] workPercent = { 0 };
+ TestListener listener = new TestListener()
+ {
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ super.notifyEvent(event);
+ if (event instanceof ProgressEvent)
+ {
+ ProgressEvent e = (ProgressEvent)event;
+ workPercent[0] = (int)e.getWorkPercent();
+ msg(e.getTask() + ": " + workPercent[0] + " percent");
+ }
+ }
+ };
+
+ clone.getSynchronizer().addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ assertEquals(100, workPercent[0]);
+ }
}

Back to the top