summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-04-28 04:05:15 -0400
committerEike Stepper2011-04-28 04:05:15 -0400
commitdd86bcd3afd4397736f114f050e199cfc4843692 (patch)
tree76f97b3d729079b06d12e8eec70a219266482006
parent45940e6bffef293769569f99f28d2ebbb5e344e3 (diff)
downloadcdo-dd86bcd3afd4397736f114f050e199cfc4843692.zip
cdo-dd86bcd3afd4397736f114f050e199cfc4843692.tar.gz
cdo-dd86bcd3afd4397736f114f050e199cfc4843692.tar.xz
[337054] Unwanted CDOElementProxy items in CDOChangeSetData when partial collection loading is used
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337054
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java103
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java1
6 files changed, 113 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index 6ec1b71..c677d4a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -210,6 +210,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_336314_Test.class);
testClasses.add(Bugzilla_336382_Test.class);
testClasses.add(Bugzilla_336590_Test.class);
+ testClasses.add(Bugzilla_337054_Test.class);
testClasses.add(Bugzilla_337523_Test.class);
testClasses.add(Bugzilla_337587_Test.class);
testClasses.add(Bugzilla_338779_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
index 8c9d244..08c41e8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MergingTest.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IMEMStore;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -642,7 +641,7 @@ public class MergingTest extends AbstractCDOTest
@SuppressWarnings("unused")
public void test_Bugzilla_309467_ServerRestart() throws Exception
{
- skipTest(getRepository().getStore() instanceof IMEMStore);
+ skipMEM();
{
CDOSession session = openSession();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
index 521a036..1578798 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RepositoryTest.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.CDOServerUtil;
-import org.eclipse.emf.cdo.server.IMEMStore;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.ISessionManager;
@@ -132,7 +131,7 @@ public class RepositoryTest extends AbstractCDOTest
*/
public void testLastCommitTime() throws Exception
{
- skipTest(getRepository().getStore() instanceof IMEMStore);
+ skipMEM();
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java
new file mode 100644
index 0000000..720f913
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337054_Test.java
@@ -0,0 +1,103 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Szabolcs Bardy - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+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.spi.cdo.DefaultCDOMerger;
+
+/**
+ * @author Szabolcs Bardy
+ */
+public class Bugzilla_337054_Test extends AbstractCDOTest
+{
+ private final static String RESOURCE_NAME = "/337054";
+
+ private int testedListSize = 3;
+
+ public void testCDOElementProxies() throws Exception
+ {
+ skipMEM();
+ skipUnlessBranching();
+
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
+
+ CDOTransaction mainTransaction = session.openTransaction();
+ CDOResource resource = mainTransaction.createResource(getResourcePath(RESOURCE_NAME));
+
+ // fill up resource contents if empty
+ int actualSize = resource.getContents().size();
+ if (actualSize < testedListSize)
+ {
+ msg("Filling up list...");
+
+ for (int i = actualSize; i < testedListSize; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("TestCompany_" + i);
+ resource.getContents().add(company);
+
+ resource.getContents().add(company);
+
+ actualSize++;
+ }
+
+ msg("Committing data...");
+ mainTransaction.commit();
+ }
+
+ mainTransaction.close();
+
+ msg("Creating a branch with a new element: ");
+
+ String branchName = String.valueOf(System.currentTimeMillis());
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch(branchName);
+
+ Company branchCompany = getModel1Factory().createCompany();
+ branchCompany.setName("TestCompany_" + actualSize);
+
+ CDOTransaction branchTransaction = session.openTransaction(branch);
+ CDOResource branchRootResource = branchTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));
+ branchRootResource.getContents().add(branchCompany);
+
+ branchTransaction.commit();
+ branchTransaction.close();
+
+ // restart repository
+ restartRepository();
+
+ session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
+
+ // merge
+ mainTransaction = session.openTransaction(session.getBranchManager().getMainBranch());
+ branch = session.getBranchManager().getMainBranch().getBranch(branchName);
+
+ resource = mainTransaction.getResource(getResourcePath(RESOURCE_NAME));
+ int resourceContentsBeforeMerge = resource.getContents().size();
+ msg("Before: " + resourceContentsBeforeMerge);
+
+ mainTransaction.merge(branch.getHead(), new DefaultCDOMerger.PerFeature.ManyValued());
+ mainTransaction.commit();
+
+ int resourceContentsAfterMerge = resource.getContents().size();
+ msg("After: " + resourceContentsAfterMerge);
+
+ assertEquals(resourceContentsBeforeMerge + 1, resourceContentsAfterMerge);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
index a28fbc9..92ba34c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.tests.config.impl;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.server.IMEMStore;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
@@ -591,6 +592,11 @@ public abstract class ConfigTest extends AbstractOMTest implements IConstants
skipTest(!getRepository().isSupportingBranches());
}
+ protected void skipMEM()
+ {
+ skipTest(getRepository().getStore() instanceof IMEMStore);
+ }
+
protected void skipMongo()
{
skipConfig("MongoDBStore");
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index ec1f5f6..4724d7c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -1316,6 +1316,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
if (revision != null)
{
+ resolveAllElementProxies(revision);
info.addRevision(revision);
}
}