Skip to content

Commit d779361

Browse files
committed
Fix compatibility probs with latest 3.0 databind
1 parent b7c08e3 commit d779361

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

avro/src/test/java/tools/jackson/dataformat/avro/SimpleGenerationTest.java renamed to avro/src/test/java/tools/jackson/dataformat/avro/SimpleAvroGenerationTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
99

10+
import tools.jackson.core.JacksonException;
1011
import tools.jackson.core.StreamWriteFeature;
1112

1213
import tools.jackson.databind.DatabindException;
1314
import tools.jackson.databind.ObjectMapper;
1415

15-
public class SimpleGenerationTest extends AvroTestBase
16+
public class SimpleAvroGenerationTest extends AvroTestBase
1617
{
1718
protected final String SCHEMA_WITH_BINARY_JSON_SRC = "{\n"
1819
+"\"type\": \"record\",\n"
@@ -61,7 +62,7 @@ public BinaryAndArray(String name) {
6162

6263
private final AvroSchema SCHEMA_WITH_BINARY_JSON;
6364

64-
public SimpleGenerationTest() throws IOException
65+
public SimpleAvroGenerationTest() throws IOException
6566
{
6667
SCHEMA_WITH_BINARY_JSON = getMapper().schemaFrom(SCHEMA_WITH_BINARY_JSON_SRC);
6768
}
@@ -120,7 +121,7 @@ public void testIgnoringOfUnknownScalar() throws Exception
120121
try {
121122
mapper.writer(SCHEMA_WITH_BINARY_JSON).writeValue(b, input);
122123
fail("Should have thrown exception");
123-
} catch (DatabindException e) {
124+
} catch (JacksonException e) {
124125
verifyException(e, "no field named");
125126
}
126127

@@ -146,7 +147,7 @@ public void testIgnoringOfUnknownObject() throws Exception
146147
try {
147148
mapper.writer(SCHEMA_WITH_BINARY_JSON).writeValueAsBytes(input);
148149
fail("Should have thrown exception");
149-
} catch (DatabindException e) {
150+
} catch (JacksonException e) {
150151
verifyException(e, "no field named 'stuff'");
151152
}
152153

avro/src/test/java/tools/jackson/dataformat/avro/interop/annotations/UnionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import java.util.List;
77
import java.util.Map;
88

9-
import tools.jackson.databind.DatabindException;
9+
import org.junit.Test;
10+
11+
import tools.jackson.core.JacksonException;
1012
import tools.jackson.dataformat.avro.interop.InteropTestBase;
1113

1214
import org.apache.avro.UnresolvedUnionException;
1315
import org.apache.avro.reflect.Nullable;
1416
import org.apache.avro.reflect.Union;
1517

16-
import org.junit.Test;
17-
1818
import static org.assertj.core.api.Assertions.assertThat;
1919
import static org.junit.Assert.fail;
2020

@@ -144,7 +144,7 @@ public void testInterfaceUnionWithBird() throws IOException {
144144
try {
145145
roundTrip(cage);
146146
fail("Should throw exception about Bird not being in union");
147-
} catch (UnresolvedUnionException | DatabindException e) {
147+
} catch (UnresolvedUnionException | JacksonException e) {
148148
// success
149149
}
150150
}

ion/src/test/java/tools/jackson/dataformat/ion/IonGeneratorTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import com.amazon.ion.system.IonSystemBuilder;
3232

3333
import static org.hamcrest.Matchers.is;
34+
import static org.hamcrest.Matchers.startsWith;
3435
import static org.hamcrest.MatcherAssert.assertThat;
35-
import static org.junit.Assert.assertEquals;
3636
import static org.junit.Assert.fail;
3737

3838
public class IonGeneratorTest {
@@ -127,8 +127,7 @@ public void testWriteFieldNameFailsInSexp() throws Exception {
127127
joiGenerator.writeName("foo");
128128
fail("Should not pass");
129129
} catch (StreamWriteException e) {
130-
assertEquals("Can not write a property name, expecting a value",
131-
e.getMessage());
130+
assertThat(e.getMessage(), startsWith("Can not write a property name, expecting a value"));
132131
}
133132
}
134133

@@ -139,8 +138,7 @@ public void testWriteStartSexpFailsWithoutWriteFieldName() throws Exception {
139138
joiGenerator.writeStartSexp();
140139
fail("Should not pass");
141140
} catch (StreamWriteException e) {
142-
assertEquals("Can not start a sexp, expecting a property name",
143-
e.getMessage());
141+
assertThat(e.getMessage(), startsWith("Can not start a sexp, expecting a property name"));
144142
}
145143
}
146144
}

