public void testLongArrays() throws Exception { for (int length : new int[] { 0xFF, 0x100, 0x101, 0x102, 0x100FF, 0x10100, 0x10101, 0x10102 }) { String[] array = new String[length]; // test null marshallAndAssertArrayEquality(array); // test filled Arrays.fill(array, "a"); marshallAndAssertArrayEquality(array); } }
public void testByteArray() throws Exception { byte[] bytes = new byte[]{1, 2, 3}; marshallAndAssertByteArrayEquality(bytes); }
public void testImmutableResponseMarshalling() throws Exception { marshallAndAssertEquality(UnsuccessfulResponse.EMPTY); marshallAndAssertEquality(UnsureResponse.INSTANCE); }
public void testExternalAndInternalWithOffset() throws Exception { PojoWithExternalAndInternal obj = new PojoWithExternalAndInternal(new Human().age(23), "value"); byte[] bytes = marshaller.objectToByteBuffer(obj); bytes = prependBytes(new byte[]{1, 2, 3}, bytes); Object readObj = marshaller.objectFromByteBuffer(bytes, 3, bytes.length); assertEquals(obj, readObj); }
public void testSingleFlagMarshalling() throws Exception { marshallAndAssertEquality(Flag.FORCE_SYNCHRONOUS); }
public void testListArray() throws Exception { List<Integer>[] numbers = new List[]{Arrays.asList(1), Arrays.asList(2)}; marshallAndAssertArrayEquality(numbers); }
public void testEnumSetMultiElementMarshalling() throws Exception { marshallAndAssertEquality(EnumSet.of(Flag.FORCE_SYNCHRONOUS, Flag.FORCE_ASYNCHRONOUS)); }
public void testArrays() throws Exception { marshallAndAssertArrayEquality(new Object[] { }); marshallAndAssertArrayEquality(new String[] { null, "foo" }); marshallAndAssertArrayEquality(new String[] { "foo", "bar" }); marshallAndAssertArrayEquality(new Object[] { 1.2, 3.4 }); marshallAndAssertArrayEquality(new Pojo[] { }); marshallAndAssertArrayEquality(new Pojo[] { null }); marshallAndAssertArrayEquality(new Pojo[] { null, null }); marshallAndAssertArrayEquality(new Pojo[] { new Pojo(1, false), new Pojo(2, true) }); marshallAndAssertArrayEquality(new Pojo[] { new Pojo(3, false), null }); marshallAndAssertArrayEquality(new Pojo[] { new Pojo(4, false), new PojoExtended(5, true) }); marshallAndAssertArrayEquality(new I[] { new Pojo(6, false), new Pojo(7, true) }); marshallAndAssertArrayEquality(new I[] { new Pojo(8, false), new PojoExtended(9, true) }); marshallAndAssertArrayEquality(new I[] { new Pojo(10, false), new PojoWithExternalizer(11, false) }); marshallAndAssertArrayEquality(new PojoWithExternalizer[] { new PojoWithExternalizer(12, true), new PojoWithExternalizer(13, false) }); marshallAndAssertArrayEquality(new I[] { new PojoWithExternalizer(14, false), new PojoWithExternalizer(15, true)}); marshallAndAssertArrayEquality(new PojoWithMultiExternalizer[] { new PojoWithMultiExternalizer(16, true), new PojoWithMultiExternalizer(17, false) }); marshallAndAssertArrayEquality(new I[] { new PojoWithMultiExternalizer(18, false), new PojoWithExternalizer(19, true)}); marshallAndAssertArrayEquality(new I[] { new PojoWithMultiExternalizer(20, false), new PojoWithMultiExternalizer(21, true)}); marshallAndAssertArrayEquality(new Object[] { new PojoWithMultiExternalizer(22, false), new PojoWithMultiExternalizer(23, true)}); marshallAndAssertArrayEquality(new Object[] { new PojoWithExternalizer(24, false), new PojoWithExternalizer(25, true)}); marshallAndAssertArrayEquality(new Object[] { new PojoAnnotated(26, false), "foo"}); marshallAndAssertArrayEquality(new Object[] { new PojoAnnotated(27, false), new PojoAnnotated(28, true)}); marshallAndAssertArrayEquality(new PojoAnnotated[] { new PojoAnnotated(27, false), new PojoAnnotated(28, true)}); marshallAndAssertArrayEquality(new PojoAnnotated[] { null, null }); }
public void testEnumSetSingleElementMarshalling() throws Exception { marshallAndAssertEquality(EnumSet.of(Flag.FORCE_SYNCHRONOUS)); }
public void testSetMarshalling() throws Exception { Set<Integer> s1 = new HashSet<>(); Set<Integer> s2 = new TreeSet<>(); for (int i = 0; i < 10; i++) { Integer integ = 1000 * i; s1.add(integ); s2.add(integ); } marshallAndAssertEquality(s1); marshallAndAssertEquality(s2); }
public void testConcurrentHashMap() throws Exception { ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>(); map.put(1, "v1"); map.put(2, "v2"); map.put(3, "v3"); marshallAndAssertEquality(map); }
public void testInternalCacheEntryMarshalling() throws Exception { ImmortalCacheEntry entry1 = (ImmortalCacheEntry) TestInternalCacheEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), -1); marshallAndAssertEquality(entry1); MortalCacheEntry entry2 = (MortalCacheEntry) TestInternalCacheEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), -1); marshallAndAssertEquality(entry2); TransientCacheEntry entry3 = (TransientCacheEntry) TestInternalCacheEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), 4000000); marshallAndAssertEquality(entry3); TransientMortalCacheEntry entry4 = (TransientMortalCacheEntry) TestInternalCacheEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), 4000000); marshallAndAssertEquality(entry4); }
public void testFlagMarshalling() throws Exception { marshallAndAssertEquality(Arrays.asList(Flag.values())); }
public void testSerializableWithAnnotation() throws Exception { marshallAndAssertEquality(new PojoWithSerializeWith(20, "k2")); }
public void testListMarshalling() throws Exception { List<GlobalTransaction> l1 = new ArrayList<>(); List<GlobalTransaction> l2 = new LinkedList<>(); for (int i = 0; i < 10; i++) { JGroupsAddress jGroupsAddress = new JGroupsAddress(new IpAddress("localhost", 1000 * i)); GlobalTransaction gtx = gtf.newGlobalTransaction(jGroupsAddress, false); l1.add(gtx); l2.add(gtx); } marshallAndAssertEquality(l1); marshallAndAssertEquality(l2); }
public void testMarshallObjectThatContainsACustomReadObjectMethod() throws Exception { ObjectThatContainsACustomReadObjectMethod obj = new ObjectThatContainsACustomReadObjectMethod(); obj.anObjectWithCustomReadObjectMethod = new CustomReadObjectMethod(); marshallAndAssertEquality(obj); }
public void testPojoWithJBossMarshallingExternalizer(Method m) throws Exception { PojoWithJBossExternalize pojo = new PojoWithJBossExternalize(27, k(m)); marshallAndAssertEquality(pojo); }
public void testJGroupsAddressMarshalling() throws Exception { JGroupsAddress address = new JGroupsAddress(UUID.randomUUID()); marshallAndAssertEquality(address); }
public void testMapMarshalling() throws Exception { Map<Integer, GlobalTransaction> m1 = new HashMap<>(); Map<Integer, GlobalTransaction> m2 = new TreeMap<>(); Map<Integer, GlobalTransaction> m3 = new HashMap<>(); Map<Integer, GlobalTransaction> m4 = new FastCopyHashMap<>(); for (int i = 0; i < 10; i++) { JGroupsAddress jGroupsAddress = new JGroupsAddress(UUID.randomUUID()); GlobalTransaction gtx = gtf.newGlobalTransaction(jGroupsAddress, false); m1.put(1000 * i, gtx); m2.put(1000 * i, gtx); m4.put(1000 * i, gtx); } Map m5 = Immutables.immutableMapWrap(m3); marshallAndAssertEquality(m1); marshallAndAssertEquality(m2); byte[] bytes = marshaller.objectToByteBuffer(m4); Map<Integer, GlobalTransaction> m4Read = (Map<Integer, GlobalTransaction>) marshaller.objectFromByteBuffer(bytes); for (Map.Entry<Integer, GlobalTransaction> entry : m4.entrySet()) { assert m4Read.get(entry.getKey()).equals(entry.getValue()) : "Writen[" + entry.getValue() + "] and read[" + m4Read.get(entry.getKey()) + "] objects should be the same"; } marshallAndAssertEquality(m5); }
public void testSingletonListMarshalling() throws Exception { GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(UUID.randomUUID()), false); List<GlobalTransaction> l = Collections.singletonList(gtx); marshallAndAssertEquality(l); }