作者 crossoverJie

:recycle: Refactoring code.

@@ -54,4 +54,68 @@ public class SortArrayMapConsistentHashTest { @@ -54,4 +54,68 @@ public class SortArrayMapConsistentHashTest {
54 System.out.println(process); 54 System.out.println(process);
55 Assert.assertEquals("127.0.0.6",process); 55 Assert.assertEquals("127.0.0.6",process);
56 } 56 }
  57 +
  58 +
  59 + @Test
  60 + public void getFirstNodeValue4() {
  61 + AbstractConsistentHash map = new SortArrayMapConsistentHash() ;
  62 +
  63 + List<String> strings = new ArrayList<String>();
  64 + strings.add("1551253899106") ;
  65 + strings.add("45.78.28.220:9000:8081") ;
  66 + strings.add("45.78.28.220:9100:9081") ;
  67 +
  68 + String process = map.process(strings);
  69 +
  70 + System.out.println(process);
  71 + Assert.assertEquals("45.78.28.220:9000:8081",process);
  72 + }
  73 + @Test
  74 + public void getFirstNodeValue5() {
  75 + AbstractConsistentHash map = new SortArrayMapConsistentHash() ;
  76 +
  77 + List<String> strings = new ArrayList<String>();
  78 + strings.add("1551253899106") ;
  79 + strings.add("45.78.28.220:9000:8081") ;
  80 + strings.add("45.78.28.220:9100:9081") ;
  81 + strings.add("45.78.28.220:9100:10081") ;
  82 +
  83 + String process = map.process(strings);
  84 +
  85 + System.out.println(process);
  86 + Assert.assertEquals("45.78.28.220:9100:10081",process);
  87 + }
  88 +
  89 + @Test
  90 + public void getFirstNodeValue6() {
  91 + AbstractConsistentHash map = new SortArrayMapConsistentHash() ;
  92 +
  93 + List<String> strings = new ArrayList<String>();
  94 + strings.add("1551253899106") ;
  95 + strings.add("45.78.28.220:9000:8081") ;
  96 + strings.add("45.78.28.220:9100:9081") ;
  97 + strings.add("45.78.28.220:9100:10081") ;
  98 +
  99 + String process = map.process(strings);
  100 +
  101 + System.out.println(process);
  102 + Assert.assertEquals("45.78.28.220:9100:10081",process);
  103 + }
  104 + @Test
  105 + public void getFirstNodeValue7() {
  106 + AbstractConsistentHash map = new SortArrayMapConsistentHash() ;
  107 +
  108 + List<String> strings = new ArrayList<String>();
  109 + strings.add("1551253899106") ;
  110 + strings.add("45.78.28.220:9000:8081") ;
  111 + strings.add("45.78.28.220:9100:9081") ;
  112 + strings.add("45.78.28.220:9100:10081") ;
  113 + strings.add("45.78.28.220:9100:00081") ;
  114 +
  115 + String process = map.process(strings);
  116 +
  117 + System.out.println(process);
  118 + Assert.assertEquals("45.78.28.220:9100:10081",process);
  119 + }
  120 +
57 } 121 }