ColorActivation { public static boolean isActivated() { String color = System.getProperty("maven.color"); if (color != null) { return Boolean.valueOf(color); } String activation = System.getProperty("style.color"); if ("always".equals(activation)) { return true; } if ("never".equals(activation)) { return false; } Set<String> args = split(System.getenv("MAVEN_CMD_LINE_ARGS")); return !isBatchMode(args) && !isLogFile(args) && !isDumbTerminal(); } private  ColorActivation(); static boolean isActivated();  }
@Test public void should_be_activated_when_sys_property_style_color_is_always() { System.setProperty("style.color", "always"); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void should_not_be_activated_when_sys_property_style_color_is_never() { System.setProperty("style.color", "never"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_be_activated_when_terminal_is_not_dumb() { env.set("TERM", "xterm"); env.set("MAVEN_CMD_LINE_ARGS", "verify"); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void should_not_be_activated_when_terminal_is_dumb() { env.set("TERM", "dumb"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_is_launched_in_batch_mode() { env.set("MAVEN_CMD_LINE_ARGS", "-B verify"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_is_launched_in_batch_mode_long_opt() { env.set("MAVEN_CMD_LINE_ARGS", "--batch-mode verify"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_log_in_a_file() { env.set("MAVEN_CMD_LINE_ARGS", "-l test.log verify"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_log_in_a_file_and_equal_delimiter() { env.set("MAVEN_CMD_LINE_ARGS", "test -l=test.log"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_log_in_a_file_long_opt() { env.set("MAVEN_CMD_LINE_ARGS", "--log-file test.log verify"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_maven_log_in_a_file_long_opt_and_equal_delimiter() { env.set("MAVEN_CMD_LINE_ARGS", "test --log-file=test.log"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_be_activated_when_a_maven_build_is_launched() { env.set("MAVEN_CMD_LINE_ARGS", "clean verify"); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void should_be_activated_when_arguments_could_have_been_misinterpreted_as_log_file_option() { env.set("MAVEN_CMD_LINE_ARGS", "dependency:tree -Dincludes=\"commons-logging\""); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void return_maven_color_property_first() { System.setProperty("maven.color", "true"); System.setProperty("style.color", "false"); env.set("TERM", "dumb"); env.set("MAVEN_CMD_LINE_ARGS", "test -B"); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void should_be_activated_when_sys_property_maven_color_is_true() { System.setProperty("maven.color", "true"); assertThat(ColorActivation.isActivated()).isTrue(); }
@Test public void should_not_be_activated_when_sys_property_maven_color_is_false() { System.setProperty("maven.color", "false"); assertThat(ColorActivation.isActivated()).isFalse(); }
@Test public void should_not_be_activated_when_sys_property_maven_color_is_unparsable() { System.setProperty("maven.color", "WHATT!?"); assertThat(ColorActivation.isActivated()).isFalse(); }