@Test public void testTwenty() throws Exception { for (int i = 0; i < 20; i++) { TestActionSequence seq = factory.create(); seq.addTo(exec); Thread.sleep(3); } Thread.sleep(1500); for (TestActionSequence t : factory.getSequences()) { assertEquals(10, t.getTimesRun().size()); assertAllInRange( "requestedDelays", t.getRequestedDelays(), factory.getDelayTime(), factory.getDelayDeviation()); List<Long> dd = t.getDelayDiffs(); Collections.sort(dd); assertAllInRange("diffs", dd.subList(1, t.getDelayDiffs().size() - 2), 0, 5); } }
@Test public void testTwentySlower() throws Exception { factory.setDelayTime(50); factory.setDelayDeviation(5); for (int i = 0; i < 20; i++) { TestActionSequence seq = factory.create(); exec.addActionSequence(seq); Thread.sleep(3); } Thread.sleep(8000); for (TestActionSequence t : factory.getSequences()) { assertEquals(10, t.getTimesRun().size()); assertAllInRange( "requestedDelays", t.getRequestedDelays(), factory.getDelayTime(), factory.getDelayDeviation()); assertAllInRange("diffs", t.getDelayDiffs().subList(1, t.getDelayDiffs().size() - 2), 0, 5); } }
@Test public void testOne() throws Exception { TestActionSequence seq = factory.create(); exec.addActionSequence(seq); Thread.sleep(350); ArrayList<Long> rd = new ArrayList<Long>(seq.getRequestedDelays()); assertAllInRange("", rd, factory.getDelayTime(), factory.getDelayDeviation()); ArrayList<Long> md = new ArrayList<Long>(seq.getMeasuredDelays()); assertAllInRange("", rd, factory.getDelayTime(), 5); System.out.println(rd); System.out.println(md); Collections.sort(md); System.out.println(md); assertEquals(factory.getDelayTime(), md.get(0), 4); assertEquals(factory.getDelayTime(), md.get(rd.size() - 1), 4); assertEquals(factory.getDelayTime(), rd.get(0), 5); assertEquals(factory.getDelayTime(), rd.get(rd.size() - 1), 5); assertEquals(10, seq.getTimesRun().size()); assertEquals(1, factory.getSequences().size()); assertSame(seq, factory.getSequences().get(0)); }