forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-7582: Update initlocator list (apache#4488)
* GEODE-7582: Update initlocator list * GEODE-7582: update after rebase * GEODE-7582: Updated initialLocators list * GEODE-7582: Update LocatorAddress * GEODE-7582: update of LocatorAddress after comments * GEODE-7582: Update solution * GEODE-7582: removed unused methods and tests * GEODE-7582: added test for LocatorAddress * GEODE-7582: added more tests * GEODE-7582: update dependencies * GEODE-7582: update tests after comments
- Loading branch information
Showing
5 changed files
with
153 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...ver/src/test/java/org/apache/geode/distributed/internal/tcpserver/LocatorAddressTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* 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.geode.distributed.internal.tcpserver; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
import org.junit.Test; | ||
|
||
public class LocatorAddressTest { | ||
|
||
/** | ||
* Test that getSocketInentAddress returns resolved InetSocketAddress | ||
*/ | ||
@Test | ||
public void Test_getSocketInentAddress_returns_resolved_SocketAddress() { | ||
InetSocketAddress host1address = new InetSocketAddress(8080); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "localhost"); | ||
|
||
InetSocketAddress actual = locator1.getSocketInetAddress(); | ||
|
||
assertThat(actual.isUnresolved()).isFalse(); | ||
} | ||
|
||
/** | ||
* Test that getSocketInentAddress returns unresolved InetSocketAddress | ||
*/ | ||
@Test | ||
public void Test_getSocketInentAddress_returns_unresolved_SocketAddress() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("fakelocalhost", 8090); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "fakelocalhost"); | ||
|
||
InetSocketAddress actual = locator1.getSocketInetAddress(); | ||
|
||
assertThat(actual.isUnresolved()).isTrue(); | ||
} | ||
|
||
/** | ||
* Test whether LocatorAddress are equal, when created from resolved and unresolved | ||
* InetSocketAddress | ||
*/ | ||
@Test | ||
public void Test_equals_LocatorAddress_from_resolved_and_unresolved_SocketAddress() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("localhost", 8090); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "localhost"); | ||
|
||
InetSocketAddress host2address = locator1.getSocketInetAddress(); | ||
LocatorAddress locator2 = new LocatorAddress(host2address, "localhost"); | ||
|
||
assertThat(host1address.isUnresolved()).isTrue(); | ||
assertThat(host2address.isUnresolved()).isFalse(); | ||
assertThat(locator1.equals(locator2)).isTrue(); | ||
} | ||
|
||
@Test | ||
public void Test_getPort_returns_port() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("localhost", 8090); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "localhost"); | ||
assertThat(locator1.getPort()).isEqualTo(8090); | ||
} | ||
|
||
@Test | ||
public void Test_getHostName_returns_hostname() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("fakelocalhost", 8091); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "fakelocalhost"); | ||
assertThat(locator1.getHostName()).isEqualTo("fakelocalhost"); | ||
} | ||
|
||
@Test | ||
public void Test_hashCode_of_SocketAddress() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("fakelocalhost", 8091); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "fakelocalhost"); | ||
assertThat(locator1.hashCode()).isEqualTo(host1address.hashCode()); | ||
} | ||
|
||
@Test | ||
public void Test_toString_LocatorAddress() { | ||
InetSocketAddress host1address = InetSocketAddress.createUnresolved("fakelocalhost", 8091); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "fakelocalhost"); | ||
assertThat(locator1.toString()).contains("socketInetAddress"); | ||
} | ||
|
||
@Test | ||
public void Test_isIpString_for_LocatorAddress_constructed_from_IPstring() { | ||
InetSocketAddress host1address = new InetSocketAddress(8080); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "127.0.0.1"); | ||
assertThat(locator1.isIpString()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void Test_isIpString_for_LocatorAddress_constructed_from_hostname() { | ||
InetSocketAddress host1address = new InetSocketAddress(8080); | ||
LocatorAddress locator1 = new LocatorAddress(host1address, "localhost"); | ||
assertThat(locator1.isIpString()).isFalse(); | ||
} | ||
} |