org.springframework.core.serializer.support.SerializationFailedException#org.springframework.core.serializer.support.DeserializingConverter源码实例Demo

下面列出了org.springframework.core.serializer.support.SerializationFailedException#org.springframework.core.serializer.support.DeserializingConverter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
@Test(expected = SerializationFailedException.class)
public void deserializationFailure() {
	DeserializingConverter fromBytes = new DeserializingConverter();
	fromBytes.convert("Junk".getBytes());
}
 
@Test(expected = SerializationFailedException.class)
public void deserializationFailure() {
	DeserializingConverter fromBytes = new DeserializingConverter();
	fromBytes.convert("Junk".getBytes());
}
 
public CustomJdkSerializationRedisSerializer() {
    this(new SerializingConverter(), new DeserializingConverter());
}
 
public CustomJdkSerializationRedisSerializer(ClassLoader classLoader) {
    this(new SerializingConverter(), new DeserializingConverter(classLoader));
}
 
@Test(expected = SerializationFailedException.class)
public void deserializationFailure() {
	DeserializingConverter fromBytes = new DeserializingConverter();
	fromBytes.convert("Junk".getBytes());
}
 
public SpringDevToolsSerializer(){
	this.deserializer = new DeserializingConverter(new DefaultDeserializer(Thread.currentThread().getContextClassLoader()));
}
 
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;
}
 
private static GenericConversionService createConversionServiceWithBeanClassLoader(ClassLoader classLoader) {
	GenericConversionService conversionService = new GenericConversionService();
	conversionService.addConverter(Object.class, byte[].class, new SerializingConverter());
	conversionService.addConverter(byte[].class, Object.class, new DeserializingConverter(classLoader));
	return conversionService;
}