Hello folks.
I am concerned that I am missing something rather basic.
When getting a distributed List from Hazelcast, similar to the code
samples shown on the wiki and
hazelcast.com sites, the behaviour
differs from the expected behaviour of java.util.Lists.
This seems very basic, but I can't see that I'm doing anything wrong.
Attaching a small testcase which fails in two ways:
a) The ordering of the elements in IList does not match the expected
{1, 2, 3}. Instead, the elements are unordered, similar to an ISet
implementation.
b) The List.get() method calls throw exceptions (more specifically
java.lang.UnsupportedOperationException
at com.hazelcast.impl.BaseCollection.get(BaseCollection.java:36))
What am I missing here?
@Test
public void validateOrderingInDistributedList() {
// Assemble
final HazelcastInstance cacheNode =
Hazelcast.newHazelcastInstance(HazelcastCache.readConfigFile(configFile));
final List<String> unitUnderTest =
cacheNode.getList("testList");
// Act
unitUnderTest.add("1");
unitUnderTest.add("2");
unitUnderTest.add("3");
// Assert
Assert.assertEquals(3, unitUnderTest.size());
Assert.assertEquals("1", unitUnderTest.get(0));
Assert.assertEquals("2", unitUnderTest.get(1));
Assert.assertEquals("3", unitUnderTest.get(2));
}