Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c2ca85e5 authored by Cédric Eoche-Duval's avatar Cédric Eoche-Duval
Browse files

Merge branch 'feature/GTB-54' into 'develop'

GTB-54 | GITB Session Manager

See merge request !8
parents 53427e6a 6dae3000
No related branches found
No related tags found
1 merge request!8GTB-54 | GITB Session Manager
......@@ -19,35 +19,24 @@ variables:
P_NAME: "${projectName}"
P_APP_TYPE: "java"
P_CODE_SRC_PATH: "."
P_MAVEN_IMAGE_TAG: "3.6.3"
# Define jobs
code:
stage: build
extends:
- .codeForJava
variables:
P_MAVEN_IMAGE_TAG: "3.6.3"
- .buildCodeForJava
quality:
stage: tests
extends:
- .sonarqubeForJava
- .testQualityForJavaWithSonarqube
variables:
P_MAVEN_IMAGE_TAG: "3.6.3"
P_CODE_BINARIES: "target/classes/"
P_CODE_JACOCO_REPORT_PATH: "target/jacoco.exec"
P_CODE_JUNIT_REPORTS_PATH: "target/surefire-reports"
P_CODE_DYNAMIC_ANALYSIS: "reuseReports"
P_CODE_COVERAGE_PLUGIN: "jacoco"
P_CODE_SOURCE_ENCODING: "UTF-8"
P_CODE_LANGUAGE: "java"
P_CODE_DEVELOPER_EDITION: "true"
release/code:
stage: release
extends:
- .releaseCodeForJava
variables:
P_MAVEN_IMAGE_TAG: "3.6.3"
\ No newline at end of file
package net.ihe.gazelle.lib.gitbmessagingclient.adapter;
import com.gitb.ms.BasicRequest;
import com.gitb.ms.BeginTransactionRequest;
import com.gitb.ms.FinalizeRequest;
import com.gitb.ms.GetModuleDefinitionResponse;
import com.gitb.ms.InitiateRequest;
import com.gitb.ms.InitiateResponse;
import com.gitb.ms.MessagingService;
import com.gitb.ms.MessagingServiceService;
import com.gitb.ms.ReceiveRequest;
import com.gitb.ms.SendRequest;
import com.gitb.ms.SendResponse;
import com.gitb.ms.Void;
import com.gitb.ms.*;
import com.gitb.ps.ProcessingServiceService;
import javax.xml.namespace.QName;
import java.net.URL;
/**
......@@ -29,13 +21,16 @@ public class GITBClientMessagingImpl implements MessagingService {
/**
* Client constructor with associated server url
* @param endPoint the url of the server implementing the messaging service
*
* @param endPoint the url of the server implementing the processing service
* @param serviceName name of the ProcessingServiceService service
* @param portName name of the port of the ProcessingServiceService
*/
public GITBClientMessagingImpl(URL endPoint) {
MessagingServiceService serviceHandler = new MessagingServiceService(endPoint);
service = serviceHandler.getMessagingServicePort();
public GITBClientMessagingImpl(URL endPoint, String serviceName, String portName) {
ProcessingServiceService serviceHandler = new ProcessingServiceService(endPoint,
new QName("http://www.gitb.com/ms/v1/", serviceName));
service = serviceHandler.getPort(new QName("http://www.gitb.com/ms/v1/", portName), MessagingService.class);
}
/**
* {@inheritDoc}
*/
......
package net.ihe.gazelle.lib.gitbmessagingclient.adapter;
import com.gitb.ms.BasicRequest;
import com.gitb.ms.BeginTransactionRequest;
import com.gitb.ms.FinalizeRequest;
import com.gitb.ms.GetModuleDefinitionResponse;
import com.gitb.ms.InitiateRequest;
import com.gitb.ms.InitiateResponse;
import com.gitb.ms.ReceiveRequest;
import com.gitb.ms.SendRequest;
import com.gitb.ms.SendResponse;
import com.gitb.ms.Void;
import com.gitb.ms.*;
import com.github.tomakehurst.wiremock.WireMockServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
......@@ -19,10 +11,7 @@ import javax.ws.rs.core.MediaType;
import java.net.MalformedURLException;
import java.net.URL;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertNotNull;
......@@ -66,7 +55,8 @@ class GITBClientMessagingImplTest {
.willReturn(aResponse()
.withStatus(200).withHeader("Content-Type", MediaType.APPLICATION_XML)
.withBodyFile("gitb_tr.xsd")));
gitbClientMessaging = new GITBClientMessagingImpl(new URL("http://localhost:9999/"+ SERVICE_PATH + "?wsdl"));
gitbClientMessaging = new GITBClientMessagingImpl(new URL("http://localhost:9999/" + SERVICE_PATH + "?wsdl"),
"MessagingServiceService", "MessagingServicePort");
}
/**
......
<?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"
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>
<parent>
<artifactId>lib.gitb</artifactId>
<groupId>net.ihe.gazelle</groupId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>net.ihe.gazelle</groupId>
<artifactId>lib.gitb-messaging-service</artifactId>
<name>GITB Messaging Service</name>
<version>1.0.2-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>eu.europa.ec.itb</groupId>
<artifactId>gitb-types</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package net.ihe.gazelle.lib.gitbmessagingservice.application;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* Session Manager to create and store GITB Test Sessions in a thread-safe way.
*/
public class SessionManager {
static final String CALLBACK_URL = "CALLBACK_URL";
private Map<String, Map<String, Object>> sessions = new ConcurrentHashMap<>();
/**
* Creates a new Session and attributes it a new identifier. The created session in then stored.
*
* @param callbackURL URL of the Test Bed if callback is needed.
* @return the literal representation of the created Session identifier
*/
public String createSession(String callbackURL) {
String sessionId = UUID.randomUUID().toString();
Map<String, Object> sessionInfo = new HashMap<>();
if (callbackURL != null) {
sessionInfo.put(CALLBACK_URL, callbackURL);
}
sessions.put(sessionId, sessionInfo);
return sessionId;
}
/**
* Destroy a stored session, identified by its identifier, if exists.
*
* @param sessionId identifier of the Session to destroy
*/
public void destroySession(String sessionId) {
sessions.remove(sessionId);
}
/**
* Get an info stored in a GITB Test Session.
*
* @param sessionId identifier of the Session where the info is stored.
* @param infoKey key of the info to get.
* @return the Object corresponding to the requested key in the specified Session.
*/
public Object getSessionInfo(String sessionId, String infoKey) {
Object value = null;
if (sessions.containsKey(sessionId)) {
value = sessions.get(sessionId).get(infoKey);
}
return value;
}
/**
* Add a new info in a specific Session.
*
* @param sessionId identifier of the Session where to put the info.
* @param infoKey key of the information to store.
* @param infoValue value to link to the given key.
*/
public void setSessionInfo(String sessionId, String infoKey, Object infoValue) {
sessions.get(sessionId).put(infoKey, infoValue);
}
}
\ No newline at end of file
package net.ihe.gazelle.lib.gitbmessagingservice.application;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class SessionManagerTest {
@Test
public void testCreateSessionWithoutCallback() {
SessionManager sessionManager = new SessionManager();
String sessionId = sessionManager.createSession(null);
assertNull(sessionManager.getSessionInfo(sessionId, SessionManager.CALLBACK_URL));
}
@Test
public void testCreateSessionWithCallback() {
SessionManager sessionManager = new SessionManager();
String callbackURL = "MyCallbackURL";
String sessionId = sessionManager.createSession(callbackURL);
assertEquals(callbackURL, sessionManager.getSessionInfo(sessionId, SessionManager.CALLBACK_URL));
}
@Test
public void testSetSessionInfo() {
SessionManager sessionManager = new SessionManager();
String infoKey = "infoKey";
String infoValue = "infoValue";
String sessionId = sessionManager.createSession(null);
sessionManager.setSessionInfo(sessionId, infoKey, infoValue);
assertEquals(infoValue, sessionManager.getSessionInfo(sessionId, infoKey));
}
@Test
public void testDestroySession() {
SessionManager sessionManager = new SessionManager();
String infoKey = "infoKey";
String infoValue = "infoValue";
String sessionId = sessionManager.createSession(null);
sessionManager.setSessionInfo(sessionId, infoKey, infoValue);
sessionManager.destroySession(sessionId);
assertNull(sessionManager.getSessionInfo(sessionId, infoKey));
}
}
<?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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>net.ihe.gazelle</groupId>
......@@ -7,7 +8,6 @@
<version>1.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>GITB</name>
<url>http://gazelle.ihe.net</url>
<scm>
......@@ -27,10 +27,9 @@
<nexus.url>https://gazelle.ihe.net/nexus</nexus.url>
<nexus.path>/content/groups/public/</nexus.path>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<git.user.name>gitlab-ci</git.user.name>
<git.user.name>gitlab-ci</git.user.name>
<git.user.token>changeit</git.user.token>
<git.project.url>https://${git.user.name}:${git.user.token}@gitlab.inria.fr/gazelle/model-api/gitb.git</git.project.url>
</properties>
<repositories>
......@@ -88,6 +87,7 @@
</dependenciesToScan>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
......@@ -141,7 +141,6 @@
</execution>
</executions>
</plugin>
</plugins>
</build>
......@@ -207,11 +206,10 @@
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>eu.europa.ec.itb</groupId>
<artifactId>gitb-types</artifactId>
<version>1.8.0</version>
<groupId>eu.europa.ec.itb</groupId>
<artifactId>gitb-types</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
......@@ -219,21 +217,19 @@
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<!-- Test engine Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.25.1</version>
<scope>test</scope>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<!-- JAXWS Implementation for Tests -->
<dependency>
<groupId>org.apache.cxf</groupId>
......@@ -247,7 +243,6 @@
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<!-- Logger implementation for tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
......@@ -262,6 +257,7 @@
<module>gitb-processing-client</module>
<module>gitb-messaging-client</module>
<module>gitb-utils</module>
<module>gitb-messaging-service</module>
</modules>
</project>
\ No newline at end of file
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment