Skip to content

Commit

Permalink
Add some native tests
Browse files Browse the repository at this point in the history
emitter() fails in native
  • Loading branch information
jponge committed Oct 18, 2023
1 parent 8535f58 commit 36cca74
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
84 changes: 84 additions & 0 deletions native-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<name>SmallRye Mutiny - Native tests</name>
<description>Native tests</description>
<artifactId>native-tests</artifactId>

<dependencies>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-test-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<dependencies>
<dependency>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>junit-platform-native</artifactId>
<version>0.9.27</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.7.1</version>
<extensions>true</extensions>
<executions>
<!-- <execution>-->
<!-- <id>build-native</id>-->
<!-- <goals>-->
<!-- <goal>build</goal>-->
<!-- </goals>-->
<!-- <phase>package</phase>-->
<!-- </execution>-->
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>--verbose</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.smallrye.mutiny.nativetests;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Random;

import org.junit.jupiter.api.Test;

import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.helpers.test.AssertSubscriber;

public class SmokeTest {

@Test
public void concatMap() {
AssertSubscriber<Integer> subscriber = AssertSubscriber.create();
Multi.createFrom().range(1, 10_000)
.onItem().transformToMultiAndConcatenate(n -> Multi.createFrom().range(n + 2, n + 4))
.subscribe().withSubscriber(subscriber);

subscriber.request(5);
subscriber.assertItems(3, 4, 4, 5, 5);

subscriber.request(Long.MAX_VALUE);
subscriber.assertCompleted();
assertEquals(19998, subscriber.getItems().size());
}

@Test
public void emitter() {
AssertSubscriber<Integer> subscriber = AssertSubscriber.create();
Multi.createFrom().<Integer> emitter(emitter -> {
new Thread(() -> {
Random random = new Random();
for (int i = 0; i < 10_000; i++) {
emitter.emit(random.nextInt());
}
emitter.complete();
}).start();
}).subscribe().withSubscriber(subscriber);

subscriber.request(Long.MAX_VALUE);
subscriber.awaitCompletion();
assertEquals(10_000, subscriber.getItems().size());
}
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<module>bom</module>
<module>math</module>
<module>workshop-examples</module>
<module>native-tests</module>
</modules>

<properties>
Expand Down

0 comments on commit 36cca74

Please sign in to comment.