当前位置: 首页>>代码示例>>Java>>正文


Java JdbcTestUtils.countRowsInTable方法代码示例

本文整理汇总了Java中org.springframework.test.jdbc.JdbcTestUtils.countRowsInTable方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcTestUtils.countRowsInTable方法的具体用法?Java JdbcTestUtils.countRowsInTable怎么用?Java JdbcTestUtils.countRowsInTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.test.jdbc.JdbcTestUtils的用法示例。


在下文中一共展示了JdbcTestUtils.countRowsInTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkUserNotDuplicated

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void checkUserNotDuplicated() throws Exception {
    final SavedQuery savedQuery1 = new SavedQuery.Builder()
            .setTitle("title1")
            .setMinScore(0)
            .build();

    final SavedQuery savedQuery2 = new SavedQuery.Builder()
            .setTitle("title2")
            .setMinScore(0)
            .build();

    createSavedQuery(savedQuery1);
    createSavedQuery(savedQuery2);

    final int userRows = JdbcTestUtils.countRowsInTable(jdbcTemplate, "find." + UserEntity.Table.NAME);
    assertThat(userRows, is(1));
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:19,代码来源:AbstractSavedQueryIT.java

示例2: ddlOrDelete

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
private void ddlOrDelete() {
    try {

        final int pathsCount = JdbcTestUtils.countRowsInTable(jdbcTemplate, NAMES_TABLE);
        if (pathsCount > 0) {
            JdbcTestUtils.deleteFromTables(jdbcTemplate, NAMES_TABLE);
        }

    } catch (BadSqlGrammarException e) {
        switch (e.getSQLException().getErrorCode()) {
            case ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1:

                jdbcTemplate.execute(new StringBuilder()
                        .append("CREATE TABLE ").append(NAMES_TABLE).append(" (\n")
                        .append(" id INT PRIMARY KEY,\n")
                        .append(" name VARCHAR,\n")
                        .append(" automat VARCHAR\n")
                        .append(");").toString());

                break;
            default:
                throw e;
        }
    }
}
 
开发者ID:bedla,项目名称:parkovani-v-praze,代码行数:26,代码来源:GeoCodingController.java

示例3: testLaunchJsrBasedJob

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testLaunchJsrBasedJob() throws Exception {
	int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	JobExecution jobExecution = jobService.launch("jsr352-job", jobParameters);

	while(jobExecution.isRunning()) {
		jobExecution = jobService.getJobExecution(jobExecution.getId());
	}

	assertNotNull(jobExecution);
	assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
	int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	assertEquals(before + 1, after);
}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:15,代码来源:JobExecutionTests.java

示例4: testLaunchJavaConfiguredJob

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testLaunchJavaConfiguredJob() throws Exception {
	int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	JobExecution jobExecution = jobService.launch("javaJob", jobParameters);
	assertNotNull(jobExecution);
	assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
	int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	assertEquals(before + 1, after);
}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:10,代码来源:JobExecutionTests.java

示例5: testLaunchJob

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testLaunchJob() throws Exception {
	int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	JobExecution jobExecution = jobService.launch("job1", jobParameters);
	assertNotNull(jobExecution);
	assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
	int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	assertEquals(before + 1, after);
}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:10,代码来源:JobExecutionTests.java

示例6: testFailedJob

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testFailedJob() throws Exception {
	int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	jobParameters = new JobParametersBuilder().addString("fail", "true").toJobParameters();
	JobExecution jobExecution = jobService.launch("job1", jobParameters);
	assertNotNull(jobExecution);
	assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
	int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	assertEquals(before + 1, after);
}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:11,代码来源:JobExecutionTests.java

示例7: testLaunchTwoJobs

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testLaunchTwoJobs() throws Exception {
	int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	long count = 0;
	JobExecution jobExecution1 = jobService.launch("job1", new JobParametersBuilder(jobParameters).addLong("run.id", count++)
			.toJobParameters());
	JobExecution jobExecution2 = jobService.launch("job1", new JobParametersBuilder(jobParameters).addLong("run.id", count++)
			.toJobParameters());
	assertEquals(BatchStatus.COMPLETED, jobExecution1.getStatus());
	assertEquals(BatchStatus.COMPLETED, jobExecution2.getStatus());
	int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
	assertEquals(before + 2, after);
}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:14,代码来源:JobExecutionTests.java

示例8: useDataSetDefaultResources

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
@DataSet
public void useDataSetDefaultResources() throws Exception {
    // assert / then
    int numUsers = JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "PUBLIC.USERS");
    assertThat("#User(s)?", numUsers, is(1));
}
 
