diff --git a/src/main/java/com/fanruan/api/cluster/state/FineCollectionsKit.java b/src/main/java/com/fanruan/api/cluster/state/FineCollectionsKit.java new file mode 100644 index 0000000..72c1794 --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/state/FineCollectionsKit.java @@ -0,0 +1,16 @@ +package com.fanruan.api.cluster.state; + +import com.fr.collections.FineCollections; +import com.fr.collections.api.FineCollectionClient; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2020/10/16 + */ +public class FineCollectionsKit { + + public static FineCollectionClient getClient() { + return FineCollections.getInstance().getClient(); + } +} diff --git a/src/main/java/com/fanruan/api/cluster/state/RedisConfigKit.java b/src/main/java/com/fanruan/api/cluster/state/RedisConfigKit.java index 6a9407c..d977a80 100644 --- a/src/main/java/com/fanruan/api/cluster/state/RedisConfigKit.java +++ b/src/main/java/com/fanruan/api/cluster/state/RedisConfigKit.java @@ -14,7 +14,6 @@ public class RedisConfigKit { * @return Redis 里表名的统一的前缀 */ public static String getTableNamePrefix() { - return RedisConfig.getInstance().getTableNamePrefix(); } @@ -23,7 +22,6 @@ public class RedisConfigKit { * @return Redis 里过期 key 删除间隔时间 */ public static int getExpireStateRemoveInterval() { - return RedisConfig.getInstance().getExpireStateRemoveInterval(); } } diff --git a/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java b/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java index 1dd6be0..6339079 100644 --- a/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java +++ b/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java @@ -16,7 +16,6 @@ public class StateServerConfigKit { * @return 当前状态服务器类型 */ public static String getType() { - return StateServerConfig.getInstance().getType(); } @@ -25,16 +24,18 @@ public class StateServerConfigKit { * @param isShareMode 当前是否开启状态服务器 */ public static void setShareMode(boolean isShareMode) { - StateServerConfig.getInstance().setShareMode(isShareMode); } + public static boolean isShareMode() { + return StateServerConfig.getInstance().isShareMode(); + } + /** * 设置状态服务器类型 * @param type 状态服务器类型 */ public static void setType(String type) { - StateServerConfig.getInstance().setType(type); } @@ -43,7 +44,6 @@ public class StateServerConfigKit { * @return StateServerConfig 类对象 */ public static Class getConfigClass() { - return StateServerConfig.class; } } diff --git a/src/main/java/com/fanruan/api/cluster/state/StoreTemplateKit.java b/src/main/java/com/fanruan/api/cluster/state/StoreTemplateKit.java new file mode 100644 index 0000000..79727e2 --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/state/StoreTemplateKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.cluster.state; + +import com.fr.store.impl.StoreTemplate; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2020/10/16 + */ +public class StoreTemplateKit { + + public static void close(){ + StoreTemplate.getInstance().close(); + } +} diff --git a/src/test/java/com/fanruan/api/cluster/state/FineCollectionsKitTest.java b/src/test/java/com/fanruan/api/cluster/state/FineCollectionsKitTest.java new file mode 100644 index 0000000..69e2ad2 --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/state/FineCollectionsKitTest.java @@ -0,0 +1,24 @@ +package com.fanruan.api.cluster.state; + +import com.fr.collections.api.FineCollectionClient; +import com.fr.collections.api.FineCollectionClientWrapper; +import org.junit.Test; + +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2020/10/23 + */ +public class FineCollectionsKitTest { + + @Test + public void testGetClient() throws Exception { + // test + FineCollectionClient client = FineCollectionsKit.getClient(); + + assertTrue(client instanceof FineCollectionClientWrapper); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java b/src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java index 38f3124..63c4c3d 100644 --- a/src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java +++ b/src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java @@ -19,7 +19,7 @@ import static org.easymock.EasyMock.mock; public class FineJedisPoolKitTest { @Test - public void TestSetRealClient() { + public void testSetRealClient() { FineJedisPoolKit.setRealClient(new FineStoreWrapper() { diff --git a/src/test/java/com/fanruan/api/cluster/state/RedisConfigKitTest.java b/src/test/java/com/fanruan/api/cluster/state/RedisConfigKitTest.java index 077c45c..162abea 100644 --- a/src/test/java/com/fanruan/api/cluster/state/RedisConfigKitTest.java +++ b/src/test/java/com/fanruan/api/cluster/state/RedisConfigKitTest.java @@ -13,7 +13,7 @@ import org.junit.Test; public class RedisConfigKitTest extends Prepare { @Test - public void TestGetTableNamePrefix() { + public void testGetTableNamePrefix() { RedisConfig.getInstance().setTableNamePrefix("test_table name_prefix"); Assert.assertEquals("test_table name_prefix", RedisConfigKit.getTableNamePrefix()); @@ -23,7 +23,7 @@ public class RedisConfigKitTest extends Prepare { } @Test - public void TestGetExpireStateRemoveInterval() { + public void testGetExpireStateRemoveInterval() { RedisConfig.getInstance().setExpireStateRemoveInterval(111); Assert.assertEquals(111, RedisConfig.getInstance().getExpireStateRemoveInterval()); diff --git a/src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java b/src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java index e871ad1..2e73347 100644 --- a/src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java +++ b/src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java @@ -18,7 +18,7 @@ import static org.easymock.EasyMock.mock; public class StandAloneJedisKitTest { @Test - public void TestCreateStandAloneJedis() { + public void testCreateStandAloneJedis() { Jedis mockJedis = mock(Jedis.class); expect(mockJedis.type(anyObject(byte[].class))).andReturn("test_echo"); diff --git a/src/test/java/com/fanruan/api/cluster/state/StateServerConfigKitTest.java b/src/test/java/com/fanruan/api/cluster/state/StateServerConfigKitTest.java index 1818c99..9ec9a10 100644 --- a/src/test/java/com/fanruan/api/cluster/state/StateServerConfigKitTest.java +++ b/src/test/java/com/fanruan/api/cluster/state/StateServerConfigKitTest.java @@ -13,7 +13,7 @@ import org.junit.Test; public class StateServerConfigKitTest extends Prepare { @Test - public void TestGetType() { + public void testGetType() { StateServerConfig.getInstance().setType("test_type"); Assert.assertEquals("test_type", StateServerConfigKit.getType()); @@ -23,7 +23,7 @@ public class StateServerConfigKitTest extends Prepare { } @Test - public void TestSetShareMode() { + public void testSetShareMode() { StateServerConfigKit.setShareMode(true); Assert.assertTrue(StateServerConfig.getInstance().isShareMode()); @@ -33,7 +33,7 @@ public class StateServerConfigKitTest extends Prepare { } @Test - public void TestSetType() { + public void testSetType() { StateServerConfigKit.setType("test_type3"); Assert.assertEquals("test_type3", StateServerConfig.getInstance().getType()); @@ -43,8 +43,17 @@ public class StateServerConfigKitTest extends Prepare { } @Test - public void TestGetConfigClass() { + public void testGetConfigClass() { Assert.assertEquals(StateServerConfigKit.getConfigClass(), StateServerConfig.class); } + + @Test + public void testIsShareMode() { + StateServerConfig.getInstance().setShareMode(false); + Assert.assertFalse(StateServerConfigKit.isShareMode()); + + StateServerConfig.getInstance().setShareMode(true); + Assert.assertTrue(StateServerConfigKit.isShareMode()); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/cluster/state/StoreTemplateKitTest.java b/src/test/java/com/fanruan/api/cluster/state/StoreTemplateKitTest.java new file mode 100644 index 0000000..c8d40ba --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/state/StoreTemplateKitTest.java @@ -0,0 +1,39 @@ +package com.fanruan.api.cluster.state; + +import com.fr.ftp.client.FineSFTPClient; +import com.fr.store.impl.accessor.FineStorePool; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2020/10/23 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({FineStorePool.class}) +public class StoreTemplateKitTest { + + @Test + public void testClose() throws Exception { + // test + FineStorePool fineStorePool = mock(FineStorePool.class); + fineStorePool.close(); + expectLastCall().times(1); + + PowerMock.mockStaticPartial(FineStorePool.class, "getPool"); + expect(FineStorePool.getPool()).andReturn(fineStorePool).times(1); + + PowerMock.replayAll(); + + StoreTemplateKit.close(); + + PowerMock.verifyAll(); + } +} \ No newline at end of file