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"); } }
@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 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); }
@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 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); }
@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 registerClass(final int id, final String className) { this.dos.writeByte(Id.CLAZZ); this.dos.writeInt(id); this.dos.writeString(className); }