org.apache.edgent.topology.Topology.getTester()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.apache.edgent.topology.Topology.getTester()方法的一些代码示例,展示了Topology.getTester()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Topology.getTester()方法的具体详情如下:
包路径:org.apache.edgent.topology.Topology
类名称:Topology
方法名:getTester

Topology.getTester介绍

[英]Get the tester for this topology.
[中]获取此拓扑的测试仪。

代码示例

代码示例来源:origin: apache/incubator-edgent

protected boolean complete(Topology topology, Condition<?> endCondition, long timeout, TimeUnit units) throws Exception {
  return topology.getTester().complete(getSubmitter(), new JsonObject(), endCondition, timeout, units);
}

代码示例来源:origin: apache/incubator-edgent

protected void waitUntilComplete(Topology t, TStream<String> s, String[] data) throws Exception {
    Condition<Long> tc = t.getTester().tupleCount(s, data.length);
    complete(t, tc);
    
    // Save the job.
    job = t.getTester().getJob();
    assertNotNull(job);
    
  }
}

代码示例来源:origin: apache/incubator-edgent

private void waitUntilComplete(Topology t, TStream<String> s, String[] data) throws Exception {
    Condition<Long> tc = t.getTester().tupleCount(s, data.length);
    complete(t, tc);
  }
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testFanout2() throws Exception {
  Topology t = newTopology();
  
  TStream<String> s = t.strings("a", "b", "c");
  TStream<String> sf = s.filter(tuple -> "b".equals(tuple));
  TStream<String> sm = s.modify(tuple -> tuple.concat("fo2"));
  Condition<Long> tsmc = t.getTester().tupleCount(sm, 3);
  Condition<List<String>> tsf = t.getTester().streamContents(sf, "b");
  Condition<List<String>> tsm = t.getTester().streamContents(sm, "afo2", "bfo2", "cfo2");
  complete(t, t.getTester().and(tsm, tsmc));
  assertTrue(tsf.getResult().toString(), tsf.valid());
  assertTrue(tsm.getResult().toString(), tsm.valid());
}
@Test

代码示例来源:origin: apache/incubator-edgent

@Test
public void tesFlattMapWithNullValues() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("mary had a little lamb",
      "its fleece was white as snow");
  TStream<String> w = s.flatMap(tuple-> {List<String> values = Arrays.asList(tuple.split(" "));
   values.set(2, null); values.set(4, null); return values;});
  assertStream(t, w);
  Condition<List<String>> contents = t.getTester().streamContents(w, "mary", "had",
      "little", "its", "fleece",  "white",
      "snow");
  complete(t, contents);
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

