Revision 50695
Added by Claudio Atzori about 6 years ago
DatabaseUtilsTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.enabling.database.utils; |
2 | 2 |
|
3 | 3 |
import java.io.StringReader; |
4 |
import java.sql.Connection; |
|
4 | 5 |
import java.sql.Date; |
5 | 6 |
import java.util.Arrays; |
6 | 7 |
import java.util.HashMap; |
... | ... | |
66 | 67 |
private TransactionTemplateFactory transactionTemplateFactory; |
67 | 68 |
@Mock |
68 | 69 |
private TransactionTemplate transactionTemplate; |
70 |
@Mock |
|
71 |
private Connection connection; |
|
69 | 72 |
|
70 | 73 |
@SuppressWarnings("unchecked") |
71 | 74 |
@Before |
... | ... | |
86 | 89 |
dbUtils.setDbPrefix(DB_PREFIX); |
87 | 90 |
dbUtils.setNumbersOfRecordsForTransaction(20); |
88 | 91 |
|
92 |
//when(jdbcTemplate.getDataSource()).thenReturn(dataSource); |
|
93 |
when(dataSourceFactory.createDataSource(anyString())).thenReturn(dataSource); |
|
94 |
//when(dataSource.getConnection()).thenReturn(connection); |
|
95 |
|
|
96 |
when(transactionTemplateFactory.createTransactionTemplate(dataSource)).thenReturn(transactionTemplate); |
|
97 |
|
|
89 | 98 |
when(jdbcTemplateFactory.createJdbcTemplate(DB)).thenReturn(jdbcTemplate); |
90 | 99 |
when(jdbcTemplate.queryForList(QUERY, Integer.class)).thenReturn(Arrays.asList(1, 2, 3, 4)); |
91 | 100 |
|
... | ... | |
101 | 110 |
//when(jdbcTemplate.queryForList("SELECT profileid FROM dnet_tables WHERE table_name='THE_TABLE' AND database_db_name='THE_DB'", String.class)) |
102 | 111 |
// .thenReturn(Arrays.asList("1234")); |
103 | 112 |
|
104 |
when(dataSourceFactory.createDataSource(anyString())).thenReturn(dataSource); |
|
105 |
//when(jdbcTemplate.getDataSource()).thenReturn(dataSource); |
|
106 |
|
|
107 |
when(transactionTemplateFactory.createTransactionTemplate(dataSource)).thenReturn(transactionTemplate); |
|
108 |
|
|
109 | 113 |
} |
110 | 114 |
|
111 | 115 |
@Test |
Also available in: Unified diff
avoid to use jdbcTemplate as it tries to load the entire resultset in memory