当前位置: 首页>>代码示例>>Java>>正文


Java TestUtils.endOutputCapture方法代码示例

本文整理汇总了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);
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:27,代码来源:ConsoleLoggingTests.java

示例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);
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:16,代码来源:ConsoleLoggingTests.java

示例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);
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:28,代码来源:ConsoleLoggingTests.java

示例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);
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:28,代码来源:ConsoleLoggingTests.java

示例5: down

import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void down() {
  TestUtils.endOutputCapture();
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:5,代码来源:ListenerTests.java

示例6: restore

import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void restore() {
  TestUtils.endOutputCapture();
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:5,代码来源:MultiOSMOTests.java

示例7: resetAfter

import osmo.common.TestUtils; //导入方法依赖的package包/类
@After
public void resetAfter() {
  TestUtils.endOutputCapture();
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:5,代码来源:MultiGreedyTests.java

示例8: after

import osmo.common.TestUtils; //导入方法依赖的package包/类
@AfterMethod
public void after() {
  TestUtils.endOutputCapture();
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:5,代码来源:MainTests.java


注:本文中的osmo.common.TestUtils.endOutputCapture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。