Java Code Examples for org.springframework.core.serializer.support.SerializingConverter#convert()

The following examples show how to use org.springframework.core.serializer.support.SerializingConverter#convert() . 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);
	}
}