From 2307d150580a646c8315d403f78e582577082853 Mon Sep 17 00:00:00 2001 From: beiwei30 Date: Tue, 15 May 2018 10:22:10 +0800 Subject: [PATCH] unit test for SimpleDataStore --- .../store/support/SimpleDataStoreTest.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/store/support/SimpleDataStoreTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/store/support/SimpleDataStoreTest.java index 42de80d517e..0b81a9ad670 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/store/support/SimpleDataStoreTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/store/support/SimpleDataStoreTest.java @@ -18,14 +18,18 @@ import org.junit.Test; +import java.util.Map; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class SimpleDataStoreTest { - SimpleDataStore dataStore = new SimpleDataStore(); + private SimpleDataStore dataStore = new SimpleDataStore(); @Test - public void testPut_Get() throws Exception { + public void testPutGet() throws Exception { assertNull(dataStore.get("xxx", "yyy")); dataStore.put("name", "key", "1"); @@ -42,4 +46,15 @@ public void testRemove() throws Exception { dataStore.remove("name", "key"); assertNull(dataStore.get("name", "key")); } + + @Test + public void testGetComponent() throws Exception { + Map map = dataStore.get("component"); + assertTrue(map != null && map.isEmpty()); + dataStore.put("component", "key", "value"); + map = dataStore.get("component"); + assertTrue(map != null && map.size() == 1); + dataStore.remove("component", "key"); + assertNotEquals(map, dataStore.get("component")); + } }