summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-05-03 22:33:24 (EDT)
committerCaspar De Groot2010-05-03 22:33:24 (EDT)
commit4f6a6cc930afb6cf1b4fc8fac24d1b96617208de (patch)
tree9f1a9a17489cd3745a73d0f239aa828127853366
parent3edb65235a6d3d39f66273a7c27b6208e1209510 (diff)
downloadcdo-4f6a6cc930afb6cf1b4fc8fac24d1b96617208de.zip
cdo-4f6a6cc930afb6cf1b4fc8fac24d1b96617208de.tar.gz
cdo-4f6a6cc930afb6cf1b4fc8fac24d1b96617208de.tar.bz2
[301671] MEMRevisionCache does not revise
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301671
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java309
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TestRevision.java314
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_301671_Test.java157
5 files changed, 492 insertions, 311 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java
index 709f93c..ee09868 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java
@@ -375,7 +375,8 @@ public class MEMRevisionCache extends ReferenceQueueWorker<InternalCDORevision>
for (ListIterator<KeyedReference<CDOIDAndVersion, InternalCDORevision>> it = listIterator(); it.hasNext();)
{
KeyedReference<CDOIDAndVersion, InternalCDORevision> ref = it.next();
- if (ref.get() != null)
+ InternalCDORevision foundRevision = ref.get();
+ if (foundRevision != null)
{
CDOIDAndVersion key = ref.getKey();
int v = key.getVersion();
@@ -386,7 +387,23 @@ public class MEMRevisionCache extends ReferenceQueueWorker<InternalCDORevision>
if (v < version)
{
- it.previous();
+ if (foundRevision.getRevised() == CDORevision.UNSPECIFIED_DATE)
+ {
+ if (v == version - 1)
+ {
+ foundRevision.setRevised(revision.getCreated() - 1);
+ }
+ else
+ {
+ it.remove();
+ }
+ }
+
+ if (it.hasPrevious())
+ {
+ it.previous();
+ }
+
it.add(reference);
return true;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
index c258429..ba1b42f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
@@ -60,6 +60,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_289932_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_294850_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_294859_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_299190_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_301671_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -168,6 +169,7 @@ public abstract class AllTestsAllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_294850_Test.class);
testClasses.add(Bugzilla_294859_Test.class);
testClasses.add(Bugzilla_299190_Test.class);
+ testClasses.add(Bugzilla_301671_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
index 7e4daf6..20d81f4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
@@ -11,25 +11,13 @@
package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.io.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.internal.common.revision.cache.lru.DLRevisionHolder;
import org.eclipse.emf.cdo.internal.common.revision.cache.lru.LRURevisionCache;
import org.eclipse.emf.cdo.internal.common.revision.cache.lru.LRURevisionHolder;
import org.eclipse.emf.cdo.internal.common.revision.cache.lru.LRURevisionList;
import org.eclipse.emf.cdo.internal.common.revision.cache.lru.RevisionHolder;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
@@ -246,301 +234,4 @@ public class RevisionHolderTest extends AbstractCDOTest
assertEquals(expected.get(i), list.get(i));
}
}
-
- /**
- * @author Eike Stepper
- */
- private static final class TestRevision implements InternalCDORevision
- {
- private CDOID id;
-
- private int version;
-
- private long created;
-
- private long revised;
-
- public TestRevision(long id, int version, long created, long revised)
- {
- this.id = CDOIDUtil.createLong(id);
- this.version = version;
- this.created = created;
- this.revised = revised;
- }
-
- public TestRevision(long id, int version, long created)
- {
- this(id, version, created, CDORevision.UNSPECIFIED_DATE);
- }
-
- public TestRevision(long id)
- {
- this(id, 0, CDORevision.UNSPECIFIED_DATE);
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public void setID(CDOID id)
- {
- this.id = id;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public void setVersion(int version)
- {
- this.version = version;
- }
-
- public long getCreated()
- {
- return created;
- }
-
- public void setCreated(long created)
- {
- this.created = created;
- }
-
- public long getRevised()
- {
- return revised;
- }
-
- public void setRevised(long revised)
- {
- this.revised = revised;
- }
-
- public boolean isCurrent()
- {
- return revised == UNSPECIFIED_DATE;
- }
-
- public boolean isTransactional()
- {
- return version < 0;
- }
-
- public boolean isValid(long timeStamp)
- {
- return (revised == UNSPECIFIED_DATE || revised >= timeStamp) && timeStamp >= created;
- }
-
- public EClass getEClass()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisionData data()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isResourceNode()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isResourceFolder()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isResource()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisionDelta compare(CDORevision origin)
- {
- throw new UnsupportedOperationException();
- }
-
- public void merge(CDORevisionDelta delta)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevision copy()
- {
- return new TestRevision(CDOIDUtil.getLong(id), version, created, revised);
- }
-
- public void write(CDODataOutput out, int referenceChunk) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public void add(EStructuralFeature feature, int index, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public void adjustReferences(CDOReferenceAdjuster revisionAdjuster)
- {
- throw new UnsupportedOperationException();
- }
-
- public void clear(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean contains(EStructuralFeature feature, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object get(EStructuralFeature feature, int index)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object getContainerID()
- {
- throw new UnsupportedOperationException();
- }
-
- public int getContainingFeatureID()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOList getList(EStructuralFeature feature, int size)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOList getList(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOID getResourceID()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevision revision()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object getValue(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public int hashCode(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public int indexOf(EStructuralFeature feature, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public int lastIndexOf(EStructuralFeature feature, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object move(EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object remove(EStructuralFeature feature, int index)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object set(EStructuralFeature feature, int index, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setContainerID(Object containerID)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setContainingFeatureID(int containingFeatureID)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setListSize(EStructuralFeature feature, int size)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setResourceID(CDOID resourceID)
- {
- throw new UnsupportedOperationException();
- }
-
- public int setTransactional()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setUntransactional()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object setValue(EStructuralFeature feature, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public int size(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public <T> T[] toArray(EStructuralFeature feature, T[] array)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object[] toArray(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public void unset(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setList(EStructuralFeature feature, InternalCDOList list)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object basicGet(EStructuralFeature feature, int index)
- {
- throw new UnsupportedOperationException();
- }
-
- public Object basicSet(EStructuralFeature feature, int index, Object value)
- {
- throw new UnsupportedOperationException();
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TestRevision.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TestRevision.java
new file mode 100644
index 0000000..5f2d6df
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TestRevision.java
@@ -0,0 +1,314 @@
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.io.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class TestRevision implements InternalCDORevision
+{
+ private CDOID id;
+
+ private int version;
+
+ private long created;
+
+ private long revised;
+
+ public TestRevision(long id, int version, long created, long revised)
+ {
+ this.id = CDOIDUtil.createLong(id);
+ this.version = version;
+ this.created = created;
+ this.revised = revised;
+ }
+
+ public TestRevision(long id, int version, long created)
+ {
+ this(id, version, created, CDORevision.UNSPECIFIED_DATE);
+ }
+
+ public TestRevision(long id)
+ {
+ this(id, 0, CDORevision.UNSPECIFIED_DATE);
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public void setID(CDOID id)
+ {
+ this.id = id;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(int version)
+ {
+ this.version = version;
+ }
+
+ public long getCreated()
+ {
+ return created;
+ }
+
+ public void setCreated(long created)
+ {
+ this.created = created;
+ }
+
+ public long getRevised()
+ {
+ return revised;
+ }
+
+ public void setRevised(long revised)
+ {
+ this.revised = revised;
+ }
+
+ public boolean isCurrent()
+ {
+ return revised == UNSPECIFIED_DATE;
+ }
+
+ public boolean isTransactional()
+ {
+ return version < 0;
+ }
+
+ public boolean isValid(long timeStamp)
+ {
+ return (revised == UNSPECIFIED_DATE || revised >= timeStamp) && timeStamp >= created;
+ }
+
+ public EClass getEClass()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevisionData data()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isResourceNode()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isResourceFolder()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isResource()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevisionDelta compare(CDORevision origin)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void merge(CDORevisionDelta delta)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevision copy()
+ {
+ return new TestRevision(CDOIDUtil.getLong(id), version, created, revised);
+ }
+
+ public void write(CDODataOutput out, int referenceChunk) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(EStructuralFeature feature, int index, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void adjustReferences(CDOReferenceAdjuster revisionAdjuster)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void clear(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean contains(EStructuralFeature feature, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object get(EStructuralFeature feature, int index)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getContainerID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getContainingFeatureID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOList getList(EStructuralFeature feature, int size)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOList getList(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOID getResourceID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevision revision()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getValue(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int hashCode(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOf(EStructuralFeature feature, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isEmpty(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int lastIndexOf(EStructuralFeature feature, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object move(EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object remove(EStructuralFeature feature, int index)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object set(EStructuralFeature feature, int index, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContainerID(Object containerID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContainingFeatureID(int containingFeatureID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setListSize(EStructuralFeature feature, int size)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setResourceID(CDOID resourceID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int setTransactional()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setUntransactional()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object setValue(EStructuralFeature feature, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T> T[] toArray(EStructuralFeature feature, T[] array)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object[] toArray(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void unset(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setList(EStructuralFeature feature, InternalCDOList list)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object basicGet(EStructuralFeature feature, int index)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object basicSet(EStructuralFeature feature, int index, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_301671_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_301671_Test.java
new file mode 100644
index 0000000..e16340e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_301671_Test.java
@@ -0,0 +1,157 @@
+/**
+ * Copyright (c) 2004 - 2009 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.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.internal.common.revision.cache.mem.MEMRevisionCache;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.TestRevision;
+
+/**
+ * MEMRevisionCache does not revise
+ * <p>
+ * See https://bugs.eclipse.org/301671
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_301671_Test extends AbstractCDOTest
+{
+ private MEMRevisionCache cache;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ cache = new MEMRevisionCache();
+ cache.activate();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ cache.deactivate();
+ cache = null;
+ super.tearDown();
+ }
+
+ public void test_revise() throws Exception
+ {
+ TestRevision r1v1 = new TestRevision(1, 1, 10);
+ cache.addRevision(r1v1);
+
+ TestRevision r1v2 = new TestRevision(1, 2, 20);
+ cache.addRevision(r1v2);
+
+ assertEquals(19, r1v1.getRevised());
+ }
+
+ public void test_toss() throws Exception
+ {
+ TestRevision r1v1 = new TestRevision(1, 1, 10);
+ cache.addRevision(r1v1);
+
+ TestRevision r1v3 = new TestRevision(1, 3, 30);
+ cache.addRevision(r1v3);
+
+ assertNull(cache.getRevisionByVersion(r1v1.getID(), 1));
+ }
+
+ public void test_noTossNoRevise() throws Exception
+ {
+ TestRevision r1v1 = new TestRevision(1, 1, 10, 19);
+ cache.addRevision(r1v1);
+
+ TestRevision r1v3 = new TestRevision(1, 3, 30);
+ cache.addRevision(r1v3);
+
+ assertEquals(19, r1v1.getRevised());
+ }
+
+ public void test_revise2()
+ {
+ final long a = 10;
+ TestRevision av1 = new TestRevision(a, 1, 100);
+ TestRevision av2 = new TestRevision(a, 2, 200);
+
+ cache.addRevision(av1);
+ assertTrue(av1.isCurrent());
+ assertTrue(av2.isCurrent());
+
+ cache.addRevision(av2);
+ assertFalse(av1.isCurrent());
+ assertEquals(199, av1.getRevised());
+ assertTrue(av2.isCurrent());
+ }
+
+ public void test_toss2()
+ {
+ final long b = 20;
+ TestRevision bv3 = new TestRevision(b, 3, 100);
+ TestRevision bv5 = new TestRevision(b, 5, 300);
+ cache.addRevision(bv3);
+ cache.addRevision(bv5);
+ CDOID id = CDOIDUtil.createLong(b);
+ CDORevision rev = cache.getRevisionByVersion(id, 3);
+ assertNull(rev);
+ rev = cache.getRevision(id);
+ assertSame(bv5, rev);
+ }
+
+ public void test_maintainOrdering()
+ {
+ final long c = 30;
+ TestRevision[] crevisions = new TestRevision[8];
+ for (int i = 0; i < crevisions.length; i++)
+ {
+ crevisions[i] = new TestRevision(c, i, 100 * i);
+ }
+
+ for (int i = 0; i < crevisions.length; i++)
+ {
+ if (i != 0 && i != 4)
+ {
+ cache.addRevision(crevisions[i]);
+ }
+ }
+
+ CDOID id = CDOIDUtil.createLong(c);
+ for (int i = 0; i < crevisions.length; i++)
+ {
+ CDORevision rev;
+ switch (i)
+ {
+ case 0: // was never put
+ case 3: // should have been evicted
+ case 4: // was never put
+ assertNull(cache.getRevisionByVersion(id, i));
+ break;
+
+ // 1, 2, 5 and 6 should have been revised
+ case 1:
+ case 2:
+ case 5:
+ case 6:
+ rev = cache.getRevisionByVersion(id, i);
+ assertFalse(rev.isCurrent());
+ assertEquals(rev.getCreated() + 99, rev.getRevised());
+ break;
+
+ // 7 should be current
+ case 7:
+ rev = cache.getRevisionByVersion(id, i);
+ assertTrue(rev.isCurrent());
+ break;
+ }
+ }
+ }
+}