Commit efec7571 authored by Adam Cozzette's avatar Adam Cozzette Committed by GitHub

Merge pull request #2937 from anuraaga/dev_rag2

Fix duplicate fields test and Any test. The repeated version is passing because nu…
parents 69bfde22 09328db1
...@@ -264,7 +264,7 @@ public class JsonFormatTest extends TestCase { ...@@ -264,7 +264,7 @@ public class JsonFormatTest extends TestCase {
assertRoundTripEquals(message); assertRoundTripEquals(message);
} }
public void testParserAcceptStringForNumbericField() throws Exception { public void testParserAcceptStringForNumericField() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder(); TestAllTypes.Builder builder = TestAllTypes.newBuilder();
mergeFromJson( mergeFromJson(
"{\n" "{\n"
...@@ -479,8 +479,8 @@ public class JsonFormatTest extends TestCase { ...@@ -479,8 +479,8 @@ public class JsonFormatTest extends TestCase {
TestAllTypes.Builder builder = TestAllTypes.newBuilder(); TestAllTypes.Builder builder = TestAllTypes.newBuilder();
mergeFromJson( mergeFromJson(
"{\n" "{\n"
+ " \"repeatedNestedMessage\": [null, null],\n" + " \"repeatedInt32\": [1, 2],\n"
+ " \"repeated_nested_message\": [null, null]\n" + " \"repeated_int32\": [5, 6]\n"
+ "}", + "}",
builder); builder);
fail(); fail();
...@@ -488,7 +488,7 @@ public class JsonFormatTest extends TestCase { ...@@ -488,7 +488,7 @@ public class JsonFormatTest extends TestCase {
// Exception expected. // Exception expected.
} }
// Duplicated oneof fields. // Duplicated oneof fields, same name.
try { try {
TestOneof.Builder builder = TestOneof.newBuilder(); TestOneof.Builder builder = TestOneof.newBuilder();
mergeFromJson("{\n" + " \"oneofInt32\": 1,\n" + " \"oneof_int32\": 2\n" + "}", builder); mergeFromJson("{\n" + " \"oneofInt32\": 1,\n" + " \"oneof_int32\": 2\n" + "}", builder);
...@@ -496,6 +496,16 @@ public class JsonFormatTest extends TestCase { ...@@ -496,6 +496,16 @@ public class JsonFormatTest extends TestCase {
} catch (InvalidProtocolBufferException e) { } catch (InvalidProtocolBufferException e) {
// Exception expected. // 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 { public void testMapFields() throws Exception {
...@@ -1089,7 +1099,7 @@ public class JsonFormatTest extends TestCase { ...@@ -1089,7 +1099,7 @@ public class JsonFormatTest extends TestCase {
public void testParserUnexpectedTypeUrl() throws Exception { public void testParserUnexpectedTypeUrl() throws Exception {
try { try {
TestAllTypes.Builder builder = TestAllTypes.newBuilder(); Any.Builder builder = Any.newBuilder();
mergeFromJson( mergeFromJson(
"{\n" "{\n"
+ " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n" + " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment