private static List<ClassName> receiveTestClassesFromParent( final SafeDataInputStream dis) { final int count = dis.readInt(); LOG.fine("Expecting " + count + " tests classes from parent"); final List<ClassName> classes = new ArrayList<>(count); for (int i = 0; i != count; i++) { classes.add(ClassName.fromString(dis.readString())); } LOG.fine("Tests classes received"); return classes; }
private CoverageResult createCoverageResult(final SafeDataInputStream is, final Description d, Collection<BlockLocation> visitedBlocks) { final boolean isGreen = is.readBoolean(); final int executionTime = is.readInt(); final CoverageResult cr = new CoverageResult(d, executionTime, isGreen, visitedBlocks); return cr; }
private void handleProbes(final SafeDataInputStream is) { final int classId = is.readInt(); final String methodName = is.readString(); final String methodSig = is.readString(); final int first = is.readInt(); final int last = is.readInt(); final Location loc = Location.location(this.classIdToName.get(classId), MethodName.fromString(methodName), methodSig); for (int i = first; i != (last + 1); i++) { // nb, convert from classwide id to method scoped index within // BlockLocation this.probeToBlock.put(CodeCoverageStore.encode(classId, i), new BlockLocation(loc, i - first)); } }
private void handleTestEnd(final SafeDataInputStream is) { final Description d = is.read(Description.class); final int numberOfResults = is.readInt(); final Set<BlockLocation> hits = new HashSet<>(numberOfResults); for (int i = 0; i != numberOfResults; i++) { readProbeHit(is, hits); } this.handler.apply(createCoverageResult(is, d, hits)); }
@Override public void apply(final byte control, final SafeDataInputStream is) { switch (control) { case Id.CLAZZ: final int id = is.readInt(); final String name = is.readString(); this.classIdToName.put(id, ClassName.fromString(name)); break; case Id.PROBES: handleProbes(is); break; case Id.OUTCOME: handleTestEnd(is); break; case Id.DONE: // nothing to do ? } }
private ExitCode receiveResults(final SafeDataInputStream is) { byte control = is.readByte(); while (control != Id.DONE) { this.receive.apply(control, is); control = is.readByte(); } return ExitCode.fromCode(is.readInt()); }
private void recordTestCoverage(final int executionTime, final int classId, final int probeNumber, final boolean testPassed) { when(this.is.readInt()).thenReturn(classId, executionTime); when(this.is.readString()).thenReturn("foo"); this.testee.apply(Id.CLAZZ, this.is); when(this.is.read(Description.class)).thenReturn(this.description); when(this.is.readInt()).thenReturn(1); when(this.is.readLong()).thenReturn(1l, CodeCoverageStore.encode(classId, probeNumber)); when(this.is.readBoolean()).thenReturn(testPassed); this.testee.apply(Id.OUTCOME, this.is); }
@Test public void shouldSendExitCode() { this.testee.done(ExitCode.TIMEOUT); final SafeDataInputStream is = resultToStream(); assertEquals(Id.DONE, is.readByte()); assertEquals(is.readInt(), ExitCode.TIMEOUT.getCode()); }
private static List<ClassName> receiveTestClassesFromParent( final SafeDataInputStream dis) { final int count = dis.readInt(); LOG.fine("Expecting " + count + " tests classes from parent"); final List<ClassName> classes = new ArrayList<>(count); for (int i = 0; i != count; i++) { classes.add(ClassName.fromString(dis.readString())); } LOG.fine("Tests classes received"); return classes; }