Set socket closing by interruption trace as FINE level

Additional comments, extract exec command default name to constant

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
2016-08-30 12:16:58 -04:00
parent ecc10994ca
commit 80d10d7d85
13 changed files with 72 additions and 78 deletions

View File

@@ -198,6 +198,8 @@ public class CLIPrompter {
}
} catch (final NumberFormatException e) {
LOGGER.log(Level.FINER,
"Unrecognized number. Prompting user again.", e); //$NON-NLS-1$
keepOn = true;
manager.println(CLIPrompterMessages
.getString(PROMPTCHOICE_FORMATERR, 0, index));
@@ -384,6 +386,8 @@ public class CLIPrompter {
try {
added = addUserChoice(val, chs, index);
} catch (final NumberFormatException e) {
LOGGER.log(Level.FINER,
"Unrecognized number. Prompting user again.", e); //$NON-NLS-1$
keepOn = true;
manager.println(CLIPrompterMessages
.getString(PROMPTCHOICE_FORMATERR, 0, index));

View File

@@ -55,6 +55,7 @@ import fr.bigeon.gclc.manager.SystemConsoleManager;
* @author Emmanuel Bigeon
*
*/
@SuppressWarnings("javadoc")
public class CommandTestingApplication {
private final PrintWriter writer;
@@ -62,6 +63,7 @@ public class CommandTestingApplication {
private final Thread th;
/** @throws IOException if the streams cannot be build */
@SuppressWarnings("resource")
public CommandTestingApplication() throws IOException {
final PipedOutputStream src = new PipedOutputStream();
InputStream in = new PipedInputStream(src);
@@ -70,6 +72,7 @@ public class CommandTestingApplication {
new SystemConsoleManager(System.out, in));
th = new Thread(new Runnable() {
@SuppressWarnings("synthetic-access")
@Override
public void run() {
application.start();

View File

@@ -124,7 +124,7 @@ public class ConsoleApplicationTest {
e.printStackTrace();
}
} catch (IOException e) {
fail("pipe creation"); //$NON-NLS-1$
fail("pipe creation " + e.getLocalizedMessage()); //$NON-NLS-1$
}
}
}

View File

@@ -62,7 +62,7 @@ public class GCLCConstantsTest {
try {
res = GCLCConstants.splitCommand("aCommand");
} catch (CommandParsingException e) {
fail("Unable to parse simple command"); //$NON-NLS-1$
fail("Unable to parse simple command " + e.getLocalizedMessage()); //$NON-NLS-1$
return;
}
assertTrue(res.size() == 1);
@@ -71,7 +71,8 @@ public class GCLCConstantsTest {
try {
res = GCLCConstants.splitCommand("aCommand with some arguments");
} catch (CommandParsingException e) {
fail("Unable to parse command with arguments"); //$NON-NLS-1$
fail("Unable to parse command with arguments " + //$NON-NLS-1$
e.getLocalizedMessage());
return;
}
assertTrue(res.size() == 4);
@@ -82,7 +83,8 @@ public class GCLCConstantsTest {
try {
res = GCLCConstants.splitCommand("aCommand with some arguments");
} catch (CommandParsingException e) {
fail("Unable to parse command with arguments and double whitspaces"); //$NON-NLS-1$
fail("Unable to parse command with arguments and double whitspaces " + //$NON-NLS-1$
e.getLocalizedMessage());
return;
}
assertTrue(res.size() == 4);
@@ -94,7 +96,8 @@ public class GCLCConstantsTest {
res = GCLCConstants
.splitCommand("aCommand \"with some\" arguments");
} catch (CommandParsingException e) {
fail("Unable to parse command with string argument"); //$NON-NLS-1$
fail("Unable to parse command with string argument " + //$NON-NLS-1$
e.getLocalizedMessage());
return;
}
assertTrue(res.size() == 3);
@@ -104,7 +107,8 @@ public class GCLCConstantsTest {
try {
res = GCLCConstants.splitCommand("aCommand with\\ some arguments");
} catch (CommandParsingException e) {
fail("Unable to parse command with arguments with escaped whitspaces"); //$NON-NLS-1$
fail("Unable to parse command with arguments with escaped whitspaces " + //$NON-NLS-1$
e.getLocalizedMessage());
return;
}
assertTrue(res.size() == 3);
@@ -115,7 +119,8 @@ public class GCLCConstantsTest {
res = GCLCConstants
.splitCommand("aCommand wi\\\"th some arguments");
} catch (CommandParsingException e) {
fail("Unable to parse command with string argument"); //$NON-NLS-1$
fail("Unable to parse command with string argument " + //$NON-NLS-1$
e.getLocalizedMessage());
return;
}
assertTrue(res.size() == 4);
@@ -131,6 +136,7 @@ public class GCLCConstantsTest {
fail("Parsing argument with string cut");
} catch (CommandParsingException e) {
// OK
assertTrue(e.getLocalizedMessage(), true);
}
}

View File

@@ -54,6 +54,7 @@ import fr.bigeon.gclc.exception.InvalidCommandName;
* @author Emmanuel Bigeon
*
*/
@SuppressWarnings("static-method")
public class ScriptExecutionTest {
/**
@@ -64,20 +65,20 @@ public class ScriptExecutionTest {
try {
CommandTestingApplication application = new CommandTestingApplication();
application.add(new ScriptExecution("script",
application.getApplication(), "#"));
application.add(new ScriptExecution("script", //$NON-NLS-1$
application.getApplication(), "#")); //$NON-NLS-1$
application.sendCommand("script src/test/resources/script1.txt");
application.sendCommand("script src/test/resources/script2.txt");
application.sendCommand("script src/test/resources/script3.txt");
application.sendCommand("script src/test/resources/script4.txt");
application.sendCommand("script src/test/resources/script1.txt"); //$NON-NLS-1$
application.sendCommand("script src/test/resources/script2.txt"); //$NON-NLS-1$
application.sendCommand("script src/test/resources/script3.txt"); //$NON-NLS-1$
application.sendCommand("script src/test/resources/script4.txt"); //$NON-NLS-1$
application
.sendCommand("script src/test/resources/script5.txt test");
.sendCommand("script src/test/resources/script5.txt test"); //$NON-NLS-1$
application.waitAndStop();
} catch (IOException | InvalidCommandName e) {
fail("Unexpected exception");
fail("Unexpected exception " + e.getLocalizedMessage()); //$NON-NLS-1$
}
}