@Test public void test1() { PartitionByPattern autoPartition = new PartitionByPattern(); autoPartition.setPatternValue(256); autoPartition.setDefaultNode(2); autoPartition.setMapFile("partition-pattern.txt"); autoPartition.init(); String idVal = "0"; Assert.assertEquals(true, 7 == autoPartition.calculate(idVal)); idVal = "45a"; Assert.assertEquals(true, 2 == autoPartition.calculate(idVal)); Integer[] err1 = autoPartition.calculateRange("45a", "0"); Assert.assertEquals(true, 8 == err1.length); Integer[] err2 = autoPartition.calculateRange("45", "0"); Assert.assertEquals(true, 0 == err2.length); Integer[] normal = autoPartition.calculateRange("0", "45"); Assert.assertEquals(true, 3 == normal.length); Integer[] type1 = autoPartition.calculateRange("1", "45"); Assert.assertEquals(true, 2 == type1.length); Integer[] type2 = autoPartition.calculateRange("200", "260"); Assert.assertEquals(true, 3 == type2.length); Integer[] type3 = autoPartition.calculateRange("200", "456"); Assert.assertEquals(true, 8 == type3.length); }