_state.listenToService("service-1", new NullStateListenerCallback());
_state.listenToCluster("cluster-1", new NullStateListenerCallback());
assertNull(_state.getStrategy("service-1", "http"));
_serviceRegistry.put("service-1", new ServiceProperties("service-1",
"cluster-1",
"/test",
"random",
Collections.<String>emptyList(),
Collections.<String,Object>emptyMap(),
null,
null,
schemes,
null));
assertNotNull(_state.getStrategy("service-1", "http"));
LoadBalancerStrategy strategy = _state.getStrategy("service-1", "http");
assertNotNull(strategy);
assertTrue(strategy instanceof RandomLoadBalancerStrategy);
// check that we're getting the exact same strategy (by pointer) every time
assertTrue(strategy == _state.getStrategy("service-1", "http"));
assertTrue(strategy == _state.getStrategy("service-1", "http"));
// now make sure adding a cluster property won't change the strategy
_clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));
// we should still have the same strategy now
LoadBalancerStrategy newStrategy = _state.getStrategy("service-1", "http");
assertNotNull(newStrategy);
assertTrue(strategy == newStrategy);
assertTrue(newStrategy instanceof RandomLoadBalancerStrategy);
strategy = newStrategy;
// refresh by adding service
_serviceRegistry.put("service-1", new ServiceProperties("service-1",
"cluster-1",
"/test",
"random",
Collections.<String>emptyList(),
Collections.<String,Object>emptyMap(),