public void completeAndValidate(boolean ordered, String msg, Topology t,
    TStream<String> s, int secTimeout, String... expected)
    throws Exception {
  // if expected.length==0 we must run until the job completes or tmo
  Condition<Long> tc = t.getTester().tupleCount(s, 
      expected.length == 0 ? Long.MAX_VALUE : expected.length);
  Condition<List<String>> contents = 
      ordered ? t.getTester().streamContents(s, expected)
          : t.getTester().contentsUnordered(s, expected);
  complete(t, tc, secTimeout, TimeUnit.SECONDS);
  assertTrue(msg + " contents:" + contents.getResult(), contents.valid());
  if (expected.length != 0)
    assertTrue("valid:" + tc.getResult(), tc.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testDeadtimeTooShort() throws Exception {
  Topology topology = newTopology("testDeadtimeTooShort");
  
  TStream<Integer> values = topology.of(1,2,3,4,5,6,7,8,9,10);
  
  // no deadtime due to < 1ms
  TStream<Integer> filtered = Filters.deadtime(values, 999, TimeUnit.MICROSECONDS);
  
  Condition<Long> count = topology.getTester().tupleCount(filtered, 10);
  Condition<List<Integer>> contents = topology.getTester().streamContents(filtered, 1,2,3,4,5,6,7,8,9,10 );
  complete(topology, count);
  
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testFilter() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("a", "b", "c");
  s = s.filter(tuple -> "b".equals(tuple));
  assertStream(t, s);
  Condition<Long> tc = t.getTester().tupleCount(s, 1);
  Condition<List<String>> contents = t.getTester().streamContents(s, "b");
  complete(t, tc);
  assertTrue(contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void tesFlattMapWithNullIterator() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("mary had a little lamb", "NOTUPLES",
      "its fleece was white as snow");
  TStream<String> w = s.flatMap(tuple->tuple.equals("NOTUPLES") ? null : Arrays.asList(tuple.split(" ")));
  assertStream(t, w);
  Condition<List<String>> contents = t.getTester().streamContents(w, "mary", "had",
      "a", "little", "lamb", "its", "fleece", "was", "white", "as",
      "snow");
  complete(t, contents);
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testModify() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("a", "b", "c");
  TStream<String> i = s.modify(tuple -> tuple.concat("M"));
  assertStream(t, i);
  Condition<Long> tc = t.getTester().tupleCount(i, 3);
  Condition<List<String>> contents = t.getTester().streamContents(i, "aM", "bM", "cM");
  complete(t, tc);
  assertTrue(contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testDeadtimeNoDeadtime() throws Exception {
  Topology topology = newTopology("testDeadtimeNoDeadtime");
  
  TStream<Integer> values = topology.of(1,2,3,4,5,6,7,8,9,10);
  
  // no deadtime
  TStream<Integer> filtered = Filters.deadtime(values, 0, TimeUnit.MILLISECONDS);
  
  Condition<Long> count = topology.getTester().tupleCount(filtered, 10);
  Condition<List<Integer>> contents = topology.getTester().streamContents(filtered, 1,2,3,4,5,6,7,8,9,10 );
  complete(topology, count);
  
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testStringContants() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("a", "b", "c");
  assertStream(t, s);
  Condition<Long> tc = t.getTester().tupleCount(s, 3);
  Condition<List<String>> contents = t.getTester().streamContents(s, "a", "b", "c");
  complete(t, tc);
  assertTrue(contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testMap() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("32", "423", "-746");
  TStream<Integer> i = s.map(Integer::valueOf);
  assertStream(t, i);
  Condition<Long> tc = t.getTester().tupleCount(i, 3);
  Condition<List<Integer>> contents = t.getTester().streamContents(i, 32, 423, -746);
  complete(t, tc);
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void tesFlattMap() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("mary had a little lamb",
      "its fleece was white as snow");
  TStream<String> w = s.flatMap(tuple->Arrays.asList(tuple.split(" ")));
  assertStream(t, w);
  Condition<List<String>> contents = t.getTester().streamContents(w, "mary", "had",
      "a", "little", "lamb", "its", "fleece", "was", "white", "as",
      "snow");
  complete(t, contents);
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testModifyWithDrops() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("32", "423", "-746");
  TStream<Integer> i = s.map(Integer::valueOf);
  i = i.modify(tuple -> tuple < 0 ? null : tuple + 27);
  assertStream(t, i);
  Condition<Long> tc = t.getTester().tupleCount(i, 2);
  Condition<List<Integer>> contents = t.getTester().streamContents(i, 59, 450);
  complete(t, tc);
  assertTrue(contents.getResult().toString(), contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testDeadbandIdentity() throws Exception {
  Topology topology = newTopology("testDeadband");
  
  TStream<Double> values = topology.of(12.9, 3.4, 12.3, 15.6, 18.4, -3.7, -4.5, 15.0, 16.0, 30.0, 42.0 );
  
  TStream<Double> filtered = Filters.deadband(values, identity(),
      v -> v >= 10.0 && v <= 30.0);
  
  Condition<Long> count = topology.getTester().tupleCount(filtered, 7);
  Condition<List<Double>> contents = topology.getTester().streamContents(filtered, 12.9, 3.4, 12.3, -3.7, -4.5, 15.0, 42.0 );
  complete(topology, count);
  assertTrue(count.valid());
  assertTrue(contents.valid());
}
@Test

代码示例来源:origin: apache/incubator-edgent

@Test
public void testNoStringContants() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings();
  Condition<Long> tc = t.getTester().tupleCount(s, 0);
  complete(t, tc);
  
  assertTrue(tc.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testPressureRelieverNoDrop() throws Exception {
  Topology topology = newTopology();
  
  // Same pipeline config as testPressureRelieverDrop but the reliever queue is
  // big enough to avoid drops
  String[] tuples = {"A", "B", "C", "D", "E", "F", "G", "H"};
  TStream<String> raw = topology.strings(tuples);
  
  TStream<String> pr = PlumbingStreams.pressureReliever(raw, Functions.unpartitioned(), 100);
  
  TStream<String> pr2 = PlumbingStreams.blockingOneShotDelay(pr, 1, TimeUnit.SECONDS);
  
  Condition<Long> tcCount = topology.getTester().tupleCount(pr2, tuples.length);
  Condition<List<String>> contents = topology.getTester().streamContents(pr2, tuples);
  complete(topology, tcCount);
  
  assertTrue(tcCount.valid());
  assertTrue(contents.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testDelete() throws Exception {
  DirectProvider ep = new DirectProvider();
  
  Topology topology = ep.newTopology();
  
  String url = "http://httpbin.org/delete";
  
  TStream<String> stream = topology.strings(url);
  TStream<String> rc = HttpStreams.<String, String>requests(
      stream, HttpClients::noAuthentication,
      t -> HttpDelete.METHOD_NAME, 
      t-> t, HttpResponders.inputOn200());
  
  Tester tester = topology.getTester();
  
  Condition<List<String>> endCondition = tester.streamContents(rc, url);
  
  tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS);
  
  assertTrue(endCondition.valid());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testRuntimeServices() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("A");
  
  Supplier<RuntimeServices> serviceGetter =
      t.getRuntimeServiceSupplier();
  
  TStream<Boolean> b = s.map(tuple -> 
    serviceGetter.get().getService(ThreadFactory.class) != null
    && serviceGetter.get().getService(ScheduledExecutorService.class) != null
  );
  
  Condition<List<Boolean>> tc = t.getTester().streamContents(b, Boolean.TRUE);
  complete(t, tc);
  
  assertTrue(tc.valid());
}

相关文章