Java 类org.springframework.boot.ansi.AnsiOutput.Enabled 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void enabled() {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "ALWAYS");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.ALWAYS);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabled() throws Exception {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "never");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.NEVER);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabledViaApplicationProperties() throws Exception {
    ConfigurableEnvironment environment = new StandardEnvironment();
    TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
            "spring.config.name=ansi");
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    application.setEnvironment(environment);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.NEVER);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldRenderGradient() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("gradient.gif", "banner.image.width=10",
            "banner.image.margin=0");
    assertThat(banner).contains("@#8&o:*.  ");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldCapWidthAndCalculateHeight() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=0");
    assertThat(getBannerWidth(banner)).isEqualTo(76);
    assertThat(getBannerHeight(banner)).isEqualTo(37);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintMargin() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("  @");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerWhenHasMarginPropertyShouldPrintSizedMargin()
        throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=4");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("    @");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("\u001B[31mThis is red.\u001B[0m");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("This is red.");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InternalOutputCapture.java   
protected void captureOutput() {
    AnsiOutput.setEnabled(Enabled.NEVER);
    this.copy = new ByteArrayOutputStream();
    this.captureOut = new CaptureOutputStream(System.out, this.copy);
    this.captureErr = new CaptureOutputStream(System.err, this.copy);
    System.setOut(new PrintStream(this.captureOut));
    System.setErr(new PrintStream(this.captureErr));
}
项目:spring-boot-concourse    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目:spring-boot-concourse    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void enabled() {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "ALWAYS");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.ALWAYS);
}
项目:spring-boot-concourse    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabled() throws Exception {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "never");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.NEVER);
}
项目:spring-boot-concourse    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabledViaApplicationProperties() throws Exception {
    ConfigurableEnvironment environment = new StandardEnvironment();
    TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
            "spring.config.name=ansi");
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    application.setEnvironment(environment);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.NEVER);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldRenderGradient() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("gradient.gif", "banner.image.width=10",
            "banner.image.margin=0");
    assertThat(banner).contains("@#8&o:*.  ");
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldCapWidthAndCalculateHeight() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=0");
    assertThat(getBannerWidth(banner)).isEqualTo(76);
    assertThat(getBannerHeight(banner)).isEqualTo(37);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintMargin() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("  @");
    }
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerWhenHasMarginPropertyShouldPrintSizedMargin()
        throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=4");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("    @");
    }
}
项目:spring-boot-concourse    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("\u001B[31mThis is red.\u001B[0m");
}
项目:spring-boot-concourse    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("This is red.");
}
项目:spring-boot-concourse    文件:InternalOutputCapture.java   
protected void captureOutput() {
    AnsiOutput.setEnabled(Enabled.NEVER);
    this.copy = new ByteArrayOutputStream();
    this.captureOut = new CaptureOutputStream(System.out, this.copy);
    this.captureErr = new CaptureOutputStream(System.err, this.copy);
    System.setOut(new PrintStream(this.captureOut));
    System.setErr(new PrintStream(this.captureErr));
}
项目:contestparser    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目:contestparser    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void enabled() {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "ALWAYS");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.ALWAYS));
}
项目:contestparser    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabled() throws Exception {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "never");
    application.setDefaultProperties(props);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.NEVER));
}
项目:contestparser    文件:AnsiOutputApplicationListenerTests.java   
@Test
public void disabledViaApplicationProperties() throws Exception {
    ConfigurableEnvironment environment = new StandardEnvironment();
    EnvironmentTestUtils.addEnvironment(environment, "spring.config.name:ansi");
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    application.setEnvironment(environment);
    this.context = application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.NEVER));
}
项目:contestparser    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null);
    assertThat(banner, startsWith("\u001B[31mThis is red.\u001B[0m"));
}
项目:contestparser    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null);
    assertThat(banner, startsWith("This is red."));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputEnabledValue.java   
public static Enabled get() {
    return AnsiOutput.getEnabled();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiPropertySourceTests.java   
@After
public void reset() {
    AnsiOutput.setEnabled(Enabled.DETECT);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiPropertySourceTests.java   
@Test
public void encodeEnabled() throws Exception {
    AnsiOutput.setEnabled(Enabled.ALWAYS);
    AnsiPropertySource source = new AnsiPropertySource("ansi", true);
    assertThat(source.getProperty("Ansi.RED")).isEqualTo("\033[31m");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiPropertySourceTests.java   
@Test
public void encodeDisabled() throws Exception {
    AnsiOutput.setEnabled(Enabled.NEVER);
    AnsiPropertySource source = new AnsiPropertySource("ansi", true);
    assertThat(source.getProperty("Ansi.RED")).isEqualTo("");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputTests.java   
@BeforeClass
public static void enable() {
    AnsiOutput.setEnabled(Enabled.ALWAYS);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputTests.java   
@AfterClass
public static void reset() {
    AnsiOutput.setEnabled(Enabled.DETECT);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListenerTests.java   
@Before
public void resetAnsi() {
    AnsiOutput.setEnabled(Enabled.DETECT);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Before
public void setup() {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@After
public void cleanup() {
    AnsiOutput.setEnabled(Enabled.DETECT);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBannerTests.java   
@After
public void reset() {
    AnsiOutput.setEnabled(Enabled.DETECT);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InternalOutputCapture.java   
protected void releaseOutput() {
    AnsiOutput.setEnabled(Enabled.DETECT);
    System.setOut(this.captureOut.getOriginal());
    System.setErr(this.captureErr.getOriginal());
    this.copy = null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OutputCapture.java   
@Override
public void disableAnsiOutput() {
    AnsiOutput.setEnabled(Enabled.NEVER);
}