Fix test, license, minor code cmpliance

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
2017-11-13 22:38:32 -05:00
parent 83c02f82ec
commit 283090d361
14 changed files with 321 additions and 54 deletions

View File

@@ -38,6 +38,10 @@
*/
package fr.bigeon.gclc.command;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
@@ -78,6 +82,21 @@ public class CommandTest {
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// details
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@Override
@@ -98,6 +117,20 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// details
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@@ -126,6 +159,20 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// details
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@@ -154,6 +201,20 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// details
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@@ -177,6 +238,20 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// details
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@@ -200,6 +275,24 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// pattern
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// details
assertEquals("Unexpected detail", "details", test.readNextLine());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@Override
@@ -222,6 +315,22 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// pattern
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// details
assertEquals("Unexpected detail", "details", test.readNextLine());
assertFalse("Only 6 line should be printed", test.available());
cmd = new Command("name") {
@@ -245,6 +354,22 @@ public class CommandTest {
}
};
cmd.help(test);
// name
assertEquals("First line should be command name", "name",
test.readNextLine());
// tip
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
// Usage
test.readNextLine();
// pattern
test.readNextLine();
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
//
assertTrue("Section line is empty", test.readNextLine().isEmpty());
assertFalse("Only 6 line should be printed", test.available());
}
}

View File

@@ -38,6 +38,7 @@
*/
package fr.bigeon.gclc.command;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.IOException;
@@ -95,25 +96,15 @@ public class HelpExecutorTest {
}
}
/** Test method for
* {@link fr.bigeon.gclc.command.HelpExecutor#HelpExecutor(java.lang.String, fr.bigeon.gclc.manager.ConsoleManager, fr.bigeon.gclc.command.ICommand)}.
*
* @throws IOException if an IO occurs */
@Test
public final void testHelpExecutor() throws IOException {
HelpExecutor help;
help = new HelpExecutor("?", new MockCommand("mock"));
}
/** Test method for {@link fr.bigeon.gclc.command.HelpExecutor#tip()}.
*
*
* @throws IOException */
@Test
public final void testTip() throws IOException {
try (PipedConsoleOutput test = new PipedConsoleOutput()) {
final HelpExecutor help = new HelpExecutor("?",
new MockCommand("mock"));
help.tip();
assertNotNull("Tip should be provided", help.tip());
help.help(test);
}
try (PipedConsoleOutput test = new PipedConsoleOutput()) {

View File

@@ -38,6 +38,7 @@
*/
package fr.bigeon.gclc.manager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
@@ -51,7 +52,8 @@ import java.nio.charset.Charset;
import org.junit.Before;
import org.junit.Test;
/** <p>
/**
* <p>
* TODO
*
* @author Emmanuel Bigeon */
@@ -85,7 +87,8 @@ public class ReadingRunnableTest {
* @throws InterruptedException
* @throws IOException */
@Test
public final void testGetWaitForDelivery() throws InterruptedException, IOException {
public final void testGetWaitForDelivery() throws InterruptedException,
IOException {
try (PipedOutputStream out = new PipedOutputStream();
InputStream piped = new PipedInputStream(out);
BufferedReader reader = new BufferedReader(
@@ -111,7 +114,9 @@ public class ReadingRunnableTest {
}
}, "get");
th2.start();
th.join();
th.join();
assertFalse("Runnable should have consumed every message",
runnable.hasMessage());
runnable.setRunning(false);
out.close();
}