-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from project-husky/develop
Update master as preparation for release
- Loading branch information
Showing
24 changed files
with
3,479 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
<!-- | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -211,6 +229,7 @@ | |
<artifactId>camel-cxf</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
|
32 changes: 32 additions & 0 deletions
32
src/test/java/org/projecthusky/communication/TestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... | ||
|
||
}); | ||
} | ||
|
||
} | ||
|
67 changes: 67 additions & 0 deletions
67
src/test/java/org/projecthusky/communication/config/InitializerTestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
78 changes: 78 additions & 0 deletions
78
src/test/java/org/projecthusky/communication/config/ServerTestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
Oops, something went wrong.