开发者ID:dataz,项目名称:datastore-sql,代码行数:8,代码来源:SqlDataStoreTest.java

示例9: useDataSetWithSettings

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
@DataSet(setup = "SqlDataStoreTest-testAlias.setup.sql.vm", cleanup = "SqlDataStoreTest-testAlias.cleanup.sql")
@RangeGenerator(name = "id", limit = Limit.UNLIMITED, from= 1)
@ListGenerator(name = "user", values = {"Marko", "Loddar", "Frodo"})
@ListGenerator(name = "alias", values = {"Kurt", "Bodo", "Bilbo"})
public void useDataSetWithSettings() throws Exception {
    // assert / then
    int numUsers = JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "PUBLIC.USERS");
    int numAliases = JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "PUBLIC.ALIASES");

    assertThat("#Users?", numUsers, is(3));
    assertThat("#Aliases?", numAliases, is(9));
}
 
开发者ID:dataz,项目名称:datastore-sql,代码行数:14,代码来源:SqlDataStoreTest.java

示例10: testRepairProcessingMessages

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testRepairProcessingMessages() {
    msg.setState(MsgStateEnum.PROCESSING);
    msg.setStartProcessTimestamp(msg.getMsgTimestamp());
    messageDao.insert(msg);

    em.flush();

    int msgCount = JdbcTestUtils.countRowsInTable(getJdbcTemplate(), "message");
    assertThat(msgCount, is(1));

    // call repairing
    repairMsgService.repairProcessingMessages();

    em.flush();

    // verify results
    msgCount = JdbcTestUtils.countRowsInTable(getJdbcTemplate(), "message");
    assertThat(msgCount, is(1));

    getJdbcTemplate().query("select * from message", new RowMapper<Message>() {
        @Override
        public Message mapRow(ResultSet rs, int rowNum) throws SQLException {
            // verify row values
            assertThat(rs.getLong("msg_id"), is(1L));
            assertThat((int)rs.getShort("failed_count"), is(1));
            assertThat(rs.getTimestamp("last_update_timestamp"), notNullValue());
            assertThat(MsgStateEnum.valueOf(rs.getString("state")), is(MsgStateEnum.PARTLY_FAILED));

            return new Message();
        }
    });
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:34,代码来源:RepairProcessingMsgServiceDbTest.java

示例11: countRows

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
protected int countRows() {
    return JdbcTestUtils.countRowsInTable(jdbcTemplate, table);
}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:4,代码来源:AbstractJDBCDAOTest.java

示例12: countRowsInTable

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
protected int countRowsInTable(String tableName) {
	return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:TransactionalInlinedStatementsSqlScriptsTests.java

示例13: countRowsInTable

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
private int countRowsInTable(String tableName) {
    return JdbcTestUtils.countRowsInTable(jdbcTemplate, tableName);
}
 
开发者ID:crispab,项目名称:codekvast,代码行数:4,代码来源:MariadbIntegrationTest.java

示例14: testResponseOK

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Test
public void testResponseOK() throws Exception {
    getCamelContext().getRouteDefinition(AsynchInMessageRoute.ROUTE_ID_ASYNC)
            .adviceWith(getCamelContext(), new AdviceWithRouteBuilder() {
                @Override
                public void configure() throws Exception {
                    weaveAddLast().to("mock:test");
                }
            });

    mock.expectedMessageCount(1);

    producer.sendBodyAndHeaders("bodyContent", getHeaders());

    mock.assertIsSatisfied();

    // verify response
    Exchange exchange = mock.getExchanges().get(0);
    assertThat(exchange.getIn().getBody(), instanceOf(CallbackResponse.class));
    CallbackResponse callbackResponse = (CallbackResponse) exchange.getIn().getBody();
    assertThat(callbackResponse.getStatus(), is(ConfirmationTypes.OK));

    // verify DB
    int msgCount = JdbcTestUtils.countRowsInTable(getJdbcTemplate(), "message");
    assertThat(msgCount, is(1));

    final List<Message> messages = getJdbcTemplate().query("select * from message", new RowMapper<Message>() {
        @Override
        public Message mapRow(ResultSet rs, int rowNum) throws SQLException {
            TraceIdentifier traceIdentifier = getTraceHeader().getTraceIdentifier();

            // verify row values
            assertThat(rs.getLong("msg_id"), notNullValue());
            assertThat(rs.getString("correlation_id"), is(traceIdentifier.getCorrelationID()));
            assertThat((int)rs.getShort("failed_count"), is(0));
            assertThat(rs.getString("failed_desc"), nullValue());
            assertThat(rs.getString("failed_error_code"), nullValue());
            assertThat(rs.getTimestamp("last_update_timestamp"), notNullValue());
            assertThat(rs.getTimestamp("start_process_timestamp"), notNullValue());
            assertThat(rs.getTimestamp("msg_timestamp").compareTo(traceIdentifier.getTimestamp().toDate()), is(0));
            assertThat(rs.getString("object_id"), is(getHeaders().get(AsynchConstants.OBJECT_ID_HEADER)));
            assertThat(rs.getString("operation_name"), is(getHeaders().get(AsynchConstants.OPERATION_HEADER)));
            assertThat(rs.getString("payload"), is("bodyContent"));
            assertThat(rs.getTimestamp("receive_timestamp"), notNullValue());
            assertThat(rs.getString("service"), is(ServiceTestEnum.CUSTOMER.getServiceName()));
            assertThat(rs.getString("source_system"), is(ExternalSystemTestEnum.CRM.getSystemName()));
            assertThat(MsgStateEnum.valueOf(rs.getString("state")), is(MsgStateEnum.PROCESSING));
            assertThat(rs.getString("parent_binding_type"), nullValue());
            assertThat(rs.getString("funnel_component_id"), nullValue());
            assertThat(rs.getLong("parent_msg_id"), is(0L));
            assertThat(rs.getBoolean("guaranteed_order"), is(false));
            assertThat(rs.getBoolean("exclude_failed_state"), is(false));

            return new Message();
        }
    });

    assertThat(messages.size(), is(1));
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:60,代码来源:AsynchInMessageRouteTest.java

示例15: savePathsIntoDb

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
private void savePathsIntoDb(List<Path> paths) throws SQLException {
        LOG.info("--- savePathsIntoDb ---");

        try {

            final int pathsCount = JdbcTestUtils.countRowsInTable(jdbcTemplate, PATHS_TABLE);
            if (pathsCount > 0) {
                JdbcTestUtils.deleteFromTables(jdbcTemplate, PATHS_TABLE);
            }

        } catch (BadSqlGrammarException e) {
            switch (e.getSQLException().getErrorCode()) {
                case ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1:

                    jdbcTemplate.execute(new StringBuilder()
                            .append("CREATE TABLE ").append(PATHS_TABLE).append(" (\n")
                            .append(" id INT PRIMARY KEY AUTO_INCREMENT,\n")
                            .append(" source_uid INT,\n")
                            .append(" target_uid INT,\n")
                            .append(" distance DOUBLE,\n")
                            .append(" bbox VARCHAR,\n")
                            .append(" weight DOUBLE,\n")
                            .append(" time INT,\n")
                            .append(" points CLOB\n")
                            .append(");").toString());

                    jdbcTemplate.execute(String.format("CREATE UNIQUE INDEX IDX_source_target ON %s (source_uid, target_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_source_uid ON %s (source_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_target_uid ON %s (target_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_distance ON %s (distance);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_time ON %s (time);", PATHS_TABLE));

                    break;
                default:
                    throw e;
            }
        }

        final String insertSql = "INSERT INTO " + PATHS_TABLE + " (source_uid, target_uid, distance, bbox, weight, time, points) VALUES (?, ?, ?, ?, ?, ?, ?)";
        jdbcTemplate.batchUpdate(insertSql, paths, paths.size(), (ps, argument) -> {
            ps.setInt(1, argument.source.uid);
            ps.setInt(2, argument.target.uid);
            ps.setDouble(3, argument.distance);
            ps.setString(4, Joiner.on(',').join(argument.bbox));
            ps.setDouble(5, argument.weight);
            ps.setInt(6, argument.time);
            ps.setString(7, argument.points);
        });


//        System.out.println(JdbcTestUtils.countRowsInTable(jdbcTemplate, PATHS_TABLE));
//        List<Map<String, Object>> list = jdbcTemplate.queryForList("SELECT * FROM " + PATHS_TABLE);
//        for (Map<String, Object> map : list) {
//            System.out.println(map);
//        }
    }
 
开发者ID:bedla,项目名称:parkovani-v-praze,代码行数:57,代码来源:GraphDataLoaderController.java


注:本文中的org.springframework.test.jdbc.JdbcTestUtils.countRowsInTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。