aboutsummaryrefslogtreecommitdiffhomepage
path: root/java/util
diff options
context:
space:
mode:
Diffstat (limited to 'java/util')
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/JsonFormat.java2
-rw-r--r--java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java24
2 files changed, 17 insertions, 9 deletions
diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
index 37fa194a..e1c2d73d 100644
--- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
+++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
@@ -1558,7 +1558,7 @@ public class JsonFormat {
BigDecimal value = new BigDecimal(json.getAsString());
return value.longValueExact();
} catch (Exception e) {
- throw new InvalidProtocolBufferException("Not an int32 value: " + json);
+ throw new InvalidProtocolBufferException("Not an int64 value: " + json);
}
}
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 695176ed..460b81f6 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
@@ -233,9 +233,7 @@ public class JsonFormatTest extends TestCase {
TestMap.Builder mapBuilder = TestMap.newBuilder();
mapBuilder.putInt32ToEnumMapValue(1, 0);
- Map<Integer, Integer> mapWithInvalidValues = new HashMap<Integer, Integer>();
- mapWithInvalidValues.put(2, 12345);
- mapBuilder.putAllInt32ToEnumMapValue(mapWithInvalidValues);
+ mapBuilder.putInt32ToEnumMapValue(2, 12345);
TestMap mapMessage = mapBuilder.build();
assertEquals(
"{\n"
@@ -268,7 +266,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"
@@ -483,8 +481,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();
@@ -492,7 +490,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);
@@ -500,6 +498,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 {
@@ -1093,7 +1101,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"