/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pinot.transport.common;

import org.apache.pinot.common.response.ServerInstance;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;


public class ServerInstanceTest {

  @Test
  public void testServerInstance() {
    // Same local host name and port
    assertEquals(new ServerInstance("localhost", 8080), new ServerInstance("localhost", 8080));

    // Same IP address host and port
    assertEquals(new ServerInstance("127.0.0.1", 8080), new ServerInstance("127.0.0.1", 8080));

    // Same other host name and port
    assertEquals(new ServerInstance("test-host", 8080), new ServerInstance("test-host", 8080));

    // Same other IP address host and port
    assertEquals(new ServerInstance("192.168.0.1", 8080), new ServerInstance("192.168.0.1", 8080));

    // Same local host and port, one with host name and one with IP address
    assertEquals(new ServerInstance("localhost", 8080), new ServerInstance("127.0.0.1", 8080));

    // Same host but different port
    assertNotEquals(new ServerInstance("localhost", 8081), new ServerInstance("localhost", 8082));

    // Same port but different host
    assertNotEquals(new ServerInstance("foo", 8080), new ServerInstance("bar", 8080));
  }
}

@@ -846,16 +846,45 @@
 ommon;%0A%0A
+import java.net.InetAddress;%0A
 import o
@@ -931,16 +931,16 @@
 stance;%0A
-
 import o
@@ -1142,16 +1142,39 @@
 stance()
+%0A      throws Exception
  %7B%0A    /
@@ -1314,16 +1314,27 @@
 // Same 
+local host 
 IP addre
@@ -1328,37 +1328,32 @@
 host IP address 
-host 
 and port%0A    ass
@@ -1594,16 +1594,21 @@
 e other 
+host 
 IP addre
@@ -1610,21 +1610,16 @@
 address 
-host 
 and port
@@ -1762,25 +1762,26 @@
 ne with 
-host name
+IP address
  and one
@@ -1786,26 +1786,25 @@
 ne with 
-IP address
+host name
 %0A    ass
@@ -1829,33 +1829,33 @@
 erInstance(%22
-localhost
+127.0.0.1
 %22, 8080), ne
@@ -1843,32 +1843,40 @@
 7.0.0.1%22, 8080),
+%0A       
  new ServerInsta
@@ -1875,35 +1875,72 @@
 verInstance(
-%22127.0.0.1%22
+InetAddress.getByName(%22127.0.0.1%22).getHostName()
 , 8080));%0A%0A 

Fix ServerInstanceTest (#4442)