ion/src/test/java/tools/jackson/dataformat/ion/dos/CyclicIonDataSerTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.junit.Test;
7+
68
import tools.jackson.core.StreamWriteConstraints;
9+
import tools.jackson.core.exc.StreamConstraintsException;
710
import tools.jackson.databind.*;
811

912
import tools.jackson.dataformat.ion.IonObjectMapper;
1013

11-
import org.junit.Test;
12-
1314
import static org.junit.Assert.assertTrue;
1415
import static org.junit.Assert.fail;
1516

@@ -28,7 +29,7 @@ public void testListWithSelfReference() throws Exception {
2829
try {
2930
MAPPER.writeValueAsBytes(list);
3031
fail("expected DatabindException");
31-
} catch (DatabindException e) {
32+
} catch (StreamConstraintsException e) {
3233
String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed",
3334
StreamWriteConstraints.DEFAULT_MAX_DEPTH + 1);
3435
assertTrue("DatabindException message is as expected?",

protobuf/src/test/java/tools/jackson/dataformat/protobuf/ReadSimpleTest.java renamed to protobuf/src/test/java/tools/jackson/dataformat/protobuf/ReadSimpleProtobufTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import tools.jackson.core.JsonToken;
1010
import tools.jackson.core.StreamReadConstraints;
1111
import tools.jackson.core.StreamReadFeature;
12-
import tools.jackson.databind.DatabindException;
12+
import tools.jackson.core.exc.StreamConstraintsException;
1313
import tools.jackson.databind.ObjectMapper;
1414
import tools.jackson.databind.ObjectWriter;
1515

1616
import tools.jackson.dataformat.protobuf.schema.ProtobufSchema;
1717
import tools.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader;
1818

19-
public class ReadSimpleTest extends ProtobufTestBase
19+
public class ReadSimpleProtobufTest extends ProtobufTestBase
2020
{
2121
final protected static String PROTOC_STRINGS =
2222
"message Strings {\n"
@@ -450,8 +450,8 @@ public void testStringArraySimpleLowLimit() throws Exception
450450

451451
try {
452452
protobufMapper.readerFor(Strings.class).with(schema).readValue(bytes);
453-
fail("Expected DatabindException");
454-
} catch (DatabindException jme) {
453+
fail("Expected StreamConstraintsException");
454+
} catch (StreamConstraintsException jme) {
455455
String message = jme.getMessage();
456456
assertTrue("unexpected message: " + message,
457457
message.startsWith("String value length (4) exceeds the maximum allowed"));

protobuf/src/test/java/tools/jackson/dataformat/protobuf/WriteErrorsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import tools.jackson.core.JsonGenerator;
66
import tools.jackson.core.StreamWriteFeature;
7-
7+
import tools.jackson.core.exc.StreamWriteException;
88
import tools.jackson.databind.DatabindException;
99
import tools.jackson.databind.ObjectMapper;
1010
import tools.jackson.databind.ObjectWriter;
@@ -41,7 +41,7 @@ public void testUnknownProperties() throws Exception
4141
/*byte[] bytes =*/ w
4242
.without(StreamWriteFeature.IGNORE_UNKNOWN)
4343
.writeValueAsBytes(new Point3D(1, 2, 3));
44-
} catch (DatabindException e) {
44+
} catch (StreamWriteException e) {
4545
verifyException(e, "Unrecognized field 'z'");
4646
}
4747

0 commit comments

Comments
 (0)