Skip to content

Commit 5756456

Browse files
committed
[Avro] Re-Enable ignored namespace unit tests in 2.9
1 parent cb1a58d commit 5756456

10 files changed

+21
-105
lines changed

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/InteropTestBase.java

+1-23
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@
55
import java.lang.reflect.Type;
66

77
import org.apache.avro.Schema;
8-
import org.junit.Assume;
98
import org.junit.runner.RunWith;
109
import org.junit.runners.Parameterized;
1110

12-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.apacheDeserializer;
13-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.apacheSerializer;
14-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonDeserializer;
15-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonSerializer;
16-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.getApacheSchema;
17-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.getJacksonSchema;
18-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.Function;
19-
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.BiFunction;
11+
import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.*;
2012

2113
/**
2214
* Parameterized base class for tests that populates {@link #schemaFunctor}, {@link #serializeFunctor}, and
@@ -30,20 +22,6 @@ public enum DummyEnum {
3022
NORTH, SOUTH, EAST, WEST
3123
}
3224

33-
// To work around 2.8/2.9 difference wrt namespaces for enums
34-
// See [dataformats-binary#58] for details
35-
protected void assumeCompatibleNsForDeser() {
36-
Assume.assumeTrue(deserializeFunctor != apacheDeserializer
37-
|| schemaFunctor != ApacheAvroInteropUtil.getJacksonSchema);
38-
}
39-
40-
// To work around 2.8/2.9 difference wrt namespaces for enums
41-
// See [dataformats-binary#58] for details
42-
protected void assumeCompatibleNsForSer() {
43-
Assume.assumeTrue(serializeFunctor != apacheSerializer
44-
|| schemaFunctor != ApacheAvroInteropUtil.getJacksonSchema);
45-
}
46-
4725
/**
4826
* Helper method for building a {@link ParameterizedType} for use with {@link #roundTrip(Type, Object)}
4927
*

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroIgnoreTest.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.annotations;
22

3+
import java.io.IOException;
4+
35
import org.apache.avro.reflect.AvroIgnore;
4-
import org.junit.Before;
56
import org.junit.Test;
67

7-
import static org.hamcrest.CoreMatchers.*;
8+
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
89

10+
import static org.hamcrest.CoreMatchers.equalTo;
11+
import static org.hamcrest.CoreMatchers.is;
12+
import static org.hamcrest.CoreMatchers.not;
13+
import static org.hamcrest.CoreMatchers.nullValue;
914
import static org.junit.Assert.assertThat;
1015

11-
import java.io.IOException;
12-
13-
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
14-
1516
public class AvroIgnoreTest extends InteropTestBase
1617
{
1718
static class RecordWithIgnoredField {
@@ -22,12 +23,6 @@ public RecordWithIgnoredField() {}
2223
public String notIgnoredField;
2324
}
2425

25-
@Before
26-
public void setup() {
27-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
28-
assumeCompatibleNsForDeser();
29-
}
30-
3126
@Test
3227
public void testFieldIgnored() throws IOException {
3328
RecordWithIgnoredField r = new RecordWithIgnoredField();

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroNameTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.annotations;
22

3-
import com.fasterxml.jackson.dataformat.avro.AvroTestBase;
4-
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
3+
import java.io.IOException;
54

65
import org.apache.avro.reflect.AvroName;
7-
import org.junit.Before;
86
import org.junit.Test;
97

8+
import com.fasterxml.jackson.dataformat.avro.AvroTestBase;
9+
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
10+
1011
import static org.assertj.core.api.Assertions.assertThat;
1112
import static org.junit.Assert.fail;
1213

13-
import java.io.IOException;
14-
1514
/**
1615
* Tests the {@link AvroName @AvroName} annotation
1716
*/
@@ -34,12 +33,6 @@ public static class RecordWithNameCollision {
3433
public String otherField;
3534
}
3635

