diff options
| author | Hao Nguyen <haon@google.com> | 2019-04-05 16:39:18 -0700 |
|---|---|---|
| committer | Hao Nguyen <haon@google.com> | 2019-04-05 16:39:18 -0700 |
| commit | a48a574f7e890436363ca8ac71d866252b216052 (patch) | |
| tree | 7829f1b60e31da551f22a3df4756bfef0b7f9096 /java/util | |
| parent | 3a3956e8a258784461270961c6577341356bce52 (diff) | |
| download | platform_external_protobuf-a48a574f7e890436363ca8ac71d866252b216052.tar.gz platform_external_protobuf-a48a574f7e890436363ca8ac71d866252b216052.tar.bz2 platform_external_protobuf-a48a574f7e890436363ca8ac71d866252b216052.zip | |
Down integrate to Github
Diffstat (limited to 'java/util')
| -rw-r--r-- | java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java index b7b437cea..75e2ae8a8 100644 --- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java +++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java @@ -464,6 +464,20 @@ public class JsonFormatTest extends TestCase { assertEquals(NullValue.NULL_VALUE, message.getOneofNullValue()); } + public void testNullMessageInDuplicateOneof() throws Exception { + // Succeeds if null is first. + TestOneof.Builder successBuilder = TestOneof.newBuilder(); + mergeFromJson("{\"oneofNestedMessage\": null, \"oneofInt32\": 1}", successBuilder); + + // Fails if null is last. + try { + TestOneof.Builder builder = TestOneof.newBuilder(); + mergeFromJson("{\"oneofInt32\": 1, \"oneofNestedMessage\": null}", builder); + fail(); + } catch (InvalidProtocolBufferException expected) { + } + } + public void testParserRejectDuplicatedFields() throws Exception { // TODO(xiaofeng): The parser we are currently using (GSON) will accept and keep the last // one if multiple entries have the same name. This is not the desired behavior but it can |
