當前位置: 首頁>>代碼示例>>Java>>正文


Java TestUtils.getOutput方法代碼示例

本文整理匯總了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);
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:27,代碼來源:ConsoleLoggingTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:osmo,代碼行數:38,代碼來源:ListenerTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:osmo,代碼行數:14,代碼來源:MultiOSMOTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:osmo,代碼行數:15,代碼來源:GreedyTests.java

示例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");
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:10,代碼來源:MainTests.java

示例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");
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:10,代碼來源:MainTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:16,代碼來源:ConsoleLoggingTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:28,代碼來源:ConsoleLoggingTests.java

示例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);
}
 
開發者ID:mukatee,項目名稱:java-tcp-tunnel,代碼行數:28,代碼來源:ConsoleLoggingTests.java


注:本文中的osmo.common.TestUtils.getOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。