37-
@Before
38-
public void setup() {
39-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
40-
assumeCompatibleNsForDeser();
41-
}
42-
4336
@Test
4437
public void testRecordWithRenamedField() throws IOException{
4538
RecordWithRenamed original = new RecordWithRenamed();

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/arrays/ListWithComplexTest.java

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
*/
2121
public class ListWithComplexTest extends InteropTestBase
2222
{
23-
@Before
24-
public void setup() {
25-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
26-
assumeCompatibleNsForDeser();
27-
}
2823

2924
@Test
3025
public void testEmptyListWithRecordElements() throws IOException {

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/maps/MapWithComplexTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.IOException;
44
import java.util.*;
55

6-
import org.junit.Before;
76
import org.junit.Test;
87

98
import com.fasterxml.jackson.dataformat.avro.interop.DummyRecord;
@@ -17,11 +16,6 @@
1716
*/
1817
public class MapWithComplexTest extends InteropTestBase
1918
{
20-
@Before
21-
public void setup() {
22-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
23-
assumeCompatibleNsForDeser();
24-
}
2519

2620
@Test
2721
public void testMapWithRecordValues() throws IOException {

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithComplexTest.java

-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import java.util.Map;
66

77
import org.apache.avro.AvroTypeException;
8-
9-
import org.junit.Before;
108
import org.junit.Test;
119

1210
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -21,12 +19,6 @@
2119
*/
2220
public class RecordWithComplexTest extends InteropTestBase
2321
{
24-
@Before
25-
public void setup() {
26-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
27-
assumeCompatibleNsForDeser();
28-
assumeCompatibleNsForSer();
29-
}
3022

3123
@Test
3224
public void testEmptyRecordWithRecordValues() throws IOException {

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithPrimitiveArrayTest.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.records;
22

3-
import lombok.Data;
3+
import java.io.IOException;
44

5-
import org.junit.Before;
5+
import lombok.Data;
66
import org.junit.Test;
77

88
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
99

1010
import static org.assertj.core.api.Assertions.assertThat;
1111

12-
import java.io.IOException;
13-
1412
/**
1513
* Tests serializing primitive array fields on records
1614
*/
1715
public class RecordWithPrimitiveArrayTest extends InteropTestBase
1816
{
19-
@Before
20-
public void setup() {
21-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
22-
assumeCompatibleNsForDeser();
23-
}
2417

2518
@Data
2619
public static class TestRecord {

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithPrimitiveTest.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.records;
22

3-
import lombok.Data;
3+
import java.io.IOException;
44

5-
import org.junit.Before;
5+
import lombok.Data;
66
import org.junit.Test;
77

88
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
99

1010
import static org.assertj.core.api.Assertions.assertThat;
1111

12-
import java.io.IOException;
13-
1412
/**
1513
* Tests serializing primitive fields on records
1614
*/
@@ -26,12 +24,6 @@ public static class TestRecord {
2624
private float floatField;
2725
private double doubleField;
2826
}
29-
30-
@Before
31-
public void setup() {
32-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
33-
assumeCompatibleNsForDeser();
34-
}
3527

3628
@Test
3729
public void testByteField() throws IOException {

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithPrimitiveWrapperArrayTest.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.records;
22

3-
import lombok.Data;
3+
import java.io.IOException;
44

5-
import org.junit.Before;
5+
import lombok.Data;
66
import org.junit.Test;
77

88
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
99

1010
import static org.assertj.core.api.Assertions.assertThat;
1111

12-
import java.io.IOException;
13-
1412
/**
1513
* Tests serializing primitive array fields on records
1614
*/
@@ -28,12 +26,6 @@ public static class TestRecord {
2826
private String[] stringArrayField = new String[0];
2927
}
3028

31-
@Before
32-
public void setup() {
33-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
34-
assumeCompatibleNsForDeser();
35-
}
36-
3729
@Test
3830
public void testByteField() throws IOException {
3931
TestRecord record = new TestRecord();

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithPrimitiveWrapperTest.java

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package com.fasterxml.jackson.dataformat.avro.interop.records;
22

3-
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
3+
import java.io.IOException;
44

55
import lombok.Data;
6-
7-
import org.junit.Before;
86
import org.junit.Test;
97

10-
import static org.assertj.core.api.Assertions.assertThat;
8+
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
119

12-
import java.io.IOException;
10+
import static org.assertj.core.api.Assertions.assertThat;
1311

1412
/**
1513
* Tests serializing wrapper types for primitives on records
@@ -27,12 +25,6 @@ public static class TestRecord {
2725
private Double doubleField = 0D;
2826
private String stringField = "";
2927
}
30-
31-
@Before
32-
public void setup() {
33-
// 2.8 doesn't generate schemas with compatible namespaces for Apache deserializer
34-
assumeCompatibleNsForDeser();
35-
}
3628

3729
@Test
3830
public void testByteField() throws IOException {

0 commit comments

Comments
 (0)