/** * Convenience method for counting the rows in the given table. * @param tableName table name to count rows in * @return the number of rows in the table * @see JdbcTestUtils#countRowsInTable */ protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
/** * Convenience method for counting the rows in the given table. * @param tableName table name to count rows in * @return the number of rows in the table * @see JdbcTestUtils#countRowsInTable */ protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
private void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table", expected, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
@Before public void testInit() { jdbcTemplate = new JdbcTemplate(dataSource); String[] names = {"Foo", "Bar", "Baz", "Foo", "Bar", "Baz", "Foo", "Bar", "Baz"}; String[] codes = {"A", "B", "A", "B", "B", "B", "A", "B", "A"}; jdbcTemplate.update("DELETE from T_FOOS"); for(int i = 0; i < names.length; i++) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME, CODE, VALUE) values (?, ?, ?, ?)", maxId, names[i], codes[i], i); maxId++; } assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); }
@Before public void init() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); Integer tempMaxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); maxId = tempMaxId != null? tempMaxId : 0; for (int i = ITEM_COUNT; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); }
@Before public void init() { jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); for (int i = itemCount; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); }
@Before public void init() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); for (int i = maxId + 1; i <= ITEM_COUNT; i++) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); }
@Before public void init() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); for (int i = maxId + 1; i <= ITEM_COUNT; i++) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); }
@Test @Sql("data.sql") public void dataSourceTest() { TransactionTestUtils.assertInTransaction(false); assertEquals("Number of rows in the 'user' table.", 1, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
@Test public void testCreateJobExecutionsByName() throws Exception { utils = new JobRepositoryTestUtils(jobRepository, dataSource); List<JobExecution> list = utils.createJobExecutions("foo",new String[] {"bar", "spam"}, 3); assertEquals(3, list.size()); assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION")); assertEquals(beforeSteps + 6, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION")); utils.removeJobExecutions(list); assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION")); assertEquals(beforeSteps, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION")); }
@Test public void testLaunchJob() throws Exception { int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING"); JobExecution execution = jobLauncherTestUtils.launchJob(); int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING"); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); assertEquals(after - before, execution.getStepExecutions().iterator().next().getReadCount()); }
@Test public void testUpdatesNoRollback() throws Exception { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); writer.write(Arrays.asList("foo", "bar")); processor.process("spam"); assertEquals(3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG")); writer.clear(); processor.clear(); assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG")); }
@Test public void testRemoveJobExecutionsIncrementally() throws Exception { utils = new JobRepositoryTestUtils(jobRepository, dataSource); List<JobExecution> list1 = utils.createJobExecutions(3); List<JobExecution> list2 = utils.createJobExecutions(2); assertEquals(beforeJobs + 5, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION")); utils.removeJobExecutions(list2); assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION")); utils.removeJobExecutions(list1); assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION")); }
@Test public void testJobLaunch() throws Exception { JobExecution jobExecution = jobLauncher.run(job, new JobParameters()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); assertEquals(1, JdbcTestUtils.countRowsInTable(jdbcTemplate, "PREFIX_JOB_INSTANCE")); }