-
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.
- Loading branch information
Gerard Klijs
committed
Jan 10, 2024
1 parent
9c4e757
commit 7bb7bf1
Showing
13 changed files
with
745 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2024. Axon Framework | ||
~ | ||
~ Licensed 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. | ||
--> | ||
|
||
<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> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.2.1</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<artifactId>axon-cosmosdb-spring-boot-3-integrationtests</artifactId> | ||
<groupId>org.axonframework.extensions.cosmosdb</groupId> | ||
|
||
<name>Axon Framework Cosmos DB Extension Spring Boot 3 Integration Tests</name> | ||
<description> | ||
Module used to test the integration with Spring Boot 3 | ||
</description> | ||
<version>4.9.0-SNAPSHOT</version> | ||
|
||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<axon.version>4.9.1</axon.version> | ||
<testcontainers.version>1.19.3</testcontainers.version> | ||
<spring-cloud-azure.version>5.8.0</spring-cloud-azure.version> | ||
<!-- Build / Plugin --> | ||
<jacoco-maven.version>0.8.11</jacoco-maven.version> | ||
<maven-jar.version>3.3.0</maven-jar.version> | ||
<maven-surefire.version>3.2.3</maven-surefire.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Axon --> | ||
<dependency> | ||
<groupId>org.axonframework</groupId> | ||
<artifactId>axon-eventsourcing</artifactId> | ||
<version>${axon.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.axonframework</groupId> | ||
<artifactId>axon-spring-boot-autoconfigure</artifactId> | ||
<version>${axon.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.axonframework.extensions.cosmosdb</groupId> | ||
<artifactId>axon-cosmosdb-spring-boot-starter</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- Cosmos DB --> | ||
<dependency> | ||
<groupId>com.azure.spring</groupId> | ||
<artifactId>spring-cloud-azure-starter-data-cosmos</artifactId> | ||
<version>${spring-cloud-azure.version}</version> | ||
</dependency> | ||
<!-- Spring --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j2</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
</dependency> | ||
<!-- Serialization --> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Testing --> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>azure</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers-bom</artifactId> | ||
<version>${testcontainers.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<!-- compile --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>17</source> | ||
<target>17</target> | ||
<encoding>UTF-8</encoding> | ||
<showWarnings>true</showWarnings> | ||
<showDeprecation>true</showDeprecation> | ||
</configuration> | ||
</plugin> | ||
<!-- package --> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>${maven-jar.version}</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<!-- deploy --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>${maven-deploy-plugin.version}</version> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>coverage</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>${jacoco-maven.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>report</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>coverage-aggregate</id> | ||
<build> | ||
<defaultGoal>verify</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven-surefire.version}</version> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<repositories> | ||
<repository> | ||
<id>sonatype-snapshots</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</repository> | ||
</repositories> | ||
</project> |
93 changes: 93 additions & 0 deletions
93
...est/java/org/axonframework/extensions/cosmosdb/integration/TokenStoreIntegrationTest.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,93 @@ | ||
package org.axonframework.extensions.cosmosdb.integration; | ||
|
||
import org.axonframework.eventhandling.GlobalSequenceTrackingToken; | ||
import org.axonframework.eventhandling.TrackingToken; | ||
import org.axonframework.eventhandling.tokenstore.TokenStore; | ||
import org.axonframework.extensions.cosmosdb.eventsourcing.tokenstore.CosmosTokenStore; | ||
import org.junit.jupiter.api.*; | ||
import org.junit.jupiter.api.io.*; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
import org.springframework.context.annotation.EnableMBeanExport; | ||
import org.springframework.jmx.support.RegistrationPolicy; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.testcontainers.containers.CosmosDBEmulatorContainer; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.cert.CertificateException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@Testcontainers | ||
class TokenStoreIntegrationTest { | ||
|
||
@Container | ||
private static final CosmosDBEmulatorContainer COSMOS_CONTAINER = new CosmosDBEmulatorContainer( | ||
DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest") | ||
); | ||
|
||
@TempDir | ||
private static Path tempFolder; | ||
|
||
private ApplicationContextRunner testApplicationContext; | ||
|
||
@BeforeAll | ||
static void setup() throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { | ||
Path keyStoreFile = tempFolder.resolve("azure-cosmos-emulator.keystore"); | ||
KeyStore keyStore = COSMOS_CONTAINER.buildNewKeyStore(); | ||
keyStore.store(Files.newOutputStream(keyStoreFile.toFile().toPath()), | ||
COSMOS_CONTAINER.getEmulatorKey().toCharArray()); | ||
|
||
System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); | ||
System.setProperty("javax.net.ssl.trustStorePassword", COSMOS_CONTAINER.getEmulatorKey()); | ||
System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
testApplicationContext = new ApplicationContextRunner() | ||
.withPropertyValues("axon.axonserver.enabled=false"); | ||
} | ||
|
||
@Test | ||
void tokenStoreWillUseCosmosDB() { | ||
testApplicationContext | ||
.withPropertyValues("spring.cloud.azure.cosmos.endpoint=" + COSMOS_CONTAINER.getEmulatorEndpoint()) | ||
.withPropertyValues("spring.cloud.azure.cosmos.key=" + COSMOS_CONTAINER.getEmulatorKey()) | ||
.withPropertyValues("spring.cloud.azure.cosmos.database=someProjection") | ||
.withPropertyValues("spring.cloud.azure.cosmos.endpoint-discovery-enabled=false") | ||
.withPropertyValues("spring.cloud.azure.cosmos.connection-mode=gateway") | ||
.withUserConfiguration(DefaultContext.class) | ||
.run(context -> { | ||
TokenStore tokenStore = context.getBean(TokenStore.class); | ||
assertNotNull(tokenStore); | ||
assertInstanceOf(CosmosTokenStore.class, tokenStore); | ||
testTokenStore(tokenStore); | ||
}); | ||
} | ||
|
||
private void testTokenStore(TokenStore tokenStore) { | ||
String testProcessorName = "testProcessorName"; | ||
int testSegment = 9; | ||
tokenStore.initializeTokenSegments(testProcessorName, testSegment + 1); | ||
assertNull(tokenStore.fetchToken(testProcessorName, testSegment)); | ||
TrackingToken token = new GlobalSequenceTrackingToken(1L); | ||
tokenStore.storeToken(token, testProcessorName, testSegment); | ||
assertEquals(token, tokenStore.fetchToken(testProcessorName, testSegment)); | ||
} | ||
|
||
@ContextConfiguration | ||
@EnableAutoConfiguration | ||
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) | ||
public static class DefaultContext { | ||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
axon-cosmosdb-spring-boot-3-integrationtests/src/test/resources/log4j2.properties
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,55 @@ | ||
# | ||
# Copyright (c) 2010-2022. Axon Framework | ||
# | ||
# Licensed 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. | ||
# | ||
name=AxonTestConfiguration | ||
appenders=console | ||
appender.console.type=Console | ||
appender.console.name=STDOUT | ||
appender.console.layout.type=PatternLayout | ||
appender.console.layout.pattern=%d [%t] %-5p %-30.30c{1} %x - %m%n | ||
rootLogger.level=info | ||
rootLogger.appenderRefs=stdout | ||
rootLogger.appenderRef.stdout.ref=STDOUT | ||
logger.axon.name=org.axonframework | ||
logger.axon.level=INFO | ||
logger.axon.additivity=false | ||
logger.axon.appenderRefs=stdout | ||
logger.axon.appenderRef.stdout.ref=STDOUT | ||
logger.axon-server-connection-manager.name=org.axonframework.axonserver.connector.AxonServerConnectionManager | ||
logger.axon-server-connection-manager.level=ERROR | ||
logger.chaining-converter.name=org.axonframework.serialization.ChainingConverter | ||
logger.chaining-converter.level=OFF | ||
logger.tracking-event-processor.name=org.axonframework.eventhandling.TrackingEventProcessor | ||
logger.tracking-event-processor.level=WARN | ||
logger.hibernate.name=org.hibernate | ||
logger.hibernate.level=WARN | ||
logger.hibernate-sql-exception-helper.name=org.hibernate.engine.jdbc.spi.SqlExceptionHelper | ||
logger.hibernate-sql-exception-helper.level=ERROR | ||
logger.hikari.name=com.zaxxer.hikari | ||
logger.hikari.level=WARN | ||
logger.hikari-util.name=com.zaxxer.hikari.util | ||
logger.hikari-util.level=ERROR | ||
logger.spring-boot-test.name=org.springframework.boot.test | ||
logger.spring-boot-test.level=WARN | ||
logger.spring-context-annotation.name=org.springframework.context.annotation | ||
logger.spring-context-annotation.level=WARN | ||
logger.spring-context-support.name=org.springframework.context.support | ||
logger.spring-context-support.level=WARN | ||
logger.spring-data-repo-config.name=org.springframework.data.repository.config | ||
logger.spring-data-repo-config.level=WARN | ||
logger.spring-orm.name=org.springframework.orm | ||
logger.spring-orm.level=WARN | ||
logger.spring-test.name=org.springframework.test | ||
logger.spring-test.level=WARN |
Oops, something went wrong.