コード例 #1
0
 @Test
 public void testDefaultToNodePool() {
   serviceSelector =
       new CachingServiceSelector(
           "apple",
           new ServiceSelectorConfig(),
           new NodeInfo(
               "test-application",
               new NodeConfig().setEnvironment("environment").setPool("nodepool")));
   assertEquals(serviceSelector.getType(), "apple");
   assertEquals(serviceSelector.getPool(), "nodepool");
 }
コード例 #2
0
  @Test
  public void testNotStartedWithServices() {
    discoveryClient.addDiscoveredService(APPLE_1_SERVICE);
    discoveryClient.addDiscoveredService(APPLE_2_SERVICE);
    discoveryClient.addDiscoveredService(DIFFERENT_TYPE);
    discoveryClient.addDiscoveredService(DIFFERENT_POOL);

    assertEquals(serviceSelector.selectAllServices(), ImmutableList.of());
  }
コード例 #3
0
  @Test
  public void testStartedWithServices() throws Exception {
    discoveryClient.addDiscoveredService(APPLE_1_SERVICE);
    discoveryClient.addDiscoveredService(APPLE_2_SERVICE);
    discoveryClient.addDiscoveredService(DIFFERENT_TYPE);
    discoveryClient.addDiscoveredService(DIFFERENT_POOL);

    updater.start();

    Thread.sleep(100);

    assertEqualsIgnoreOrder(
        serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE));
  }
コード例 #4
0
  @Test
  public void testServiceUpdaterDefaultToNodePool() throws Exception {
    discoveryClient.addDiscoveredService(APPLE_1_SERVICE);
    discoveryClient.addDiscoveredService(APPLE_2_SERVICE);
    discoveryClient.addDiscoveredService(DIFFERENT_TYPE);
    discoveryClient.addDiscoveredService(DIFFERENT_POOL);

    updater =
        new ServiceDescriptorsUpdater(
            serviceSelector,
            "apple",
            new ServiceSelectorConfig(),
            new NodeInfo(
                "test-application", new NodeConfig().setEnvironment("environment").setPool("pool")),
            discoveryClient,
            executor);
    updater.start();

    Thread.sleep(100);

    assertEqualsIgnoreOrder(
        serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE));
  }
コード例 #5
0
  @Test
  public void testStartedEmpty() throws Exception {
    updater.start();

    assertEquals(serviceSelector.selectAllServices(), ImmutableList.of());
  }
コード例 #6
0
 @Test
 public void testNotStartedEmpty() {
   assertEquals(serviceSelector.selectAllServices(), ImmutableList.of());
 }
コード例 #7
0
 @Test
 public void testBasics() {
   assertEquals(serviceSelector.getType(), "apple");
   assertEquals(serviceSelector.getPool(), "pool");
 }