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


Java TestUtils.getResource方法代码示例

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


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

示例1: schemaSNMPFloatToTable

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void schemaSNMPFloatToTable() {
  Config.cassandraKeySpace = "test_ks";
  SchemaRepository repo = new SchemaRepository();
  Collection<Schema> schemas = repo.getSchemas();
  Schema snmpFloat = null;
  for (Schema schema : schemas) {
    String name = schema.getName();
    if (name.equals("SNMPFloat")) {
      snmpFloat = schema;
      break;
    }
  }
  String table = CassandaAvroConsumer.tableFor(snmpFloat);
  String expected = TestUtils.getResource(CassandraAvroTests.class, "expected_snmpfloat_table.txt");
  assertEquals(table, expected, "Generated table for SNMPFloat schema");
}
 
开发者ID:mukatee,项目名称:kafka-consumer,代码行数:18,代码来源:CassandraAvroTests.java

示例2: issue32

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void issue32() {
  OSMOTester tester = new OSMOTester();
  tester.setTestEndCondition(new Length(5));
  tester.setSuiteEndCondition(new Length(5));
  tester.setAlgorithm(new WeightedBalancingAlgorithm());
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(bos);
  tester.setModelFactory(new MyModelFactory(ps));
  tester.generate(333);
  String expected = TestUtils.getResource(Issue32to36.class, "expected/issue32.txt");
  String actual = bos.toString();
  actual = unifyLineSeparators(actual, "\n");
  expected = unifyLineSeparators(expected, "\n");
  assertEquals("WeightedBalancing should not interfere with guards", expected, actual);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:17,代码来源:Issue32to36.java

示例3: issue33

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void issue33() throws IOException {
  OSMOTester tester = new OSMOTester();
  tester.setTestEndCondition(new Length(5));
  tester.setSuiteEndCondition(new Length(5));
  tester.setAlgorithm(new WeightedBalancingAlgorithm());
  tester.setModelFactory(new MyModelFactory(NullPrintStream.stream));
  tester.generate(333);
  TestSuite suite = tester.getSuite();
  FSM fsm = tester.getFsm();
  HTMLCoverageReporter reporter = new HTMLCoverageReporter(suite.getCoverage(), suite.getAllTestCases(), fsm);
  String matrix = reporter.getTraceabilityMatrix();
  String expected = TestUtils.getResource(Issue32to36.class, "expected/issue33.txt");
  matrix = unifyLineSeparators(matrix, "\n");
  expected = unifyLineSeparators(expected, "\n");
  assertEquals("Reporting of test trace order", expected, matrix);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:18,代码来源:Issue32to36.java

示例4: issue34

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void issue34() throws Exception {
  OSMOTester tester = new OSMOTester();
  tester.getConfig().setDataTraceRequested(true);
  tester.setTestEndCondition(new Length(5));
  tester.setSuiteEndCondition(new Length(5));
  tester.setAlgorithm(new WeightedBalancingAlgorithm());
  tester.setModelFactory(new MyModelFactory(NullPrintStream.stream));
  tester.generate(333);
  TestSuite suite = tester.getSuite();
  TraceReportWriter tracer = new TraceReportWriter();
  String report = tracer.createReport(suite.getAllTestCases());
  String expected = TestUtils.getResource(Issue32to36.class, "expected/issue34.txt");
  report = unifyLineSeparators(report, "\n");
  expected = unifyLineSeparators(expected, "\n");
  assertEquals("Reporting of test trace order", expected, report);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:18,代码来源:Issue32to36.java

示例5: twoVariablesTwoTestsTwoSteps

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void twoVariablesTwoTestsTwoSteps() {
  RFScripter scripter = new RFScripter(2);
  scripter.setTestLibrary("SeleniumLibrary");
  scripter.addVariable("var1", "hello");
  scripter.addVariable("var2", "world");
  scripter.startTest("test1");
  scripter.addStep("step1-1", new RFParameter("s1-1 p1"), new RFParameter("s1-1 p2"));
  scripter.addStep("step1-2", new RFParameter("s1-2 p1"), new RFParameter("s1-2 p2"));
  scripter.startTest("test2");
  scripter.addStep("step2-1", new RFParameter("s2-1 p1"), new RFParameter("s2-1 p2"));
  scripter.addStep("step2-2", new RFParameter("s2-2 p1"), new RFParameter("s2-2 p2"));
  String script = scripter.createScript();
  script = unifyLineSeparators(script, "\n");
  String expected = TestUtils.getResource(RobotFrameworkTests.class, "expected1.html");
  expected = unifyLineSeparators(expected, "\n");
  assertEquals("Generated script", expected, script);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:19,代码来源:RobotFrameworkTests.java

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

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

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

示例9: errorMsg

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void errorMsg() {
  String msg = TestUtils.getResource(InFluxJSONTests.class, "test_msg_error.json");
  influx.process(msg);
  QueryResult result = db.query(new Query("select * from test_oid3", dbName));
  assertMeasure(result, 0, 0, 1, 1, "1.1.1.2.1", "127.0.0.1:155", "test target 3", "error", "test_oid3", "value_could_not_be_read");
}
 
开发者ID:mukatee,项目名称:kafka-consumer,代码行数:8,代码来源:InFluxJSONTests.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: floatMeasures2

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void floatMeasures2() {
  String msg = TestUtils.getResource(InFluxJSONTests.class, "test_msg_cpu_float.json");
  influx.process(msg);
  msg = TestUtils.getResource(InFluxJSONTests.class, "test_msg_cpu_int.json");
  influx.process(msg);
  QueryResult result = db.query(new Query("select * from cpu_load", dbName));
  assertMeasure(result, 0, 0, 2, 1, "1.1.1.2.1", "127.0.0.1:155", "server01", "data_value", "cpu_load", "2.0");
  assertMeasure(result, 0, 1, 2, 1, "1.1.1.2.1", "127.0.0.1:155", "server01", "data_value", "cpu_load", "3");
}
 
开发者ID:mukatee,项目名称:kafka-consumer,代码行数:11,代码来源:InFluxJSONTests.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: 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

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

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


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