task/780 Add integration test with Jboss and postgres
This commit is contained in:
parent
d38626f775
commit
acae3e633b
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -10,10 +9,15 @@
|
|||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<version>1.0.8-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>taskana-rest-spring-wildfly-example</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<version.wildfly.swarm>2017.4.0</version.wildfly.swarm>
|
||||
<version.resteasy>3.1.2.Final</version.resteasy>
|
||||
<skipIntegrationTests>true</skipIntegrationTests>
|
||||
<!-- Default H2 DB configuration -->
|
||||
<connection-url>jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0</connection-url>
|
||||
<driver-class>org.h2.Driver</driver-class>
|
||||
|
@ -21,6 +25,30 @@
|
|||
<user-name>sa</user-name>
|
||||
<password>sa</password>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.swarm</groupId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>${version.wildfly.swarm}</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian</groupId>
|
||||
<artifactId>arquillian-bom</artifactId>
|
||||
<version>1.1.10.Final</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -59,6 +87,53 @@
|
|||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.swarm</groupId>
|
||||
<artifactId>jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.swarm</groupId>
|
||||
<artifactId>cdi</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<version>${version.resteasy}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Brought in via WildFly Swarm `bom` -->
|
||||
<dependency>
|
||||
<groupId>org.wildfly.swarm</groupId>
|
||||
<artifactId>arquillian</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Brought in via Arquillian BOM, see dependencyManagement section above -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.junit</groupId>
|
||||
<artifactId>arquillian-junit-container</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.shrinkwrap.resolver</groupId>
|
||||
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>5.1.5.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
@ -77,6 +152,7 @@
|
|||
<user-name>postgres</user-name>
|
||||
<password>postgres</password>
|
||||
<activatedProperties>postgres</activatedProperties>
|
||||
<skipIntegrationTests>false</skipIntegrationTests>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
@ -171,6 +247,32 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-test</id>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>integration-tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${skipIntegrationTests}</skip>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -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<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange(
|
||||
"http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request,
|
||||
new ParameterizedTypeReference<TaskanaUserInfoResource>() {
|
||||
});
|
||||
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.<HttpMessageConverter<?>>singletonList(converter));
|
||||
return template;
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue