From 89180993494a176ea8c7dfbb1250f81d693637cb Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 15 Apr 2018 13:01:18 +0200 Subject: [PATCH] Fix Thread test to run test in additional threads correct Thread().run() to Thread().start() --- .../java/org/fusesource/jansi/AnsiTest.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/jansi/src/test/java/org/fusesource/jansi/AnsiTest.java b/jansi/src/test/java/org/fusesource/jansi/AnsiTest.java index f5e683ee..7c9a26d3 100644 --- a/jansi/src/test/java/org/fusesource/jansi/AnsiTest.java +++ b/jansi/src/test/java/org/fusesource/jansi/AnsiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2017 the original author(s). + * Copyright (C) 2009-2018 the original author(s). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import org.fusesource.jansi.Ansi.Color; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; /** * Tests for the {@link Ansi} class. @@ -27,26 +27,38 @@ */ public class AnsiTest { @Test - public void testSetEnabled() throws Exception { + public void testSetEnabled() throws InterruptedException { + Ansi.setEnabled(false); - new Thread() { + Thread threadDisabled = new Thread() { @Override public void run() { - assertEquals(false, Ansi.isEnabled()); + System.out.println(Ansi.ansi().fgRed().a("ANSI disabled").reset()); + assertFalse( Ansi.isEnabled() ); } - }.run(); + }; Ansi.setEnabled(true); - new Thread() { + Thread threadEnabled =new Thread() { @Override public void run() { - assertEquals(true, Ansi.isEnabled()); + System.out.println(Ansi.ansi().fgBlue().a("ANSI enabled").reset()); + assertTrue( Ansi.isEnabled() ); } - }.run(); + }; + + Ansi.setEnabled(false); + System.out.println(Ansi.ansi().fgBlue().a("Ansi test thread start").reset()); + + threadDisabled.start(); + threadEnabled.start(); + + threadEnabled.join(); + threadDisabled.join(); } @Test - public void testClone() throws CloneNotSupportedException { + public void testClone() { Ansi ansi = Ansi.ansi().a("Some text").bg(Color.BLACK).fg(Color.WHITE); Ansi clone = new Ansi(ansi);