|
1 | 1 | /*
|
2 |
| - * Copyright 2008-2014 the original author or authors. |
| 2 | + * Copyright 2008-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
15 | 15 | */
|
16 | 16 | package org.springframework.batch.core.repository.dao;
|
17 | 17 |
|
| 18 | +import org.junit.Assert; |
| 19 | +import org.junit.Test; |
18 | 20 | import org.junit.runner.RunWith;
|
| 21 | + |
| 22 | +import org.springframework.jdbc.core.JdbcOperations; |
19 | 23 | import org.springframework.test.context.ContextConfiguration;
|
20 | 24 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
21 | 25 |
|
| 26 | +import static org.mockito.Mockito.mock; |
| 27 | + |
22 | 28 | @RunWith(SpringJUnit4ClassRunner.class)
|
23 | 29 | @ContextConfiguration(locations = {"sql-dao-test.xml"})
|
24 | 30 | public class JdbcExecutionContextDaoTests extends AbstractExecutionContextDaoTests {
|
25 | 31 |
|
| 32 | + @Test |
| 33 | + public void testNoSerializer() { |
| 34 | + try { |
| 35 | + JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao(); |
| 36 | + jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class)); |
| 37 | + jdbcExecutionContextDao.afterPropertiesSet(); |
| 38 | + } catch (Exception e) { |
| 39 | + Assert.assertTrue(e instanceof IllegalStateException); |
| 40 | + Assert.assertEquals("ExecutionContextSerializer is required", e.getMessage()); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void testNullSerializer() { |
| 46 | + try { |
| 47 | + JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao(); |
| 48 | + jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class)); |
| 49 | + jdbcExecutionContextDao.setSerializer(null); |
| 50 | + jdbcExecutionContextDao.afterPropertiesSet(); |
| 51 | + } catch (Exception e) { |
| 52 | + Assert.assertTrue(e instanceof IllegalArgumentException); |
| 53 | + Assert.assertEquals("Serializer must not be null", e.getMessage()); |
| 54 | + } |
| 55 | + } |
| 56 | + |
26 | 57 | @Override
|
27 | 58 | protected JobInstanceDao getJobInstanceDao() {
|
28 | 59 | return applicationContext.getBean("jobInstanceDao", JobInstanceDao.class);
|
|
0 commit comments