Skip to content
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
29 changes: 29 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
baseBranchPatterns: ["develop"],
labels: ["dependencies"],
// Max 10 PRs in total, 10 per hour
prConcurrentLimit: 10,
prHourlyLimit: 10,
customManagers: [
{
// See renovate docs https://docs.renovatebot.com/modules/manager/regex/
customType: 'regex',
managerFilePatterns: [
'**/container.properties'
],
matchStrings: [
"(?:# renovate: versioning=(?<versioning>\\S+)\\n)?[\\w-]+\\.image=(?<registryUrl>[^/]+)/(?<depName>[^:]+):(?<currentValue>.+)"
],
registryUrlTemplate: "https://{{{registryUrl}}}",
datasourceTemplate: 'docker',
versioningTemplate: '{{#if versioning}}{{{versioning}}}{{else}}docker{{/if}}'
}
],
// Dependabot handles everything else,
// force renovate to only look for images used by test containers and the Maven wrapper
enabledManagers: [
'maven-wrapper',
'custom.regex'
],
}
20 changes: 0 additions & 20 deletions Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>5.1.5.Final</version>
<configuration>
<id>${jbossServerId}</id>
<hostname>${jbossHostname}</hostname>
</configuration>
</plugin>
<plugin>
<groupId>io.ultreia.java4all.jgitflow</groupId>
<artifactId>jgitflow-maven-plugin</artifactId>
Expand Down
32 changes: 31 additions & 1 deletion scim-server-examples/scim-server-memory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,47 @@
<groupId>org.apache.directory.scimple</groupId>
<artifactId>scim-server</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>2.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.21.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>package wildfly:run</defaultGoal>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>5.1.5.Final</version>
<configuration>
<filename>${project.artifactId}-${project.version}.war</filename>
<filename>${project.artifactId}.war</filename>
<add-user>
<users>
<user>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.directory.scim.example.memory;

import org.apache.directory.scim.example.memory.containers.GlassfishContainer;
import org.apache.directory.scim.example.memory.containers.OpenLibertyContainer;
import org.apache.directory.scim.example.memory.containers.PayaraContainer;
import org.apache.directory.scim.example.memory.containers.WebAppContainer;
import org.apache.directory.scim.example.memory.containers.WildflyContainer;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Named;
import org.junit.jupiter.api.extension.TestInstantiationException;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.junit.jupiter.Testcontainers;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import java.util.stream.Stream;

import static io.restassured.RestAssured.given;

@Testcontainers
public class ContainerIT {

static Stream<Arguments> containers() {

// this project's war file to test
Path warFile = Paths.get("target/scim-server-memory.war");

Map<String, Function<ContainerConfiguration, WebAppContainer<?>>> containers = Map.of(
"payara", config -> new PayaraContainer(config.imageName, warFile, config.timeout),
"glassfish", config -> new GlassfishContainer(config.imageName, warFile, config.timeout),
"wildfly", config -> new WildflyContainer(config.imageName, warFile, config.timeout),
"open-liberty", config -> new OpenLibertyContainer(config.imageName, warFile, config.timeout)
);

// Apply config from container.properties and system properties
Properties testConfig = getTestConfiguration();
return containers.entrySet().stream()
.map(e -> {
ContainerConfiguration config = ContainerConfiguration.fromConfig(e.getKey(), testConfig);
return Arguments.of(Named.of(e.getKey(), config), Named.of(config.imageName, e.getValue().apply(config)));
});
}

@ParameterizedTest
@MethodSource("containers")
void webAppTest(ContainerConfiguration config, WebAppContainer<?> container) {

Assumptions.assumeTrue(config.enabled,
"This test has been disabled by configuring the property '" + config.name + ".enabled=false'");

try (container) {
container.start();

given()
.log().everything()
.contentType("application/scim+json")
.when()
.get(container.getAppUrl() + "/v2/ServiceProviderConfig")
.then()
.log().ifValidationFails()
.assertThat()
.statusCode(200);
}
}

static Properties getTestConfiguration() {
// images are referenced from a properties file, see container.properties
// system properties can override default configuration.
Properties containerProps = new Properties(System.getProperties());
try {
containerProps.load(ContainerIT.class.getResourceAsStream("/container.properties"));
} catch (IOException e) {
throw new TestInstantiationException("Unable to load container.properties", e);
}
return containerProps;
}

record ContainerConfiguration(String name, String imageName, Duration timeout, boolean enabled) {
static ContainerConfiguration fromConfig(String name, Properties properties) {
boolean enabled = Boolean.parseBoolean(properties.getProperty(name + ".enabled", "true"));
String imageName = properties.getProperty(name + ".image");
Duration timeout = Duration.parse(properties.getProperty(name + ".timeout", "PT60S"));

if (imageName == null) {
throw new TestInstantiationException("Missing image for " + name + ", check the '" + name + ".image' property, in container.properties");
}

return new ContainerConfiguration(name, imageName, timeout, enabled);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.directory.scim.example.memory.containers;

import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.MountableFile;

import java.nio.file.Path;
import java.time.Duration;

public class GlassfishContainer extends GenericContainer<GlassfishContainer> implements WebAppContainer<GlassfishContainer> {

public GlassfishContainer(String baseImage, Path warFile, Duration startupTimeout) {
super(baseImage);
this.withExposedPorts(8080)
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("container")))
.withCopyFileToContainer(
MountableFile.forHostPath(warFile.toAbsolutePath(), 0444),
"/deploy/application.war")
.withStartupTimeout(Duration.ofSeconds(60))
.waitingFor(Wait.forLogMessage(".*successfully deployed.*", 1)
.withStartupTimeout(startupTimeout));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.directory.scim.example.memory.containers;

import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.images.builder.Transferable;
import org.testcontainers.utility.MountableFile;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;

public class OpenLibertyContainer extends GenericContainer<OpenLibertyContainer> implements WebAppContainer<OpenLibertyContainer> {

public OpenLibertyContainer(String baseImage, Path warFile, Duration startupTimeout) {
super(
new ImageFromDockerfile("open-liberty:testcontainer")

.withFileFromTransferable("target/app.war",
MountableFile.forHostPath(warFile.toAbsolutePath(), 0444))
.withFileFromTransferable("liberty/config/server.xml",
Transferable.of(serverXml(8080, "/config/apps/example.war"), 0444))

.withDockerfileFromBuilder(builder ->
builder
.from(baseImage)
.user("root")

.copy("liberty/config/server.xml", "/config/server.xml")

.copy("target/app.war", "/config/apps/example.war")
.run("chown default:root /config/apps/example.war /config/server.xml")

.user("default")
.run("configure.sh")
.build()));

this.withExposedPorts(8080)
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("container")))
.withStartupTimeout(Duration.ofSeconds(60))
.waitingFor(Wait.forLogMessage("^.*CWWKF0011I.*$", 1)
.withStartupTimeout(startupTimeout));
}

static String serverXml(int port, String warPath) {
return """
<?xml version="1.0" encoding="UTF-8"?>
<server description="example">

<featureManager>
<platform>jakartaee-11.0</platform>
<feature>restfulWS-3.1</feature>
</featureManager>

<variable name="http.port" defaultValue="%d" />
<!-- tag::contextRoot[] -->
<variable name="context.root" defaultValue="/" />
<!-- end::contextRoot[] -->

<httpEndpoint id="defaultHttpEndpoint" host="*"
httpPort="${http.port}" />

<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<applicationMonitor dropinsEnabled="true" />

<!-- Configures the application on a specified context root -->
<webApplication contextRoot="${context.root}"
location="%s"/>
</server>
""".formatted(port, warPath);
}
}
Loading
Loading