-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
emitter() fails in native
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 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,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> |
46 changes: 46 additions & 0 deletions
46
native-tests/src/test/java/io/smallrye/mutiny/nativetests/SmokeTest.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,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()); | ||
} | ||
} |
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