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


Java TestUtils.unifyLineSeparators方法代码示例

本文整理汇总了Java中osmo.common.TestUtils.unifyLineSeparators方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.unifyLineSeparators方法的具体用法?Java TestUtils.unifyLineSeparators怎么用?Java TestUtils.unifyLineSeparators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osmo.common.TestUtils的用法示例。


在下文中一共展示了TestUtils.unifyLineSeparators方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: explorationModeEnabled

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void explorationModeEnabled() {
  ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
  PrintStream ps = new PrintStream(out);
  config = new ExplorationConfiguration(new PaperModel1Factory(ps), 8, 8);
  config.setStepWeight(0);
  config.setStepPairWeight(0);
  config.setDefaultValueWeight(1);
  config.setVariableCountWeight(0);
  config.setRequirementWeight(0);
  config.setMinTestLength(5);
  config.setMinSuiteLength(5);
  config.setFallbackProbability(1d);
  osmo.explore(config);
  List<TestCase> tests = osmo.getSuite().getAllTestCases();
  assertEquals("Suite size", 5, tests.size());
  String expected =
          "Starting new test case 1\n" +
                  "+++++Starting new test case 2\n" +
                  "+++--Starting new test case 3\n" +
                  "+++++Starting new test case 4\n" +
                  "++-++Starting new test case 5\n" +
                  "+++++";
  String actual = out.toString();
  actual = TestUtils.unifyLineSeparators(actual, "\n");
  assertEquals("Exploration output", expected, actual);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:28,代码来源:ExplorationTests.java

示例2: probableModel

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void probableModel() throws Exception {
  TestUtils.recursiveDelete(REDUCER_FOLDER);
  ReducerConfig config = new ReducerConfig(111);
  config.setParallelism(1);
  Reducer reducer = new Reducer(config);
  OSMOConfiguration osmoConfig = reducer.getOsmoConfig();
  osmoConfig.setFactory(new ReflectiveModelFactory(ErrorModelProbability.class));
  config.setInitialTime(TimeUnit.SECONDS, 5);
  config.setFuzzTime(TimeUnit.SECONDS, 5);
  config.setShorteningTime(TimeUnit.SECONDS, 5);
  config.setPopulationSize(50);
  config.setLength(10);
  config.setTestMode(true);
  ReducerState state = reducer.search();
  List<TestCase> tests = state.getTests();
  assertEquals("Number of tests", 1, tests.size());
  TestCase test1 = tests.get(0);
  assertEquals("Final test length", 1, test1.getAllStepNames().size());
  assertEquals("Iteration lengths", "[]", state.getLengths().toString());
  String report = TestUtils.readFile(REDUCER_FOLDER + "/reducer-final.txt", "UTF8");
  String expected = TestUtils.getResource(ReducerTests.class, "expected-reducer.txt");
  report = TestUtils.unifyLineSeparators(report, "\n");
  expected = TestUtils.unifyLineSeparators(expected, "\n");
  assertEquals("Reducer report", expected, report);
  List<String> files = TestUtils.listFiles(REDUCER_FOLDER, ".html", false);
  assertEquals("Generated report files", "[final-tests.html]", files.toString());
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:29,代码来源:ReducerTests.java

示例3: model10

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void model10() throws Exception {
  TestUtils.recursiveDelete(REDUCER_FOLDER);
  ReducerConfig config = new ReducerConfig(111);
  config.setStrictReduction(false);
  config.setParallelism(1);
  //changed here on 8apr15
  config.setInitialTime(TimeUnit.SECONDS, 10);
  config.setFuzzTime(TimeUnit.SECONDS, 10);
  config.setShorteningTime(TimeUnit.SECONDS, 10);
  Reducer reducer = new Reducer(config);
  OSMOConfiguration osmoConfig = reducer.getOsmoConfig();
  osmoConfig.setFactory(new ReflectiveModelFactory(Model10Debug.class));
  //TODO: move this to config object
  reducer.setDeleteOldOutput(true);
  // config.setTotalTime(TimeUnit.SECONDS, 1);
  //TODO: length asettaa siis oikeasti sen pituuden ja jos osmo-config on mitään asetettu pitäisi herjata
  config.setPopulationSize(1500);
  config.setLength(50);
  config.setTestMode(true);
  ReducerState state = reducer.search();
  List<TestCase> tests = state.getTests();
  // assertEquals("Number of tests", 230, tests.size());
  TestCase test1 = tests.get(0);
  //this does not produce multiple tests as the initial fuzz only stores the shortest of all found failures
  //since finding equally short failing tests by fuzzing is very unlikely, we end up with just one
  //although it would be possible to have others as well..
  // assertEquals("Final test length", 11, test1.getAllStepNames().size());
  // assertEquals("Iteration lengths", "[25, 22, 17, 14, 13, 12, 11]", state.getLengths().toString());
  String report = TestUtils.readFile(REDUCER_FOLDER + "/reducer-final.txt", "UTF8");
  String expected = TestUtils.getResource(ReducerTests.class, "expected-reducer3.txt");
  report = TestUtils.unifyLineSeparators(report, "\n");
  expected = TestUtils.unifyLineSeparators(expected, "\n");
  String[] replaced = TestUtils.replace("##", expected, report);
  report = replaced[0];
  expected = replaced[1];
  assertEquals("Reducer report", expected, report);
  List<String> files = TestUtils.listFiles(REDUCER_FOLDER, ".html", false);
  assertEquals("Generated report files", "[final-tests.html]", files.toString());
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:41,代码来源:ReducerTests.java

示例4: 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

示例5: 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

示例6: stripResponseForTest

import osmo.common.TestUtils; //导入方法依赖的package包/类
public String stripResponseForTest(String from) {
  String s = TestUtils.unifyLineSeparators(from, "\n");
  String[] lines = s.split("\n");
  StringBuilder sb = new StringBuilder(from.length());
  for (String line : lines) {
    //remove tunnel status lines. ports on those lines are random so better to remove them from assert
    if (line.startsWith("UDP Forwarding")) continue;
    //remove also output from UDP test server
    if (line.startsWith("UDP test")) continue;
    //trim the line since looking at the expected files in editor stripts trailing whitespace
    sb.append(line.trim());
    sb.append("\n");
  }
  return sb.toString();
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:16,代码来源:ConsoleLoggingTests.java

示例7: assertUDPStream

import osmo.common.TestUtils; //导入方法依赖的package包/类
private void assertUDPStream(InMemoryLogger logger, String filename) throws Exception {
  //here we get the actual data that was passed through the tunnel (UDP only does one-way so this has to be upstream)
  String actual = logger.getString("UTF8");
  //the rest of this is just making sure the test should run the same over different platforms and with varying date-times in HTTP headers
  actual = TestUtils.unifyLineSeparators(actual, "\n");
  String expected = TestUtils.getResource(InMemoryCaptureTests.class, filename);
  expected = TestUtils.unifyLineSeparators(expected, "\n");
  assertEquals(actual, expected, "Request content");
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:10,代码来源:InMemoryCaptureTests.java

示例8: captureTextBytes

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void captureTextBytes() throws Exception {
  //create a test server to give us a page to request
  int serverPort = PortManager.port();
  int proxyPort = PortManager.port();
  UDPTestServer server = new UDPTestServer(serverPort);
  server.start();
  while (!server.isStarted()) {
    //first wait for server to start up before sending it something
    Thread.sleep(100);
  }
  //configure the tunnel to accept connections on proxyport and forward them to localhost:serverpot
  Params params = new Params(proxyPort, "localhost", serverPort);
  params.enableByteFileLogger(null, UPLOADLOGFILE); //TODO: check if UDP logging enabled downstream logger definition should give error
  params.setUDP(true);
  //this is how we actually start the tunnel
  Main main = new Main(params);
  main.start();
  Thread.sleep(100);
  //send a test request to get some data in the tunnel
  UDPMsgSender.send2("localhost", proxyPort, "hi there");
  Thread.sleep(300);
  //check we got the correct data at test server
  assertEquals(server.getReceiveString(), "hi there", "Data received by UDP test server");

  String up = TestUtils.readFile(UPLOADLOGFILE + ".bytes", "UTF8");
  up = TestUtils.unifyLineSeparators(up, "\n");
  assertEquals(up, "hi there");
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:30,代码来源:FileLoggingTests.java

示例9: stripResponseForTest

import osmo.common.TestUtils; //导入方法依赖的package包/类
public String stripResponseForTest(String from) {
    String s = TestUtils.unifyLineSeparators(from, "\n");
    String[] lines = s.split("\n");
    StringBuilder sb = new StringBuilder(from.length());
    for (String line : lines) {
      //remove tunnel status lines. ports on those lines are random so better to remove them from assert
      if (line.startsWith("TCP Forwarding")) continue;
      //remove date lines as datetimes vary across executions
//      if (line.startsWith("Date")) continue;
      //trim the line since looking at the expected files in editor stripts trailing whitespace
      sb.append(line.trim());
      sb.append("\n");
    }
    return sb.toString();
  }
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:16,代码来源:ConsoleLoggingTests.java

示例10: assertTcpStream

import osmo.common.TestUtils; //导入方法依赖的package包/类
private void assertTcpStream(InMemoryLogger logger, String filename) throws Exception {
  //here we get the actual data that was passed through the tunnel in one direction (depending if we get passed the upstream memorylogger or downstream)
  String actual = logger.getString("UTF8");
  //the rest of this is just making sure the test should run the same over different platforms and with varying date-times in HTTP headers
  actual = TestUtils.unifyLineSeparators(actual, "\n");
  String expected = TestUtils.getResource(InMemoryCaptureTests.class, filename);
  expected = TestUtils.unifyLineSeparators(expected, "\n");
  assertEquals(actual, expected, "Request content");
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:10,代码来源:InMemoryCaptureTests.java

示例11: captureTextBytes

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void captureTextBytes() 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.enableByteFileLogger(DOWNLOADLOGFILE, UPLOADLOGFILE);
  //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);
  String down = TestUtils.readFile(DOWNLOADLOGFILE + ".bytes", "UTF8");
  down = TestUtils.unifyLineSeparators(down, "\n");
  String up = TestUtils.readFile(UPLOADLOGFILE + ".bytes", "UTF8");
  up = TestUtils.unifyLineSeparators(up, "\n");
  assertEquals(down, "console test1");
  assertEquals(up, "hi there");
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:28,代码来源:FileLoggingTests.java

示例12: helpText

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void helpText() {
  String help = ArgumentParser.help();
  help = TestUtils.unifyLineSeparators(help, "\n");
  String expected = TestUtils.getResource(ParserTests.class, "expected_help.txt");
  expected = TestUtils.unifyLineSeparators(expected, "\n");
  assertEquals(help, expected, "Help text");
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:9,代码来源:ParserTests.java

示例13: invalidTests

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test(dataProvider = "invalidDataProvider")
public void invalidTests(String[] args, String expectedError, String failMsg) {
  Params params = ArgumentParser.parseArgs(args);
  String errors = params.getErrors();
  errors = TestUtils.unifyLineSeparators(errors, "\n");
  assertEquals(errors, expectedError, failMsg);
}
 
开发者ID:mukatee,项目名称:java-tcp-tunnel,代码行数:8,代码来源:ParserTests.java


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