@Test
  public void doesNotBindToNonPublishedProvidersInOtherZones() throws Exception {
    InMemoryServiceRegistry serviceRegistry = new InMemoryServiceRegistry();

    astrixConfigurer.setSubsystem("default");
    astrixConfigurer.set(AstrixSettings.SERVICE_REGISTRY_URI, serviceRegistry.getServiceUri());
    astrixConfigurer.registerApiProvider(PingApiProvider.class);
    clientContext = astrixConfigurer.configure();

    ServiceRegistryExporterClient server1serviceRegistryClient =
        new ServiceRegistryExporterClient(serviceRegistry, "my-subsystem", "server-1");
    ServiceProperties service1Properties =
        DirectComponent.registerAndGetProperties(Ping.class, new PingImpl("1"));
    service1Properties.setProperty(ServiceProperties.PUBLISHED, "false");
    service1Properties.setProperty(ServiceProperties.SERVICE_ZONE, "foo-zone");
    server1serviceRegistryClient.register(Ping.class, service1Properties, Integer.MAX_VALUE);

    ServiceRegistryClient serviceRegistryClient =
        clientContext.getBean(ServiceRegistryClient.class);
    List<ServiceProperties> providers =
        serviceRegistryClient.list(AstrixBeanKey.create(Ping.class));
    assertEquals(1, providers.size());

    Ping ping = clientContext.getBean(Ping.class);
    try {
      ping.ping();
      fail("Expected service to not be available when server is INACTIVE");
    } catch (ServiceUnavailableException e) {
      // expected
    }
  }
  @Test
  public void bindsToNonPublishedProvidersInSameZone() throws Exception {
    InMemoryServiceRegistry serviceRegistry = new InMemoryServiceRegistry();

    astrixConfigurer.setSubsystem("my-subsystem");
    astrixConfigurer.set(AstrixSettings.SERVICE_REGISTRY_URI, serviceRegistry.getServiceUri());
    astrixConfigurer.registerApiProvider(PingApiProvider.class);
    clientContext = astrixConfigurer.configure();

    ServiceRegistryExporterClient server1serviceRegistryClient =
        new ServiceRegistryExporterClient(serviceRegistry, "my-subsystem", "server-1");
    ServiceProperties service1Properties =
        DirectComponent.registerAndGetProperties(Ping.class, new PingImpl("1"));
    service1Properties.setProperty(ServiceProperties.PUBLISHED, "false");
    server1serviceRegistryClient.register(Ping.class, service1Properties, Integer.MAX_VALUE);

    ServiceRegistryClient serviceRegistryClient =
        clientContext.getBean(ServiceRegistryClient.class);
    List<ServiceProperties> providers =
        serviceRegistryClient.list(AstrixBeanKey.create(Ping.class));
    assertEquals(1, providers.size());

    Ping ping = clientContext.getBean(Ping.class);
    assertNotNull(ping.ping());
  }