-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not assume interning for non-ParserBase parsers (#28)
- Loading branch information
1 parent
e37583c
commit a8e4616
Showing
3 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/java/org/curioswitch/common/protobuf/json/JacksonInteropTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) Choko (choko@curioswitch.org) | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package org.curioswitch.common.protobuf.json; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.fasterxml.jackson.core.JsonFactory; | ||
import com.fasterxml.jackson.core.JsonFactoryBuilder; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.google.protobuf.util.JsonFormat; | ||
import com.google.protobuf.util.JsonTestProto.TestAllTypes; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class JacksonInteropTest { | ||
@Test | ||
@Disabled // Currently we do not support non-interned field names. | ||
void interningDisabled() throws Exception { | ||
JsonFactory factory = | ||
new JsonFactoryBuilder().configure(JsonFactory.Feature.INTERN_FIELD_NAMES, false).build(); | ||
|
||
String json = JsonFormat.printer().print(JsonTestUtil.testAllTypesAllFields()); | ||
|
||
MessageMarshaller marshaller = MessageMarshaller.builder().register(TestAllTypes.class).build(); | ||
|
||
TestAllTypes.Builder builder = TestAllTypes.newBuilder(); | ||
|
||
JsonParser parser = factory.createParser(json); | ||
marshaller.mergeValue(parser, builder); | ||
assertThat(builder.build()).isEqualTo(JsonTestUtil.testAllTypesAllFields()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters