Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update buildSrc to Java 11 Toolchain & Update Wiremock Test Dependency #546

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ dependencies {
testImplementation(libs.shrinkwrap.api)
testRuntimeOnly(libs.shrinkwrap.impl)
testImplementation(libs.byteBuddy)
testImplementation(libs.wiremock.jre8.standalone)
testImplementation(libs.wiremock.standalone)
testImplementation(libs.javassist)
testImplementation(libs.awaitility)
testImplementation(libs.stefanBirkner.systemRules) {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ group = "com.hivemq"

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(JavaLanguageVersion.of(11))
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rocksdb = "8.3.3"
shrinkwrap = "1.2.6"
slf4j = "2.0.16"
stefanBirkner-systemRules = "1.19.0"
wiremock = "3.0.1"
wiremock = "3.9.2"
xodus = "1.2.3"
zeroAllocationHashing = "0.16"

Expand Down Expand Up @@ -73,7 +73,7 @@ shrinkwrap-api = { module = "org.jboss.shrinkwrap:shrinkwrap-api", version.ref =
shrinkwrap-impl = { module = "org.jboss.shrinkwrap:shrinkwrap-impl-base", version.ref = "shrinkwrap" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
stefanBirkner-systemRules = { module = "com.github.stefanbirkner:system-rules", version.ref = "stefanBirkner-systemRules" }
wiremock-jre8-standalone = { module = "com.github.tomakehurst:wiremock-jre8-standalone", version.ref = "wiremock" }
wiremock-standalone = { module = "org.wiremock:wiremock-standalone", version.ref = "wiremock" }
xodus-environment = { module = "org.jetbrains.xodus:xodus-environment", version.ref = "xodus" }
xodus-openApi = { module = "org.jetbrains.xodus:xodus-openAPI", version.ref = "xodus" }
zeroAllocationHashing = { module = "net.openhft:zero-allocation-hashing", version.ref = "zeroAllocationHashing" }
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/com/hivemq/bootstrap/BindInformationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.hivemq.configuration.service.entity.TcpListener;
import io.netty.channel.ChannelFuture;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand All @@ -31,13 +32,19 @@ public class BindInformationTest {
ChannelFuture future;

private TcpListener listener;
private AutoCloseable closeable;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);
listener = new TcpListener(1883, "0.0.0.0");
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_bind_information() throws Exception {
final BindInformation bindInformation = new BindInformation(listener, future);
Expand All @@ -55,4 +62,4 @@ public void test_listener_null() throws Exception {
public void test_future_null() throws Exception {
new BindInformation(listener, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand All @@ -52,6 +53,7 @@
public class HiveMQNettyBootstrapTest {

private HiveMQNettyBootstrap hiveMQNettyBootstrap;
private AutoCloseable closeable;

@Mock
private ShutdownHooks shutdownHooks;
Expand All @@ -73,7 +75,7 @@ public class HiveMQNettyBootstrapTest {

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);
hiveMQNettyBootstrap = new HiveMQNettyBootstrap(shutdownHooks,
listenerConfigurationService,
channelInitializerFactoryImpl,
Expand All @@ -87,6 +89,11 @@ public void before() {
abstractChannelInitializer);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void bootstrapServer_whenNoListenersProvided_thenSuccessfulBootstrap() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.hivemq.security.ssl.SslParameterHandler;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.traffic.GlobalTrafficShapingHandler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -145,10 +146,11 @@ public class ChannelDependenciesTest {
private @NotNull ShutdownHooks shutdownHooks;

private @NotNull ChannelDependencies channelDependencies;
private AutoCloseable closeable;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

channelDependencies = new ChannelDependencies(noConnectIdleHandler,
() -> connectHandler,
Expand Down Expand Up @@ -182,6 +184,11 @@ public void setUp() throws Exception {
shutdownHooks);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void getters_returnAllHandlers() {
assertNotNull(channelDependencies.getNoConnectIdleHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.CorruptedFrameException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -57,10 +58,11 @@ public class ExceptionHandlerTest {
ClientConnection clientConnection;

private ExceptionHandler handler;
private AutoCloseable closeable;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

when(ctx.pipeline()).thenReturn(pipeline);
when(channel.pipeline()).thenReturn(pipeline);
Expand All @@ -72,6 +74,11 @@ public void before() {
handler = new ExceptionHandler(mqttServerDisconnector);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_SSLException() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.group.ChannelGroup;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand All @@ -44,16 +45,22 @@ public class ChannelGroupHandlerTest {
ChannelPipeline channelPipeline;

private ChannelGroupHandler channelGroupHandler;
private AutoCloseable closeable;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);
channelGroupHandler = new ChannelGroupHandler(channelGroup);

when(ctx.channel()).thenReturn(channel);
when(ctx.pipeline()).thenReturn(channelPipeline);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_channel_active() throws Exception {
channelGroupHandler.channelActive(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.hivemq.security.ssl.NonSslHandler;
import com.hivemq.security.ssl.SslFactory;
import io.netty.channel.Channel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -69,17 +70,23 @@ public class ChannelInitializerFactoryImplTest {
private RestrictionsConfigurationService restrictionsConfigurationService;

private ChannelInitializerFactoryImpl channelInitializerFactory;
private AutoCloseable closeable;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);
when(channelDependencies.getConfigurationService()).thenReturn(fullConfigurationService);
when(channelDependencies.getRestrictionsConfigurationService()).thenReturn(restrictionsConfigurationService);
when(restrictionsConfigurationService.incomingLimit()).thenReturn(0L);
channelInitializerFactory =
new TestChannelInitializerFactory(channelDependencies, sslFactory, nonSslHandlerProvider);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_get_tcp_initializer() {
final TcpListener tcpListener = new TcpListener(0, "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.hivemq.security.ssl.NonSslHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -58,14 +59,13 @@ public class TcpChannelInitializerTest {
@Mock
private RestrictionsConfigurationService restrictionsConfigurationService;


private ChannelPipeline pipeline;

private TcpChannelInitializer tcpChannelInitializer;
private AutoCloseable closeable;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

when(channelDependencies.getConfigurationService()).thenReturn(fullConfigurationService);
when(channelDependencies.getRestrictionsConfigurationService()).thenReturn(restrictionsConfigurationService);
Expand All @@ -80,10 +80,15 @@ public void before() {

}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_add_special_handlers() throws Exception {

tcpChannelInitializer.addSpecialHandlers(socketChannel);
assertEquals(NON_SSL_HANDLER, pipeline.names().get(0));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.Future;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -90,10 +91,11 @@ public class TlsTcpChannelInitializerTest {
private ChannelPipeline pipeline;

private TlsTcpChannelInitializer tlstcpChannelInitializer;
private AutoCloseable closeable;

@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

pipeline = new FakeChannelPipeline();

Expand All @@ -117,6 +119,11 @@ public void before() throws Exception {

}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_add_special_handlers() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.Future;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -95,10 +96,11 @@ public class TlsWebsocketChannelInitializerTest {
private Tls tls;

private ChannelPipeline pipeline;
private AutoCloseable closeable;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

pipeline = new FakeChannelPipeline();

Expand All @@ -120,6 +122,11 @@ public void before() {
when(channelDependencies.getMqttServerDisconnector()).thenReturn(mqttServerDisconnector);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_add_special_handlers() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.hivemq.security.ssl.NonSslHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -58,10 +59,11 @@ public class WebsocketChannelInitializerTest {
private RestrictionsConfigurationService restrictionsConfigurationService;

private ChannelPipeline pipeline;
private AutoCloseable closeable;

@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
closeable = MockitoAnnotations.openMocks(this);

pipeline = new FakeChannelPipeline();

Expand All @@ -72,6 +74,11 @@ public void before() throws Exception {
when(restrictionsConfigurationService.incomingLimit()).thenReturn(0L);
}

@After
public void releaseMocks() throws Exception {
closeable. close();
}

@Test
public void test_add_special_handlers() throws Exception {

Expand Down
Loading