mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 02:06:00 +02:00
Get rid of all remaining JUnit 4 usages except in prober & proxy (#731)
* Get rid of all remaining JUnit 4 usages except in prober & proxy subprojects Caveat: Test suites aren't yet implemented in JUnit 5 so we still use the ones from JUnit 5 in the core subproject. * Fix some build errors
This commit is contained in:
parent
a02b67caf5
commit
16a31e460c
347 changed files with 3785 additions and 1536 deletions
|
@ -60,6 +60,7 @@ org.checkerframework:checker-qual:2.11.1
|
|||
org.hamcrest:hamcrest-core:1.3
|
||||
org.junit.jupiter:junit-jupiter-api:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-engine:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-params:5.6.2
|
||||
org.junit.platform:junit-platform-commons:1.6.2
|
||||
org.junit.platform:junit-platform-engine:1.6.2
|
||||
org.junit.vintage:junit-vintage-engine:5.6.2
|
||||
|
|
|
@ -60,6 +60,7 @@ org.checkerframework:checker-qual:2.11.1
|
|||
org.hamcrest:hamcrest-core:1.3
|
||||
org.junit.jupiter:junit-jupiter-api:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-engine:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-params:5.6.2
|
||||
org.junit.platform:junit-platform-commons:1.6.2
|
||||
org.junit.platform:junit-platform-engine:1.6.2
|
||||
org.junit.vintage:junit-vintage-engine:5.6.2
|
||||
|
|
|
@ -60,6 +60,7 @@ org.checkerframework:checker-qual:2.11.1
|
|||
org.hamcrest:hamcrest-core:1.3
|
||||
org.junit.jupiter:junit-jupiter-api:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-engine:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-params:5.6.2
|
||||
org.junit.platform:junit-platform-commons:1.6.2
|
||||
org.junit.platform:junit-platform-engine:1.6.2
|
||||
org.junit.vintage:junit-vintage-engine:5.6.2
|
||||
|
|
|
@ -60,6 +60,7 @@ org.checkerframework:checker-qual:2.11.1
|
|||
org.hamcrest:hamcrest-core:1.3
|
||||
org.junit.jupiter:junit-jupiter-api:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-engine:5.6.2
|
||||
org.junit.jupiter:junit-jupiter-params:5.6.2
|
||||
org.junit.platform:junit-platform-commons:1.6.2
|
||||
org.junit.platform:junit-platform-engine:1.6.2
|
||||
org.junit.vintage:junit-vintage-engine:5.6.2
|
||||
|
|
|
@ -30,7 +30,7 @@ import google.registry.monitoring.blackbox.handler.TestActionHandler;
|
|||
import google.registry.monitoring.blackbox.message.OutboundMessageType;
|
||||
import google.registry.monitoring.blackbox.message.TestMessage;
|
||||
import google.registry.monitoring.blackbox.token.Token;
|
||||
import google.registry.networking.handler.NettyRule;
|
||||
import google.registry.networking.handler.NettyExtension;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
|
@ -40,15 +40,15 @@ import io.netty.channel.local.LocalAddress;
|
|||
import io.netty.channel.local.LocalChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ProbingSequence}s and {@link ProbingStep}s and their specific
|
||||
* implementations
|
||||
* implementations.
|
||||
*/
|
||||
public class ProbingStepTest {
|
||||
class ProbingStepTest {
|
||||
|
||||
/** Basic Constants necessary for tests */
|
||||
private static final String ADDRESS_NAME = "TEST_ADDRESS";
|
||||
|
@ -61,12 +61,13 @@ public class ProbingStepTest {
|
|||
private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup(1);
|
||||
private final Bootstrap bootstrap =
|
||||
new Bootstrap().group(eventLoopGroup).channel(LocalChannel.class);
|
||||
|
||||
/** Used for testing how well probing step can create connection to blackbox server */
|
||||
@Rule public NettyRule nettyRule = new NettyRule();
|
||||
@RegisterExtension NettyExtension nettyExtension = new NettyExtension();
|
||||
|
||||
/**
|
||||
* The two main handlers we need in any test pipeline used that connects to {@link NettyRule's
|
||||
* server}
|
||||
* The two main handlers we need in any test pipeline used that connects to {@link NettyExtension
|
||||
* 's server}
|
||||
*/
|
||||
private ActionHandler testHandler = new TestActionHandler();
|
||||
|
||||
|
@ -87,7 +88,7 @@ public class ProbingStepTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProbingActionGenerate_embeddedChannel() throws UndeterminedStateException {
|
||||
void testProbingActionGenerate_embeddedChannel() throws UndeterminedStateException {
|
||||
// Sets up Protocol to represent existing channel connection.
|
||||
Protocol testProtocol =
|
||||
Protocol.builder()
|
||||
|
@ -125,7 +126,7 @@ public class ProbingStepTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProbingActionGenerate_newChannel() throws UndeterminedStateException {
|
||||
void testProbingActionGenerate_newChannel() throws UndeterminedStateException {
|
||||
// Sets up Protocol for when we create a new channel.
|
||||
Protocol testProtocol =
|
||||
Protocol.builder()
|
||||
|
@ -149,7 +150,7 @@ public class ProbingStepTest {
|
|||
Token testToken = testToken(ADDRESS_NAME);
|
||||
|
||||
// Sets up server listening at LocalAddress so generated action can have successful connection.
|
||||
nettyRule.setUpServer(address);
|
||||
nettyExtension.setUpServer(address);
|
||||
|
||||
ProbingAction testAction = testStep.generateAction(testToken);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import google.registry.monitoring.blackbox.handler.ActionHandler;
|
|||
import google.registry.monitoring.blackbox.handler.ConversionHandler;
|
||||
import google.registry.monitoring.blackbox.handler.TestActionHandler;
|
||||
import google.registry.monitoring.blackbox.message.TestMessage;
|
||||
import google.registry.networking.handler.NettyRule;
|
||||
import google.registry.networking.handler.NettyExtension;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
@ -34,11 +34,9 @@ import io.netty.channel.embedded.EmbeddedChannel;
|
|||
import io.netty.channel.local.LocalAddress;
|
||||
import io.netty.channel.local.LocalChannel;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ProbingAction} subtypes
|
||||
|
@ -46,8 +44,7 @@ import org.junit.runners.JUnit4;
|
|||
* <p>Attempts to test how well each {@link ProbingAction} works with an {@link ActionHandler}
|
||||
* subtype when receiving to all possible types of responses
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class ProbingActionTest {
|
||||
class ProbingActionTest {
|
||||
|
||||
private static final String TEST_MESSAGE = "MESSAGE_TEST";
|
||||
private static final String SECONDARY_TEST_MESSAGE = "SECONDARY_MESSAGE_TEST";
|
||||
|
@ -55,7 +52,7 @@ public class ProbingActionTest {
|
|||
private static final String ADDRESS_NAME = "TEST_ADDRESS";
|
||||
private static final int TEST_PORT = 0;
|
||||
|
||||
@Rule public NettyRule nettyRule = new NettyRule();
|
||||
@RegisterExtension NettyExtension nettyExtension = new NettyExtension();
|
||||
|
||||
/**
|
||||
* We use custom Test {@link ActionHandler} and {@link ConversionHandler} so test depends only on
|
||||
|
@ -67,9 +64,9 @@ public class ProbingActionTest {
|
|||
|
||||
// TODO - Currently, this test fails to receive outbound messages from the embedded channel, which
|
||||
// we will fix in a later release.
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testSuccess_existingChannel() {
|
||||
void testSuccess_existingChannel() {
|
||||
// setup
|
||||
EmbeddedChannel channel = new EmbeddedChannel(conversionHandler, testHandler);
|
||||
channel.attr(CONNECTION_FUTURE_KEY).set(channel.newSucceededFuture());
|
||||
|
@ -118,12 +115,12 @@ public class ProbingActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_newChannel() throws Exception {
|
||||
void testSuccess_newChannel() throws Exception {
|
||||
// setup
|
||||
|
||||
LocalAddress address = new LocalAddress(ADDRESS_NAME);
|
||||
Bootstrap bootstrap =
|
||||
new Bootstrap().group(nettyRule.getEventLoopGroup()).channel(LocalChannel.class);
|
||||
new Bootstrap().group(nettyExtension.getEventLoopGroup()).channel(LocalChannel.class);
|
||||
|
||||
// Sets up a Protocol corresponding to when a new connection is created.
|
||||
Protocol protocol =
|
||||
|
@ -134,7 +131,7 @@ public class ProbingActionTest {
|
|||
.setPersistentConnection(false)
|
||||
.build();
|
||||
|
||||
nettyRule.setUpServer(address);
|
||||
nettyExtension.setUpServer(address);
|
||||
|
||||
// Sets up a ProbingAction with existing channel using test specified attributes.
|
||||
ProbingAction action =
|
||||
|
@ -150,7 +147,7 @@ public class ProbingActionTest {
|
|||
ChannelFuture future = action.call();
|
||||
|
||||
// Tests to see if message is properly sent to remote server
|
||||
nettyRule.assertReceivedMessage(TEST_MESSAGE);
|
||||
nettyExtension.assertReceivedMessage(TEST_MESSAGE);
|
||||
|
||||
future = future.syncUninterruptibly();
|
||||
// Tests to see that, since server responds, we have set future to true
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.monitoring.blackbox.handler;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.monitoring.blackbox.exception.EppClientException;
|
||||
import google.registry.monitoring.blackbox.exception.FailureException;
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.monitoring.blackbox.message;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.monitoring.blackbox.exception.EppClientException;
|
||||
import google.registry.monitoring.blackbox.exception.FailureException;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue