@Test
    public void testTwoInstancesDontStepOnEachOther() throws Exception{

        // setup override client

        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.DeploymentContextBasedVipAddresses", "dummy");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.IsSecure", "false");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.Port", "6001");  // override from 8001
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.TargetRegion", "region");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());

        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1.ribbon.ForceClientPortConfiguration", "true");

        // setup non override client

        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.DeploymentContextBasedVipAddresses", "dummy");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.IsSecure", "false");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.Port", "6001");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.TargetRegion", "region");
        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());

        ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2.ribbon.ForceClientPortConfiguration", "false");

        // check override client

        DiscoveryEnabledNIWSServerList deList1 = new DiscoveryEnabledNIWSServerList();

        DefaultClientConfigImpl clientConfig1 = DefaultClientConfigImpl.class.newInstance();
        clientConfig1.loadProperties("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther1");
        deList1.initWithNiwsConfig(clientConfig1);

        List<DiscoveryEnabledServer> serverList1 = deList1.getInitialListOfServers();

        Assert.assertEquals(1, serverList1.size());
        Assert.assertEquals(6001, serverList1.get(0).getPort());                           // client property overridden
        Assert.assertEquals(6001, serverList1.get(0).getInstanceInfo().getPort());         // client property overridden
        Assert.assertEquals(7002, serverList1.get(0).getInstanceInfo().getSecurePort());   // 7002 is the secure default

        // check non-override client

        DiscoveryEnabledNIWSServerList deList2 = new DiscoveryEnabledNIWSServerList();

        DefaultClientConfigImpl clientConfig2 = DefaultClientConfigImpl.class.newInstance();
        clientConfig2.loadProperties("DiscoveryEnabled.testTwoInstancesDontStepOnEachOther2");
        deList2.initWithNiwsConfig(clientConfig2);

        List<DiscoveryEnabledServer> serverList2 = deList2.getInitialListOfServers();

        Assert.assertEquals(1, serverList2.size());

        Assert.assertEquals(8001, serverList2.get(0).getPort());                           // client property indicated in ii
        Assert.assertEquals(8001, serverList2.get(0).getInstanceInfo().getPort());         // client property indicated in ii
        Assert.assertEquals(7002, serverList2.get(0).getInstanceInfo().getSecurePort());   // 7002 is the secure default
    }
Tests case where two different clients want to use the same instance, one with overriden ports and one without

@throws Exception for anything unexpected
ribbon-eureka/src/test/java/com/netflix/niws/loadbalancer/DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java