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

Support Java 14 #3310

Merged
merged 3 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ ext {
h2Version = '1.4.200'
jacksonVersion = '2.11.0'
javaxActivationVersion = '1.2.0'
javaxAnnotationVersion= '1.3.2'
javaxMailVersion = '1.6.2'
jaxbVersion = '2.3.3'
jmsApiVersion = '2.0.1'
jpa21ApiVersion = '1.0.2.Final'
jpaApiVersion = '2.2.1'
Expand All @@ -90,8 +92,10 @@ ext {
resilience4jVersion = '1.4.0'
romeToolsVersion = '1.12.2'
rsocketVersion = '1.0.0'
saajVersion = '1.5.2'
servletApiVersion = '4.0.1'
smackVersion = '4.3.4'
soapVersion = '1.4.0'
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.0-SNAPSHOT'
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.0-SNAPSHOT'
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.4.0-SNAPSHOT'
Expand Down Expand Up @@ -231,6 +235,7 @@ configure(javaProjects) { subproject ->
testImplementation 'io.projectreactor:reactor-test'
testImplementation "com.jayway.jsonpath:json-path:$jsonpathVersion"
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
testImplementation "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"

// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
Expand Down Expand Up @@ -314,6 +319,8 @@ configure(javaProjects) { subproject ->
environment 'SI_FATAL_WHEN_NO_BEANFACTORY', 'true'

useJUnitPlatform()

enableAssertions = false
}

checkstyle {
Expand Down Expand Up @@ -774,6 +781,11 @@ project('spring-integration-ws') {
exclude group: 'org.springframework'
}

optionalApi "javax.activation:javax.activation-api:$javaxActivationVersion"
providedImplementation "javax.xml.soap:javax.xml.soap-api:$soapVersion"
providedImplementation "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
providedImplementation "com.sun.xml.messaging.saaj:saaj-impl:$saajVersion"

testImplementation "com.thoughtworks.xstream:xstream:$xstreamVersion"
testImplementation ("org.springframework.ws:spring-ws-support:$springWsVersion") {
exclude group: 'org.springframework'
Expand Down Expand Up @@ -801,6 +813,8 @@ project('spring-integration-xml') {
optionalApi ("org.springframework.ws:spring-ws-core:$springWsVersion") {
exclude group: 'org.springframework'
}

testImplementation "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void fromHeaders() {
assertThat(amqpProperties.getDeliveryMode()).isEqualTo(MessageDeliveryMode.NON_PERSISTENT);
assertThat(amqpProperties.getDeliveryTag()).isEqualTo(1234L);
assertThat(amqpProperties.getExpiration()).isEqualTo("test.expiration");
assertThat(amqpProperties.getMessageCount()).isEqualTo(new Integer(42));
assertThat(amqpProperties.getMessageCount()).isEqualTo(42);
assertThat(amqpProperties.getMessageId()).isEqualTo("test.messageId");
assertThat(amqpProperties.getReceivedExchange()).isEqualTo("test.receivedExchange");
assertThat(amqpProperties.getReceivedRoutingKey()).isEqualTo("test.receivedRoutingKey");
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.function.Function;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.core.ResolvableType;
import org.springframework.integration.channel.DirectChannel;
Expand Down Expand Up @@ -55,14 +56,9 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be

@SuppressWarnings("unchecked")
protected EndpointSpec(H handler) {
try {
Class<?> fClass = ResolvableType.forClass(this.getClass()).as(EndpointSpec.class).resolveGenerics()[1];
this.endpointFactoryBean = (F) fClass.newInstance();
this.handler = handler;
}
catch (Exception e) {
throw new IllegalStateException(e);
}
Class<?> fClass = ResolvableType.forClass(this.getClass()).as(EndpointSpec.class).resolveGenerics()[1];
this.endpointFactoryBean = (F) BeanUtils.instantiateClass(fClass);
this.handler = handler;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ protected IntegrationFlowDefinition<?> from(MessagingGatewaySpec<?, ?> inboundGa
return IntegrationFlows.from(inboundGatewaySpec);
}

protected <T> IntegrationFlowBuilder from(Supplier<T> messageSource) {
return IntegrationFlows.from(messageSource);
protected <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource) {
return IntegrationFlows.fromSupplier(messageSource);
}

protected <T> IntegrationFlowBuilder from(Supplier<T> messageSource,
protected <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource,
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {

return IntegrationFlows.from(messageSource, endpointConfigurer);
return IntegrationFlows.fromSupplier(messageSource, endpointConfigurer);
}

protected IntegrationFlowBuilder from(Class<?> serviceInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends Message
* @return new {@link IntegrationFlowBuilder}.
* @see Supplier
*/
public static <T> IntegrationFlowBuilder from(Supplier<T> messageSource) {
return from(messageSource, null);
public static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource) {
return fromSupplier(messageSource, null);
}

/**
Expand All @@ -156,7 +156,7 @@ public static <T> IntegrationFlowBuilder from(Supplier<T> messageSource) {
* @return new {@link IntegrationFlowBuilder}.
* @see Supplier
*/
public static <T> IntegrationFlowBuilder from(Supplier<T> messageSource,
public static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource,
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {

Assert.notNull(messageSource, "'messageSource' must not be null");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -27,7 +27,7 @@
* <p>
* The BridgeHandler can be used as a stopper at the end of an assembly line of
* channels. In this setup the output channel doesn't have to be set, but if the
* output channel is omitted the <tt>REPLY_CHANNEL</tt> MUST be set on the
* output channel is omitted the {@code REPLY_CHANNEL} MUST be set on the
* message. Otherwise, a MessagingException will be thrown at runtime.
*
* @author Mark Fisher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -52,8 +52,8 @@ public interface MetadataStore {
/**
* Remove a value for the given key from this MetadataStore.
* @param key The key.
* @return The previous value associated with <tt>key</tt>, or
* <tt>null</tt> if there was no mapping for <tt>key</tt>.
* @return The previous value associated with key, or
* null if there was no mapping for key.
*/
@ManagedAttribute
String remove(String key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun integrationFlow(messageSource: MessageSourceSpec<*, out MessageSource<*>>,
fun integrationFlow(source: () -> Any,
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
buildIntegrationFlow(IntegrationFlows.from(source, options), flow)
buildIntegrationFlow(IntegrationFlows.fromSupplier(source, options), flow)

/**
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -63,13 +63,13 @@ public void defaultScheduler() {
DelayHandler delayHandler = context.getBean("delayerWithDefaultScheduler.handler", DelayHandler.class);
assertThat(delayHandler.getOrder()).isEqualTo(99);
assertThat(delayHandler.getOutputChannel()).isSameAs(this.context.getBean("output"));
assertThat(TestUtils.getPropertyValue(delayHandler, "defaultDelay", Long.class)).isEqualTo(new Long(1234));
assertThat(TestUtils.getPropertyValue(delayHandler, "defaultDelay", Long.class)).isEqualTo(1234L);
//INT-2243
assertThat(TestUtils.getPropertyValue(delayHandler, "delayExpression")).isNotNull();
assertThat(TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString())
.isEqualTo("headers.foo");
assertThat(TestUtils.getPropertyValue(delayHandler, "messagingTemplate.sendTimeout", Long.class))
.isEqualTo(new Long(987));
.isEqualTo(987L);
assertThat(TestUtils.getPropertyValue(delayHandler, "taskScheduler")).isNull();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -159,7 +159,7 @@ public void priorityExplicitOverwriteTrue() {
template.setDefaultDestination(channel);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("test"));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(new Integer(42));
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(42);
}

@Test
Expand All @@ -173,7 +173,7 @@ public void priorityExplicitOverwriteFalse() {
input.send(message);
Message<?> result = replyChannel.receive(0);
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(new Integer(77));
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(77);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-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.
Expand All @@ -22,6 +22,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -137,7 +138,7 @@ public void expirationDateValue() {
MessageChannel channel = context.getBean("expirationDateValueInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<>("test"));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getExpirationDate()).isEqualTo(new Long(1111));
assertThat(new IntegrationMessageHeaderAccessor(result).getExpirationDate()).isEqualTo(1111L);
}

@Test
Expand All @@ -146,7 +147,7 @@ public void expirationDateRef() {
MessageChannel channel = context.getBean("expirationDateRefInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<>("test"));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getExpirationDate()).isEqualTo(new Long(9999));
assertThat(new IntegrationMessageHeaderAccessor(result).getExpirationDate()).isEqualTo(9999);
}

@Test
Expand All @@ -155,7 +156,7 @@ public void priority() {
MessageChannel channel = context.getBean("priorityInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<>("test"));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(new Integer(42));
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(42);
}

@Test
Expand All @@ -165,7 +166,7 @@ public void priorityExpression() {
Message<?> result = template.sendAndReceive(channel,
new GenericMessage<>(Collections.singletonMap("priority", "-10")));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(new Integer(-10));
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(-10);
}

@Test
Expand Down Expand Up @@ -300,7 +301,7 @@ public boolean equals(Object o) {

TestBean testBean = (TestBean) o;

return !(name != null ? !name.equals(testBean.name) : testBean.name != null);
return Objects.equals(name, testBean.name);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public Supplier<String> stringSupplier() {

@Bean
public IntegrationFlow supplierFlow() {
return IntegrationFlows.from(stringSupplier())
return IntegrationFlows.fromSupplier(stringSupplier())
.transform(toUpperCaseFunction())
.channel("suppliedChannel")
.get();
Expand Down Expand Up @@ -572,7 +572,8 @@ public static class SupplierContextConfiguration2 {

@Bean
public IntegrationFlow supplierFlow2() {
return IntegrationFlows.from(() -> "foo", c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1)))
return IntegrationFlows.fromSupplier(() -> "foo",
c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1)))
.<String, String>transform(String::toUpperCase)
.channel("suppliedChannel2")
.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,8 +25,7 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
Expand Down Expand Up @@ -60,15 +59,15 @@
import org.springframework.scheduling.TriggerContext;
import org.springframework.stereotype.Component;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.StringUtils;

/**
* @author Artem Bilan
*
* @since 5.0
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class FlowServiceTests {

Expand Down Expand Up @@ -174,7 +173,7 @@ private Date nextExecutionTime(TriggerContext triggerContext) {

@Override
protected IntegrationFlowDefinition<?> buildFlow() {
return from(this::messageSource, e -> e.poller(p -> p.trigger(this::nextExecutionTime)))
return fromSupplier(this::messageSource, e -> e.poller(p -> p.trigger(this::nextExecutionTime)))
.split(this, null, e -> e.applySequence(false))
.transform(this)
.aggregate(a -> a.processor(this, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanCreationNotAllowedException;
Expand Down Expand Up @@ -87,7 +86,7 @@
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.ReflectionUtils;

import reactor.core.publisher.Flux;
Expand All @@ -100,7 +99,7 @@
*/
@ContextConfiguration(loader = NoBeansOverrideAnnotationConfigContextLoader.class,
classes = ManualFlowTests.RootConfiguration.class)
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ManualFlowTests {

Expand Down Expand Up @@ -537,7 +536,7 @@ public void testBeanDefinitionInfoInTheException() {
.withCauseExactlyInstanceOf(IllegalStateException.class)
.withRootCauseInstanceOf(ClassCastException.class)
.withMessageContaining("from source: '" + source + "'")
.withStackTraceContaining("java.util.Date cannot be cast to java.lang.String");
.withStackTraceContaining("java.util.Date cannot be cast to");

flowRegistration.destroy();
}
Expand Down