Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests #338

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/On-PR-assigned_intermediate-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI | On-PR-assigned_intermediate-dispatch

on:
pull_request:
types: [assigned]

jobs:
build:

runs-on: ubuntu-16.04

steps:
- uses: actions/checkout@v2
- name: Informations
run: |
echo "github.event.pull_request: ${{ toJson(github.event.pull_request) }}"
- name: Intermediate dispatch
working-directory: ./phis2-ws
run: |
echo "curl Intermediate dispatch"
curl http://proxmox15.asa-showroom.com/intermediate-dispatcher.php\?sha=${{ github.event.pull_request.head.sha }}\&ref\=${{ github.event.pull_request.head.ref }}\&repo__clone_url\=${{ github.event.pull_request.head.repo.clone_url }}
20 changes: 20 additions & 0 deletions .github/workflows/On-Push_dispatch-to-opensilex-phis-docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI | OnPush_dispatch-to-opensilex-phis-docker-ci

on: [push]

jobs:
dispatch-to-opensilex-phis-docker-ci:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Informations
run: |
echo "Github-repository: '${{ github.repositoryUrl }}' "
echo " Repository: $GITHUB_REPOSITORY "
echo " GITHUB_SHA: '"$GITHUB_SHA"' "
echo " GITHUB_REF: '"$GITHUB_REF"' "
- name: curl (dispatch-to-opensilex-phis-docker-ci)
run: |
curl -XPOST -u "${{ secrets.TRIGGER_USERNAME}}:${{secrets.TRIGGER_TOKEN}}" -H "Accept:application/vnd.github.everest-preview+json" -H "Content-Type:application/json" https://api.github.com/repos/"${{ secrets.TRIGGER_USERNAME}}"/"${{ secrets.TRIGGER_REPO_NAME}}"/dispatches --data '{"event_type":"build_application", "client_payload":{"repo__clone_url":"'"${{ github.repositoryUrl }}"'", "sha":"'"$GITHUB_SHA"'", "ref":"'"$GITHUB_REF"'" }}'
68 changes: 66 additions & 2 deletions phis2-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<logback-version>1.2.3</logback-version>

<jersey.version>2.28</jersey.version>
<junit.version>4.12</junit.version>
</properties>

<repositories>
<!--REPO CRYPTAGE-->
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/libs-milestone/</url>
<url>https://repo.spring.io/libs-milestone/</url>
</repository>
</repositories>

Expand Down Expand Up @@ -106,10 +109,32 @@
<version>2.7.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>2.28</version>
<scope>test</scope>
</dependency>-->
<!-- <dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-external</artifactId>
<version>2.28</version>
</dependency>-->
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>2.28</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -324,7 +349,30 @@
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>before-integration-test-execution</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</destFile>
<propertyName>failsafe.jacoco.args</propertyName>
</configuration>
</execution>

<execution>
<id>after-integration-test-execution</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-integration-test-coverage-report</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -407,6 +455,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>${failsafe.jacoco.args}</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,23 @@ public TokenResponseStructure(String id, String userDisplayName, String expires_
this.expires_in = expires_in;
}
}

public Metadata getMetadata() {
return metadata;
}

public String getUserDisplayName() {
return userDisplayName;
}

public String getAccess_token() {
return access_token;
}

public String getExpires_in() {
return expires_in;
}



}
3 changes: 3 additions & 0 deletions phis2-ws/src/main/java/opensilex/service/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class User {
private String available;

private ArrayList<Group> groups = new ArrayList<>();

public User() {
}

public User(String email, String password) {
this.email = email;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package opensilex.service.itests;

import javax.inject.Singleton;
import javax.ws.rs.core.Application;
import opensilex.service.authentication.Session;
import opensilex.service.injection.SessionFactory;
import opensilex.service.injection.SessionInject;
import opensilex.service.injection.SessionInjectResolver;
import opensilex.service.json.CustomJsonWriterReader;
import opensilex.service.resource.ResourceService;
import org.glassfish.hk2.api.InjectionResolver;
import org.glassfish.hk2.api.TypeLiteral;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.test.DeploymentContext;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.ServletDeploymentContext;
import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerFactory;

/**
*
* @author training
*/
public class InternalProviderIntegrationTestHelper extends JerseyTest {

@Override
public Application configure() {

// enable(TestProperties.LOG_TRAFFIC);
// enable(TestProperties.DUMP_ENTITY);
ResourceConfig resConf = new ResourceConfig(ResourceService.class);

resConf.register(MultiPartFeature.class);
resConf.register(JacksonFeature.class);
resConf.register(CustomJsonWriterReader.class);
resConf.register(SessionFactory.class);

resConf.packages("io.swagger.jaxrs.listing;"
+ "opensilex.service.resource;"
+ "opensilex.service.json;"
+ "opensilex.service.resource.request.filter"
);

return resConf;

}

@Override
public TestContainerFactory getTestContainerFactory() {
return new GrizzlyWebTestContainerFactory();
}

@Override
protected DeploymentContext configureDeployment() {
ResourceConfig config = (ResourceConfig) configure();
config.register(new AbstractBinder() {
@Override
protected void configure() {
bindFactory(SessionFactory.class).to(Session.class);
bind(SessionInjectResolver.class)
.to(new TypeLiteral<InjectionResolver<SessionInject>>() {
})
.in(Singleton.class);
}
});
return ServletDeploymentContext.forServlet(
new ServletContainer(config)).build();
}

@Override
protected void configureClient(ClientConfig config) {
super.configureClient(config); //To change body of generated methods, choose Tools | Templates.
config.register(CustomJsonWriterReader.class);
config.register(MultiPartFeature.class);

}

protected void preTestCaseTrace(String testcaseName) {
System.out.println("\n"
+ "|||⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻"
+ ">>>>>>>>>>>>>>>>>>>>>>>>>> \nSTART TEST: " + testcaseName + "\n");
}

protected void postTestCaseTrace(String testcaseName) {
System.out.println("\n" + "END TEST: " + testcaseName + "\n"
+ "______________________________________________________"
+ "_______________________|||"
+ "\n");
}

}
Loading