Search in sources :

Example 1 with SerializingConverter

use of org.springframework.core.serializer.support.SerializingConverter 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 SerializingConverter

use of org.springframework.core.serializer.support.SerializingConverter 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)

Example 3 with SerializingConverter

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

the class SerializationConverterTests method serializeAndDeserializeString.

@Test
public void serializeAndDeserializeString() {
    SerializingConverter toBytes = new SerializingConverter();
    byte[] bytes = toBytes.convert("Testing");
    DeserializingConverter fromBytes = new DeserializingConverter();
    assertEquals("Testing", fromBytes.convert(bytes));
}
Also used : DeserializingConverter(org.springframework.core.serializer.support.DeserializingConverter) SerializingConverter(org.springframework.core.serializer.support.SerializingConverter) Test(org.junit.Test)

Aggregations

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