From 753eb6961b6face1992866b341f36fa8b2768ac6 Mon Sep 17 00:00:00 2001 From: "Dylan.Liu" Date: Tue, 19 Jan 2021 15:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=20jira=20=E4=BB=BB=E5=8A=A1=20fix:=20?= =?UTF-8?q?=20=E4=B9=8B=E5=89=8D=E7=9A=84commit=E6=97=A0=E6=95=85=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1,=E9=87=8D=E6=9E=84=E5=86=85=E5=BF=83=E8=A1=A5?= =?UTF-8?q?=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cluster/state/BaseStandAloneStore.java | 17 +++++++++ .../api/cluster/state/FineCollectionsKit.java | 20 ++++++++++ .../cluster/state/StateServerConfigKit.java | 9 +++++ .../cluster/state/FineCollectionsKitTest.java | 20 ++++++++++ .../cluster/state/FineJedisPoolKitTest.java | 2 +- .../api/cluster/state/RedisConfigKitTest.java | 4 +- .../cluster/state/StandAloneJedisKitTest.java | 2 +- .../state/StateServerConfigKitTest.java | 17 +++++++-- .../cluster/state/StoreTemplateKitTest.java | 38 +++++++++++++++++++ 9 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/fanruan/api/cluster/state/BaseStandAloneStore.java create mode 100644 src/main/java/com/fanruan/api/cluster/state/FineCollectionsKit.java create mode 100644 src/test/java/com/fanruan/api/cluster/state/FineCollectionsKitTest.java create mode 100644 src/test/java/com/fanruan/api/cluster/state/StoreTemplateKitTest.java diff --git a/src/main/java/com/fanruan/api/cluster/state/BaseStandAloneStore.java b/src/main/java/com/fanruan/api/cluster/state/BaseStandAloneStore.java new file mode 100644 index 0000000..6fc5fac --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/state/BaseStandAloneStore.java @@ -0,0 +1,17 @@ +package com.fanruan.api.cluster.state; + +import com.fr.store.impl.accessor.api.impl.StandAloneStore; +import com.fr.third.redis.clients.jedis.Jedis; + +/** + * 单机Redis API层. + * + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2021/1/18 + */ +public class BaseStandAloneStore extends StandAloneStore { + public BaseStandAloneStore(Jedis jedis) { + super(jedis); + } +} 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..a1d9825 --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/state/FineCollectionsKit.java @@ -0,0 +1,20 @@ +package com.fanruan.api.cluster.state; + +import com.fr.collections.FineCollections; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2021/1/18 + */ +public class FineCollectionsKit { + + public FineCollectionsKit() {} + + /** + * 销毁集群集合 + */ + public static void destroy() { + FineCollections.getInstance().getClient().destroy(); + } +} 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..4be2a8c 100644 --- a/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java +++ b/src/main/java/com/fanruan/api/cluster/state/StateServerConfigKit.java @@ -29,6 +29,15 @@ public class StateServerConfigKit { StateServerConfig.getInstance().setShareMode(isShareMode); } + /** + * 是否是共享仓库 + * @return 是否是共享仓库 + */ + public static boolean isShareMode() { + + return StateServerConfig.getInstance().isShareMode(); + } + /** * 设置状态服务器类型 * @param type 状态服务器类型 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..51abc7d --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/state/FineCollectionsKitTest.java @@ -0,0 +1,20 @@ +package com.fanruan.api.cluster.state; + +import com.fr.collections.api.FineCollectionClient; +import com.fr.collections.api.FineCollectionClientWrapper; +import org.junit.Test; + +/** + * @author Dylan.Liu + * @version 10.0 + * Created by Dylan.Liu on 2021/1/19 + */ +public class FineCollectionsKitTest { + + @Test + public void testGetClient() throws Exception { + // test + FineCollectionsKit.destroy(); + } + +} 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..c5a56d1 --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/state/StoreTemplateKitTest.java @@ -0,0 +1,38 @@ +package com.fanruan.api.cluster.state; + +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 2021/1/19 + */ +@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(); + } +}