Search in sources :

Example 1 with SerializationFailedException

use of org.springframework.core.serializer.support.SerializationFailedException in project spring-framework by spring-projects.

the class SerializationConverterTests method nonSerializableField.

@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);
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) SerializingConverter(org.springframework.core.serializer.support.SerializingConverter) SerializationFailedException(org.springframework.core.serializer.support.SerializationFailedException) Test(org.junit.Test)

Example 2 with SerializationFailedException

use of org.springframework.core.serializer.support.SerializationFailedException in project spring-framework by spring-projects.

the class SerializationConverterTests method nonSerializableObject.

@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);
    }
}
Also used : SerializingConverter(org.springframework.core.serializer.support.SerializingConverter) SerializationFailedException(org.springframework.core.serializer.support.SerializationFailedException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SerializationFailedException (org.springframework.core.serializer.support.SerializationFailedException)2 SerializingConverter (org.springframework.core.serializer.support.SerializingConverter)2 NotSerializableException (java.io.NotSerializableException)1