Fix Checkstyle violations & RMI tests
* Increase latch timeouts for `RedisLockRegistryLeaderInitiatorTests` * Some RMI tests fail with different outcome because an RMI registry might be available on default `1099` port. Fix them to not rely on that port
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 the original author or authors.
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,6 +42,7 @@ public final class JacksonPresent {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if Jackson 1.x is present on classpath
|
||||
* @deprecated Jackson 1.x is not supported any more. Use Jackson 2.x.
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,7 +116,7 @@ public class FileSplitterTests {
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE)).isEqualTo(2);
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)).isEqualTo(1);
|
||||
assertThat(this.selector.accept(receive)).isTrue();
|
||||
assertThat(this.store.get(this.file.getAbsolutePath())).isEqualTo("1");
|
||||
assertThat(this.store.get(file.getAbsolutePath())).isEqualTo("1");
|
||||
receive = this.output.receive(10000);
|
||||
assertThat(receive).isNotNull(); //äöüß
|
||||
assertThat(receive.getPayload()).isEqualTo("äöüß");
|
||||
@@ -125,7 +125,7 @@ public class FileSplitterTests {
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)).isEqualTo(2);
|
||||
assertThat(this.output.receive(1)).isNull();
|
||||
assertThat(this.selector.accept(receive)).isTrue();
|
||||
assertThat(this.store.get(this.file.getAbsolutePath())).isEqualTo("2");
|
||||
assertThat(this.store.get(file.getAbsolutePath())).isEqualTo("2");
|
||||
assertThat(this.selector.accept(receive)).isFalse();
|
||||
|
||||
this.input1.send(new GenericMessage<>(file.getAbsolutePath()));
|
||||
@@ -378,7 +378,7 @@ public class FileSplitterTests {
|
||||
splitter.setOutputChannel(outputChannel);
|
||||
FileReader fileReader = Mockito.spy(new FileReader(file));
|
||||
try {
|
||||
splitter.handleMessage(new GenericMessage<Reader>(fileReader));
|
||||
splitter.handleMessage(new GenericMessage<>(fileReader));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// ignore
|
||||
@@ -421,13 +421,10 @@ public class FileSplitterTests {
|
||||
@Bean
|
||||
public MetadataStoreSelector selector() {
|
||||
return new MetadataStoreSelector(
|
||||
message -> message.getHeaders().get(FileHeaders.ORIGINAL_FILE, File.class)
|
||||
.getAbsolutePath(),
|
||||
message -> message.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)
|
||||
.toString(),
|
||||
message -> message.getHeaders().get(FileHeaders.ORIGINAL_FILE, File.class).getAbsolutePath(),
|
||||
message -> message.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER).toString(),
|
||||
store())
|
||||
.compareValues(
|
||||
(oldVal, newVal) -> Integer.parseInt(oldVal) < Integer.parseInt(newVal));
|
||||
.compareValues((oldVal, newVal) -> Integer.parseInt(oldVal) < Integer.parseInt(newVal));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,7 +72,7 @@ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests {
|
||||
initiator.start();
|
||||
}
|
||||
|
||||
assertThat(granted.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(granted.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
|
||||
LockRegistryLeaderInitiator initiator1 = countingPublisher.initiator;
|
||||
|
||||
@@ -106,8 +106,8 @@ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests {
|
||||
|
||||
initiator1.getContext().yield();
|
||||
|
||||
assertThat(revoked1.await(20, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(granted2.await(20, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(revoked1.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(granted2.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
|
||||
assertThat(initiator2.getContext().isLeader()).isTrue();
|
||||
assertThat(initiator1.getContext().isLeader()).isFalse();
|
||||
@@ -117,8 +117,8 @@ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests {
|
||||
|
||||
initiator2.getContext().yield();
|
||||
|
||||
assertThat(revoked2.await(20, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(granted1.await(20, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(revoked2.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(granted1.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
|
||||
assertThat(initiator1.getContext().isLeader()).isTrue();
|
||||
assertThat(initiator2.getContext().isLeader()).isFalse();
|
||||
@@ -131,7 +131,7 @@ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests {
|
||||
|
||||
initiator1.getContext().yield();
|
||||
|
||||
assertThat(revoked11.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(revoked11.await(60, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(initiator1.getContext().isLeader()).isFalse();
|
||||
|
||||
initiator1.stop();
|
||||
|
||||
@@ -46,22 +46,24 @@ public class RmiOutboundGatewayTests {
|
||||
|
||||
private static final QueueChannel OUTPUT = new QueueChannel(1);
|
||||
|
||||
private static int RMI_PORT;
|
||||
|
||||
private static RmiServiceExporter EXPORTER;
|
||||
|
||||
private static RmiOutboundGateway GATEWAY;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws RemoteException {
|
||||
int rmiPort = SocketUtils.findAvailableTcpPort();
|
||||
RMI_PORT = SocketUtils.findAvailableTcpPort();
|
||||
|
||||
EXPORTER = new RmiServiceExporter();
|
||||
EXPORTER.setService(new TestExchanger());
|
||||
EXPORTER.setServiceInterface(RequestReplyExchanger.class);
|
||||
EXPORTER.setServiceName("testRemoteHandler");
|
||||
EXPORTER.setRegistryPort(rmiPort);
|
||||
EXPORTER.setRegistryPort(RMI_PORT);
|
||||
EXPORTER.afterPropertiesSet();
|
||||
|
||||
GATEWAY = new RmiOutboundGateway("rmi://localhost:" + rmiPort + "/testRemoteHandler");
|
||||
GATEWAY = new RmiOutboundGateway("rmi://localhost:" + RMI_PORT + "/testRemoteHandler");
|
||||
GATEWAY.setOutputChannel(OUTPUT);
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ public class RmiOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
void invalidServiceName() {
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://localhost:1099/noSuchService");
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://localhost:" + RMI_PORT + "/noSuchService");
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> gateway.handleMessage(new GenericMessage<>("test")))
|
||||
.withCauseInstanceOf(RemoteLookupFailureException.class);
|
||||
@@ -136,7 +138,7 @@ public class RmiOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
void invalidUrl() {
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("invalid");
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("http://sample.com/");
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> gateway.handleMessage(new GenericMessage<>("test")))
|
||||
.withCauseInstanceOf(RemoteLookupFailureException.class);
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
@@ -40,6 +41,7 @@ import org.springframework.util.ErrorHandler;
|
||||
* @since 1.0.3
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class DefaultConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user