org.springframework.core.serializer.support.SerializingConverter Java Examples

The following examples show how to use org.springframework.core.serializer.support.SerializingConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerializationConverterTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
Example #2
Source File: SerializationConverterTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void nonSerializableObject() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new Object());
		fail("Expected IllegalArgumentException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof IllegalArgumentException);
	}
}
 
Example #3
Source File: SerializationConverterTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void nonSerializableField() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new UnSerializable());
		fail("Expected SerializationFailureException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof NotSerializableException);
	}
}
 
Example #4
Source File: SerializationConverterTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
Example #5
Source File: SerializationConverterTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void nonSerializableObject() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new Object());
		fail("Expected IllegalArgumentException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof IllegalArgumentException);
	}
}
 
Example #6
Source File: SerializationConverterTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void nonSerializableField() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new UnSerializable());
		fail("Expected SerializationFailureException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof NotSerializableException);
	}
}
 
Example #7
Source File: SerializationConverterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void serializeAndDeserializeString() {
	SerializingConverter toBytes = new SerializingConverter();
	byte[] bytes = toBytes.convert("Testing");
	DeserializingConverter fromBytes = new DeserializingConverter();
	assertEquals("Testing", fromBytes.convert(bytes));
}
 
Example #8
Source File: SerializationConverterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void nonSerializableObject() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new Object());
		fail("Expected IllegalArgumentException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof IllegalArgumentException);
	}
}
 
Example #9
Source File: SerializationConverterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void nonSerializableField() {
	SerializingConverter toBytes = new SerializingConverter();
	try {
		toBytes.convert(new UnSerializable());
		fail("Expected SerializationFailureException");
	}
	catch (SerializationFailedException e) {
		assertNotNull(e.getCause());
		assertTrue(e.getCause() instanceof NotSerializableException);
	}
}
 
Example #10
Source File: CustomJdkSerializationRedisSerializer.java    From oauth-server with Apache License 2.0 4 votes vote down vote up
public CustomJdkSerializationRedisSerializer() {
    this(new SerializingConverter(), new DeserializingConverter());
}
 
Example #11
Source File: CustomJdkSerializationRedisSerializer.java    From oauth-server with Apache License 2.0 4 votes vote down vote up
public CustomJdkSerializationRedisSerializer(ClassLoader classLoader) {
    this(new SerializingConverter(), new DeserializingConverter(classLoader));
}
 
Example #12
Source File: JdbcIndexedSessionRepository.java    From spring-session with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #13
Source File: JdbcHttpSessionConfiguration.java    From spring-session with Apache License 2.0 4 votes vote down vote up
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;
}