| OLD | NEW |
| 1 | 1 |
| 2 import com.google.protobuf.conformance.Conformance; | 2 import com.google.protobuf.conformance.Conformance; |
| 3 import com.google.protobuf.InvalidProtocolBufferException; | 3 import com.google.protobuf.InvalidProtocolBufferException; |
| 4 | 4 |
| 5 class ConformanceJavaLite { | 5 class ConformanceJavaLite { |
| 6 private int testCount = 0; | 6 private int testCount = 0; |
| 7 | 7 |
| 8 private boolean readFromStdin(byte[] buf, int len) throws Exception { | 8 private boolean readFromStdin(byte[] buf, int len) throws Exception { |
| 9 int ofs = 0; | 9 int ofs = 0; |
| 10 while (len > 0) { | 10 while (len > 0) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 case PROTOBUF_PAYLOAD: { | 51 case PROTOBUF_PAYLOAD: { |
| 52 try { | 52 try { |
| 53 testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPa
yload()); | 53 testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPa
yload()); |
| 54 } catch (InvalidProtocolBufferException e) { | 54 } catch (InvalidProtocolBufferException e) { |
| 55 return Conformance.ConformanceResponse.newBuilder().setParseError(e.ge
tMessage()).build(); | 55 return Conformance.ConformanceResponse.newBuilder().setParseError(e.ge
tMessage()).build(); |
| 56 } | 56 } |
| 57 break; | 57 break; |
| 58 } | 58 } |
| 59 case JSON_PAYLOAD: { | 59 case JSON_PAYLOAD: { |
| 60 return Conformance.ConformanceResponse.newBuilder().setSkipped( | 60 return Conformance.ConformanceResponse.newBuilder().setSkipped( |
| 61 "Lite runtime does not suport Json Formant.").build(); | 61 "Lite runtime does not support JSON format.").build(); |
| 62 } | 62 } |
| 63 case PAYLOAD_NOT_SET: { | 63 case PAYLOAD_NOT_SET: { |
| 64 throw new RuntimeException("Request didn't have payload."); | 64 throw new RuntimeException("Request didn't have payload."); |
| 65 } | 65 } |
| 66 | 66 |
| 67 default: { | 67 default: { |
| 68 throw new RuntimeException("Unexpected payload case."); | 68 throw new RuntimeException("Unexpected payload case."); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 switch (request.getRequestedOutputFormat()) { | 72 switch (request.getRequestedOutputFormat()) { |
| 73 case UNSPECIFIED: | 73 case UNSPECIFIED: |
| 74 throw new RuntimeException("Unspecified output format."); | 74 throw new RuntimeException("Unspecified output format."); |
| 75 | 75 |
| 76 case PROTOBUF: | 76 case PROTOBUF: |
| 77 return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(t
estMessage.toByteString()).build(); | 77 return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(t
estMessage.toByteString()).build(); |
| 78 | 78 |
| 79 case JSON: | 79 case JSON: |
| 80 return Conformance.ConformanceResponse.newBuilder().setSkipped( | 80 return Conformance.ConformanceResponse.newBuilder().setSkipped( |
| 81 "Lite runtime does not suport Json Formant.").build(); | 81 "Lite runtime does not support JSON format.").build(); |
| 82 | 82 |
| 83 default: { | 83 default: { |
| 84 throw new RuntimeException("Unexpected request output."); | 84 throw new RuntimeException("Unexpected request output."); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 private boolean doTestIo() throws Exception { | 89 private boolean doTestIo() throws Exception { |
| 90 int bytes = readLittleEndianIntFromStdin(); | 90 int bytes = readLittleEndianIntFromStdin(); |
| 91 | 91 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 System.err.println("ConformanceJavaLite: received EOF from test runner after
" + | 118 System.err.println("ConformanceJavaLite: received EOF from test runner after
" + |
| 119 this.testCount + " tests"); | 119 this.testCount + " tests"); |
| 120 } | 120 } |
| 121 | 121 |
| 122 public static void main(String[] args) throws Exception { | 122 public static void main(String[] args) throws Exception { |
| 123 new ConformanceJavaLite().run(); | 123 new ConformanceJavaLite().run(); |
| 124 } | 124 } |
| 125 } | 125 } |
| OLD | NEW |