package com.statusParser.tests;
import com.statusParser.Configuring;
import org.junit.*;
import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/**
* Created with IntelliJ IDEA.
* User: sadvr
* Date: 1/17/14
* Time: 9:57 AM
*/
public class ConfiguringTestDrive {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
private static PrintStream oldOut;
private static PrintStream oldErr;
@Before
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
oldOut = System.out;
oldErr = System.err;
}
@After
public void cleanUpStreams() {
System.setOut(null);
System.setErr(null);
/*
System.out.flush();
System.setOut(oldOut);
System.setErr(oldErr);
*/
}
@Test
public void startWrong() {
Configuring conf = new Configuring();
String[] randomArgs = {"wrongCommand", "что", "1", "!", "5", "3", ";", "smth", "1 2", "h a", "smth да"};
for (String randomArg : randomArgs) {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
String[] argsTest = {"smth", randomArg};
conf.start(argsTest);
// assertEquals("Unknown config parameter: " + randomArg + "\\n", outContent.toString()); //FIXME!!! the end of the line
//assertTrue(outContent.toString().matches("Unknown config parameter: " + randomArg + "[randomArg\\n]")); //FIXME!!! wrong regex
}
}
}