use of com.amazonaws.athena.connector.lambda.request.FederationResponse in project aws-athena-query-federation by awslabs.
the class ObjectMapperUtil method assertBaseSerialization.
private static <T> void assertBaseSerialization(Object object) {
Class<?> clazz = object.getClass();
if (object instanceof FederationRequest)
clazz = FederationRequest.class;
else if (object instanceof FederationResponse) {
clazz = FederationResponse.class;
}
try (BlockAllocator allocator = new BlockAllocatorImpl()) {
// check SerDe write, SerDe read
ByteArrayOutputStream serDeOut = new ByteArrayOutputStream();
ObjectMapper serDe = VersionedObjectMapperFactory.create(allocator, SERDE_VERSION_TWO);
serDe.writeValue(serDeOut, object);
byte[] serDeOutput = serDeOut.toByteArray();
assertEquals(object, serDe.readValue(new ByteArrayInputStream(serDeOutput), clazz));
} catch (IOException | AssertionError ex) {
throw new RuntimeException(ex);
}
}
use of com.amazonaws.athena.connector.lambda.request.FederationResponse in project aws-athena-query-federation by awslabs.
the class ObjectMapperUtil method assertSerializationBackwardsCompatibleV3toV2.
private static <T> void assertSerializationBackwardsCompatibleV3toV2(Object object) {
Class<?> clazz = object.getClass();
if (object instanceof FederationRequest)
clazz = FederationRequest.class;
else if (object instanceof FederationResponse) {
clazz = FederationResponse.class;
}
try (BlockAllocator allocator = new BlockAllocatorImpl()) {
// check SerDe write, SerDe read
ByteArrayOutputStream serDeOut = new ByteArrayOutputStream();
ObjectMapper serDeV3 = VersionedObjectMapperFactory.create(allocator, SERDE_VERSION_THREE);
ObjectMapper serDeV2 = VersionedObjectMapperFactory.create(allocator, SERDE_VERSION_TWO);
serDeV3.writeValue(serDeOut, object);
byte[] serDeOutput = serDeOut.toByteArray();
assertEquals(object, serDeV2.readValue(new ByteArrayInputStream(serDeOutput), clazz));
} catch (IOException | AssertionError ex) {
throw new RuntimeException(ex);
}
}
use of com.amazonaws.athena.connector.lambda.request.FederationResponse in project aws-athena-query-federation by awslabs.
the class ObjectMapperUtil method assertSerializationForwardsCompatibleV2toV3.
private static <T> void assertSerializationForwardsCompatibleV2toV3(Object object) {
Class<?> clazz = object.getClass();
if (object instanceof FederationRequest)
clazz = FederationRequest.class;
else if (object instanceof FederationResponse) {
clazz = FederationResponse.class;
}
try (BlockAllocator allocator = new BlockAllocatorImpl()) {
// check SerDe write, SerDe read
ByteArrayOutputStream serDeOut = new ByteArrayOutputStream();
ObjectMapper serDeV3 = VersionedObjectMapperFactory.create(allocator, SERDE_VERSION_THREE);
ObjectMapper serDeV2 = VersionedObjectMapperFactory.create(allocator, SERDE_VERSION_TWO);
serDeV2.writeValue(serDeOut, object);
byte[] serDeOutput = serDeOut.toByteArray();
assertEquals(object, serDeV3.readValue(new ByteArrayInputStream(serDeOutput), clazz));
} catch (IOException | AssertionError ex) {
throw new RuntimeException(ex);
}
}
use of com.amazonaws.athena.connector.lambda.request.FederationResponse in project foundry-athena-query-federation-connector by palantir.
the class FoundryRecordHandlerTest method assetRoundTripSerializable.
private void assetRoundTripSerializable(FederationResponse response) throws JsonProcessingException {
FederationResponse other = objectMapper.readValue(objectMapper.writeValueAsString(response), FederationResponse.class);
assertThat(other).isNotNull();
}
Aggregations