Add assertion that a serializer was set in the JdbcExecutionContextDao
Resolves BATCH-2779
This commit is contained in:
committed by
Michael Minella
parent
2a578ae663
commit
7ca11f2f99
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,45 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"sql-dao-test.xml"})
|
||||
public class JdbcExecutionContextDaoTests extends AbstractExecutionContextDaoTests {
|
||||
|
||||
@Test
|
||||
public void testNoSerializer() {
|
||||
try {
|
||||
JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao();
|
||||
jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class));
|
||||
jdbcExecutionContextDao.afterPropertiesSet();
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e instanceof IllegalStateException);
|
||||
Assert.assertEquals("ExecutionContextSerializer is required", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullSerializer() {
|
||||
try {
|
||||
JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao();
|
||||
jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class));
|
||||
jdbcExecutionContextDao.setSerializer(null);
|
||||
jdbcExecutionContextDao.afterPropertiesSet();
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e instanceof IllegalArgumentException);
|
||||
Assert.assertEquals("Serializer must not be null", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
return applicationContext.getBean("jobInstanceDao", JobInstanceDao.class);
|
||||
|
||||
Reference in New Issue
Block a user