Java 类org.springframework.core.serializer.support.SerializingConverter 实例源码

项目:oma-riista-web    文件:HttpSessionConfig.java   
private static GenericConversionService safeConversionService() {
    final GenericConversionService converter = new GenericConversionService();
    converter.addConverter(Object.class, byte[].class, new SerializingConverter());

    final DeserializingConverter byteConverter = new DeserializingConverter();
    converter.addConverter(byte[].class, Object.class, (byte[] bytes) -> {
        try {
            return byteConverter.convert(bytes);
        } catch (SerializationFailedException e) {
            LOG.error("Could not extract attribute: {}", e.getMessage());
            return null;
        }
    });

    return converter;
}
项目:spring4-understanding    文件:SerializationConverterTests.java   
@Test
public void serializeAndDeserializeString() {
    SerializingConverter toBytes = new SerializingConverter();
    byte[] bytes = toBytes.convert("Testing");
    DeserializingConverter fromBytes = new DeserializingConverter();
    assertEquals("Testing", fromBytes.convert(bytes));
}
项目:spring4-understanding    文件:SerializationConverterTests.java   
@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);
    }
}
项目:spring4-understanding    文件:SerializationConverterTests.java   
@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);
    }
}
项目:pivotal-cla    文件:MylynGitHubApiITests.java   
@Test
@EnqueueRequests({
    "getContributingUrls302",
    "getContributingUrls200",
    "getContributingUrls404",
    "getContributingUrls404",
    "getContributingUrls302",
    "getContributingUrls200",
    "getContributingUrls404"
})
public void getContributingUrls() {
    // make sure we use GitHubHost and not the GitHubApiHost
    oauthConfig.setGitHubApiHost("donotuse");
    oauthConfig.setGitHubHost(server.getServer().getHostName());

    service = new MylynGitHubApi(oauthConfig);

    List<String> repositoryIds = Arrays.asList("spring-projects/has-md", "spring-projects/has-adoc", "spring-projects/no-contributor");

    ContributingUrlsResponse urls = service.getContributingUrls(repositoryIds);

    assertThat(urls.getAsciidoc()).containsExactly(
            server.getServerUrl() + "/spring-projects/has-adoc/edit/master/CONTRIBUTING.adoc",
            server.getServerUrl() + "/spring-projects/no-contributor/new/master?filename=CONTRIBUTING.adoc");
    assertThat(urls.getMarkdown()).containsOnly(server.getServerUrl() + "/spring-projects/has-md/edit/master/CONTRIBUTING.md");

    SerializingConverter converter = new SerializingConverter();
    // ensure we can serialize the result as it is placed in FlashMap
    assertThat(converter.convert(urls.getMarkdown())).isNotNull();
    assertThat(converter.convert(urls.getAsciidoc())).isNotNull();
}
项目:spring-session    文件:JdbcHttpSessionConfiguration.java   
private GenericConversionService createConversionServiceWithBeanClassLoader() {
    GenericConversionService conversionService = new GenericConversionService();
    conversionService.addConverter(Object.class, byte[].class,
            new SerializingConverter());
    conversionService.addConverter(byte[].class, Object.class,
            new DeserializingConverter(this.classLoader));
    return conversionService;
}
项目:spring-session    文件:JdbcOperationsSessionRepository.java   
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;
}
项目:class-guard    文件:SerializationConverterTests.java   
@Test
public void serializeAndDeserializeString() {
    SerializingConverter toBytes = new SerializingConverter();
    byte[] bytes = toBytes.convert("Testing");
    DeserializingConverter fromBytes = new DeserializingConverter();
    assertEquals("Testing", fromBytes.convert(bytes));
}
项目:class-guard    文件:SerializationConverterTests.java   
@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);
    }
}
项目:class-guard    文件:SerializationConverterTests.java   
@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);
    }
}
项目:spring-data-tarantool    文件:JdkTarantoolSerializer.java   
public JdkTarantoolSerializer() {
    this(new SerializingConverter(), new DeserializingConverter());
}
项目:spring-session-data-mongodb    文件:JdkMongoSessionConverter.java   
public JdkMongoSessionConverter(Duration maxInactiveInterval) {
    this(new SerializingConverter(), new DeserializingConverter(), maxInactiveInterval);
}
项目:spring-session-data-mongodb    文件:JdkMongoSessionConverterTest.java   
@Test(expected = IllegalArgumentException.class)
public void constructorNullDeserializer() {
    new JdkMongoSessionConverter(new SerializingConverter(), null, inactiveInterval);
}