コード例 #1
0
  public void testThatDefaultProfileInheritsFromStandardSettings() throws Exception {
    Settings settings =
        Settings.builder()
            .put("network.host", host)
            .put(TransportSettings.PORT.getKey(), 0)
            .put("transport.profiles.client1.port", 0)
            .build();

    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
      assertEquals(1, transport.profileBoundAddresses().size());
      assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
      terminate(threadPool);
    }
  }
コード例 #2
0
  public void testThatDefaultProfilePortOverridesGeneralConfiguration() throws Exception {
    Settings settings =
        Settings.builder()
            .put("network.host", host)
            .put(TransportSettings.PORT.getKey(), 22) // will not actually bind to this
            .put("transport.profiles.default.port", 0)
            .build();

    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
      assertEquals(0, transport.profileBoundAddresses().size());
      assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
      terminate(threadPool);
    }
  }
コード例 #3
0
  public void testThatProfileWithoutPortSettingsFails() throws Exception {

    Settings settings =
        Settings.builder()
            .put("network.host", host)
            .put(TransportSettings.PORT.getKey(), 0)
            .put("transport.profiles.client1.whatever", "foo")
            .build();

    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
      assertEquals(0, transport.profileBoundAddresses().size());
      assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
      terminate(threadPool);
    }
  }
コード例 #4
0
  public void testThatProfileWithoutValidNameIsIgnored() throws Exception {
    Settings settings =
        Settings.builder()
            .put("network.host", host)
            .put(TransportSettings.PORT.getKey(), 0)
            // mimics someone trying to define a profile for .local which is the profile for a node
            // request to itself
            .put(
                "transport.profiles." + TransportService.DIRECT_RESPONSE_PROFILE + ".port",
                22) // will not actually bind to this
            .put("transport.profiles..port", 23) // will not actually bind to this
            .build();

    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
      assertEquals(0, transport.profileBoundAddresses().size());
      assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
      terminate(threadPool);
    }
  }