Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 package com.google.protobuf; 31 package com.google.protobuf;
32 32
33 import static org.junit.Assert.assertEquals; 33 import static org.junit.Assert.assertEquals;
34 import static org.junit.Assert.assertFalse; 34 import static org.junit.Assert.assertFalse;
35 import static org.junit.Assert.assertTrue; 35 import static org.junit.Assert.assertTrue;
36 import static org.junit.Assert.fail; 36 import static org.junit.Assert.fail;
37 37
38 import com.google.protobuf.DescriptorProtos.DescriptorProto; 38 import com.google.protobuf.DescriptorProtos.DescriptorProto;
39
40 import org.junit.Test;
41 import org.junit.runner.RunWith;
42 import org.junit.runners.JUnit4;
43
44 import java.io.ByteArrayInputStream; 39 import java.io.ByteArrayInputStream;
45 import java.io.ByteArrayOutputStream; 40 import java.io.ByteArrayOutputStream;
46 import java.io.FilterInputStream; 41 import java.io.FilterInputStream;
47 import java.io.IOException; 42 import java.io.IOException;
48 import java.io.InputStream; 43 import java.io.InputStream;
44 import org.junit.Test;
45 import org.junit.runner.RunWith;
46 import org.junit.runners.JUnit4;
49 47
50 /** 48 /**
51 * Tests the exceptions thrown when parsing from a stream. The methods on the {@ link Parser} 49 * Tests the exceptions thrown when parsing from a stream. The methods on the {@ link Parser}
52 * interface are specified to only throw {@link InvalidProtocolBufferException}. But we really want 50 * interface are specified to only throw {@link InvalidProtocolBufferException}. But we really want
53 * to distinguish between invalid protos vs. actual I/O errors (like failures re ading from a 51 * to distinguish between invalid protos vs. actual I/O errors (like failures re ading from a
54 * socket, etc.). So, when we're not using the parser directly, an {@link IOExce ption} should be 52 * socket, etc.). So, when we're not using the parser directly, an {@link IOExce ption} should be
55 * thrown where appropriate, instead of always an {@link InvalidProtocolBufferEx ception}. 53 * thrown where appropriate, instead of always an {@link InvalidProtocolBufferEx ception}.
56 * 54 *
57 * @author jh@squareup.com (Joshua Humphries) 55 * @author jh@squareup.com (Joshua Humphries)
58 */ 56 */
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 262
265 @Override public int read(byte b[], int off, int len) throws IOException { 263 @Override public int read(byte b[], int off, int len) throws IOException {
266 if ((count += len) >= 50) { 264 if ((count += len) >= 50) {
267 throw new IOException("I'm broken!"); 265 throw new IOException("I'm broken!");
268 } 266 }
269 return super.read(b, off, len); 267 return super.read(b, off, len);
270 } 268 }
271 }; 269 };
272 } 270 }
273 } 271 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698