Skip to content

Commit

Permalink
Revert InteropTestBase
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim committed Jan 12, 2025
1 parent b74973f commit 1a71347
Showing 1 changed file with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.stream.Stream;

import org.apache.avro.Schema;
import org.junit.jupiter.api.BeforeEach;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import com.fasterxml.jackson.dataformat.avro.testsupport.BiFunction;
import com.fasterxml.jackson.dataformat.avro.testsupport.Function;
Expand All @@ -18,6 +20,7 @@
* {@link #deserializeFunctor} with permutations of Apache and Jackson implementations to test all aspects of
* interoperability between the implementations.
*/
@RunWith(Parameterized.class)
public abstract class InteropTestBase
{
public enum DummyEnum {
Expand All @@ -26,7 +29,7 @@ public enum DummyEnum {

// see https://github.com/FasterXML/jackson-dataformats-binary/pull/539 for
// explanation (need to allow-list Jackson test packages for Avro 1.11.4+)
@BeforeEach
@Before
public void init() {
System.setProperty("org.apache.avro.SERIALIZABLE_PACKAGES",
"java.lang,java.math,java.io,java.net,org.apache.avro.reflect," +
Expand Down Expand Up @@ -101,22 +104,27 @@ public String toString() {
}
}

@Parameterized.Parameter
public Function<Type, Schema> schemaFunctor;
@Parameterized.Parameter(1)
public BiFunction<Schema, Object, byte[]> serializeFunctor;
@Parameterized.Parameter(2)
public BiFunction<Schema, byte[], Object> deserializeFunctor;
@Parameterized.Parameter(3)
public String combinationName;

public static Stream<Object[]> getParameters() {
return Stream.of(
new Object[] {getApacheSchema, apacheSerializer, jacksonDeserializer, "Apache to Jackson with Apache schema"},
new Object[] {getJacksonSchema, apacheSerializer, jacksonDeserializer, "Apache to Jackson with Jackson schema"},
new Object[] {getApacheSchema, jacksonSerializer, jacksonDeserializer, "Jackson to Jackson with Apache schema"},
new Object[] {getJacksonSchema, jacksonSerializer, jacksonDeserializer, "Jackson to Jackson with Jackson schema"},
new Object[] {getApacheSchema, jacksonSerializer, apacheDeserializer, "Jackson to Apache with Apache schema"},
new Object[] {getJacksonSchema, jacksonSerializer, apacheDeserializer, "Jackson to Apache with Jackson schema"},
new Object[] {getJacksonSchema, apacheSerializer, apacheDeserializer, "Apache to Apache with Jackson schema"},
new Object[] {getApacheSchema, apacheSerializer, apacheDeserializer, "Apache to Apache with Apache schema"}
);
@Parameterized.Parameters(name = "{3}")
public static Object[][] getParameters() {
return new Object[][]{
{getApacheSchema, apacheSerializer, jacksonDeserializer, "Apache to Jackson with Apache schema"},
{getJacksonSchema, apacheSerializer, jacksonDeserializer, "Apache to Jackson with Jackson schema"},
{getApacheSchema, jacksonSerializer, jacksonDeserializer, "Jackson to Jackson with Apache schema"},
{getJacksonSchema, jacksonSerializer, jacksonDeserializer, "Jackson to Jackson with Jackson schema"},
{getApacheSchema, jacksonSerializer, apacheDeserializer, "Jackson to Apache with Apache schema"},
{getJacksonSchema, jacksonSerializer, apacheDeserializer, "Jackson to Apache with Jackson schema"},
{getJacksonSchema, apacheSerializer, apacheDeserializer, "Apache to Apache with Jackson schema"},
{getApacheSchema, apacheSerializer, apacheDeserializer, "Apache to Apache with Apache schema"}
};
}

/**
Expand Down Expand Up @@ -154,14 +162,4 @@ protected <T> T roundTrip(Type schemaType, T object) throws IOException {
Schema schema = schemaFunctor.apply(schemaType);
return (T) deserializeFunctor.apply(schema, serializeFunctor.apply(schema, object));
}

protected void useParameters(Function<Type, Schema> schemaFunctor,
BiFunction<Schema, Object, byte[]> serializeFunctor,
BiFunction<Schema, byte[], Object> deserializeFunctor
) {
this.schemaFunctor = schemaFunctor;
this.serializeFunctor = serializeFunctor;
this.deserializeFunctor = deserializeFunctor;
}

}

0 comments on commit 1a71347

Please sign in to comment.