AbstractJmxConfiguration implements PropertyConfiguration { @Override public Map<String, String> getProperties() { return Map.ofEntries( Map.entry("com.sun.management.jmxremote", Boolean.toString(jmxEnabled))); } AbstractJmxConfiguration(final boolean jmxEnabled); @Override Map<String, String> getProperties();  }
@Test void disabled() { PropertyConfiguration configuration = PropertyConfiguration.disabledJmx(); assertThat(configuration.getProperties()) .containsExactly(Map.entry("com.sun.management.jmxremote", "false")); }
@Test void enabledSecure() throws IOException { Path installDir = Files.createTempDirectory("robozonky-install"); Path props = installDir.resolve("management.properties"); PropertyConfiguration configuration = PropertyConfiguration.enabledJmx("localhost", 7091, true); configuration.accept(null, installDir); assertThat(load(props)).containsOnly( Map.entry("com.sun.management.jmxremote.authenticate", "true"), Map.entry("com.sun.management.jmxremote.ssl", "false"), Map.entry("com.sun.management.jmxremote.rmi.port", "7091"), Map.entry("com.sun.management.jmxremote.port", "7091")); assertThat(configuration.getProperties()).containsOnly( Map.entry("com.sun.management.config.file", props.toString()), Map.entry("com.sun.management.jmxremote", "true"), Map.entry("java.rmi.server.hostname", "localhost"), Map.entry("jmx.remote.x.notification.buffer.size", "10")); }
@Test void enabledInsecure() throws IOException { Path installDir = Files.createTempDirectory("robozonky-install"); Path props = installDir.resolve("management.properties"); PropertyConfiguration configuration = PropertyConfiguration.enabledJmx("localhost", 7091, false); configuration.accept(null, installDir); assertThat(load(props)).containsOnly( Map.entry("com.sun.management.jmxremote.authenticate", "false"), Map.entry("com.sun.management.jmxremote.ssl", "false"), Map.entry("com.sun.management.jmxremote.rmi.port", "7091"), Map.entry("com.sun.management.jmxremote.port", "7091")); assertThat(configuration.getProperties()) .containsOnly( Map.entry("com.sun.management.config.file", props.toString()), Map.entry("com.sun.management.jmxremote", "true"), Map.entry("java.rmi.server.hostname", "localhost"), Map.entry("jmx.remote.x.notification.buffer.size", "10")); }