From b3961cdcc595ab799a250fd4b1e7af53ef1c7749 Mon Sep 17 00:00:00 2001 From: liuyuanmu Date: Tue, 19 Nov 2019 22:09:34 +0800 Subject: [PATCH] add test for rocketdb URI_PATTER --- .../impl/rocksdb/RocksDBStorageTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/storage/storage-rocksdb/src/test/java/test/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBStorageTest.java b/source/storage/storage-rocksdb/src/test/java/test/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBStorageTest.java index c930d961..d33b809f 100644 --- a/source/storage/storage-rocksdb/src/test/java/test/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBStorageTest.java +++ b/source/storage/storage-rocksdb/src/test/java/test/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBStorageTest.java @@ -1,5 +1,6 @@ package test.com.jd.blockchain.storage.service.impl.rocksdb; +import static com.jd.blockchain.storage.service.impl.rocksdb.RocksDBConnectionFactory.URI_PATTER; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -7,6 +8,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.File; +import java.util.HashMap; +import java.util.Map; import org.junit.Test; @@ -133,4 +136,18 @@ public class RocksDBStorageTest { return dbURI; } + @Test + // test rocksDB uri patter + public void testRocksDBUriPatter() { + Map cases = new HashMap<>(); + cases.put("rocksdb:///home/peer0/rocksdb", true); + cases.put("rocksdb://D:\\home\\rocksdb", true); + cases.put("rocksdb://\\home\\rocksdb", false); + cases.put("rocksdb://:\\home\\rocksdb", false); + cases.put("rocksdb://D:\\home\\", true); + cases.put("rocksdb:///home/peer0/", true); + for(Map.Entry entity : cases.entrySet()) { + assertEquals(URI_PATTER.matcher(entity.getKey()).matches(), entity.getValue()); + } + } }