diff options
author | Adam Cozzette <acozzette@gmail.com> | 2017-04-06 16:27:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-06 16:27:54 -0700 |
commit | efec7571047c680e11354bd30bf8bd3dfda15ff0 (patch) | |
tree | cb48f91b7cc57a222492d55e161fe7db8b1b4bcc /java | |
parent | 69bfde22b6eb9effd84f7d554b565285e62c0824 (diff) | |
parent | 09328db1ff546e5c535ee0c3fbbe2b1f3ec07b63 (diff) | |
download | protobuf-efec7571047c680e11354bd30bf8bd3dfda15ff0.tar.gz protobuf-efec7571047c680e11354bd30bf8bd3dfda15ff0.tar.bz2 protobuf-efec7571047c680e11354bd30bf8bd3dfda15ff0.zip |
Merge pull request #2937 from anuraaga/dev_rag2
Fix duplicate fields test and Any test. The repeated version is passing because nu…
Diffstat (limited to 'java')
-rw-r--r-- | java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java | 20 |
1 files changed, 15 insertions, 5 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 de02c117..808e542d 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 @@ -264,7 +264,7 @@ public class JsonFormatTest extends TestCase { assertRoundTripEquals(message); } - public void testParserAcceptStringForNumbericField() throws Exception { + public void testParserAcceptStringForNumericField() throws Exception { TestAllTypes.Builder builder = TestAllTypes.newBuilder(); mergeFromJson( "{\n" @@ -479,8 +479,8 @@ public class JsonFormatTest extends TestCase { TestAllTypes.Builder builder = TestAllTypes.newBuilder(); mergeFromJson( "{\n" - + " \"repeatedNestedMessage\": [null, null],\n" - + " \"repeated_nested_message\": [null, null]\n" + + " \"repeatedInt32\": [1, 2],\n" + + " \"repeated_int32\": [5, 6]\n" + "}", builder); fail(); @@ -488,7 +488,7 @@ public class JsonFormatTest extends TestCase { // Exception expected. } - // Duplicated oneof fields. + // Duplicated oneof fields, same name. try { TestOneof.Builder builder = TestOneof.newBuilder(); mergeFromJson("{\n" + " \"oneofInt32\": 1,\n" + " \"oneof_int32\": 2\n" + "}", builder); @@ -496,6 +496,16 @@ public class JsonFormatTest extends TestCase { } catch (InvalidProtocolBufferException e) { // Exception expected. } + + // Duplicated oneof fields, different name. + try { + TestOneof.Builder builder = TestOneof.newBuilder(); + mergeFromJson( + "{\n" + " \"oneofInt32\": 1,\n" + " \"oneofNullValue\": null\n" + "}", builder); + fail(); + } catch (InvalidProtocolBufferException e) { + // Exception expected. + } } public void testMapFields() throws Exception { @@ -1089,7 +1099,7 @@ public class JsonFormatTest extends TestCase { public void testParserUnexpectedTypeUrl() throws Exception { try { - TestAllTypes.Builder builder = TestAllTypes.newBuilder(); + Any.Builder builder = Any.newBuilder(); mergeFromJson( "{\n" + " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n" |