verifyEsLogLevel(ctx, Level.DEBUG);
}
+ @Test
+ public void jmx_logger_level_changes_with_global_property_and_is_case_insensitive() {
+ props.set("sonar.log.level", "InFO");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.INFO);
+ }
+
+ @Test
+ public void jmx_logger_level_changes_with_jmx_property_and_is_case_insensitive() {
+ props.set("sonar.log.level.ce", "TrACe");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.TRACE);
+ }
+
+ @Test
+ public void jmx_logger_level_changes_with_ce_jmx_property_and_is_case_insensitive() {
+ props.set("sonar.log.level.ce.jmx", "debug");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_ce_jmx_property_over_ce_property() {
+ props.set("sonar.log.level.ce.jmx", "debug");
+ props.set("sonar.log.level.ce", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_ce_jmx_property_over_global_property() {
+ props.set("sonar.log.level.ce.jmx", "debug");
+ props.set("sonar.log.level", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_ce_property_over_global_property() {
+ props.set("sonar.log.level.ce", "debug");
+ props.set("sonar.log.level", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
@Test
public void root_logger_level_defaults_to_INFO_if_ce_property_has_invalid_value() {
props.set("sonar.log.level.ce", "DodoDouh!");
verifyEsLogLevel(ctx, Level.INFO);
}
+ @Test
+ public void jmx_loggers_level_defaults_to_INFO_if_ce_jmx_property_has_invalid_value() {
+ props.set("sonar.log.level.ce.jmx", "DodoDouh!");
+
+ LoggerContext ctx = underTest.configure(props);
+ verifyJmxLogLevel(ctx, Level.INFO);
+ }
+
@Test
public void fail_with_IAE_if_global_property_unsupported_level() {
props.set("sonar.log.level", "ERROR");
underTest.configure(props);
}
+ @Test
+ public void fail_with_IAE_if_ce_jmx_property_unsupported_level() {
+ props.set("sonar.log.level.ce.jmx", "ERROR");
+
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("log level ERROR in property sonar.log.level.ce.jmx is not a supported value (allowed levels are [TRACE, DEBUG, INFO])");
+
+ underTest.configure(props);
+ }
+
private void verifyRootLogLevel(LoggerContext ctx, Level expected) {
assertThat(ctx.getLogger(ROOT_LOGGER_NAME).getLevel()).isEqualTo(expected);
}
private void verifyEsLogLevel(LoggerContext ctx, Level expected) {
assertThat(ctx.getLogger("es").getLevel()).isEqualTo(expected);
}
+
+ private void verifyJmxLogLevel(LoggerContext ctx, Level expected) {
+ assertThat(ctx.getLogger("javax.management.remote.timeout").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.remote.misc").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.remote.rmi").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.mbeanserver").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.loader").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.transport.tcp").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.transport.misc").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.server.call").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.dgc").getLevel()).isEqualTo(expected);
+ }
}
verifyEsLogLevel(ctx, Level.DEBUG);
}
+ @Test
+ public void jmx_logger_level_changes_with_global_property_and_is_case_insensitive() {
+ props.set("sonar.log.level", "InFO");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.INFO);
+ }
+
+ @Test
+ public void jmx_logger_level_changes_with_jmx_property_and_is_case_insensitive() {
+ props.set("sonar.log.level.web", "TrACe");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.TRACE);
+ }
+
+ @Test
+ public void jmx_logger_level_changes_with_web_jmx_property_and_is_case_insensitive() {
+ props.set("sonar.log.level.web.jmx", "debug");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_web_jmx_property_over_web_property() {
+ props.set("sonar.log.level.web.jmx", "debug");
+ props.set("sonar.log.level.web", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_web_jmx_property_over_global_property() {
+ props.set("sonar.log.level.web.jmx", "debug");
+ props.set("sonar.log.level", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
+ @Test
+ public void jmx_logger_level_is_configured_from_web_property_over_global_property() {
+ props.set("sonar.log.level.web", "debug");
+ props.set("sonar.log.level", "TRACE");
+
+ LoggerContext ctx = underTest.configure(props);
+
+ verifyJmxLogLevel(ctx, Level.DEBUG);
+ }
+
@Test
public void root_logger_level_defaults_to_INFO_if_web_property_has_invalid_value() {
props.set("sonar.log.level.web", "DodoDouh!");
verifyEsLogLevel(ctx, Level.INFO);
}
+ @Test
+ public void jmx_loggers_level_defaults_to_INFO_if_wedb_jmx_property_has_invalid_value() {
+ props.set("sonar.log.level.web.jmx", "DodoDouh!");
+
+ LoggerContext ctx = underTest.configure(props);
+ verifyJmxLogLevel(ctx, Level.INFO);
+ }
+
@Test
public void fail_with_IAE_if_global_property_unsupported_level() {
props.set("sonar.log.level", "ERROR");
underTest.configure(props);
}
+ @Test
+ public void fail_with_IAE_if_web_jmx_property_unsupported_level() {
+ props.set("sonar.log.level.web.jmx", "ERROR");
+
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("log level ERROR in property sonar.log.level.web.jmx is not a supported value (allowed levels are [TRACE, DEBUG, INFO])");
+
+ underTest.configure(props);
+ }
+
private void verifyRootLogLevel(LoggerContext ctx, Level expected) {
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME);
assertThat(rootLogger.getLevel()).isEqualTo(expected);
assertThat(ctx.getLogger("es").getLevel()).isEqualTo(expected);
}
+ private void verifyJmxLogLevel(LoggerContext ctx, Level expected) {
+ assertThat(ctx.getLogger("javax.management.remote.timeout").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.remote.misc").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.remote.rmi").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("javax.management.mbeanserver").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.loader").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.transport.tcp").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.transport.misc").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.server.call").getLevel()).isEqualTo(expected);
+ assertThat(ctx.getLogger("sun.rmi.dgc").getLevel()).isEqualTo(expected);
+ }
+
}