Utils { public static int getPort(byte[] bytes) { return ((bytes[0] << 8) & 0x0000ff00) | (bytes[1] & 0x000000ff); }  static String getNeighbour(String s1, String s2); static String randomId(); static String getRandomString(int size); static byte[] enBencode(Map<String, Object> map); static Map<String, Object> deBencode(byte[] data); static List<Node> decodeNodes(String encodeNodes); static byte[] getByteArray(byte[] bytes, int start, int end); static int getPort(byte[] bytes); static List<Node> fixedNodes; }
@Test public void testGetPort() { byte[] bytes = new byte[2]; bytes[0] = -3; bytes[1] = 40; assertEquals(64808, Utils.getPort(bytes)); }