Skip to content

Commit

Permalink
server runner update to 1.2.0 (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf committed Feb 6, 2023
1 parent ba5dd0d commit a97243d
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 115 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/build.yml → .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
name: Build for Pr, Merge or Tag
name: Build Main

on:
pull_request:
types: [opened, synchronize, edited, reopened]
push:
branches:
- main
release:
branches:
- main
types: [released]

jobs:
build:
Expand Down Expand Up @@ -49,13 +43,7 @@ jobs:
uses: actions/checkout@v2
- name: Build and Test
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
- name: On Pull Request, Verify Javadoc
if: ${{ success() && github.event_name == 'pull_request' }}
- name: Verify Javadoc
run: ./gradlew javadoc
- name: On Merge to Main, Verify and Publish Snapshot
if: ${{ success() && github.event_name == 'push' }}
- name: Publish Snapshot
run: ./gradlew -i publishToSonatype
- name: On Tag Release Main, Verify, Sign and Publish Release
if: ${{ success() && github.event_name == 'release' }}
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository

46 changes: 46 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GODEBUG: x509sha1=1
steps:
- name: Setup JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Setup GO
uses: actions/setup-go@v2
with:
go-version: 1.19.1
- name: Install Nats Server
run: |
cd $GITHUB_WORKSPACE
git clone https://github.com/nats-io/nats-server.git
cd nats-server
go get
go build main.go
mkdir -p ~/.local/bin
cp main ~/.local/bin/nats-server
cd ..
rm -rf nats-server
nats-server -v
- name: Check out code
uses: actions/checkout@v2
- name: Build and Test
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
- name: Verify Javadoc
run: ./gradlew javadoc
48 changes: 48 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Release

on:
release:
branches:
- main
types: [released]

jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
GODEBUG: x509sha1=1
steps:
- name: Setup JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Setup GO
uses: actions/setup-go@v2
with:
go-version: 1.19.1
- name: Install Nats Server
run: |
cd $GITHUB_WORKSPACE
git clone https://github.com/nats-io/nats-server.git
cd nats-server
go get
go build main.go
mkdir -p ~/.local/bin
cp main ~/.local/bin/nats-server
cd ..
rm -rf nats-server
nats-server -v
- name: Check out code
uses: actions/checkout@v2
- name: Build and Test
run: chmod +x gradlew && ./gradlew clean test
- name: Verify, Sign and Publish Release
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
A [Java](http://java.com) client for the [NATS messaging system](https://nats.io).

[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.org/nats-io/nats.java.svg?branch=master)](http://travis-ci.org/nats-io/nats.java?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/nats.java/badge.svg?branch=main)](https://coveralls.io/github/nats-io/nats.java?branch=main)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.nats/jnats/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.nats/jnats)
[![Javadoc](http://javadoc.io/badge/io.nats/jnats.svg?branch=master)](http://javadoc.io/doc/io.nats/jnats?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/nats.java/badge.svg?branch=main)](https://coveralls.io/github/nats-io/nats.java?branch=main)
[![Build Main Badge](https://github.com/nats-io/nats.java/actions/workflows/build-main.yml/badge.svg?event=push)](https://github.com/nats-io/nats.java/actions/workflows/build-main.yml)
[![Release Badge](https://github.com/nats-io/nats.java/actions/workflows/build-release.yml/badge.svg?event=release)](https://github.com/nats-io/nats.java/actions/workflows/build-release.yml)

## A Note on Versions

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
dependencies {
implementation 'net.i2p.crypto:eddsa:0.3.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation 'io.nats:jnats-server-runner:1.1.1'
testImplementation 'io.nats:jnats-server-runner:1.2.1'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.12.3'
}

Expand Down
34 changes: 17 additions & 17 deletions src/test/java/io/nats/client/ConnectTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class ConnectTests {
@Test
public void testDefaultConnection() throws IOException, InterruptedException {
public void testDefaultConnection() throws Exception {
try (NatsTestServer ts = new NatsTestServer(Options.DEFAULT_PORT, false)) {
Connection nc = standardConnection();
assertEquals(Options.DEFAULT_PORT, nc.getServerInfo().getPort());
Expand All @@ -38,7 +38,7 @@ public void testDefaultConnection() throws IOException, InterruptedException {
}

@Test
public void testConnection() throws IOException, InterruptedException {
public void testConnection() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false)) {
Connection nc = standardConnection(ts.getURI());
assertEquals(ts.getPort(), nc.getServerInfo().getPort());
Expand All @@ -51,22 +51,22 @@ public void testConnection() throws IOException, InterruptedException {
}

@Test
public void testConnectionWithOptions() throws IOException, InterruptedException {
public void testConnectionWithOptions() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false)) {
Options options = new Options.Builder().server(ts.getURI()).build();
assertCanConnect(options);
}
}

@Test
public void testFullFakeConnect() throws IOException, InterruptedException {
public void testFullFakeConnect() throws Exception {
try (NatsServerProtocolMock ts = new NatsServerProtocolMock(ExitAt.NO_EXIT)) {
assertCanConnect(ts.getURI());
}
}

@Test
public void testFullFakeConnectWithTabs() throws IOException, InterruptedException {
public void testFullFakeConnectWithTabs() throws Exception {
try (NatsServerProtocolMock ts = new NatsServerProtocolMock(ExitAt.NO_EXIT)) {
ts.useTabs();
assertCanConnect(ts.getURI());
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testConnectExitAfterPing() {
}

@Test
public void testConnectionFailureWithFallback() throws IOException, InterruptedException {
public void testConnectionFailureWithFallback() throws Exception {

try (NatsTestServer ts = new NatsTestServer(false)) {
try (NatsServerProtocolMock fake = new NatsServerProtocolMock(ExitAt.EXIT_AFTER_PING)) {
Expand All @@ -126,14 +126,14 @@ public void testConnectionFailureWithFallback() throws IOException, InterruptedE
}

@Test
public void testConnectWithConfig() throws IOException, InterruptedException {
public void testConnectWithConfig() throws Exception {
try (NatsTestServer ts = new NatsTestServer("src/test/resources/simple.conf", false)) {
assertCanConnect(ts.getURI());
}
}

@Test
public void testConnectWithCommas() throws IOException, InterruptedException {
public void testConnectWithCommas() throws Exception {
try (NatsTestServer ts1 = new NatsTestServer(false)) {
try (NatsTestServer ts2 = new NatsTestServer(false)) {
assertCanConnect(ts1.getURI() + "," + ts2.getURI());
Expand All @@ -142,7 +142,7 @@ public void testConnectWithCommas() throws IOException, InterruptedException {
}

@Test
public void testConnectRandomize() throws IOException, InterruptedException {
public void testConnectRandomize() throws Exception {
try (NatsTestServer ts1 = new NatsTestServer(false)) {
try (NatsTestServer ts2 = new NatsTestServer(false)) {
int one = 0;
Expand All @@ -169,7 +169,7 @@ public void testConnectRandomize() throws IOException, InterruptedException {
}

@Test
public void testConnectNoRandomize() throws IOException, InterruptedException {
public void testConnectNoRandomize() throws Exception {
try (NatsTestServer ts1 = new NatsTestServer(false)) {
try (NatsTestServer ts2 = new NatsTestServer(false)) {
int one = 0;
Expand Down Expand Up @@ -241,7 +241,7 @@ public void testIncompleteInitialInfo() {
}

@Test
public void testAsyncConnection() throws IOException, InterruptedException {
public void testAsyncConnection() throws Exception {
TestHandler handler = new TestHandler();
Connection nc = null;

Expand All @@ -261,7 +261,7 @@ public void testAsyncConnection() throws IOException, InterruptedException {
}

@Test
public void testAsyncConnectionWithReconnect() throws IOException, InterruptedException {
public void testAsyncConnectionWithReconnect() throws Exception {
TestHandler handler = new TestHandler();
int port = NatsTestServer.nextPort();
Options options = new Options.Builder().server("nats://localhost:" + port).maxReconnects(-1)
Expand Down Expand Up @@ -292,7 +292,7 @@ public void testThrowOnAsyncWithoutListener() {
}

@Test
public void testErrorOnAsync() throws IOException, InterruptedException {
public void testErrorOnAsync() throws Exception {
TestHandler handler = new TestHandler(false);
Options options = new Options.Builder().server("nats://localhost:" + NatsTestServer.nextPort())
.connectionListener(handler).errorListener(handler).noReconnect().build();
Expand All @@ -318,7 +318,7 @@ public void testConnectionTimeout() {
}

@Test
public void testSlowConnectionNoTimeout() throws IOException, InterruptedException {
public void testSlowConnectionNoTimeout() throws Exception {
try (NatsServerProtocolMock ts = new NatsServerProtocolMock(ExitAt.SLEEP_BEFORE_INFO)) {
Options options = new Options.Builder().server(ts.getURI()).noReconnect()
.connectionTimeout(Duration.ofSeconds(6)). // longer than the sleep
Expand All @@ -328,7 +328,7 @@ public void testSlowConnectionNoTimeout() throws IOException, InterruptedExcepti
}

@Test
public void testTimeCheckCoverage() throws IOException, InterruptedException {
public void testTimeCheckCoverage() throws Exception {
try (NatsTestServer ts = new NatsTestServer(Options.DEFAULT_PORT, false)) {
Options options = new Options.Builder().server(ts.getURI()).traceConnection().build();
assertCanConnect(options);
Expand All @@ -346,7 +346,7 @@ public void testConnectExceptionHasURLS() {
}

@Test
public void testFlushBuffer() throws IOException, InterruptedException {
public void testFlushBuffer() throws Exception {
try (NatsTestServer ts = new NatsTestServer(Options.DEFAULT_PORT, false)) {
Connection nc = standardConnection(ts.getURI());

Expand All @@ -366,7 +366,7 @@ public void testFlushBuffer() throws IOException, InterruptedException {
}

@Test
public void testFlushBufferThreadSafety() throws IOException, InterruptedException {
public void testFlushBufferThreadSafety() throws Exception {
try (NatsTestServer ts = new NatsTestServer(Options.DEFAULT_PORT, false)) {
Connection nc = standardConnection(ts.getURI());

Expand Down
6 changes: 5 additions & 1 deletion src/test/java/io/nats/client/NatsTestServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.nats.client;

import nats.io.ConsoleOutput;
import nats.io.NatsRunnerUtils;
import nats.io.NatsServerRunner;

Expand All @@ -21,9 +22,12 @@

public class NatsTestServer extends NatsServerRunner {
static {
NatsServerRunner.setDefaultDisplayLevel(Level.SEVERE);
NatsServerRunner.setDefaultOutputSupplier(ConsoleOutput::new);
NatsServerRunner.setDefaultOutputLevel(Level.WARNING);
}

public static void init() { /* does nothing except force static initializer */ }

public NatsTestServer() throws IOException {
super();
}
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/io/nats/client/SubscriberTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.time.Duration;
import java.util.HashSet;
import java.util.concurrent.CompletableFuture;
Expand All @@ -28,7 +27,7 @@
public class SubscriberTests {

@Test
public void testCreateInbox() throws IOException, InterruptedException {
public void testCreateInbox() throws Exception {
HashSet<String> check = new HashSet<>();
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
Expand All @@ -43,7 +42,7 @@ public void testCreateInbox() throws IOException, InterruptedException {
}

@Test
public void testSingleMessage() throws IOException, InterruptedException {
public void testSingleMessage() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand All @@ -62,7 +61,7 @@ public void testSingleMessage() throws IOException, InterruptedException {
}

@Test
public void testMessageFromSubscriptionContainsConnection() throws IOException, InterruptedException {
public void testMessageFromSubscriptionContainsConnection() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand Down Expand Up @@ -138,7 +137,7 @@ public void testTabInProtocolLine() throws Exception {
}

@Test
public void testMultiMessage() throws IOException, InterruptedException {
public void testMultiMessage() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand All @@ -164,7 +163,7 @@ public void testMultiMessage() throws IOException, InterruptedException {
}

@Test
public void testQueueSubscribers() throws IOException, InterruptedException, TimeoutException {
public void testQueueSubscribers() throws Exception, TimeoutException {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand Down Expand Up @@ -472,7 +471,7 @@ public void testUnsubscribeWhileWaiting() {
}

@Test
public void testWhiteSpaceInSubject() throws IOException, InterruptedException {
public void testWhiteSpaceInSubject() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand All @@ -485,7 +484,7 @@ public void testWhiteSpaceInSubject() throws IOException, InterruptedException {
}

@Test
public void testWhiteSpaceInQueue() throws IOException, InterruptedException {
public void testWhiteSpaceInQueue() throws Exception {
try (NatsTestServer ts = new NatsTestServer(false);
Connection nc = Nats.connect(ts.getURI())) {
standardConnectionWait(nc);
Expand Down
Loading

0 comments on commit a97243d

Please sign in to comment.