Search in sources :

Example 1 with TempFileSink

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());
}
Also used : TempFileSink(io.grpc.protobuf.services.TempFileSink) Test(org.junit.Test)

Example 2 with TempFileSink

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();
    }
}
Also used : GrpcLogEntry(io.grpc.binarylog.v1.GrpcLogEntry) DataInputStream(java.io.DataInputStream) TempFileSink(io.grpc.protobuf.services.TempFileSink) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

TempFileSink (io.grpc.protobuf.services.TempFileSink)2 Test (org.junit.Test)2 GrpcLogEntry (io.grpc.binarylog.v1.GrpcLogEntry)1 DataInputStream (java.io.DataInputStream)1 FileInputStream (java.io.FileInputStream)1