Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-06-12 06:46:57 +0000
committerEike Stepper2008-06-12 06:46:57 +0000
commitdf25e08f5eac7e457220207fc71c435616ea8961 (patch)
tree76bb3631904fa144d293b51aeb632e4ace63bd40 /plugins
parentfab9ab386abbebe620a20a456a70100c2eaf6dbb (diff)
downloadcdo-df25e08f5eac7e457220207fc71c435616ea8961.tar.gz
cdo-df25e08f5eac7e457220207fc71c435616ea8961.tar.xz
cdo-df25e08f5eac7e457220207fc71c435616ea8961.zip
[236784] Invalidate and cache problem
https://bugs.eclipse.org/bugs/show_bug.cgi?id=236784
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java97
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java2
4 files changed, 102 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
index 447d2f7879..c9b95a416f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
@@ -32,6 +32,8 @@ import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
+
import junit.framework.Assert;
/**
@@ -136,7 +138,7 @@ public class RevisionDeltaTest extends AbstractCDOTest
public void testBugzilla214431() throws Exception
{
CDOSession session = openModel1Session();
- CDOTransaction transaction = session.openTransaction();
+ CDOTransactionImpl transaction = (CDOTransactionImpl)session.openTransaction();
CDOResource resource = transaction.createResource("/test1");
SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
@@ -144,7 +146,7 @@ public class RevisionDeltaTest extends AbstractCDOTest
transaction.commit();
salesOrder.setId(4711);
- assertNotSame(salesOrder.cdoRevision(), transaction.getRevision(salesOrder.cdoID()));
+ assertNotSame(salesOrder.cdoRevision(), transaction.getRevision(salesOrder.cdoID(), true));
assertEquals(salesOrder.cdoRevision(), transaction.getDirtyObjects().get(salesOrder.cdoID()).cdoRevision());
transaction.close();
session.close();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java
new file mode 100644
index 0000000000..3b3e3f9228
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+
+import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public class SessionTest extends AbstractCDOTest
+{
+ public void testInvalidateAndCache() throws Exception
+ {
+ msg("Opening sessionA");
+ CDOSession sessionA = openModel1Session();
+
+ msg("Opening transactionA");
+ CDOTransactionImpl transactionA = (CDOTransactionImpl)sessionA.openTransaction();
+ CDOID cdoidA = null;
+
+ // *************************************************************
+ {
+ msg("Creating categoryA");
+ Category categoryA = Model1Factory.eINSTANCE.createCategory();
+ categoryA.setName("categoryA");
+
+ msg("Creating companyA");
+ Company companyA = Model1Factory.eINSTANCE.createCompany();
+
+ msg("Adding categories");
+ companyA.getCategories().add(categoryA);
+
+ msg("Creating resource");
+ CDOResource resourceA = transactionA.createResource("/test1");
+
+ msg("Adding companyA");
+ resourceA.getContents().add(companyA);
+
+ msg("Committing");
+ transactionA.commit();
+
+ cdoidA = categoryA.cdoID();
+ transactionA.removeObject(cdoidA);
+ }
+
+ // assertEquals(true, transaction.getObjectsMap().get(category1AID) == null);
+ // *************************************************************
+
+ // transactionA.close();
+ // transactionA = (CDOTransactionImpl)sessionA.openTransaction();
+
+ msg("Opening sessionB");
+ CDOSession sessionB = openModel1Session();
+
+ msg("Opening transactionB");
+ CDOTransaction transactionB = sessionB.openTransaction();
+ Category categoryB = (Category)transactionB.getObject(cdoidA, true);
+
+ msg("Changing name");
+ categoryB.setName("CHANGED NAME");
+
+ msg("\n\n\n\n\n\n\n\n\n\n\nCommitting");
+ transactionB.commit();
+
+ Thread.sleep(100);
+ final Category categoryA = (Category)transactionA.getObject(cdoidA, true);
+
+ msg("Checking after commit");
+ boolean timedOut = new PollingTimeOuter(200, 100)
+ {
+ @Override
+ protected boolean successful()
+ {
+ String name = categoryA.getName();
+ return "CHANGED NAME".equals(name);
+ }
+ }.timedOut();
+
+ assertEquals(false, timedOut);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 5ad0494686..ef88eaa6ed 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -63,14 +63,6 @@ public interface CDOView extends CDOProtocolView, INotifier
public void setLoadRevisionCollectionChunkSize(int loadRevisionCollectionChunkSize);
- /**
- * Returns the {@link CDORevision} that is stored in the {@link CDORevisionManager} associated with this view and that
- * is mapped for the given id. Note that, if this method is called in the context of a {@link CDOTransaction} and the
- * object with the given id is dirty, it returns the base revision of the session and not the dirty revision of the
- * transaction!
- */
- public CDORevision getRevision(CDOID id);
-
public boolean hasResource(String path);
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
index 178c217fde..6438f95547 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
@@ -42,7 +42,7 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit
}
@Override
- public InternalCDORevision getRevision(CDOID id)
+ public InternalCDORevision getRevision(CDOID id, boolean loadOnDemand)
{
CDOSessionImpl session = getSession();
CDORevisionResolver revisionManager = session.getRevisionManager();

Back to the top