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

Update master as preparation for release #14

Merged
merged 7 commits into from
Feb 8, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/java_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Java CI with Maven and CodeQL

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
build:
Expand Down
31 changes: 25 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.husky.test.integration</groupId>
<artifactId>husky-integration-tests</artifactId>
Expand All @@ -11,10 +13,12 @@
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<husky.version>2.2.0</husky.version>
<spring.boot.version>2.7.13</spring.boot.version>
<husky.version>2.2.1-SNAPSHOT</husky.version>
<spring.version>5.3.31</spring.version>
<spring.boot.version>2.7.18</spring.boot.version>
<camel.version>3.21.0</camel.version>
<junit.version>5.10.1</junit.version>
<ipf.version>4.7.0</ipf.version>
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
</properties>
<repositories>
Expand All @@ -39,9 +43,12 @@

</repositories>
<scm>
<connection>scm:git:https://github.com/project-husky/husky-integration-tests.git</connection>
<developerConnection>scm:git:[email protected]:project-husky/husky-integration-tests.git</developerConnection>
<url>https://github.com/project-husky/husky-integration-tests/tree/master</url>
<connection>
scm:git:https://github.com/project-husky/husky-integration-tests.git</connection>
<developerConnection>
scm:git:[email protected]:project-husky/husky-integration-tests.git</developerConnection>
<url>
https://github.com/project-husky/husky-integration-tests/tree/master</url>
<tag>HEAD</tag>
</scm>
<!--
Expand Down Expand Up @@ -81,6 +88,13 @@
<artifactId>husky-xua-gen-impl</artifactId>
<version>${husky.version}</version>
</dependency>

<dependency>
<groupId>org.projecthusky.communication</groupId>
<artifactId>husky-service</artifactId>
<version>${husky.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
Expand Down Expand Up @@ -179,6 +193,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projecthusky.communication</groupId>
<artifactId>husky-service</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down Expand Up @@ -211,6 +229,7 @@
<artifactId>camel-cxf</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/org/projecthusky/communication/TestApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.projecthusky.communication;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationListener;

@SpringBootApplication
public class TestApplication extends SpringBootServletInitializer {

public static void main(final String[] args) {
final SpringApplication application = new SpringApplication(TestApplication.class);
addApplicationStartupHook(application);
var context = application.run(args);
context.close();
}

/**
* Adds a hook to the Application Ready event to run some magic.
*
* @param application The IPF {@link SpringApplication} instance.
*/
public static void addApplicationStartupHook(final SpringApplication application) {
application.addListeners((ApplicationListener<ApplicationReadyEvent>) event -> {
// Do some configuration magic...

});
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.projecthusky.communication.config;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.projecthusky.xua.exceptions.SerializeException;
import org.projecthusky.xua.serialization.OpenSaml2Serializer;
import org.projecthusky.xua.serialization.impl.OpenSaml2SerializerImpl;
import org.junit.jupiter.api.BeforeAll;
import org.opensaml.core.config.InitializationService;
import org.opensaml.core.xml.XMLObject;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public abstract class InitializerTestHelper {
@BeforeAll
public static void setUpBeforeClass() throws Exception {
// Initialize the library
InitializationService.initialize();
}

public Element loadXmlDokument(String aPath)
throws SAXException, IOException, ParserConfigurationException {
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
final Document doc = dbf.newDocumentBuilder()
.parse(this.getClass().getResourceAsStream(aPath));
return doc.getDocumentElement();
}

public void logXmlObject(Element element) {
try {
final Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty(OutputKeys.INDENT, "no");
tr.setOutputProperty(OutputKeys.METHOD, "xml");
tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(4));

final ByteArrayOutputStream bas = new ByteArrayOutputStream();
tr.transform(new DOMSource(element), new StreamResult(bas));
LoggerFactory.getLogger(getClass()).info("\n" + bas.toString());
} catch (final TransformerException e) {
LoggerFactory.getLogger(getClass()).error("Error", e);
}
}

public void logXmlObject(XMLObject aXmlObject) {
try {
final OpenSaml2Serializer openSamlSerializer = new OpenSaml2SerializerImpl();
final String xmlString = openSamlSerializer.serializeToString(aXmlObject);
LoggerFactory.getLogger(getClass()).info("\n" + xmlString);
} catch (final SerializeException e) {
LoggerFactory.getLogger(getClass()).error("Error", e);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.projecthusky.communication.config;

import java.io.IOException;

import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.config.SocketConfig;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.bootstrap.HttpServer;
import org.apache.http.impl.bootstrap.ServerBootstrap;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* <!-- @formatter:off -->
* <div class="en">Helping class for client testing with simulated server</div>
* <div class="de"></div>
* <div class="fr"></div>
* <div class="it"></div>
* <!-- @formatter:on -->
*/
public abstract class ServerTestHelper extends InitializerTestHelper {

private static Logger logger = LoggerFactory.getLogger(ServerTestHelper.class);

private static HttpServer server;

private static int httpPort;

private static ServerBootstrap bootstrap;

protected static int getHttpPort() {
return httpPort;
}

protected static HttpServer getServer() {
return server;
}

public static HttpRequestHandler registerHandler() {
return null;
}

@BeforeAll
public static void setUpBefore() throws IOException {
final SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(15000)
.setTcpNoDelay(true).build();

bootstrap = ServerBootstrap.bootstrap();
server = bootstrap.setServerInfo("Test/1.1").setSocketConfig(socketConfig)
.registerHandler("*", new HttpRequestHandler() {

@Override
public void handle(HttpRequest request, HttpResponse response,
HttpContext context) throws HttpException, IOException {
logger.debug("The request %s", request.getRequestLine());
response.setStatusCode(500);
response.setEntity(new StringEntity("Hello this is a testserver"));
}

}).create();

server.start();
httpPort = server.getLocalPort();

}

@AfterAll
public static void tearDownAfter() {
server.stop();
}

}
Loading
Loading