本文整理匯總了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();
}