Java Code Examples for org.springframework.protobuf.Msg#parseFrom()
The following examples show how to use
org.springframework.protobuf.Msg#parseFrom() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtobufHttpMessageConverterTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void writeProtobuf() throws IOException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF; this.converter.write(this.testMsg, contentType, outputMessage); assertEquals(contentType, outputMessage.getHeaders().getContentType()); assertTrue(outputMessage.getBodyAsBytes().length > 0); Message result = Msg.parseFrom(outputMessage.getBodyAsBytes()); assertEquals(this.testMsg, result); String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER); assertEquals("Msg", messageHeader); String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER); assertEquals("sample.proto", schemaHeader); }
Example 2
Source File: ProtobufJsonFormatHttpMessageConverterTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void write() throws IOException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF; this.converter.write(this.testMsg, contentType, outputMessage); assertEquals(contentType, outputMessage.getHeaders().getContentType()); assertTrue(outputMessage.getBodyAsBytes().length > 0); Message result = Msg.parseFrom(outputMessage.getBodyAsBytes()); assertEquals(this.testMsg, result); String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER); assertEquals("Msg", messageHeader); String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER); assertEquals("sample.proto", schemaHeader); }
Example 3
Source File: ProtobufHttpMessageConverterTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void writeProtobuf() throws IOException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF; this.converter.write(this.testMsg, contentType, outputMessage); assertEquals(contentType, outputMessage.getHeaders().getContentType()); assertTrue(outputMessage.getBodyAsBytes().length > 0); Message result = Msg.parseFrom(outputMessage.getBodyAsBytes()); assertEquals(this.testMsg, result); String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER); assertEquals("Msg", messageHeader); String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER); assertEquals("sample.proto", schemaHeader); }
Example 4
Source File: ProtobufJsonFormatHttpMessageConverterTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void write() throws IOException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF; this.converter.write(this.testMsg, contentType, outputMessage); assertEquals(contentType, outputMessage.getHeaders().getContentType()); assertTrue(outputMessage.getBodyAsBytes().length > 0); Message result = Msg.parseFrom(outputMessage.getBodyAsBytes()); assertEquals(this.testMsg, result); String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER); assertEquals("Msg", messageHeader); String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER); assertEquals("sample.proto", schemaHeader); }
Example 5
Source File: ProtobufHttpMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void write() throws IOException { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF; this.converter.write(this.testMsg, contentType, outputMessage); assertEquals(contentType, outputMessage.getHeaders().getContentType()); assertTrue(outputMessage.getBodyAsBytes().length > 0); Message result = Msg.parseFrom(outputMessage.getBodyAsBytes()); assertEquals(this.testMsg, result); String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER); assertEquals("Msg", messageHeader); String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER); assertEquals("sample.proto", schemaHeader); }