org.springframework.test.jdbc.JdbcTestUtils Java Examples
The following examples show how to use
org.springframework.test.jdbc.JdbcTestUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepositoryTransactionManagerConfigurationTests.java From spring-cloud-task with Apache License 2.0 | 6 votes |
@Test public void testZeroCustomTransactionManagerConfiguration() { ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class, ZeroTransactionManagerConfiguration.class)) .withPropertyValues("application.name=transactionManagerTask"); applicationContextRunner.run((context) -> { DataSource dataSource = context.getBean("dataSource", DataSource.class); int taskExecutionCount = JdbcTestUtils .countRowsInTable(new JdbcTemplate(dataSource), "TASK_EXECUTION"); assertThat(taskExecutionCount).isEqualTo(1); }); }
Example #2
Source File: AbstractSavedQueryIT.java From find with MIT License | 6 votes |
@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)); }
Example #3
Source File: PrimaryDataSourceTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @Sql("data.sql") public void dataSourceTest() { TransactionTestUtils.assertInTransaction(false); assertEquals("Number of rows in the 'user' table.", 1, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
Example #4
Source File: DataFixtures.java From dubai with MIT License | 5 votes |
public static void executeScript(DataSource dataSource, String... sqlResourcePaths) throws DataAccessException { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); for (String sqlResourcePath : sqlResourcePaths) { Resource resource = resourceLoader.getResource(sqlResourcePath); JdbcTestUtils.executeSqlScript(jdbcTemplate, new EncodedResource(resource, DEFAULT_ENCODING), true); } }
Example #5
Source File: RepositoryTransactionManagerConfigurationTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
private void testConfiguration(Class configurationClass) { ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class, configurationClass)) .withPropertyValues("application.name=transactionManagerTask"); applicationContextRunner.run((context) -> { DataSource dataSource = context.getBean("dataSource", DataSource.class); int taskExecutionCount = JdbcTestUtils .countRowsInTable(new JdbcTemplate(dataSource), "TASK_EXECUTION"); // Verify that the create call was rolled back assertThat(taskExecutionCount).isEqualTo(0); // Execute a new create call so that things close cleanly TaskRepository taskRepository = context.getBean("taskRepository", TaskRepository.class); TaskExecution taskExecution = taskRepository .createTaskExecution("transactionManagerTask"); taskExecution = taskRepository.startTaskExecution( taskExecution.getExecutionId(), taskExecution.getTaskName(), new Date(), new ArrayList<>(0), null); TaskLifecycleListener listener = context.getBean(TaskLifecycleListener.class); ReflectionTestUtils.setField(listener, "taskExecution", taskExecution); }); }
Example #6
Source File: PrimaryDataSourceTests.java From java-technology-stack with MIT License | 5 votes |
@Test @Sql("data.sql") public void dataSourceTest() { TransactionTestUtils.assertInTransaction(false); assertEquals("Number of rows in the 'user' table.", 1, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
Example #7
Source File: ProgrammaticTxMgmtTests.java From spring-analysis-note with MIT License | 4 votes |
protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
Example #8
Source File: TransactionalSqlScriptsTests.java From spring-analysis-note with MIT License | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #9
Source File: EventRepositoryTests.java From spring-events with Apache License 2.0 | 4 votes |
private int countNumEvents() { return JdbcTestUtils.countRowsInTable(jdbcTemplate, "event"); }
Example #10
Source File: TransactionalSqlScriptsTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #11
Source File: NonTransactionalSqlScriptsTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #12
Source File: DataSourceOnlySqlScriptsTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #13
Source File: PrimaryTransactionManagerTests.java From spring-analysis-note with MIT License | 4 votes |
private void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table", expected, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
Example #14
Source File: JpaTicketRegistryTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 4 votes |
@Before public void setUp() { JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "SERVICETICKET"); JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "TICKETGRANTINGTICKET"); }
Example #15
Source File: NestedTestsWithSqlScriptsAndJUnitJupiterTests.java From spring-analysis-note with MIT License | 4 votes |
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #16
Source File: TransactionalInlinedStatementsSqlScriptsTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #17
Source File: DataSourceOnlySqlScriptsTests.java From spring-analysis-note with MIT License | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #18
Source File: TransactionalInlinedStatementsSqlScriptsTests.java From spring-analysis-note with MIT License | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #19
Source File: ProgrammaticTxMgmtTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
Example #20
Source File: EmptyDatabaseIntegrationTest.java From embedded-database-spring-test with Apache License 2.0 | 4 votes |
@After public void tearDown() { JdbcTestUtils.dropTables(jdbcTemplate, "test.person"); }
Example #21
Source File: NonTransactionalSqlScriptsTests.java From spring-analysis-note with MIT License | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #22
Source File: JpaTicketRegistryTests.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
@Before public void setUp() { JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "SERVICETICKET"); JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "TICKETGRANTINGTICKET"); }
Example #23
Source File: TransactionalSqlScriptsTests.java From java-technology-stack with MIT License | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #24
Source File: NonTransactionalSqlScriptsTests.java From java-technology-stack with MIT License | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #25
Source File: DataSourceOnlySqlScriptsTests.java From java-technology-stack with MIT License | 4 votes |
protected void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table.", expected, JdbcTestUtils.countRowsInTable(jdbcTemplate, "user")); }
Example #26
Source File: TransactionalInlinedStatementsSqlScriptsTests.java From java-technology-stack with MIT License | 4 votes |
protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #27
Source File: PrimaryTransactionManagerTests.java From java-technology-stack with MIT License | 4 votes |
private void assertNumUsers(int expected) { assertEquals("Number of rows in the 'user' table", expected, JdbcTestUtils.countRowsInTable(this.jdbcTemplate, "user")); }
Example #28
Source File: ProgrammaticTxMgmtTests.java From java-technology-stack with MIT License | 4 votes |
protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
Example #29
Source File: NestedTestsWithSqlScriptsAndJUnitJupiterTests.java From java-technology-stack with MIT License | 4 votes |
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
Example #30
Source File: NestedTestsWithSqlScriptsAndJUnitJupiterTests.java From java-technology-stack with MIT License | 4 votes |
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }