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


Java JdbcTestUtils类代码示例

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


JdbcTestUtils类属于org.springframework.test.jdbc包,在下文中一共展示了JdbcTestUtils类的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: testFindAll

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void testFindAll() {
	List<UserDto> userDtos = userService.findAll();
	assertEquals(JdbcTestUtils.countRowsInTable(jdbcTemplate, "user"), userDtos.size());
	assertEquals("testuser1", userDtos.get(0).getName());
	assertEquals(Integer.valueOf(18), userDtos.get(0).getAge());
	assertEquals("台灣", userDtos.get(0).getCountry());
	assertEquals("testuser2", userDtos.get(1).getName());
	assertEquals(Integer.valueOf(22), userDtos.get(1).getAge());
	assertEquals("美國", userDtos.get(1).getCountry());
}
 
开发者ID:lf23617358,项目名称:training-sample,代码行数:12,代码来源:DefaultUserServiceTest.java

示例4: findById_Existing_ShouldReturnClient

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void findById_Existing_ShouldReturnClient() {
	OIDCClientInformation client = ClientTestUtils.createClient();
	this.clientRepository.save(client);

	assertThat(this.clientRepository.findById(client.getID())).isNotNull();
	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "clients")).isEqualTo(1);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:JdbcClientRepositoryIntegrationTests.java

示例5: findAll_Na_ShouldReturnClients

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void findAll_Na_ShouldReturnClients() {
	this.clientRepository.save(ClientTestUtils.createClient());
	this.clientRepository.save(ClientTestUtils.createClient());

	assertThat(this.clientRepository.findAll()).hasSize(2);
	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "clients")).isEqualTo(2);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:JdbcClientRepositoryIntegrationTests.java

示例6: deleteById_Valid_ShouldReturnNull

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void deleteById_Valid_ShouldReturnNull() {
	OIDCClientInformation client = ClientTestUtils.createClient();
	this.clientRepository.save(client);
	this.clientRepository.deleteById(client.getID());

	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "clients")).isEqualTo(0);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:JdbcClientRepositoryIntegrationTests.java

示例7: load_Existing_ShouldReturnClient

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void load_Existing_ShouldReturnClient() throws GeneralException {
	RefreshTokenContext context = RefreshTokenTestUtils.createRefreshTokenContext(null);
	this.refreshTokenStore.save(context);

	assertThat(this.refreshTokenStore.load(context.getRefreshToken())).isNotNull();
	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "refresh_tokens")).isEqualTo(1);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:JdbcRefreshTokenStoreIntegrationTests.java

示例8: findByClientIdAndSubject_Existing_ShouldReturnClient

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void findByClientIdAndSubject_Existing_ShouldReturnClient() {
	RefreshTokenContext context = RefreshTokenTestUtils.createRefreshTokenContext(null);
	this.refreshTokenStore.save(context);

	assertThat(this.refreshTokenStore.findByClientIdAndSubject(context.getClientId(), context.getSubject()))
			.isNotNull();
	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "refresh_tokens")).isEqualTo(1);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:10,代码来源:JdbcRefreshTokenStoreIntegrationTests.java

示例9: revoke_Existing_ShouldReturnNull

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void revoke_Existing_ShouldReturnNull() {
	RefreshTokenContext context = RefreshTokenTestUtils.createRefreshTokenContext(null);
	this.refreshTokenStore.save(context);
	this.refreshTokenStore.revoke(context.getRefreshToken());

	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "refresh_tokens")).isEqualTo(0);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:JdbcRefreshTokenStoreIntegrationTests.java

示例10: cleanExpiredTokens_Valid_ShouldReturnNull

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void cleanExpiredTokens_Valid_ShouldReturnNull() {
	this.refreshTokenStore.save(RefreshTokenTestUtils.createRefreshTokenContext(null));
	this.refreshTokenStore.cleanExpiredTokens();

	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "refresh_tokens")).isEqualTo(1);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:8,代码来源:JdbcRefreshTokenStoreIntegrationTests.java

示例11: cleanExpiredTokens_Expired_ShouldReturnNull

import org.springframework.test.jdbc.JdbcTestUtils; //导入依赖的package包/类
@Test
public void cleanExpiredTokens_Expired_ShouldReturnNull() {
	this.refreshTokenStore.save(RefreshTokenTestUtils.createRefreshTokenContext(Instant.now().minusSeconds(1)));
	this.refreshTokenStore.cleanExpiredTokens();

	assertThat(JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "refresh_tokens")).isEqualTo(0);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:8,代码来源:JdbcRefreshTokenStoreIntegrationTests.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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