mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-24 04:52:05 +01:00
Fix shouldPreserveAddressOrderOnInsertions test
The test failed because the ArrayList - in contrast to the underlying Set - did not check for duplicates on insert. Under certain circumstances this lead to an index out of bounds exception because the list in the test contained duplicated entries which were not present in the set of the Socks5Proxy. I fixed the issue by only inserting the address when it was not in the list before.
This commit is contained in:
parent
08a4ee4eb2
commit
847a39b6ab
1 changed files with 9 additions and 4 deletions
|
@ -102,10 +102,15 @@ public class Socks5ProxyTest {
|
||||||
@Test
|
@Test
|
||||||
public void shouldPreserveAddressOrderOnInsertions() {
|
public void shouldPreserveAddressOrderOnInsertions() {
|
||||||
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
|
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
|
||||||
List<String> addresses = new ArrayList<String>(proxy.getLocalAddresses());
|
List<String> addresses = new ArrayList<>(proxy.getLocalAddresses());
|
||||||
addresses.add("1");
|
|
||||||
addresses.add("2");
|
for (int i = 1 ; i <= 3; i++) {
|
||||||
addresses.add("3");
|
String addr = Integer.toString(i);
|
||||||
|
if (!addresses.contains(addr)) {
|
||||||
|
addresses.add(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (String address : addresses) {
|
for (String address : addresses) {
|
||||||
proxy.addLocalAddress(address);
|
proxy.addLocalAddress(address);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue