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


Java TestUtils.readFile方法代码示例

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


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

示例1: calculatorOptimization

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void calculatorOptimization() throws Exception {
  OSMOConfiguration oc = new OSMOConfiguration();
  oc.setTestEndCondition(new LengthProbability(1, 5, 0.2d));
  oc.setFactory(new MyModelFactory());
  oc.setTrackOptions(true);
  ScoreConfiguration config = new ScoreConfiguration();
  config.setLengthWeight(0);
  MultiGreedy multiGreedy = new MultiGreedy(oc, config, 111, 5);
  List<TestCase> tests = multiGreedy.search();
  assertEquals("Number of tests from MultiGreedy", 3, tests.size());
  assertEquals("MultiGreedy test1", "TestCase:[start, increase, decrease, increase, increase]", tests.get(0).toString());
  assertEquals("MultiGreedy test2", "TestCase:[start, increase, increase, decrease, decrease]", tests.get(1).toString());
  assertEquals("MultiGreedy test3", "TestCase:[start, increase, increase, increase, increase]", tests.get(2).toString());
  String report = TestUtils.readFile(multiGreedy.createFinalReportPath(), "UTF8");
  String expected = TestUtils.getResource(GreedyTests.class, "expected-multigreedy.txt");
  assertEquals("Multi-Greedy report", expected, report);
  }
 
开发者ID:mukatee,项目名称:osmo,代码行数:19,代码来源:MultiGreedyTests.java

示例2: generation

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
  public void generation() throws Exception {
    ScoreConfiguration config = new ScoreConfiguration();
    config.setLengthWeight(0);
    oc.setTestEndCondition(new LengthProbability(1, 5, 0.1d));
    oc.setTrackOptions(true);
    ReflectiveModelFactory factory = new ReflectiveModelFactory(CalculatorModel.class);
    oc.setFactory(factory);
    GreedyOptimizer optimizer = new GreedyOptimizer(oc, config);
    GenerationResults results = optimizer.search(8);
    List<TestCase> tests = results.getTests();
    assertEquals("Number of tests from greedy", 3, tests.size());
    assertEquals("First test from greedy", "[start, increase, decrease, increase, increase]", tests.get(0).getAllStepNames().toString());
    assertEquals("Second test from greedy", "[start, increase, increase, decrease, decrease]", tests.get(1).getAllStepNames().toString());
    assertEquals("Third test from greedy", "[start, increase, increase, increase, increase]", tests.get(2).getAllStepNames().toString());
//    assertEquals("Output report from greedy", "", TestUtils.getOutput());
    String report = TestUtils.readFile(optimizer.createReportPath(), "UTF8");
    String expected = TestUtils.getResource(GreedyTests.class, "expected-greedy.txt");
    assertEquals("Greedy report", expected, report);
  }
 
开发者ID:mukatee,项目名称:osmo,代码行数:21,代码来源:GreedyTests.java

示例3: loadTests

import osmo.common.TestUtils; //导入方法依赖的package包/类
public List<TestScript> loadTests(String dir) {
  List<TestScript> scripts = new ArrayList<>();
  List<String> files = TestUtils.listFiles(dir, "tc", true);
  for (String file : files) {
    String scriptText = TestUtils.readFile(file, "UTF8");
    TestScript script = parse(scriptText);
    scripts.add(script);
  }
  return scripts;
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:11,代码来源:TestLoader.java

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

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

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

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


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