-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added metadata for io.nats:jnats:2.16.11 (#311)
* Added metadata for io.nats:jnats:2.16.11 * Changed nats docker image version
- Loading branch information
Showing
13 changed files
with
201 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
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,3 @@ | ||
[ | ||
"reflect-config.json" | ||
] |
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,16 @@ | ||
[ | ||
{ | ||
"name": "io.nats.client.impl.SocketDataPort", | ||
"condition": { | ||
"typeReachable": "io.nats.client.Options$Builder" | ||
}, | ||
"methods": [ | ||
{ | ||
"name": "<init>", | ||
"parameterTypes": [ | ||
|
||
] | ||
} | ||
] | ||
} | ||
] |
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,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "2.16.11", | ||
"module": "io.nats:jnats", | ||
"tested-versions": [ | ||
"2.16.11" | ||
] | ||
} | ||
] |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
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,29 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = tck.testedLibraryVersion.get() | ||
|
||
dependencies { | ||
testImplementation "io.nats:jnats:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
} | ||
|
||
graalvmNative { | ||
agent { | ||
defaultMode = "conditional" | ||
modes { | ||
conditional { | ||
userCodeFilterPath = "metadata-user-code-filter.json" | ||
extraFilterPath = "metadata-extra-filter.json" | ||
} | ||
} | ||
} | ||
} |
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,2 @@ | ||
library.version = 2.16.11 | ||
metadata.dir = io.nats/jnats/2.16.11/ |
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,5 @@ | ||
{ | ||
"rules": [ | ||
{"includeClasses": "io.nats.**"} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/src/io.nats/jnats/2.16.11/metadata-user-code-filter.json
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,5 @@ | ||
{ | ||
"rules": [ | ||
{"includeClasses": "io.nats.**"} | ||
] | ||
} |
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 @@ | ||
nats:2.9.19 |
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,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'io.nats.jnats_tests' |
95 changes: 95 additions & 0 deletions
95
tests/src/io.nats/jnats/2.16.11/src/test/java/io_nats/jnats/JnatsTest.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,95 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package io_nats.jnats; | ||
|
||
import io.nats.client.Connection; | ||
import io.nats.client.Dispatcher; | ||
import io.nats.client.Nats; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.Callable; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class JnatsTest { | ||
|
||
private Process process; | ||
|
||
@BeforeAll | ||
public void init() throws IOException { | ||
System.out.println("Starting NATS ..."); | ||
process = new ProcessBuilder("docker", "run", "--rm", "-p", "4222:4222", "nats:2.9.19").inheritIO().start(); | ||
|
||
waitUntil(() -> { | ||
openConnection().close(); | ||
return true; | ||
}, 120, 1); | ||
|
||
System.out.println("NATS started"); | ||
} | ||
|
||
@AfterAll | ||
public void close() { | ||
if (process != null && process.isAlive()) { | ||
System.out.println("Shutting down NATS"); | ||
process.destroy(); | ||
} | ||
} | ||
|
||
// not using Awaitility library because of `com.oracle.svm.core.jdk.UnsupportedFeatureError: ThreadMXBean methods` issue | ||
// which happens if a condition is not fulfilled when a test is running in a native image | ||
private void waitUntil(Callable<Boolean> conditionEvaluator, int timeoutSeconds, int sleepTimeSeconds) { | ||
Exception lastException = null; | ||
|
||
long end = System.currentTimeMillis() + timeoutSeconds * 1000L; | ||
while (System.currentTimeMillis() < end) { | ||
try { | ||
Thread.sleep(sleepTimeSeconds * 1000L); | ||
} catch (InterruptedException e) { | ||
// continue | ||
} | ||
try { | ||
if (conditionEvaluator.call()) { | ||
return; | ||
} | ||
} catch (Exception e) { | ||
lastException = e; | ||
} | ||
} | ||
String errorMessage = "Condition was not fulfilled within " + timeoutSeconds + " seconds"; | ||
throw lastException == null ? new IllegalStateException(errorMessage) : new IllegalStateException(errorMessage, lastException); | ||
} | ||
|
||
private Connection openConnection() throws Exception { | ||
return Nats.connect(); | ||
} | ||
|
||
@Test | ||
void test() throws Exception { | ||
try (Connection connection = openConnection()) { | ||
final List<String> receivedMessages = new ArrayList<>(); | ||
Dispatcher dispatcher = connection.createDispatcher((msg) -> receivedMessages.add(new String(msg.getData(), StandardCharsets.UTF_8))); | ||
dispatcher.subscribe("test-subject"); | ||
|
||
connection.publish("test-subject", "test-message".getBytes(StandardCharsets.UTF_8)); | ||
|
||
waitUntil(() -> !receivedMessages.isEmpty(), 10, 1); | ||
|
||
assertThat(receivedMessages) | ||
.hasSize(1) | ||
.containsExactly("test-message"); | ||
} | ||
} | ||
} |