diff --git a/build.gradle b/build.gradle index 788740f978..5b116c30df 100644 --- a/build.gradle +++ b/build.gradle @@ -194,8 +194,7 @@ configure(javaProjects) { subproject -> } compileJava { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + options.release = 8 } compileTestJava { @@ -222,6 +221,12 @@ configure(javaProjects) { subproject -> options.fork = true } + + tasks.withType(Javadoc) { + options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint + options.addBooleanOption('Werror', true) // fail build on Javadoc warnings + } + eclipse { project { natures += 'org.springframework.ide.eclipse.core.springnature' @@ -996,6 +1001,7 @@ task api(type: Javadoc) { options.overview = 'src/api/overview.html' options.stylesheetFile = file('src/api/stylesheet.css') options.links(project.ext.javadocLinks) + options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint source javaProjects.collect { project -> project.sourceSets.main.allJava } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java index 7666889525..b2dcbbf123 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -124,16 +124,7 @@ public class FileInboundChannelAdapterParserTests { Object priorityQueue = accessor.getPropertyValue("toBeReceived"); assertThat(priorityQueue).isInstanceOf(PriorityBlockingQueue.class); Object expected = context.getBean("testComparator"); - DirectFieldAccessor queueAccessor = new DirectFieldAccessor(priorityQueue); - Object innerQueue = queueAccessor.getPropertyValue("q"); - Object actual; - if (innerQueue != null) { - actual = new DirectFieldAccessor(innerQueue).getPropertyValue("comparator"); - } - else { - // probably running under JDK 7 - actual = queueAccessor.getPropertyValue("comparator"); - } + Object actual = ((PriorityBlockingQueue) priorityQueue).comparator(); assertThat(actual).as("comparator reference not set, ").isSameAs(expected); } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/splitter/FileSplitterTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/splitter/FileSplitterTests.java index e0a629d4fb..f19ab5f5ed 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/splitter/FileSplitterTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/splitter/FileSplitterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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. @@ -32,6 +32,7 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Date; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -380,14 +381,21 @@ public class FileSplitterTests { }); FileSplitter splitter = new FileSplitter(true, true); splitter.setOutputChannel(outputChannel); - FileReader fileReader = Mockito.spy(new FileReader(file)); + AtomicBoolean closeCalled = new AtomicBoolean(); + FileReader fileReader = new FileReader(file) { + + @Override public void close() throws IOException { + super.close(); + closeCalled.set(true); + } + }; try { splitter.handleMessage(new GenericMessage<>(fileReader)); } catch (RuntimeException e) { // ignore } - Mockito.verify(fileReader).close(); + assertThat(closeCalled.get()).isTrue(); } @Configuration diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java index 2912f33119..a9cbe81094 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -18,10 +18,7 @@ package org.springframework.integration.file.tail; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import java.io.File; import java.io.FileOutputStream; @@ -30,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -156,7 +154,19 @@ public class FileTailingMessageProducerTests { } }); - File file = spy(new File(this.testDir, "foo")); + AtomicBoolean existsCalled = new AtomicBoolean(); + File file = new File(this.testDir, "foo") { + + @Override + public boolean exists() { + try { + return super.exists(); + } + finally { + existsCalled.set(true); + } + } + }; file.delete(); adapter.setFile(file); @@ -169,7 +179,7 @@ public class FileTailingMessageProducerTests { assertThat(noFile).as("file does not exist event did not emit ").isTrue(); boolean noEvent = idleCountDownLatch.await(100, TimeUnit.MILLISECONDS); assertThat(noEvent).as("event should not emit when no file exit").isFalse(); - verify(file, atLeastOnce()).exists(); + assertThat(existsCalled.get()).isTrue(); file.createNewFile(); boolean eventRaised = idleCountDownLatch.await(10, TimeUnit.SECONDS); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java index f33bf2d1de..78d4648036 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -18,7 +18,6 @@ package org.springframework.integration.ip.dsl; import static org.assertj.core.api.Assertions.assertThat; -import java.net.DatagramSocket; import java.util.Collections; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -181,8 +180,6 @@ public class IpIntegrationTests { Message received = this.udpIn.receive(10000); assertThat(received).isNotNull(); assertThat(Transformers.objectToString().transform(received).getPayload()).isEqualTo("foo"); - assertThat(TestUtils.getPropertyValue(this.udpOutbound, "socket", DatagramSocket.class).getTrafficClass()) - .isEqualTo(0x10); } @Test @@ -202,7 +199,7 @@ public class IpIntegrationTests { @Test void testCloseStream() throws InterruptedException { IntegrationFlow server = IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(0) - .deserializer(new ByteArrayRawSerializer()))) + .deserializer(new ByteArrayRawSerializer()))) .transform(p -> "reply:" + new String(p).toUpperCase()) .get(); CountDownLatch latch = new CountDownLatch(1); @@ -223,8 +220,8 @@ public class IpIntegrationTests { assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue(); IntegrationFlow client = IntegrationFlows.from(MessageChannels.direct()) .handle(Tcp.outboundGateway(Tcp.netClient("localhost", port.get()) - .singleUseConnections(true) - .serializer(new ByteArrayRawSerializer())) + .singleUseConnections(true) + .serializer(new ByteArrayRawSerializer())) .remoteTimeout(20_000) .closeStreamAfterSend(true)) .transform(Transformers.objectToString()) @@ -262,10 +259,10 @@ public class IpIntegrationTests { @Bean public IntegrationFlow inTcpGateway() { return IntegrationFlows.from( - Tcp.inboundGateway(server1()) - .replyTimeout(1) - .errorOnTimeout(true) - .errorChannel("inTcpGatewayErrorFlow.input")) + Tcp.inboundGateway(server1()) + .replyTimeout(1) + .errorOnTimeout(true) + .errorChannel("inTcpGatewayErrorFlow.input")) .handle(this, "captureId") .transform(Transformers.objectToString()) .filter((payload) -> !"junk".equals(payload)) diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundChannelAdapterParserTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundChannelAdapterParserTests.java index 283d6cf9f3..8e998913a0 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundChannelAdapterParserTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -18,10 +18,9 @@ package org.springframework.integration.mongodb.config; import static org.assertj.core.api.Assertions.assertThat; -import java.util.List; - import org.junit.Test; +import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -33,6 +32,7 @@ import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice; import org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.MessageHandler; + /** * @author Oleg Zhurakousky * @author Artem Bilan @@ -129,9 +129,7 @@ public class MongoDbOutboundChannelAdapterParserTests { assertThat(endpoint).isInstanceOf(PollingConsumer.class); MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class); assertThat(AopUtils.isAopProxy(handler)).isTrue(); - List advisors = TestUtils.getPropertyValue(handler, "h.advised.advisors", List.class); - assertThat(TestUtils.getPropertyValue(advisors.get(0), "advice")).isInstanceOf(RequestHandlerRetryAdvice.class); - context.close(); + assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class); } } diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java index 2adafba433..9b16457368 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -89,8 +89,7 @@ public class MqttOutboundChannelAdapterParserTests { assertThat(this.withConverterHandler).isSameAs(((Advised) handler).getTargetSource().getTarget()); - assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice")) - .isInstanceOf(RequestHandlerRetryAdvice.class); + assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class); } @Test diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java index d62844bfac..e6fbe5822c 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -86,8 +86,7 @@ public class RedisQueueOutboundChannelAdapterParserTests { assertThat(this.defaultAdapter).isSameAs(((Advised) handler).getTargetSource().getTarget()); - assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice")) - .isInstanceOf(RequestHandlerRetryAdvice.class); + assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class); assertThat(TestUtils.getPropertyValue(this.defaultAdapter, "leftPush", Boolean.class)).isTrue(); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java index 8d793efeb9..bf5a6405f7 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2019 the original author or authors. + * Copyright 2007-2022 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,8 +72,7 @@ public class RedisStoreOutboundChannelAdapterParserTests { assertThat(withStringTemplate).isSameAs(((Advised) handler).getTargetSource().getTarget()); - assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice")) - .isInstanceOf(RequestHandlerRetryAdvice.class); + assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class); assertThat(TestUtils.getPropertyValue(withStringTemplate, "zsetIncrementScoreExpression", Expression.class).getExpressionString()).isEqualTo("true");