From 52e0a0120240d27d380b0ce24acec40c33167715 Mon Sep 17 00:00:00 2001 From: Mustapha Zorgati <15628173+mustaphazorgati@users.noreply.github.com> Date: Tue, 8 May 2018 12:59:24 +0200 Subject: [PATCH] TSK-448: removed spring-boot from taskana-rest-spring and taskana-rest --- lib/taskana-spring/pom.xml | 29 +++--- rest/taskana-rest-spring-example/pom.xml | 21 +++++ .../taskana/rest/ExampleRestApplication.java | 24 +++++ rest/taskana-rest-spring/pom.xml | 91 ++++++++++++------- .../pro/taskana/rest/RestConfiguration.java | 25 ----- .../pro/taskana/rest/TestConfiguration.java | 21 +++++ .../mapper/ClassificationMapperTest.java | 4 +- .../WorkbasketAccessItemMapperTest.java | 4 +- .../resource/mapper/WorkbasketMapperTest.java | 4 +- .../mapper/WorkbasketSummaryMapperTest.java | 4 +- 10 files changed, 145 insertions(+), 82 deletions(-) create mode 100644 rest/taskana-rest-spring/src/test/java/pro/taskana/rest/TestConfiguration.java diff --git a/lib/taskana-spring/pom.xml b/lib/taskana-spring/pom.xml index 0669fb0cf..53df7386d 100644 --- a/lib/taskana-spring/pom.xml +++ b/lib/taskana-spring/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 pro.taskana taskana-spring @@ -138,17 +138,12 @@ - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - 1.8 1.8 UTF-8 + 5.0.5.RELEASE + 2.0.1.RELEASE @@ -161,39 +156,45 @@ org.springframework spring-tx + ${spring.version} org.springframework.boot spring-boot-starter-web + ${spring-boot.version} test org.springframework spring-context + ${spring.version} test org.springframework spring-jdbc + ${spring.version} test org.springframework.boot spring-boot-starter-test + ${spring-boot.version} test com.h2database h2 + 1.4.197 test - - org.mybatis - mybatis-spring - 1.3.1 - + + org.mybatis + mybatis-spring + 1.3.1 + The helper module to integrate taskana into Spring projects. \ No newline at end of file diff --git a/rest/taskana-rest-spring-example/pom.xml b/rest/taskana-rest-spring-example/pom.xml index d5a4b9e23..5a97c9e33 100644 --- a/rest/taskana-rest-spring-example/pom.xml +++ b/rest/taskana-rest-spring-example/pom.xml @@ -31,6 +31,27 @@ taskana-rest-spring ${project.version} + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.plugin + spring-plugin-core + + + com.h2database + h2 + 1.4.197 + diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java index 78fbdd7e3..3069d59ca 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java @@ -6,10 +6,15 @@ import javax.sql.DataSource; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.PlatformTransactionManager; import pro.taskana.sampledata.SampleDataGenerator; @@ -25,6 +30,25 @@ public class ExampleRestApplication { SpringApplication.run(ExampleRestApplication.class, args); } + @Bean + @Primary + @ConfigurationProperties(prefix = "datasource") + public DataSourceProperties dataSourceProperties() { + DataSourceProperties props = new DataSourceProperties(); + props.setUrl("jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA"); + return props; + } + + @Bean + public DataSource dataSource(DataSourceProperties properties) { + return properties.initializeDataSourceBuilder().build(); + } + + @Bean + public PlatformTransactionManager txManager(DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + @Bean @DependsOn("taskanaEngineConfiguration") // generate sample data after schema was inserted public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException { diff --git a/rest/taskana-rest-spring/pom.xml b/rest/taskana-rest-spring/pom.xml index 856c595c9..508b5aef3 100644 --- a/rest/taskana-rest-spring/pom.xml +++ b/rest/taskana-rest-spring/pom.xml @@ -1,7 +1,6 @@ - + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 pro.taskana @@ -34,17 +33,13 @@ http://github.com/taskana/taskana/tree/master - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.RELEASE - - - UTF-8 UTF-8 + 1.8 + 1.8 1.8 + 5.0.5.RELEASE @@ -128,16 +123,40 @@ - org.springframework.boot - spring-boot-starter-web + org.springframework + spring-web + ${spring.version} - org.springframework.boot - spring-boot-starter-security + org.springframework + spring-beans + ${spring.version} - org.springframework.boot - spring-boot-starter-jdbc + org.springframework + spring-jdbc + ${spring.version} + + + org.springframework.hateoas + spring-hateoas + 0.24.0.RELEASE + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + javax.validation + validation-api + 2.0.1.Final + + + com.fasterxml.jackson.core + jackson-databind + 2.9.5 @@ -146,34 +165,35 @@ ${project.version} + - org.springframework.boot - spring-boot-starter-test + org.springframework + spring-test + 5.0.5.RELEASE test - - - com.h2database - h2 - - - - org.springframework.hateoas - spring-hateoas - org.springframework.plugin spring-plugin-core - - - - junit - junit + 1.2.0.RELEASE test - org.springframework - spring-test + junit + junit + 4.12 + test + + + org.slf4j + slf4j-simple + 1.6.1 + test + + + com.h2database + h2 + 1.4.197 test @@ -205,6 +225,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.5.1 true diff --git a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/RestConfiguration.java b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/RestConfiguration.java index 9c11372d4..593a06e74 100644 --- a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/RestConfiguration.java +++ b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/RestConfiguration.java @@ -5,18 +5,13 @@ import java.sql.SQLException; import javax.sql.DataSource; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Scope; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.SpringHandlerInstantiator; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; @@ -37,21 +32,6 @@ import pro.taskana.configuration.TaskanaEngineConfiguration; @EnableTransactionManagement public class RestConfiguration { - @Bean - @Primary - @ConfigurationProperties(prefix = "datasource") - public DataSourceProperties dataSourceProperties() { - DataSourceProperties props = new DataSourceProperties(); - props.setUrl("jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA"); - return props; - } - - @Bean - @Primary - public DataSource dataSource(DataSourceProperties properties) { - return properties.initializeDataSourceBuilder().build(); - } - @Bean public ClassificationService getClassificationService(TaskanaEngine taskanaEngine) { return taskanaEngine.getClassificationService(); @@ -98,9 +78,4 @@ public class RestConfiguration { public HandlerInstantiator handlerInstantiator(ApplicationContext context) { return new SpringHandlerInstantiator(context.getAutowireCapableBeanFactory()); } - - @Bean - public PlatformTransactionManager txManager(DataSource dataSource) { - return new DataSourceTransactionManager(dataSource); - } } diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/TestConfiguration.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/TestConfiguration.java new file mode 100644 index 000000000..c64880c3f --- /dev/null +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/TestConfiguration.java @@ -0,0 +1,21 @@ +package pro.taskana.rest; + +import javax.sql.DataSource; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; + +import pro.taskana.configuration.TaskanaEngineConfiguration; + +/** + * Configuration class for all rest tests. + */ +@Import(RestConfiguration.class) +public class TestConfiguration { + + @Bean + public DataSource dataSource() { + return TaskanaEngineConfiguration.createDefaultDataSource(); + } + +} diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/ClassificationMapperTest.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/ClassificationMapperTest.java index f2cdcaa62..9d5a91e50 100644 --- a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/ClassificationMapperTest.java +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/ClassificationMapperTest.java @@ -19,14 +19,14 @@ import pro.taskana.exceptions.DomainNotFoundException; import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.impl.ClassificationImpl; -import pro.taskana.rest.RestConfiguration; +import pro.taskana.rest.TestConfiguration; import pro.taskana.rest.resource.ClassificationResource; /** * Test for {@link ClassificationResourceAssembler}. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RestConfiguration.class}) +@ContextConfiguration(classes = {TestConfiguration.class}) @WebAppConfiguration public class ClassificationMapperTest { diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketAccessItemMapperTest.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketAccessItemMapperTest.java index cbe0245ad..f3eedb501 100644 --- a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketAccessItemMapperTest.java +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketAccessItemMapperTest.java @@ -12,14 +12,14 @@ import pro.taskana.WorkbasketAccessItem; import pro.taskana.WorkbasketService; import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.WorkbasketNotFoundException; -import pro.taskana.rest.RestConfiguration; +import pro.taskana.rest.TestConfiguration; import pro.taskana.rest.resource.WorkbasketAccessItemResource; /** * Test for {@link WorkbasketAccessItemMapper}. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RestConfiguration.class}) +@ContextConfiguration(classes = {TestConfiguration.class}) @WebAppConfiguration public class WorkbasketAccessItemMapperTest { diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketMapperTest.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketMapperTest.java index ccf24ea19..3603e4c06 100644 --- a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketMapperTest.java +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketMapperTest.java @@ -16,14 +16,14 @@ import pro.taskana.WorkbasketType; import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.impl.WorkbasketImpl; -import pro.taskana.rest.RestConfiguration; +import pro.taskana.rest.TestConfiguration; import pro.taskana.rest.resource.WorkbasketResource; /** * Test for {@link WorkbasketMapper}. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RestConfiguration.class}) +@ContextConfiguration(classes = {TestConfiguration.class}) @WebAppConfiguration public class WorkbasketMapperTest { diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketSummaryMapperTest.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketSummaryMapperTest.java index 2c0e70eda..3881f28dc 100644 --- a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketSummaryMapperTest.java +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/mapper/WorkbasketSummaryMapperTest.java @@ -13,14 +13,14 @@ import pro.taskana.WorkbasketType; import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.impl.WorkbasketSummaryImpl; -import pro.taskana.rest.RestConfiguration; +import pro.taskana.rest.TestConfiguration; import pro.taskana.rest.resource.WorkbasketSummaryResource; /** * Test for {@link WorkbasketSummaryMapper}. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RestConfiguration.class}) +@ContextConfiguration(classes = {TestConfiguration.class}) @WebAppConfiguration public class WorkbasketSummaryMapperTest {