Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-01-15 18:01:12 +0000
committerEike Stepper2016-01-15 18:01:12 +0000
commit1f436278ef4bc0e07e718366ef271f5c705a79fd (patch)
treea787b0ce0b2b91b4bf403b85d450c7fa8cd7ce91 /plugins
parentd0f123f61bd8899b9afb63dc07c1a761e1cdc85e (diff)
downloadcdo-1f436278ef4bc0e07e718366ef271f5c705a79fd.tar.gz
cdo-1f436278ef4bc0e07e718366ef271f5c705a79fd.tar.xz
cdo-1f436278ef4bc0e07e718366ef271f5c705a79fd.zip
[485961] Provide CDORevisionUtil.getChildRevisions() method that skips containment proxies
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485961
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485961_Test.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485961_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485961_Test.java
new file mode 100644
index 0000000000..7abbea6672
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485961_Test.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016 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.bugzilla;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_485961_Test extends AbstractCDOTest
+{
+ public void testProperContents() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+ Category cat1 = getModel1Factory().createCategory();
+ Category cat2 = getModel1Factory().createCategory();
+ Category cat3 = getModel1Factory().createCategory();
+
+ company.getCategories().add(cat1);
+ cat1.getCategories().add(cat2);
+ cat1.getCategories().add(cat3);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource res1 = transaction.createResource(getResourcePath("/res1"));
+ res1.getContents().add(company);
+
+ CDOResource res2 = transaction.createResource(getResourcePath("/res2"));
+ res2.getContents().add(cat3);
+
+ transaction.commit();
+
+ InternalRepository repository = getRepository();
+ CDORevisionProvider revisionProvider = new ManagedRevisionProvider(repository.getRevisionManager(),
+ repository.getBranchManager().getMainBranch().getHead());
+ CDOID rootResourceID = repository.getRootResourceID();
+
+ StoreThreadLocal.setSession(repository.getSessionManager().getSession(session.getSessionID()));
+
+ try
+ {
+ assertEquals(8, traverse(revisionProvider, rootResourceID));
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ private int traverse(CDORevisionProvider revisionProvider, CDOID id)
+ {
+ CDORevision revision = revisionProvider.getRevision(id);
+
+ int count = 1;
+ for (CDORevision child : CDORevisionUtil.getChildRevisions(revision, revisionProvider, true))
+ {
+ count += traverse(revisionProvider, child.getID());
+ }
+
+ return count;
+ }
+}

Back to the top