changeset 473:629e5b412864

typo
author Devel 1
date Fri, 04 Aug 2017 13:37:22 +0200
parents cdff69867843
children db7bd7630fcf
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java stress-tester/src/main/java/com/passus/st/emitter/PortIgnoringSocketAddressProvider.java stress-tester/src/main/java/com/passus/st/emitter/PortSpecificSocketAddressProvider.java stress-tester/src/main/java/com/passus/st/emitter/RuleBasedSessionMapper.java stress-tester/src/main/java/com/passus/st/emitter/SocketAddressPorviderBase.java stress-tester/src/main/java/com/passus/st/emitter/SocketAddressProviderBase.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java stress-tester/src/test/java/com/passus/st/emitter/SocketAddressPorviderBaseTest.java stress-tester/src/test/java/com/passus/st/emitter/SocketAddressProviderBaseTest.java
diffstat 9 files changed, 233 insertions(+), 235 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java	Fri Aug 04 12:23:28 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java	Fri Aug 04 13:37:22 2017 +0200
@@ -16,10 +16,10 @@
     public static final ByteString[] PROXY_HEADERS = {
         ByteString.create("Forwarded"),
         ByteString.create("Proxy-Authorization"),
+        ByteString.create("Proxy-Connection"),
         ByteString.create("X-Forwarded-For"),
         ByteString.create("X-Forwarded-Host"),
-        ByteString.create("X-Forwarded-Proto"),
-        ByteString.create("Proxy-Connection")
+        ByteString.create("X-Forwarded-Proto")
     };
 
     public HttpRequestProxyHeadersCleanerFilter() {
--- a/stress-tester/src/main/java/com/passus/st/emitter/PortIgnoringSocketAddressProvider.java	Fri Aug 04 12:23:28 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/PortIgnoringSocketAddressProvider.java	Fri Aug 04 13:37:22 2017 +0200
@@ -7,7 +7,7 @@
  *
  * @author mikolaj.podbielski
  */
-public class PortIgnoringSocketAddressProvider extends SocketAddressPorviderBase {
+public class PortIgnoringSocketAddressProvider extends SocketAddressProviderBase {
 
     private final IpAddress[] addresses;
 
--- a/stress-tester/src/main/java/com/passus/st/emitter/PortSpecificSocketAddressProvider.java	Fri Aug 04 12:23:28 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/PortSpecificSocketAddressProvider.java	Fri Aug 04 13:37:22 2017 +0200
@@ -8,7 +8,7 @@
  *
  * @author mikolaj.podbielski
  */
-public class PortSpecificSocketAddressProvider extends SocketAddressPorviderBase {
+public class PortSpecificSocketAddressProvider extends SocketAddressProviderBase {
 
     private final IpAddress[] addresses;
     private final int[] ports;
--- a/stress-tester/src/main/java/com/passus/st/emitter/RuleBasedSessionMapper.java	Fri Aug 04 12:23:28 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/RuleBasedSessionMapper.java	Fri Aug 04 13:37:22 2017 +0200
@@ -51,7 +51,7 @@
         String orgAddrStr = rule.substring(0, pos).trim();
         SocketMatcher matcher;
         SocketAddress remoteAddress;
-        SocketAddressProvider bindAddressProvider = SocketAddressPorviderBase.ANY_SOCKET_PROVIDER;
+        SocketAddressProvider bindAddressProvider = SocketAddressProviderBase.ANY_SOCKET_PROVIDER;
 
         try {
             String[] parts = StringUtils.split(orgAddrStr, ":");
@@ -96,7 +96,7 @@
 
             try {
                 String bindRuleStr = left.substring(bindPos).trim();
-                bindAddressProvider = SocketAddressPorviderBase.create(bindRuleStr);
+                bindAddressProvider = SocketAddressProviderBase.create(bindRuleStr);
             } catch (Exception e) {
                 throw new ParseException(e.getMessage(), bindPos);
             }
@@ -145,7 +145,7 @@
         String orgAddrStr = rule.substring(0, pos).trim();
         SocketMatcher matcher;
         SocketAddress remoteAddress;
-        SocketAddressProvider bindAddressProvider = SocketAddressPorviderBase.ANY_SOCKET_PROVIDER;
+        SocketAddressProvider bindAddressProvider = SocketAddressProviderBase.ANY_SOCKET_PROVIDER;
 
         try {
             String[] parts = StringUtils.split(orgAddrStr, ":");
@@ -190,7 +190,7 @@
 
             try {
                 String bindRuleStr = left.substring(bindPos).trim();
-                bindAddressProvider = SocketAddressPorviderBase.create(bindRuleStr);
+                bindAddressProvider = SocketAddressProviderBase.create(bindRuleStr);
             } catch (Exception e) {
                 throw new ParseException(e.getMessage(), bindPos);
             }
--- a/stress-tester/src/main/java/com/passus/st/emitter/SocketAddressPorviderBase.java	Fri Aug 04 12:23:28 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-package com.passus.st.emitter;
-
-import com.passus.net.Ip4Address;
-import com.passus.net.IpAddress;
-import static com.passus.st.emitter.SocketAddressPorviderBase.parseAddresses;
-import static com.passus.st.emitter.SocketAddressPorviderBase.parsePorts;
-import java.util.ArrayList;
-
-public abstract class SocketAddressPorviderBase implements SocketAddressProvider {
-
-    public static final SocketAddressProvider ANY_SOCKET_PROVIDER
-            = new PortIgnoringSocketAddressProvider(Ip4Address.EMPTY_ADDRESS);
-
-    public static final int[] ALL_PORTS;
-
-    static {
-        final int size = (1 << 16) - 1;
-        ALL_PORTS = new int[size];
-        for (int i = 0; i < size; ++i) {
-            ALL_PORTS[i] = i + 1;
-        }
-    }
-
-    public static int[] parsePorts(String s) {
-        String[] parts = s.split(LIST_SEPARATOR);
-        ArrayList<Integer> ports = new ArrayList<>();
-        for (String part : parts) {
-            part = part.trim();
-            int rangeIdx = part.indexOf(RANGE_SEPARATOR);
-            if (rangeIdx < 0) {
-                ports.add(Integer.parseInt(part));
-            } else {
-                int begin = Integer.parseInt(part.substring(0, rangeIdx).trim());
-                int end = Integer.parseInt(part.substring(rangeIdx + 1).trim());
-                if (begin > end) {
-                    throw new IllegalArgumentException("Invalid range: " + part);
-                }
-                while (begin <= end) {
-                    ports.add(begin++);
-                }
-            }
-        }
-
-        int[] result = new int[ports.size()];
-        for (int i = 0; i < result.length; ++i) {
-            result[i] = ports.get(i);
-        }
-        return result;
-    }
-
-    public static IpAddress[] parseAddresses(String s) {
-        String[] parts = s.split(LIST_SEPARATOR);
-        ArrayList<IpAddress> addresses = new ArrayList<>();
-        for (String part : parts) {
-            part = part.trim();
-            int subnetIdx = part.indexOf('/');
-            int rangeIdx = part.indexOf(RANGE_SEPARATOR);
-            if (subnetIdx >= 0 && rangeIdx >= 0) {
-                throw new IllegalArgumentException();
-            } else if (subnetIdx >= 0) {
-                final int maskLength = 32 - Integer.parseInt(part.substring(subnetIdx + 1).trim());
-                final int addrMask = MASK << maskLength;
-                final int addrCount = 1 << maskLength;
-                if (maskLength > 8) {
-                    throw new IllegalArgumentException("Mask too wide");
-                }
-
-                // TODO: IPv6 support
-                Ip4Address addr = new Ip4Address(part.substring(0, subnetIdx).trim());
-                int baseAddrValue = addr.getIntValue() & addrMask;
-
-                for (int i = 0; i < addrCount; ++i) {
-                    addresses.add(new Ip4Address(baseAddrValue + i));
-                }
-            } else if (rangeIdx >= 0) {
-                Ip4Address beginAddr = new Ip4Address(part.substring(0, rangeIdx).trim());
-                Ip4Address endAddr = new Ip4Address(part.substring(rangeIdx + 1).trim());
-                int begin = beginAddr.getIntValue();
-                int end = endAddr.getIntValue();
-                if (begin > end) {
-                    throw new IllegalArgumentException("Invalid range: " + part);
-                }
-                if (end - begin >= 256) {
-                    throw new IllegalArgumentException("Range too wide");
-                }
-
-                // TODO: IPv6 support
-                while (begin <= end) {
-                    addresses.add(new Ip4Address(begin++));
-                }
-            } else {
-                addresses.add(IpAddress.parse(part));
-            }
-        }
-
-        return addresses.toArray(new IpAddress[addresses.size()]);
-    }
-
-    public static SocketAddressPorviderBase create(String spec) {
-        int separatorIdx = spec.indexOf(ADDR_PORT_SEPARATOR);
-        if (separatorIdx >= 0) {
-            IpAddress[] addresses = parseAddresses(spec.substring(0, separatorIdx));
-            String portSpec = spec.substring(separatorIdx + 1);
-            if (portSpec.equals("*")) {
-                return new PortSpecificSocketAddressProvider(addresses, ALL_PORTS);
-            } else {
-                int[] ports = parsePorts(portSpec);
-                return new PortSpecificSocketAddressProvider(addresses, ports);
-            }
-        } else {
-            IpAddress[] addresses = parseAddresses(spec);
-            return new PortIgnoringSocketAddressProvider(addresses);
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester/src/main/java/com/passus/st/emitter/SocketAddressProviderBase.java	Fri Aug 04 13:37:22 2017 +0200
@@ -0,0 +1,114 @@
+package com.passus.st.emitter;
+
+import com.passus.net.Ip4Address;
+import com.passus.net.IpAddress;
+import java.util.ArrayList;
+
+public abstract class SocketAddressProviderBase implements SocketAddressProvider {
+
+    public static final SocketAddressProvider ANY_SOCKET_PROVIDER
+            = new PortIgnoringSocketAddressProvider(Ip4Address.EMPTY_ADDRESS);
+
+    public static final int[] ALL_PORTS;
+
+    static {
+        final int size = (1 << 16) - 1;
+        ALL_PORTS = new int[size];
+        for (int i = 0; i < size; ++i) {
+            ALL_PORTS[i] = i + 1;
+        }
+    }
+
+    public static int[] parsePorts(String s) {
+        String[] parts = s.split(LIST_SEPARATOR);
+        ArrayList<Integer> ports = new ArrayList<>();
+        for (String part : parts) {
+            part = part.trim();
+            int rangeIdx = part.indexOf(RANGE_SEPARATOR);
+            if (rangeIdx < 0) {
+                ports.add(Integer.parseInt(part));
+            } else {
+                int begin = Integer.parseInt(part.substring(0, rangeIdx).trim());
+                int end = Integer.parseInt(part.substring(rangeIdx + 1).trim());
+                if (begin > end) {
+                    throw new IllegalArgumentException("Invalid range: " + part);
+                }
+                while (begin <= end) {
+                    ports.add(begin++);
+                }
+            }
+        }
+
+        int[] result = new int[ports.size()];
+        for (int i = 0; i < result.length; ++i) {
+            result[i] = ports.get(i);
+        }
+        return result;
+    }
+
+    public static IpAddress[] parseAddresses(String s) {
+        String[] parts = s.split(LIST_SEPARATOR);
+        ArrayList<IpAddress> addresses = new ArrayList<>();
+        for (String part : parts) {
+            part = part.trim();
+            int subnetIdx = part.indexOf('/');
+            int rangeIdx = part.indexOf(RANGE_SEPARATOR);
+            if (subnetIdx >= 0 && rangeIdx >= 0) {
+                throw new IllegalArgumentException();
+            } else if (subnetIdx >= 0) {
+                final int maskLength = 32 - Integer.parseInt(part.substring(subnetIdx + 1).trim());
+                final int addrMask = MASK << maskLength;
+                final int addrCount = 1 << maskLength;
+                if (maskLength > 8) {
+                    throw new IllegalArgumentException("Mask too wide");
+                }
+
+                // TODO: IPv6 support
+                Ip4Address addr = new Ip4Address(part.substring(0, subnetIdx).trim());
+                int baseAddrValue = addr.getIntValue() & addrMask;
+
+                for (int i = 0; i < addrCount; ++i) {
+                    addresses.add(new Ip4Address(baseAddrValue + i));
+                }
+            } else if (rangeIdx >= 0) {
+                Ip4Address beginAddr = new Ip4Address(part.substring(0, rangeIdx).trim());
+                Ip4Address endAddr = new Ip4Address(part.substring(rangeIdx + 1).trim());
+                int begin = beginAddr.getIntValue();
+                int end = endAddr.getIntValue();
+                if (begin > end) {
+                    throw new IllegalArgumentException("Invalid range: " + part);
+                }
+                if (end - begin >= 256) {
+                    throw new IllegalArgumentException("Range too wide");
+                }
+
+                // TODO: IPv6 support
+                while (begin <= end) {
+                    addresses.add(new Ip4Address(begin++));
+                }
+            } else {
+                addresses.add(IpAddress.parse(part));
+            }
+        }
+
+        return addresses.toArray(new IpAddress[addresses.size()]);
+    }
+
+    public static SocketAddressProviderBase create(String spec) {
+        int separatorIdx = spec.indexOf(ADDR_PORT_SEPARATOR);
+        if (separatorIdx >= 0) {
+            IpAddress[] addresses = parseAddresses(spec.substring(0, separatorIdx));
+            String portSpec = spec.substring(separatorIdx + 1);
+            if (portSpec.equals("*")) {
+                return new PortSpecificSocketAddressProvider(addresses, ALL_PORTS);
+            } else {
+                int[] ports = parsePorts(portSpec);
+                return new PortSpecificSocketAddressProvider(addresses, ports);
+            }
+        } else {
+            IpAddress[] addresses = parseAddresses(spec);
+            return new PortIgnoringSocketAddressProvider(addresses);
+        }
+    }
+
+}
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java	Fri Aug 04 12:23:28 2017 +0200
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java	Fri Aug 04 13:37:22 2017 +0200
@@ -23,8 +23,8 @@
     @Test
     public void testFilterOutbound() {
         Map<String, String> hostMap = map(
-                e("example.com", "mapped.com:8088"),
-                e("example.com:8080", "mapped.com")
+                e("example.com", "example.org:8088"),
+                e("example.com:8080", "example.org")
         );
         HttpHostRewriterFilter filter = new HttpHostRewriterFilter();
         filter.setHostMap(hostMap);
@@ -35,11 +35,11 @@
 
         HttpRequest req1 = request("http://example.com/site1/resource1", "http://example.com/site1", "http://example.com/site1/index");
         filter.filterOutbound(req1, null, null);
-        assertHeaderValues(req1, "mapped.com:8088", "http://mapped.com:8088/site1", "http://mapped.com:8088/site1/index");
+        assertHeaderValues(req1, "example.org:8088", "http://example.org:8088/site1", "http://example.org:8088/site1/index");
 
         HttpRequest req2 = request("http://example.com:8080/site1/resource1", "http://example.com:8080/site1", "http://example.com:8080/site1/index");
         filter.filterOutbound(req2, null, null);
-        assertHeaderValues(req2, "mapped.com", "http://mapped.com/site1", "http://mapped.com/site1/index");
+        assertHeaderValues(req2, "example.org", "http://example.org/site1", "http://example.org/site1/index");
     }
 
     private static HttpRequest request(String url, String origin, String referer) {
@@ -99,8 +99,8 @@
         String filterConfig = "filters:\n"
                 + "    - type: host\n"
                 + "      hostMap:\n"
-                + "        \"example.com\": \"mapped.com:8088\"\n"
-                + "        \"example.com:8080\": \"mapped.com\"\n";
+                + "        \"example.com\": \"example.org:8088\"\n"
+                + "        \"example.com:8080\": \"example.org\"\n";
 
         Errors errors = new Errors();
         List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors);
@@ -112,12 +112,12 @@
         HttpHostRewriterFilter filter = (HttpHostRewriterFilter) filters.get(0);
 
         Map<ByteString, ByteString> expectedHostMap = map(
-                e(bs("example.com"), bs("mapped.com:8088")),
-                e(bs("example.com:8080"), bs("mapped.com"))
+                e(bs("example.com"), bs("example.org:8088")),
+                e(bs("example.com:8080"), bs("example.org"))
         );
         Map<HostPort, HostPort> expectedUrlMap = map(
-                e(hp("example.com", -1), hp("mapped.com", 8088)),
-                e(hp("example.com", 8080), hp("mapped.com", -1))
+                e(hp("example.com", -1), hp("example.org", 8088)),
+                e(hp("example.com", 8080), hp("example.org", -1))
         );
 
         assertEquals(expectedHostMap, hostMapField.get(filter));
--- a/stress-tester/src/test/java/com/passus/st/emitter/SocketAddressPorviderBaseTest.java	Fri Aug 04 12:23:28 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-package com.passus.st.emitter;
-
-import com.passus.net.IpAddress;
-import com.passus.net.SocketAddress;
-import static com.passus.st.emitter.SocketAddressPorviderBase.create;
-import static com.passus.st.emitter.SocketAddressPorviderBase.parseAddresses;
-import static com.passus.st.emitter.SocketAddressPorviderBase.parsePorts;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-public class SocketAddressPorviderBaseTest {
-
-    @Test
-    public void testParsePorts() {
-        assertEquals(parsePorts("100"), p(100));
-        assertEquals(parsePorts("100, 103"), p(100, 103));
-        assertEquals(parsePorts("100 -102"), p(100, 101, 102));
-        assertEquals(parsePorts("100 -102"), p(100, 101, 102));
-        assertEquals(parsePorts("100 -102, 105- 107"), p(100, 101, 102, 105, 106, 107));
-        assertEquals(parsePorts("100, 103- 105, 108, 110-112"), p(100, 103, 104, 105, 108, 110, 111, 112));
-    }
-
-    @Test
-    public void testParsePortsInvalidRange() {
-        shouldThrowIllegalArgumentException(() -> parsePorts("105 - 102"));
-    }
-
-    @Test
-    public void testAddresses() {
-        assertEquals(parseAddresses("10.10.10.10"), a("10.10.10.10"));
-        assertEquals(parseAddresses("10.10.10.10, 10.10.10.15"), a("10.10.10.10", "10.10.10.15"));
-
-        assertEquals(parseAddresses("10.10.10.10/30"), a("10.10.10.8", "10.10.10.9", "10.10.10.10", "10.10.10.11"));
-        assertEquals(parseAddresses("10.10.10.10/31, 10.10.10.13"), a("10.10.10.10", "10.10.10.11", "10.10.10.13"));
-
-        assertEquals(parseAddresses("10.10.10.254-10.10.11.1"), a("10.10.10.254", "10.10.10.255", "10.10.11.0", "10.10.11.1"));
-    }
-
-    @Test
-    public void testAddressesInvalid() {
-        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.10/16"));
-        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.10-10.10.10.9"));
-        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.0-10.10.9.100"));
-        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.0-10.10.11.0"));
-    }
-
-    static void shouldThrowIllegalArgumentException(Runnable r) {
-        try {
-            r.run();
-            fail("Should throw IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
-        }
-    }
-
-    @Test
-    public void testCreate() {
-        final int maxPorts = (1 << 16) - 1;
-        SocketAddressPorviderBase provider;
-
-        provider = create("10.10.10.10");
-        assertEquals(provider.count(), 0);
-        assertEquals(provider.get(5), sa("10.10.10.10", 0));
-        provider = create("10.10.10.10/31");
-        assertEquals(provider.count(), 0);
-        assertEquals(provider.get(5), sa("10.10.10.11", 0));
-
-        provider = create("10.10.10.10:*");
-        assertEquals(provider.count(), maxPorts);
-        assertEquals(provider.get(5), sa("10.10.10.10", 6));
-        provider = create("10.10.10.10/31:*");
-        assertEquals(provider.count(), 2 * maxPorts);
-        assertEquals(provider.get(5), sa("10.10.10.11", 3));
-
-        provider = create("10.10.10.10:1000-1999");
-        assertEquals(provider.count(), 1000);
-        assertEquals(provider.get(5), sa("10.10.10.10", 1005));
-        provider = create("10.10.10.10/31:1000-1999");
-        assertEquals(provider.count(), 2000);
-        assertEquals(provider.get(5), sa("10.10.10.11", 1002));
-    }
-
-    static int[] p(int... ints) {
-        return ints;
-    }
-
-    static IpAddress[] a(String... addresses) {
-        IpAddress[] result = new IpAddress[addresses.length];
-        for (int i = 0; i < result.length; i++) {
-            result[i] = IpAddress.parse(addresses[i]);
-        }
-        return result;
-    }
-
-    static SocketAddress sa(String a, int p) {
-        return new SocketAddress(IpAddress.parse(a), p);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester/src/test/java/com/passus/st/emitter/SocketAddressProviderBaseTest.java	Fri Aug 04 13:37:22 2017 +0200
@@ -0,0 +1,101 @@
+package com.passus.st.emitter;
+
+import com.passus.net.IpAddress;
+import com.passus.net.SocketAddress;
+import static com.passus.st.emitter.SocketAddressProviderBase.create;
+import static com.passus.st.emitter.SocketAddressProviderBase.parseAddresses;
+import static com.passus.st.emitter.SocketAddressProviderBase.parsePorts;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author mikolaj.podbielski
+ */
+public class SocketAddressProviderBaseTest {
+
+    @Test
+    public void testParsePorts() {
+        assertEquals(parsePorts("100"), p(100));
+        assertEquals(parsePorts("100, 103"), p(100, 103));
+        assertEquals(parsePorts("100 -102"), p(100, 101, 102));
+        assertEquals(parsePorts("100 -102"), p(100, 101, 102));
+        assertEquals(parsePorts("100 -102, 105- 107"), p(100, 101, 102, 105, 106, 107));
+        assertEquals(parsePorts("100, 103- 105, 108, 110-112"), p(100, 103, 104, 105, 108, 110, 111, 112));
+    }
+
+    @Test
+    public void testParsePortsInvalidRange() {
+        shouldThrowIllegalArgumentException(() -> parsePorts("105 - 102"));
+    }
+
+    @Test
+    public void testAddresses() {
+        assertEquals(parseAddresses("10.10.10.10"), a("10.10.10.10"));
+        assertEquals(parseAddresses("10.10.10.10, 10.10.10.15"), a("10.10.10.10", "10.10.10.15"));
+
+        assertEquals(parseAddresses("10.10.10.10/30"), a("10.10.10.8", "10.10.10.9", "10.10.10.10", "10.10.10.11"));
+        assertEquals(parseAddresses("10.10.10.10/31, 10.10.10.13"), a("10.10.10.10", "10.10.10.11", "10.10.10.13"));
+
+        assertEquals(parseAddresses("10.10.10.254-10.10.11.1"), a("10.10.10.254", "10.10.10.255", "10.10.11.0", "10.10.11.1"));
+    }
+
+    @Test
+    public void testAddressesInvalid() {
+        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.10/16"));
+        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.10-10.10.10.9"));
+        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.0-10.10.9.100"));
+        shouldThrowIllegalArgumentException(() -> parseAddresses("10.10.10.0-10.10.11.0"));
+    }
+
+    static void shouldThrowIllegalArgumentException(Runnable r) {
+        try {
+            r.run();
+            fail("Should throw IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+        }
+    }
+
+    @Test
+    public void testCreate() {
+        final int maxPorts = (1 << 16) - 1;
+        SocketAddressProviderBase provider;
+
+        provider = create("10.10.10.10");
+        assertEquals(provider.count(), 0);
+        assertEquals(provider.get(5), sa("10.10.10.10", 0));
+        provider = create("10.10.10.10/31");
+        assertEquals(provider.count(), 0);
+        assertEquals(provider.get(5), sa("10.10.10.11", 0));
+
+        provider = create("10.10.10.10:*");
+        assertEquals(provider.count(), maxPorts);
+        assertEquals(provider.get(5), sa("10.10.10.10", 6));
+        provider = create("10.10.10.10/31:*");
+        assertEquals(provider.count(), 2 * maxPorts);
+        assertEquals(provider.get(5), sa("10.10.10.11", 3));
+
+        provider = create("10.10.10.10:1000-1999");
+        assertEquals(provider.count(), 1000);
+        assertEquals(provider.get(5), sa("10.10.10.10", 1005));
+        provider = create("10.10.10.10/31:1000-1999");
+        assertEquals(provider.count(), 2000);
+        assertEquals(provider.get(5), sa("10.10.10.11", 1002));
+    }
+
+    static int[] p(int... ints) {
+        return ints;
+    }
+
+    static IpAddress[] a(String... addresses) {
+        IpAddress[] result = new IpAddress[addresses.length];
+        for (int i = 0; i < result.length; i++) {
+            result[i] = IpAddress.parse(addresses[i]);
+        }
+        return result;
+    }
+
+    static SocketAddress sa(String a, int p) {
+        return new SocketAddress(IpAddress.parse(a), p);
+    }
+}