From 798fcd2107b4f990afde1a7c2b2bca01d5df1664 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 26 Jun 2019 23:08:50 -0400 Subject: [PATCH] Add some more comprehensive redis serialization tests --- .../jbgjob/RedisSchedulerTest.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java b/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java index 7535918..d998c21 100644 --- a/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java +++ b/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java @@ -21,6 +21,9 @@ package com.moparisthebest.jbgjob; import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.*; public class RedisSchedulerTest extends AbstractSchedulerTests { @@ -28,4 +31,86 @@ public class RedisSchedulerTest extends AbstractSchedulerTests { public static void setUp() throws Throwable { bg = new RedisScheduler(); } + + @Test + public void testSerialization() throws Throwable { + bg.testSerialization(new JacksonTest(arrayList(new InList(1L)))); + bg.testSerialization(new JacksonTest(Arrays.asList(new InList(1L)))); + bg.testSerialization(new JacksonTest(Collections.singletonList(new InList(1L)))); + + //bg.testSerialization(new JacksonTest(Collections.singleton(new InList(1L)))); + + //bg.testSerialization(new JacksonTestMap(Collections.singletonMap(1L, new InList(1L)))); + } + + + public static List arrayList(T o) { + final List ret = new ArrayList<>(); + ret.add(o); + return ret; + } + + public static class InList { + private Long a; + + public InList(Long a) { + this.a = a; + } + + public InList() { + } + + public Long getA() { + return a; + } + + public void setA(final Long a) { + this.a = a; + } + + @Override + public String toString() { + return "InList{" + + "a=" + a + + '}'; + } + } + + public static class JacksonTest { + public final Collection inLists; + + public JacksonTest() { + this(null); + } + + public JacksonTest(final Collection inLists) { + this.inLists = inLists; + } + + @Override + public String toString() { + return "JacksonTest{" + + "inLists=" + inLists + + '}'; + } + } + + public static class JacksonTestMap { + public final Map inLists; + + public JacksonTestMap() { + this(null); + } + + public JacksonTestMap(final Map inLists) { + this.inLists = inLists; + } + + @Override + public String toString() { + return "JacksonTestMap{" + + "inLists=" + inLists + + '}'; + } + } }