aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-11-18 10:19:52 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-11-18 10:19:52 +0100
commit5f983eef81e31207857eb8142b7d41f8bc511b46 (patch)
tree6b2252b9874c89c866016f0241a58e7e1be98f8a /tests/src
parent2e00c7a146e7718420be288e2073cc144d054f4f (diff)
downloadcgeo-5f983eef81e31207857eb8142b7d41f8bc511b46.zip
cgeo-5f983eef81e31207857eb8142b7d41f8bc511b46.tar.gz
cgeo-5f983eef81e31207857eb8142b7d41f8bc511b46.tar.bz2
fix #2167: Not possible to open OP caches
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java b/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
index 1d0767e..b3eaedf 100644
--- a/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
+++ b/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
@@ -6,13 +6,16 @@ import java.util.List;
import junit.framework.TestCase;
public class LazyInitializedListTest extends TestCase {
+
+ private static final class MockedLazyInitializedList extends LazyInitializedList<String> {
+ @Override
+ protected List<String> loadFromDatabase() {
+ return new ArrayList<String>();
+ }
+ }
+
public static void testAccess() {
- final LazyInitializedList<String> list = new LazyInitializedList<String>() {
- @Override
- protected List<String> loadFromDatabase() {
- return new ArrayList<String>();
- }
- };
+ final LazyInitializedList<String> list = new MockedLazyInitializedList();
assertTrue(list.isEmpty());
list.add("Test");
assertFalse(list.isEmpty());
@@ -24,4 +27,21 @@ public class LazyInitializedListTest extends TestCase {
}
assertEquals(1, iterations);
}
+
+ public static void testNull() {
+ final LazyInitializedList<String> list = new MockedLazyInitializedList();
+ list.set((LazyInitializedList<String>) null);
+ list.set((ArrayList<String>) null);
+ }
+
+ public static void testUnmodifiable() {
+ final MockedLazyInitializedList list = new MockedLazyInitializedList();
+ boolean unsupported = false;
+ try {
+ list.asList().add("this is not possible");
+ } catch (UnsupportedOperationException e) {
+ unsupported = true;
+ }
+ assertTrue(unsupported);
+ }
}