Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-09-16 04:44:40 +0000
committerEike Stepper2011-09-16 04:44:40 +0000
commit7d70c49ba7f2e8976d4bf58145cd98685128a1c9 (patch)
tree7db41199812243bd96b56c876612fbf67dade0e4 /plugins/org.eclipse.emf.cdo.tests/src/org
parent16ef04126f16561d614f9341db6015d095d86f53 (diff)
downloadcdo-7d70c49ba7f2e8976d4bf58145cd98685128a1c9.tar.gz
cdo-7d70c49ba7f2e8976d4bf58145cd98685128a1c9.tar.xz
cdo-7d70c49ba7f2e8976d4bf58145cd98685128a1c9.zip
[351078] [DB] Support raw replication in HorizontalBranchingMappingStrategyWithRanges
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351078
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_351078_Test.java162
1 files changed, 145 insertions, 17 deletions
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 98b0ca3fbe..c0284e43c6 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
@@ -23,6 +23,7 @@ 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.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
@@ -59,6 +60,128 @@ public class Bugzilla_351078_Test extends AbstractSyncingTest
run(new CompanyChanger());
}
+ public void testAddTwoRemoveSecond_DoNothing() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(1);
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveFirst() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(0);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveSecond() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(1);
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_RemoveSecondAddOne() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.remove(1);
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+ });
+ }
+
+ public void testAddTwo_AddOneRemoveThird() throws Exception
+ {
+ run(new CompanyChanger()
+ {
+ @Override
+ public void beforeConnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+ }
+
+ @Override
+ public void beforeReconnect(EList<Category> categories, CDOTransaction transaction) throws Exception
+ {
+ categories.add(getModel1Factory().createCategory());
+ transaction.commit();
+
+ categories.remove(2);
+ transaction.commit();
+ }
+ });
+ }
+
public void testAddOne_AddOne() throws Exception
{
run(new CompanyChanger()
@@ -345,20 +468,7 @@ public class Bugzilla_351078_Test extends AbstractSyncingTest
waitForOnline(clone);
sleep(500); // TODO Clarify why waitForOnline() alone is not enough
- // Create client session & transaction.
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOID id = CDOUtil.getCDOObject(masterCompany).cdoID();
- Company company = (Company)transaction.getObject(id);
- EList<Category> categories = company.getCategories();
-
- for (int i = 0; i < masterCompany.getCategories().size(); i++)
- {
- CDOObject masterCategory = CDOUtil.getCDOObject(masterCompany.getCategories().get(i));
- CDOObject category = CDOUtil.getCDOObject(categories.get(i));
- assertEquals(masterCategory.cdoID(), category.cdoID());
- }
+ check(masterCompany, "after connect");
getOfflineConfig().stopMasterTransport();
waitForOffline(clone);
@@ -370,12 +480,30 @@ public class Bugzilla_351078_Test extends AbstractSyncingTest
waitForOnline(clone);
sleep(500);
- for (int i = 0; i < masterCompany.getCategories().size(); i++)
+ check(masterCompany, "after reconnect");
+ }
+
+ private void check(Company masterCompany, String when)
+ {
+ EList<Category> masterCategories = masterCompany.getCategories();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOID id = CDOUtil.getCDOObject(masterCompany).cdoID();
+ Company company = (Company)view.getObject(id);
+ EList<Category> categories = company.getCategories();
+
+ assertEquals("Size (" + when + ")", masterCategories.size(), categories.size());
+
+ for (int i = 0; i < masterCategories.size(); i++)
{
- CDOObject masterCategory = CDOUtil.getCDOObject(masterCompany.getCategories().get(i));
+ CDOObject masterCategory = CDOUtil.getCDOObject(masterCategories.get(i));
CDOObject category = CDOUtil.getCDOObject(categories.get(i));
- assertEquals("Element " + i, masterCategory.cdoID(), category.cdoID());
+ assertEquals("Element " + i + " (" + when + ")", masterCategory.cdoID(), category.cdoID());
}
+
+ session.close();
}
/**

Back to the top