-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d61c086
commit 9e27d43
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithIntArray483Test.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,61 @@ | ||
package com.fasterxml.jackson.dataformat.protobuf.schema; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
import org.junit.Ignore; | ||
|
||
import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; | ||
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; | ||
|
||
public class SchemaWithIntArray483Test extends ProtobufTestBase | ||
{ | ||
static class IntArrayBean | ||
{ | ||
// @JsonProperty(required = true, index = 1) | ||
public int[] value; | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ProtobufMapper MAPPER = new ProtobufMapper(); | ||
|
||
// [dataformats-binary#483]: int arrays supported as nested (property) values | ||
public void testWithWrappedIntArray() throws Exception | ||
{ | ||
ProtobufSchema schema = MAPPER.generateSchemaFor(IntArrayBean.class); | ||
assertNotNull(schema); | ||
|
||
IntArrayBean input = new IntArrayBean(); | ||
input.value = new int[] { 1, 2, 3 }; | ||
|
||
byte[] proto = MAPPER.writer().with(schema) | ||
.writeValueAsBytes(input); | ||
IntArrayBean result = MAPPER.readerFor(IntArrayBean.class) | ||
.with(schema) | ||
.readValue(proto); | ||
assertNotNull(result.value); | ||
assertArrayEquals(input.value, result.value); | ||
} | ||
|
||
// [dataformats-binary#483]: cannot support root-level arrays, unfortunately | ||
@Ignore("Can't be supported with Protobuf") | ||
public void dontTestWithRootIntArray() throws Exception | ||
{ | ||
ProtobufSchema schema = MAPPER.generateSchemaFor(int[].class); | ||
assertNotNull(schema); | ||
|
||
int[] input = new int[] { 1, 2, 3 }; | ||
|
||
byte[] proto = MAPPER.writer().with(schema) | ||
.writeValueAsBytes(input); | ||
int[] result = MAPPER.readerFor(int[].class) | ||
.with(schema) | ||
.readValue(proto); | ||
assertNotNull(result); | ||
assertArrayEquals(input, result); | ||
} | ||
} |
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