本文整理汇总了Java中osmo.common.TestUtils.getOutput方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.getOutput方法的具体用法?Java TestUtils.getOutput怎么用?Java TestUtils.getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmo.common.TestUtils
的用法示例。
在下文中一共展示了TestUtils.getOutput方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: captureString
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void captureString() throws Exception {
int serverPort = PortManager.port();
int proxyPort = PortManager.port();
//create a test server to give us a page to request
TCPTestServer2 server = new TCPTestServer2(serverPort, "console string test\n");
server.start();
//configure the tunnel to accept connections on port 5598 and forward them to localhost:5599
Params params = new Params(proxyPort, "localhost", serverPort);
params.enableStringConsoleLogger();
//this is how we actually start the tunnel
Main main = new Main(params);
main.start();
//send a test request to get some data in the tunnel
String response = TCPMsgSender.send2("localhost", proxyPort, "hi there");
//check we got the correct response from the server
assertEquals(response, "console string test\n", "Response content");
//short sleep in hopes the tunnel is closed
Thread.sleep(100);
TestUtils.endOutputCapture();
String actual = TestUtils.getOutput();
actual = stripResponseForTest(actual);
String expected = TestUtils.getResource(ConsoleLoggingTests.class, "expected_console2.txt")+"\n";
assertEquals(actual, expected);
}
示例2: tracePrinter
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void tracePrinter() {
osmo.addModelObject(new ValidTestModel2(new Requirements()));
TracePrinter printer = new TracePrinter();
osmo.addListener(printer);
osmo.setTestEndCondition(new Length(3));
osmo.setSuiteEndCondition(new Length(2));
osmo.getConfig().setTrackOptions(true);
osmo.generate(555);
String output = TestUtils.getOutput();
String expected = "1.1.STEP:HELLO\n" +
"1.2.STEP:WORLD\n" +
"1.3.STEP:EPIXX\n" +
"1.4.LASTSTEP:LAST\n" +
"2.1.STEP:EPIXX\n" +
"2.2.STEP:EPIXX\n" +
"2.3.STEP:EPIXX\n" +
"2.4.LASTSTEP:LAST\n" +
"generated 2 tests.\n" +
"\n" +
"Covered elements:\n" +
"Total steps: 6\n" +
"Unique steps: 3 (of 3)\n" +
"Unique step-pairs: 5 (of 5)\n" +
"Unique requirements: 3\n" +
"Variable values: 0\n" +
"Unique coverage-values: 0\n" +
"Unique coverage-value-pairs: 0\n" +
"\n" +
"Requirements:[]\n" +
"Covered:[epix, hello, world]\n" +
"Not covered:[]\n" +
"\n";
expected = unifyLineSeparators(expected, "\n");
output = unifyLineSeparators(output, "\n");
assertEquals("Captured output but TracePrinter", expected, output);
}
示例3: defaultFactory
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void defaultFactory() {
MultiOSMO mosmo = new MultiOSMO(4);
TestUtils.startOutputCapture();
try {
mosmo.generate(new Time(1), 444);
fail("Generation without any model objects should fail.");
} catch (Exception e) {
//expected
}
String output = TestUtils.getOutput();
assertEquals("Message for default factory", MultiOSMO.ERROR_MSG+System.getProperty("line.separator"), output);
}
示例4: defaultFactory
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void defaultFactory() {
GreedyOptimizer greedy = new GreedyOptimizer(oc, gc);
oc.setFactory(new SingleInstanceModelFactory());
TestUtils.startOutputCapture();
try {
greedy.search(8);
fail("Generation without any model objects should fail.");
} catch (Exception e) {
//expected
}
String output = TestUtils.getOutput();
assertEquals("Message for default factory", MultiOSMO.ERROR_MSG + System.getProperty("line.separator"), output);
}
示例5: noArgs
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void noArgs() {
Main.main(new String[] {});
String output = TestUtils.getOutput();
String expected = TestUtils.getResource(MainTests.class, "expected_help.txt")+"\n";
output = TestUtils.unifyLineSeparators(output, "\n");
expected = TestUtils.unifyLineSeparators(expected, "\n");
assertEquals(output, expected, "Output msg with no parameters");
}
示例6: helpOnly
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void helpOnly() {
Main.main(new String[] {"--help"});
String output = TestUtils.getOutput();
String expected = TestUtils.getResource(MainTests.class, "expected_help.txt")+"\n";
output = TestUtils.unifyLineSeparators(output, "\n");
expected = TestUtils.unifyLineSeparators(expected, "\n");
assertEquals(output, expected, "Output msg with no parameters");
}
示例7: sendAndReadResponse
import osmo.common.TestUtils; //导入方法依赖的package包/类
private void sendAndReadResponse(String msg, String expectedFileName) throws Exception {
//send test data in the tunnel
UDPMsgSender.send2("localhost", params.getSourcePort(), msg);
//wait for UDP server to receive the sent data
Thread.sleep(100);
//check the server received the data
assertEquals(server.getReceiveString(), msg, "UDP Server received data");
TestUtils.endOutputCapture();
String actual = TestUtils.getOutput();
//first line prints opening tunnel, last one closing it. ports on those lines are random so better to remove them from assert
actual = stripResponseForTest(actual);
String expected = TestUtils.getResource(ConsoleLoggingTests.class, expectedFileName)+"\n";
assertEquals(actual, expected);
}
示例8: captureIntList
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void captureIntList() throws Exception {
//create a test server to give us a page to request
int serverPort = PortManager.port();
int proxyPort = PortManager.port();
TCPTestServer2 server = new TCPTestServer2(serverPort, "console test1");
server.start();
//configure the tunnel to accept connections on port 5598 and forward them to localhost:5599
Params params = new Params(proxyPort, "localhost", serverPort);
params.enableByteConsoleLogger(false);
//this is how we actually start the tunnel
Main main = new Main(params);
main.start();
//send a test request to get some data in the tunnel
String response = TCPMsgSender.send2("localhost", proxyPort, "hi there");
//check we got the correct response from the server
assertEquals(response, "console test1", "Response content");
//short sleep in hopes the tunnel is closed
Thread.sleep(100);
TestUtils.endOutputCapture();
String actual = TestUtils.getOutput();
//first line prints opening tunnel, last one closing it. ports on those lines are random so better to remove them from assert
actual = stripResponseForTest(actual);
String expected = TestUtils.getResource(ConsoleLoggingTests.class, "expected_console1.txt")+"\n";
assertEquals(actual, expected);
}
示例9: captureHexString
import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void captureHexString() throws Exception {
//create a test server to give us a page to request
int serverPort = PortManager.port();
int proxyPort = PortManager.port();
TCPTestServer2 server = new TCPTestServer2(serverPort, "hex console test");
server.start();
//configure the tunnel to accept connections on port 5598 and forward them to localhost:5599
Params params = new Params(proxyPort, "localhost", serverPort);
params.enableByteConsoleLogger(true);
//this is how we actually start the tunnel
Main main = new Main(params);
main.start();
//send a test request to get some data in the tunnel
String response = TCPMsgSender.send2("localhost", proxyPort, "hi there hex boy");
//check we got the correct response from the server
assertEquals(response, "hex console test", "Response content");
//short sleep in hopes the tunnel is closed
Thread.sleep(100);
TestUtils.endOutputCapture();
String actual = TestUtils.getOutput();
//first line prints opening tunnel, last one closing it. ports on those lines are random so better to remove them from assert
actual = stripResponseForTest(actual);
String expected = TestUtils.getResource(ConsoleLoggingTests.class, "expected_console3.txt")+"\n";
assertEquals(actual, expected);
}