Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java147
1 files changed, 79 insertions, 68 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java b/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java
index b7ebdfe46d..262d17004e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyArrayListTest.java
@@ -1,3 +1,13 @@
+/**
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
package org.eclipse.emf.cdo.tests.objectivity;
import static org.junit.Assert.assertEquals;
@@ -13,32 +23,31 @@ import org.junit.Test;
import java.util.ArrayList;
/**
- * Class to be used for testing, all persistence related calls are
- * overriden by local ones.
+ * Class to be used for testing, all persistence related calls are overriden by local ones.
*
* @author ibrahim
- *
*/
class ObjyLocalArrayListLong extends ObjyArrayList<Long>
{
- public ObjyLocalArrayListLong(Class_Object classObject)
+ public ObjyLocalArrayListLong(Class_Object classObject)
{
- super(classObject);
+ super(classObject);
}
- ArrayList<Long> arrayList = new ArrayList<Long>();
- long arraySize = 0;
-
+ ArrayList<Long> arrayList = new ArrayList<Long>();
+
+ long arraySize = 0;
+
@Override
protected void setValue(long index, Long newValue)
{
- arrayList.set((int) index, newValue);
+ arrayList.set((int)index, newValue);
}
@Override
protected Long getValue(long index)
{
- return arrayList.get((int) index);
+ return arrayList.get((int)index);
}
@Override
@@ -50,90 +59,92 @@ class ObjyLocalArrayListLong extends ObjyArrayList<Long>
}
return cacheSize;
}
-
+
@Override
protected void update()
{
- // do nothing.
+ // do nothing.
}
-
+
@Override
protected long getVArraySize()
{
return arrayList.size();
}
-
+
@Override
protected void saveSize()
{
arraySize = cacheSize;
cacheSize = -1;
}
-
+
@Override
protected void grow(int item)
{
- for (int i = 0; i < Math.max(item + 10, 10); i++)
- arrayList.add(new Long(0));
+ for (int i = 0; i < Math.max(item + 10, 10); i++)
+ {
+ arrayList.add(new Long(0));
+ }
}
@Override
public long size()
{
- return arraySize;
+ return arraySize;
}
}
-
-
public class ObjyArrayListTest
{
- ObjyLocalArrayListLong arrayListLong;
- int numItems = 10;
-
- @Before
- public void setUp()
- {
- arrayListLong = new ObjyLocalArrayListLong(null);
- // fill the array.
- for (int i = 0; i < numItems; i++)
- {
- arrayListLong.add(new Long(i));
- }
- }
-
- @Test
- public void moveItems()
- {
- // move elemnt 7 to spot 2.
- arrayListLong.move(2, 7);
- assertEquals(numItems, arrayListLong.size());
- assertEquals(new Long(7), arrayListLong.get(2));
- }
-
- @Test
- public void removeLastItem()
- {
- //
- arrayListLong.remove((int) arrayListLong.size());
- assertEquals((numItems-1), arrayListLong.size());
- }
-
- @Test
- public void removeMiddleItem()
- {
- //
- arrayListLong.remove(5);
- assertEquals((numItems-1), arrayListLong.size());
- }
-
- @Test(expected= IndexOutOfBoundsException.class)
- public void empty() {
- new ArrayList<Object>().get(0);
- }
-
- @After
- public void tearDown()
- {
- }
+ ObjyLocalArrayListLong arrayListLong;
+
+ int numItems = 10;
+
+ @Before
+ public void setUp()
+ {
+ arrayListLong = new ObjyLocalArrayListLong(null);
+ // fill the array.
+ for (int i = 0; i < numItems; i++)
+ {
+ arrayListLong.add(new Long(i));
+ }
+ }
+
+ @Test
+ public void moveItems()
+ {
+ // move elemnt 7 to spot 2.
+ arrayListLong.move(2, 7);
+ assertEquals(numItems, arrayListLong.size());
+ assertEquals(new Long(7), arrayListLong.get(2));
+ }
+
+ @Test
+ public void removeLastItem()
+ {
+ //
+ arrayListLong.remove((int)arrayListLong.size());
+ assertEquals((numItems - 1), arrayListLong.size());
+ }
+
+ @Test
+ public void removeMiddleItem()
+ {
+ //
+ arrayListLong.remove(5);
+ assertEquals((numItems - 1), arrayListLong.size());
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ public void empty()
+ {
+ new ArrayList<Object>().get(0);
+ }
+
+ @After
+ public void tearDown()
+ {
+ }
}

Back to the top