mirror of
https://github.com/actiontech/dble.git
synced 2026-05-01 03:51:06 -05:00
add unitTest (#2921)
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2019 ActionTech.
|
||||
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
package com.actiontech.dble.route.function;
|
||||
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class PartitionByJumpConsistentHashTest {
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
PartitionByJumpConsistentHash partition = new PartitionByJumpConsistentHash();
|
||||
partition.setHashSlice("0:0");
|
||||
partition.setPartitionCount(5);
|
||||
partition.init();
|
||||
Assert.assertEquals(1, (int) partition.calculate("8"));
|
||||
Assert.assertEquals(4, (int) partition.calculate("5"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
PartitionByJumpConsistentHash partition = new PartitionByJumpConsistentHash();
|
||||
partition.setHashSlice("0:0");
|
||||
partition.setPartitionCount(4);
|
||||
partition.init();
|
||||
Assert.assertEquals(1, (int) partition.calculate("8"));
|
||||
Assert.assertEquals(0, (int) partition.calculate("5"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user