From cc247c1263df74890e7bc41a64c4800ffaeb8ed5 Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Thu, 2 Jun 2022 17:32:04 -0400 Subject: [PATCH] Removing DB2 based tests and dependencies --- spring-cloud-task-integration-tests/pom.xml | 7 - .../db2/Db2PagingQueryProviderTest.java | 178 ------------------ 2 files changed, 185 deletions(-) delete mode 100644 spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/database/support/db2/Db2PagingQueryProviderTest.java diff --git a/spring-cloud-task-integration-tests/pom.xml b/spring-cloud-task-integration-tests/pom.xml index b181c64e..b5f4e6ac 100644 --- a/spring-cloud-task-integration-tests/pom.xml +++ b/spring-cloud-task-integration-tests/pom.xml @@ -17,7 +17,6 @@ 1.17.2 1.17.2 1.0.8 - 11.5.7.0 @@ -128,12 +127,6 @@ ${test.containers.version} test - - com.ibm.db2 - jcc - ${db2-jdbc.version} - test - org.rnorth.duct-tape duct-tape diff --git a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/database/support/db2/Db2PagingQueryProviderTest.java b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/database/support/db2/Db2PagingQueryProviderTest.java deleted file mode 100644 index 738f063d..00000000 --- a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/database/support/db2/Db2PagingQueryProviderTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.task.database.support.db2; - - -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Db2Container; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.cloud.task.executionid.TaskStartApplication; -import org.springframework.cloud.task.repository.TaskExecution; -import org.springframework.cloud.task.repository.dao.TaskExecutionDao; -import org.springframework.cloud.task.repository.database.support.Db2PagingQueryProvider; -import org.springframework.cloud.task.repository.support.SimpleTaskExplorer; -import org.springframework.cloud.task.repository.support.TaskExecutionDaoFactoryBean; -import org.springframework.context.annotation.Bean; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.jdbc.SqlConfig; - - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.context.jdbc.SqlConfig.ErrorMode.CONTINUE_ON_ERROR; - -/** - * @author Tyler Carpenter-Rivers - * @author Ryan DCruz - * @see Db2PagingQueryProvider - */ -@SpringBootTest( - classes = {TaskStartApplication.class, Db2PagingQueryProviderTest.TestConfig.class}, - properties = "spring.cloud.task.events.enabled=false" -) -@Testcontainers(disabledWithoutDocker = true) -@DirtiesContext -@Sql( - scripts = "classpath:/org/springframework/cloud/task/schema-db2.sql", - config = @SqlConfig(errorMode = CONTINUE_ON_ERROR) -) -@Sql(statements = { - " DELETE FROM TASK_EXECUTION_PARAMS ", - " DELETE FROM TASK_TASK_BATCH ", - " DELETE FROM TASK_EXECUTION " -}) -class Db2PagingQueryProviderTest { - - @Container - public static Db2Container db2Container = - new Db2Container(DockerImageName.parse("ibmcom/db2:11.5.7.0")) - .acceptLicense() - .withDatabaseName("test") - .withStartupTimeoutSeconds(30) - .withExposedPorts(50000); - - @DynamicPropertySource - static void properties(DynamicPropertyRegistry registry) { - registry.add("spring.datasource.url", db2Container::getJdbcUrl); - registry.add("spring.datasource.username", db2Container::getUsername); - registry.add("spring.datasource.password", db2Container::getPassword); - } - - @Autowired - private SimpleTaskExplorer simpleTaskExplorer; - - @Autowired - private TaskExecutionDao taskExecutionDao; - - @DisplayName("Scenario: The page request size is less than the total number of elements" + - "Given the total number of elements is 3" + - "And the page request size is 2" + - "When the query is executed" + - "Then the returned page has 2 elements") - @Test - void pageRequest() { - // setup test data - taskExecutionDao.createTaskExecution( - UUID.randomUUID().toString(), new Date(), List.of(), UUID.randomUUID().toString()); - taskExecutionDao.createTaskExecution( - UUID.randomUUID().toString(), new Date(), List.of(), UUID.randomUUID().toString()); - taskExecutionDao.createTaskExecution( - UUID.randomUUID().toString(), new Date(), List.of(), UUID.randomUUID().toString()); - - PageRequest pageRequest = PageRequest.of(0, 2); - - // run subject under test - Page page = simpleTaskExplorer.findAll(pageRequest); - - // assert and verify - assertThat(page.getTotalElements()) - .as("Expected the total number of records in the table to be 3") - .isEqualTo(3); - - assertThat(pageRequest.getPageSize()) - .as("Expected the size of the returned page to be 2") - .isEqualTo(2); - } - - @DisplayName("Scenario: the page request size is larger than the total number of elements" + - "Given the total number of elements is 1" + - "And the page request size is 2" + - "When the query is executed" + - "Then the returned page has 1 element") - @Test - void pageRequestSinglePageEntries() { - // setup test data - taskExecutionDao.createTaskExecution( - UUID.randomUUID().toString(), new Date(), List.of(), UUID.randomUUID().toString()); - - PageRequest pageRequest = PageRequest.of(0, 2); - - // run subject under test - Page page = simpleTaskExplorer.findAll(pageRequest); - - // assert and verify - assertThat(page.getTotalElements()) - .as("Should only have one record in the table") - .isEqualTo(1); - - assertThat(page.getNumberOfElements()) - .as("Should have one record in the returned page") - .isEqualTo(1); - - assertThat(page.getTotalPages()) - .as("Should expect the total number of pages to be 1") - .isEqualTo(1); - } - - @TestConfiguration - public static class TestConfig { - @Bean - @ConfigurationProperties("spring.datasource") - public DataSource dataSource() { - return new DriverManagerDataSource(); - } - - @Bean - public TaskExecutionDaoFactoryBean taskExecutionDaoFactoryBean(DataSource dataSource) { - return new TaskExecutionDaoFactoryBean(dataSource); - } - - @Bean - public TaskExecutionDao taskExecutionDao(TaskExecutionDaoFactoryBean taskExecutionDaoFactoryBean) throws Exception { - return taskExecutionDaoFactoryBean.getObject(); - } - } -}