### Question:
SelectMessageQueueByHash implements MessageQueueSelector { @Override public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) { int value = arg.hashCode(); if (value < 0) { value = Math.abs(value); } value = value % mqs.size(); return mqs.get(value); }  @Override MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg);  }### Answer:
@Test public void testSelect() throws Exception { SelectMessageQueueByHash selector = new SelectMessageQueueByHash(); Message message = new Message(topic, new byte[] {}); List<MessageQueue> messageQueues = new ArrayList<>(); for (int i = 0; i < 10; i++) { MessageQueue messageQueue = new MessageQueue(topic, "DefaultBroker", i); messageQueues.add(messageQueue); } String orderId = "123"; String anotherOrderId = "234"; MessageQueue selected = selector.select(messageQueues, message, orderId); assertThat(selector.select(messageQueues, message, anotherOrderId)).isNotEqualTo(selected); }
@Test public void testSelect() throws Exception { SelectMessageQueueByHash selector = new SelectMessageQueueByHash(); Message message = new Message(topic, new byte[] {}); List<MessageQueue> messageQueues = new ArrayList<MessageQueue>(); for (int i = 0; i < 10; i++) { MessageQueue messageQueue = new MessageQueue(topic, "DefaultBroker", i); messageQueues.add(messageQueue); } String orderId = "123"; String anotherOrderId = "234"; MessageQueue selected = selector.select(messageQueues, message, orderId); assertThat(selector.select(messageQueues, message, anotherOrderId)).isNotEqualTo(selected); }