|
|
@ -38,6 +38,8 @@ import org.apache.commons.lang3.SerializationException;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
@ -65,6 +67,8 @@ import static org.junit.Assert.fail;
|
|
|
|
@ExtendWith(TestLoggerExtension.class)
|
|
|
|
@ExtendWith(TestLoggerExtension.class)
|
|
|
|
public abstract class SerializerTestBase<T> {
|
|
|
|
public abstract class SerializerTestBase<T> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(SerializerTestBase.class);
|
|
|
|
|
|
|
|
|
|
|
|
private final DeeplyEqualsChecker checker;
|
|
|
|
private final DeeplyEqualsChecker checker;
|
|
|
|
|
|
|
|
|
|
|
|
protected SerializerTestBase() {
|
|
|
|
protected SerializerTestBase() {
|
|
|
@ -123,8 +127,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
+ instance.getClass());
|
|
|
|
+ instance.getClass());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -181,8 +184,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
TypeSerializer<T> serializer = getSerializer();
|
|
|
|
TypeSerializer<T> serializer = getSerializer();
|
|
|
|
assertEquals(len, serializer.getLength());
|
|
|
|
assertEquals(len, serializer.getLength());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -199,8 +201,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
deepEquals("Copied element is not equal to the original element.", datum, copy);
|
|
|
|
deepEquals("Copied element is not equal to the original element.", datum, copy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -217,8 +218,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
deepEquals("Copied element is not equal to the original element.", datum, copy);
|
|
|
|
deepEquals("Copied element is not equal to the original element.", datum, copy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -238,8 +238,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
target = copy;
|
|
|
|
target = copy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -265,8 +264,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
assertTrue("Trailing data available after deserialization.", in.available() == 0);
|
|
|
|
assertTrue("Trailing data available after deserialization.", in.available() == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -296,8 +294,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
reuseValue = deserialized;
|
|
|
|
reuseValue = deserialized;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -326,8 +323,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Wrong number of elements deserialized.", testData.length, num);
|
|
|
|
assertEquals("Wrong number of elements deserialized.", testData.length, num);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -358,8 +354,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Wrong number of elements deserialized.", testData.length, num);
|
|
|
|
assertEquals("Wrong number of elements deserialized.", testData.length, num);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -392,8 +387,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
toVerify.available() == 0);
|
|
|
|
toVerify.available() == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -428,8 +422,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Wrong number of elements copied.", testData.length, num);
|
|
|
|
assertEquals("Wrong number of elements copied.", testData.length, num);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,8 +442,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
"The copy of the serializer is not equal to the original one.", ser1, ser2);
|
|
|
|
"The copy of the serializer is not equal to the original one.", ser1, ser2);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println(e.getMessage());
|
|
|
|
LOG.error("", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
fail("Exception in test: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -461,8 +453,7 @@ public abstract class SerializerTestBase<T> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
NullableSerializer.checkIfNullSupported(serializer);
|
|
|
|
NullableSerializer.checkIfNullSupported(serializer);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
} catch (Throwable t) {
|
|
|
|
System.err.println(t.getMessage());
|
|
|
|
LOG.error("", t);
|
|
|
|
t.printStackTrace();
|
|
|
|
|
|
|
|
fail("Unexpected failure of null value handling: " + t.getMessage());
|
|
|
|
fail("Unexpected failure of null value handling: " + t.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|