use of io.grpc.protobuf.services.TempFileSink in project grpc-java by grpc.
the class TempFileSinkTest method writeAfterCloseIsSilent.
@Test
public void writeAfterCloseIsSilent() throws IOException {
TempFileSink sink = new TempFileSink();
sink.close();
sink.write(GrpcLogEntry.newBuilder().setCallId(1234).build());
}
use of io.grpc.protobuf.services.TempFileSink in project grpc-java by grpc.
the class TempFileSinkTest method readMyWrite.
@Test
public void readMyWrite() throws Exception {
TempFileSink sink = new TempFileSink();
GrpcLogEntry e1 = GrpcLogEntry.newBuilder().setCallId(1234).build();
GrpcLogEntry e2 = GrpcLogEntry.newBuilder().setCallId(5678).build();
sink.write(e1);
sink.write(e2);
sink.close();
DataInputStream input = new DataInputStream(new FileInputStream(sink.getPath()));
try {
GrpcLogEntry read1 = GrpcLogEntry.parseDelimitedFrom(input);
GrpcLogEntry read2 = GrpcLogEntry.parseDelimitedFrom(input);
assertEquals(e1, read1);
assertEquals(e2, read2);
assertEquals(-1, input.read());
} finally {
input.close();
}
}
Aggregations