33import java .io .IOException ;
44import java .lang .reflect .ParameterizedType ;
55import java .lang .reflect .Type ;
6- import java .util .stream .Stream ;
76
87import org .apache .avro .Schema ;
9- import org .junit .jupiter .api .BeforeEach ;
8+
9+ import org .junit .Before ;
10+ import org .junit .runner .RunWith ;
11+ import org .junit .runners .Parameterized ;
1012
1113import com .fasterxml .jackson .dataformat .avro .testsupport .BiFunction ;
1214import com .fasterxml .jackson .dataformat .avro .testsupport .Function ;
1820 * {@link #deserializeFunctor} with permutations of Apache and Jackson implementations to test all aspects of
1921 * interoperability between the implementations.
2022 */
23+ @ RunWith (Parameterized .class )
2124public abstract class InteropTestBase
2225{
2326 public enum DummyEnum {
@@ -26,7 +29,7 @@ public enum DummyEnum {
2629
2730 // see https://github.com/FasterXML/jackson-dataformats-binary/pull/539 for
2831 // explanation (need to allow-list Jackson test packages for Avro 1.11.4+)
29- @ BeforeEach
32+ @ Before
3033 public void init () {
3134 System .setProperty ("org.apache.avro.SERIALIZABLE_PACKAGES" ,
3235 "java.lang,java.math,java.io,java.net,org.apache.avro.reflect," +
@@ -101,22 +104,27 @@ public String toString() {
101104 }
102105 }
103106
107+ @ Parameterized .Parameter
104108 public Function <Type , Schema > schemaFunctor ;
109+ @ Parameterized .Parameter (1 )
105110 public BiFunction <Schema , Object , byte []> serializeFunctor ;
111+ @ Parameterized .Parameter (2 )
106112 public BiFunction <Schema , byte [], Object > deserializeFunctor ;
113+ @ Parameterized .Parameter (3 )
107114 public String combinationName ;
108115
109- public static Stream <Object []> getParameters () {
110- return Stream .of (
111- new Object [] {getApacheSchema , apacheSerializer , jacksonDeserializer , "Apache to Jackson with Apache schema" },
112- new Object [] {getJacksonSchema , apacheSerializer , jacksonDeserializer , "Apache to Jackson with Jackson schema" },
113- new Object [] {getApacheSchema , jacksonSerializer , jacksonDeserializer , "Jackson to Jackson with Apache schema" },
114- new Object [] {getJacksonSchema , jacksonSerializer , jacksonDeserializer , "Jackson to Jackson with Jackson schema" },
115- new Object [] {getApacheSchema , jacksonSerializer , apacheDeserializer , "Jackson to Apache with Apache schema" },
116- new Object [] {getJacksonSchema , jacksonSerializer , apacheDeserializer , "Jackson to Apache with Jackson schema" },
117- new Object [] {getJacksonSchema , apacheSerializer , apacheDeserializer , "Apache to Apache with Jackson schema" },
118- new Object [] {getApacheSchema , apacheSerializer , apacheDeserializer , "Apache to Apache with Apache schema" }
119- );
116+ @ Parameterized .Parameters (name = "{3}" )
117+ public static Object [][] getParameters () {
118+ return new Object [][]{
119+ {getApacheSchema , apacheSerializer , jacksonDeserializer , "Apache to Jackson with Apache schema" },
120+ {getJacksonSchema , apacheSerializer , jacksonDeserializer , "Apache to Jackson with Jackson schema" },
121+ {getApacheSchema , jacksonSerializer , jacksonDeserializer , "Jackson to Jackson with Apache schema" },
122+ {getJacksonSchema , jacksonSerializer , jacksonDeserializer , "Jackson to Jackson with Jackson schema" },
123+ {getApacheSchema , jacksonSerializer , apacheDeserializer , "Jackson to Apache with Apache schema" },
124+ {getJacksonSchema , jacksonSerializer , apacheDeserializer , "Jackson to Apache with Jackson schema" },
125+ {getJacksonSchema , apacheSerializer , apacheDeserializer , "Apache to Apache with Jackson schema" },
126+ {getApacheSchema , apacheSerializer , apacheDeserializer , "Apache to Apache with Apache schema" }
127+ };
120128 }
121129
122130 /**
@@ -154,14 +162,4 @@ protected <T> T roundTrip(Type schemaType, T object) throws IOException {
154162 Schema schema = schemaFunctor .apply (schemaType );
155163 return (T ) deserializeFunctor .apply (schema , serializeFunctor .apply (schema , object ));
156164 }
157-
158- protected void useParameters (Function <Type , Schema > schemaFunctor ,
159- BiFunction <Schema , Object , byte []> serializeFunctor ,
160- BiFunction <Schema , byte [], Object > deserializeFunctor
161- ) {
162- this .schemaFunctor = schemaFunctor ;
163- this .serializeFunctor = serializeFunctor ;
164- this .deserializeFunctor = deserializeFunctor ;
165- }
166-
167165}
0 commit comments