Commit 860567e4 authored by uhflp's avatar uhflp
Browse files

Revert "Merge branch 'development' into 'master'"

This reverts merge request !39
parent ba28fabc
......@@ -4,6 +4,7 @@ import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.Random;
/**
* This class is a drop in replacement for the KIT Terminal class.
......@@ -42,11 +43,6 @@ public final class Terminal {
*/
private static final BufferedReader IN = new BufferedReader(new InputStreamReader(System.in));
/**
* this boolean determines whether the user already outputted something for that readLine call
*/
private static boolean concatOutput = false;
/**
* Private constructor to avoid object generation.
*
......@@ -71,17 +67,11 @@ public final class Terminal {
String out = "Error, " + message;
if (isTest) {
if (concatOutput) {
OUT_TEST.add(OUT_TEST.pollLast() + "\n" + out);
} else {
OUT_TEST.add(out);
concatOutput = true;
}
OUT_TEST.add(out);
} else if (isTestCreation) {
System.err.println(out);
if (useErrorMessagesInTestCreation) {
testPairFile.append(out);
testPairFile.append("\n");
} else {
testPairFile.append("Error, ...\n");
}
......@@ -101,12 +91,7 @@ public final class Terminal {
*/
public static void printLine(final Object object) {
if (isTest) {
if (concatOutput) {
OUT_TEST.add(OUT_TEST.pollLast() + "\n" + object);
} else {
OUT_TEST.add(object.toString());
concatOutput = true;
}
OUT_TEST.add(String.valueOf(object));
} else if (isTestCreation) {
System.out.println(object);
testPairFile.append(String.valueOf(object)).append("\n");
......@@ -157,11 +142,11 @@ public final class Terminal {
throw new RuntimeException(e);
}
else {
concatOutput = false;
assert !IN_TEST.isEmpty()
: "Either the executed test doesn't has quit as last input\n"
+ "or your quitting mechanism doesn't work properly.\n"
+ "Expect the second option or check the test!";
return IN_TEST.poll();
}
}
......@@ -225,7 +210,7 @@ public final class Terminal {
*/
public static void startTestCreation(String[] args) {
isTestCreation = true;
if (args != null && args.length > 0) {
if (args != null) {
testPairFile.append(test.TestBase.IO_FILE_COMMAND_LINE_ARGS_PREFIX);
for (String arg : args) {
testPairFile.append(arg);
......
package final_assignment.task_2.tests;
import final_assignment.task_2.Assignment2TestBase;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
/**
* This tests several error-messages
*
* @author Alexander Sommer
* @since 28.02.2018
*/
public class ErrorTests extends Assignment2TestBase {
/**
* This tests admin functionality
*/
@Test
@DisplayName("admin")
void adminErrors() {
testWithIOFile(getDataFolderDirectory() + "error_tests/admin.io");
}
}
This tests the admin functionality
>
Error, empty input
> banana
Error, unknown command.
> add-admin sebastian;stüker;god_of_gbi;modus_ponens
Error, user-name too long
> add-admin sebastian;stüker;god;modus_ponens
Error, user-name too short
> add-admin sebastian;stüker;gbi_god;modus_ponens_is_all_you_need
Error, password too long
> add-admin sebastian;stüker;gbi_god;modus
Error, password too short
> add-admin sebastian;stüker;gbi_god;modus_ponens
OK
> add-admin sebastian;stüker;gbi_god;modus_ponens
Error, this user-name already exists
> login-admin
Error, no parameters
> login-admin gbi_godd;modus_ponens
Error, user doesn't exist
> login-admin gbi_god;modus_ponen
Error, incorrect password
> login-admin gbi_god;modus_ponens
OK
> login-admin gbi_god;modus_ponens
Error, gbi_god is already logged in
\ No newline at end of file
......@@ -303,7 +303,21 @@ public abstract class TestBase {
for (TestPair testPair : testPairs) {
log.info("Testing " + testPair);
String output = popProgramOutput();
String partOutput;
StringBuilder stringBuilder = new StringBuilder();
do {
partOutput = popProgramOutput();
if (partOutput == null)
break;
stringBuilder.append(partOutput);
stringBuilder.append("\n");
} while (stringBuilder.length() < testPair.getOutput().length());
if (stringBuilder.length() != 0) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
String output = stringBuilder.toString();
switch (testPair.getType()) {
case CHECK_EQUALS:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment