public CoveragePipe(final OutputStream dos) { this.dos = new SafeDataOutputStream(dos); }
@Override public synchronized void registerClass(final int id, final String className) { this.dos.writeByte(Id.CLAZZ); this.dos.writeInt(id); this.dos.writeString(className); }
@Override public synchronized void recordTestOutcome(final Description description, final boolean wasGreen, final int executionTime) { final Collection<Long> hits = CodeCoverageStore.getHits(); this.dos.writeByte(Id.OUTCOME); this.dos.write(description); this.dos.writeInt(hits.size()); for (final Long each : hits) { this.dos.writeLong(each); } this.dos.writeBoolean(wasGreen); this.dos.writeInt(executionTime); }
private void mockClientSocketToSendExitCode(final ExitCode timeout) throws IOException { final SafeDataOutputStream dos = new SafeDataOutputStream(this.o); dos.writeByte(Id.DONE); dos.writeInt(timeout.getCode()); mockClientSocketInputStream(); }
private void sendTests(final SafeDataOutputStream dos) { // send individually to reduce memory overhead of deserializing large // suite LOG.info("Sending " + this.testClasses.size() + " test classes to minion"); dos.writeInt(this.testClasses.size()); for (final String tc : this.testClasses) { dos.writeString(tc); } dos.flush(); LOG.info("Sent tests to minion"); } }
@Test public void shouldBeAbletoReadLargeStrings() { final char[] chars = new char[65536]; Arrays.fill(chars, '!'); final String s = new String(chars); final ByteArrayOutputStream o = new ByteArrayOutputStream(); final SafeDataOutputStream dos = new SafeDataOutputStream(o); dos.writeString(s); final ByteArrayInputStream i = new ByteArrayInputStream(o.toByteArray()); final SafeDataInputStream dis = new SafeDataInputStream(i); final String actual = dis.readString(); assertEquals(s, actual); }
@Test public void shouldSendTestClassesToMinion() { this.testClasses.add("foo"); this.testClasses.add("bar"); this.testee.apply(this.os); verify(this.os).writeInt(this.testClasses.size()); verify(this.os).writeString("foo"); verify(this.os).writeString("bar"); }
@Test public void shouldSendArgumentsToMinion() { this.testee.apply(this.os); verify(this.os).write(this.arguments); }
public <T extends Serializable> void write(final T value) { try { writeBytes(toByteArray(value)); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
@Test public void shouldPassCommandsToReceiver() throws Exception { final SafeDataOutputStream dos = new SafeDataOutputStream(this.o); dos.writeByte(Id.DESCRIBE); dos.writeByte(Id.DONE); dos.writeInt(ExitCode.OK.getCode()); mockClientSocketInputStream(); this.testee.call(); verify(this.receiveStrategy, times(1)).apply(anyByte(), any(SafeDataInputStream.class)); }
public <T extends Serializable> void write(final T value) { try { writeBytes(toByteArray(value)); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
@Override public synchronized void registerProbes(int classId, String methodName, String methodDesc, int firstProbe, int lastProbe) { this.dos.writeByte(Id.PROBES); this.dos.writeInt(classId); this.dos.writeString(methodName); this.dos.writeString(methodDesc); this.dos.writeInt(firstProbe); this.dos.writeInt(lastProbe); }
@Override public synchronized void recordTestOutcome(final Description description, final boolean wasGreen, final int executionTime) { final Collection<Long> hits = CodeCoverageStore.getHits(); this.dos.writeByte(Id.OUTCOME); this.dos.write(description); this.dos.writeInt(hits.size()); for (final Long each : hits) { this.dos.writeLong(each); } this.dos.writeBoolean(wasGreen); this.dos.writeInt(executionTime); }