本文整理汇总了Java中osmo.common.TestUtils.endOutputCapture方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.endOutputCapture方法的具体用法?Java TestUtils.endOutputCapture怎么用?Java TestUtils.endOutputCapture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmo.common.TestUtils
的用法示例。
在下文中一共展示了TestUtils.endOutputCapture方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: down
import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void down() {
TestUtils.endOutputCapture();
}
示例6: restore
import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void restore() {
TestUtils.endOutputCapture();
}
示例7: resetAfter
import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void resetAfter() {
TestUtils.endOutputCapture();
}
示例8: after
import osmo.common.TestUtils; //导入方法依赖的package包/类
@AfterMethod
public void after() {
TestUtils.endOutputCapture();
}