From e27cc0e96c2512849cb8f67f794fe32c4831b48a Mon Sep 17 00:00:00 2001 From: Miguel Martin Rojas Date: Wed, 27 Feb 2019 16:29:25 +0100 Subject: [PATCH] task/780 Add integration test with Jboss and postgres --- .../src/main/resources/pss_jaas.config | 0 .../src/main/resources/pss_jaas.config | 0 .../pom.xml | 110 +++++++++++++++++- .../java/pro/taskana/TaskanaWildflyTest.java | 80 +++++++++++++ .../src/test/resources/application.properties | 35 ++++++ .../src/test/resources/project-defaults.yml | 19 +++ .../src/test/resources/taskana.properties | 15 +++ 7 files changed, 255 insertions(+), 4 deletions(-) rename rest/{taskana-rest-spring-example => taskana-rest-spring-base}/src/main/resources/pss_jaas.config (100%) rename rest/{taskana-rest-spring-wildfly-example => taskana-rest-spring-setup}/src/main/resources/pss_jaas.config (100%) create mode 100644 rest/taskana-rest-spring-wildfly-example/src/test/java/pro/taskana/TaskanaWildflyTest.java create mode 100644 rest/taskana-rest-spring-wildfly-example/src/test/resources/application.properties create mode 100644 rest/taskana-rest-spring-wildfly-example/src/test/resources/project-defaults.yml create mode 100644 rest/taskana-rest-spring-wildfly-example/src/test/resources/taskana.properties diff --git a/rest/taskana-rest-spring-example/src/main/resources/pss_jaas.config b/rest/taskana-rest-spring-base/src/main/resources/pss_jaas.config similarity index 100% rename from rest/taskana-rest-spring-example/src/main/resources/pss_jaas.config rename to rest/taskana-rest-spring-base/src/main/resources/pss_jaas.config diff --git a/rest/taskana-rest-spring-wildfly-example/src/main/resources/pss_jaas.config b/rest/taskana-rest-spring-setup/src/main/resources/pss_jaas.config similarity index 100% rename from rest/taskana-rest-spring-wildfly-example/src/main/resources/pss_jaas.config rename to rest/taskana-rest-spring-setup/src/main/resources/pss_jaas.config diff --git a/rest/taskana-rest-spring-wildfly-example/pom.xml b/rest/taskana-rest-spring-wildfly-example/pom.xml index 88168d496..a11c49531 100644 --- a/rest/taskana-rest-spring-wildfly-example/pom.xml +++ b/rest/taskana-rest-spring-wildfly-example/pom.xml @@ -1,7 +1,6 @@ - - + 4.0.0 pro.taskana org.springframework.boot @@ -10,10 +9,15 @@ 1.0.8-SNAPSHOT - 4.0.0 taskana-rest-spring-wildfly-example war + 1.8 + 1.8 + UTF-8 + 2017.4.0 + 3.1.2.Final + true jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0 org.h2.Driver @@ -21,6 +25,30 @@ sa sa + + + + org.wildfly.swarm + bom + ${version.wildfly.swarm} + import + pom + + + org.jboss.arquillian + arquillian-bom + 1.1.10.Final + pom + import + + + + + + jboss + http://repository.jboss.org/nexus/content/groups/public-jboss/ + + org.springframework.boot @@ -59,6 +87,53 @@ postgresql 42.2.5 + + + + junit + junit + 4.12 + test + + + org.wildfly.swarm + jaxrs + test + + + org.wildfly.swarm + cdi + test + + + org.jboss.resteasy + resteasy-client + ${version.resteasy} + test + + + + org.wildfly.swarm + arquillian + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + org.springframework + spring-test + 5.1.5.RELEASE + test + @@ -77,6 +152,7 @@ postgres postgres postgres + false @@ -171,6 +247,32 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + default-test + + true + + + + integration-tests + test + + test + + + ${skipIntegrationTests} + + **/*Test.java + + + + + \ No newline at end of file diff --git a/rest/taskana-rest-spring-wildfly-example/src/test/java/pro/taskana/TaskanaWildflyTest.java b/rest/taskana-rest-spring-wildfly-example/src/test/java/pro/taskana/TaskanaWildflyTest.java new file mode 100644 index 000000000..d045b54a1 --- /dev/null +++ b/rest/taskana-rest-spring-wildfly-example/src/test/java/pro/taskana/TaskanaWildflyTest.java @@ -0,0 +1,80 @@ +package pro.taskana; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.util.Collections; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.resolver.api.maven.Maven; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +import pro.taskana.rest.resource.TaskanaUserInfoResource; + +// This test class is configured to run with postgres DB if you want to run it with h2 it is needed +// to change data source configuration at project-defaults.yml +@RunWith(Arquillian.class) +public class TaskanaWildflyTest { + + @Deployment(testable = false) + public static Archive createTestArchive() { + + File[] files = Maven.resolver() + .loadPomFromFile("pom.xml") + .importRuntimeDependencies() + .resolve().withTransitivity() + .asFile(); + + return ShrinkWrap.create(WebArchive.class, "taskana.war") + .addPackages(true, "pro.taskana") + .addAsResource("taskana.properties") + .addAsResource("application.properties") + .addAsResource("project-defaults.yml") + .addAsLibraries(files); + } + + @Test + @RunAsClient + public void shouldGetStatusOK() { + + HttpHeaders headers = new HttpHeaders(); + HttpEntity request = new HttpEntity(headers); + ResponseEntity response = getRestTemplate().exchange( + "http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request, + new ParameterizedTypeReference() { + }); + assertEquals(HttpStatus.OK, response.getStatusCode()); + + } + + private RestTemplate getRestTemplate() { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json")); + converter.setObjectMapper(mapper); + + RestTemplate template = new RestTemplate(Collections.>singletonList(converter)); + return template; + } +} diff --git a/rest/taskana-rest-spring-wildfly-example/src/test/resources/application.properties b/rest/taskana-rest-spring-wildfly-example/src/test/resources/application.properties new file mode 100644 index 000000000..2aa28f90c --- /dev/null +++ b/rest/taskana-rest-spring-wildfly-example/src/test/resources/application.properties @@ -0,0 +1,35 @@ +logging.level.pro.taskana=INFO +### logging.level.org.springframework=DEBUG +######## Taskana DB ####### +datasource.jndi=java:jboss/datasources/TestDS +taskana.schemaName=taskana + +devMode=true +####### control LDAP usage +taskana.ldap.useLdap=false +####### properties to connect to LDAP +taskana.ldap.serverUrl=ldap://localhost:10389 +taskana.ldap.bindDn=uid=admin,ou=system +taskana.ldap.bindPassword=secret +taskana.ldap.baseDn=o=TaskanaTest +####### properties that control search for users and groups +taskana.ldap.userSearchBase=ou=people +taskana.ldap.userSearchFilterName=objectclass +taskana.ldap.userSearchFilterValue=person +taskana.ldap.userFirstnameAttribute=givenName +taskana.ldap.userLastnameAttribute=sn +taskana.ldap.userIdAttribute=uid +taskana.ldap.groupSearchBase=ou=groups +taskana.ldap.groupSearchFilterName=objectclass +taskana.ldap.groupSearchFilterValue=groupOfUniqueNames +taskana.ldap.groupNameAttribute=cn +taskana.ldap.minSearchForLength=3 +taskana.ldap.maxNumberOfReturnedAccessIds=50 +taskana.ldap.groupsOfUser=memberUid +####### JobScheduler cron expression that specifies when the JobSchedler runs +taskana.jobscheduler.async.cron=0 * * * * * +####### cache static resources propertiesgit add -- +spring.resources.cache.cachecontrol.cache-private=true +####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy +server.tomcat.internal-proxies=.* +server.use-forward-headers=true diff --git a/rest/taskana-rest-spring-wildfly-example/src/test/resources/project-defaults.yml b/rest/taskana-rest-spring-wildfly-example/src/test/resources/project-defaults.yml new file mode 100644 index 000000000..d5987e6a7 --- /dev/null +++ b/rest/taskana-rest-spring-wildfly-example/src/test/resources/project-defaults.yml @@ -0,0 +1,19 @@ +swarm: + port: + offset: 10 + datasources: + data-sources: + TestDS: + driver-name: postgresql + connection-url: jdbc:postgresql://localhost:50102/postgres + user-name: postgres + password: postgres + jdbc-drivers: + mypostgres: + driver-class-name: postgresql + xa-datasource-name: org.postgresql.xa.PGXADataSource + driver-module-name: org.postgresql + myh2: + driver-class-name: org.h2.Driver + xa-datasource-name: org.h2.jdbcx.JdbcDataSource + driver-module-name: com.h2database.h2 diff --git a/rest/taskana-rest-spring-wildfly-example/src/test/resources/taskana.properties b/rest/taskana-rest-spring-wildfly-example/src/test/resources/taskana.properties new file mode 100644 index 000000000..abcffeb30 --- /dev/null +++ b/rest/taskana-rest-spring-wildfly-example/src/test/resources/taskana.properties @@ -0,0 +1,15 @@ +taskana.roles.user = group1 | group2|teamlead_1 |teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone +taskana.roles.Admin=name=konrad,Organisation=novatec|admin +taskana.roles.businessadmin=max|Moritz|businessadmin +taskana.roles.monitor=john|teamlead_2 | monitor +taskana.domains=DOMAIN_A,DOMAIN_B,DOMAIN_C +taskana.classification.types=TASK,DOCUMENT +taskana.classification.categories.task= EXTERNAL, manual, autoMAtic, Process +taskana.classification.categories.document= EXTERNAL + +taskana.jobs.maxRetries=3 +taskana.jobs.batchSize=50 +taskana.jobs.cleanup.runEvery=P1D +taskana.jobs.cleanup.firstRunAt=2018-07-25T08:00:00Z +taskana.jobs.cleanup.minimumAge=P14D +