private static GenericConversionService safeConversionService() { final GenericConversionService converter = new GenericConversionService(); converter.addConverter(Object.class, byte[].class, new SerializingConverter()); final DeserializingConverter byteConverter = new DeserializingConverter(); converter.addConverter(byte[].class, Object.class, (byte[] bytes) -> { try { return byteConverter.convert(bytes); } catch (SerializationFailedException e) { LOG.error("Could not extract attribute: {}", e.getMessage()); return null; } }); return converter; }
@Test public void serializeAndDeserializeString() { SerializingConverter toBytes = new SerializingConverter(); byte[] bytes = toBytes.convert("Testing"); DeserializingConverter fromBytes = new DeserializingConverter(); assertEquals("Testing", fromBytes.convert(bytes)); }
private GenericConversionService createConversionServiceWithBeanClassLoader() { GenericConversionService conversionService = new GenericConversionService(); conversionService.addConverter(Object.class, byte[].class, new SerializingConverter()); conversionService.addConverter(byte[].class, Object.class, new DeserializingConverter(this.classLoader)); return conversionService; }
private static GenericConversionService createDefaultConversionService() { GenericConversionService converter = new GenericConversionService(); converter.addConverter(Object.class, byte[].class, new SerializingConverter()); converter.addConverter(byte[].class, Object.class, new DeserializingConverter()); return converter; }
public JdkTarantoolSerializer() { this(new SerializingConverter(), new DeserializingConverter()); }
public JdkMongoSessionConverter(Duration maxInactiveInterval) { this(new SerializingConverter(), new DeserializingConverter(), maxInactiveInterval); }
@Test(expected = IllegalArgumentException.class) public void constructorNullSerializer() { new JdkMongoSessionConverter(null, new DeserializingConverter(), inactiveInterval); }
@Test(expected = SerializationFailedException.class) public void deserializationFailure() { DeserializingConverter fromBytes = new DeserializingConverter(); fromBytes.convert("Junk".getBytes()); }
RestartCompatibleRedisSerializer(ClassLoader classLoader) { this.deserializer = new DeserializingConverter( new DefaultDeserializer(classLoader)); }
public SpringDevToolsSerializer(){ this.deserializer = new DeserializingConverter(new DefaultDeserializer(Thread.currentThread().getContextClassLoader())); }