diff --git a/build.gradle b/build.gradle index ee9036f6fe..3a5105cefa 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ subprojects { subproject -> ext { - activeMqVersion = '5.12.2' + activeMqVersion = '5.13.2' aspectjVersion = '1.8.9' apacheSshdVersion = '0.14.0' boonVersion = '0.33' @@ -96,11 +96,11 @@ subprojects { subproject -> commonsDbcpVersion = '1.4' commonsIoVersion = '2.4' commonsNetVersion = '3.4' - curatorVersion = '2.8.0' + curatorVersion = '3.1.0' derbyVersion = '10.11.1.1' eclipseLinkVersion = '2.5.2' ftpServerVersion = '1.0.6' - groovyVersion = '2.4.5' + groovyVersion = '2.4.6' guavaVersion = '19.0' hamcrestVersion = '1.3' hazelcastVersion = '3.6.1' @@ -127,28 +127,26 @@ subprojects { subproject -> openJpaVersion = '2.4.0' pahoMqttClientVersion = '1.0.2' postgresVersion = '9.1-901-1.jdbc4' - reactorVersion = '2.0.7.RELEASE' + reactorVersion = '2.0.8.RELEASE' romeToolsVersion = '1.5.0' - saajApiVersion = '1.3.5' - saajImplVersion = '1.3.23' servletApiVersion = '3.1.0' slf4jVersion = "1.7.21" tomcatVersion = "8.0.33" - smackVersion = '4.1.6' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.0.M2' + smackVersion = '4.1.7' + springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.0.BUILD-SNAPSHOT' // springCloudClusterVersion = '1.0.0.BUILD-SNAPSHOT' springDataJpaVersion = '1.10.1.RELEASE' springDataMongoVersion = '1.9.1.RELEASE' springDataRedisVersion = '1.7.1.RELEASE' springGemfireVersion = '1.8.1.RELEASE' springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '4.0.3.RELEASE' - springSocialTwitterVersion = '1.1.1.RELEASE' + springSocialTwitterVersion = '1.1.2.RELEASE' springRetryVersion = '1.1.2.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.0.RC1' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.0.BUILD-SNAPSHOT' springWsVersion = '2.3.0.RELEASE' xmlUnitVersion = '1.6' xstreamVersion = '1.4.7' - zookeeperVersion = '3.4.7' + zookeeperVersion = '3.4.8' } eclipse { @@ -682,9 +680,6 @@ project('spring-integration-ws') { testCompile "javax.mail:javax.mail-api:$javaxMailVersion" testRuntime "com.sun.mail:mailapi:$javaxMailVersion" } - - // suppress saaj path warnings - [compileJava,compileTestJava]*.options*.compilerArgs = ["${xLintArg},-path"] } project('spring-integration-xml') { diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java index bf79757063..d6105b62c6 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java @@ -398,7 +398,6 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean headerMap = headerMapper.toHeadersFromRequest(amqpProperties); - assertEquals("consumerTag", headerMap.get(AmqpHeaders.CONSUMER_TAG)); - assertEquals("consumerQueue", headerMap.get(AmqpHeaders.CONSUMER_QUEUE)); - } - catch (NoSuchMethodError e) { - // TODO: temporary for Spring IO Compatibility build - until Spring IO 1.1.x moves to amqp 1.4.2 - } + DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper(); + MessageProperties amqpProperties = new MessageProperties(); + amqpProperties.setConsumerTag("consumerTag"); + amqpProperties.setConsumerQueue("consumerQueue"); + Map headerMap = headerMapper.toHeadersFromRequest(amqpProperties); + assertEquals("consumerTag", headerMap.get(AmqpHeaders.CONSUMER_TAG)); + assertEquals("consumerQueue", headerMap.get(AmqpHeaders.CONSUMER_QUEUE)); } @Test diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java index fe9928a53a..2f56eea796 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java @@ -490,7 +490,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator "] has no eligible methods for handling Messages."); } catch (Exception e) { - //TODO backward compatibility + //TODO backward compatibility. Remove in 5.0 throw new IllegalArgumentException(e.getMessage()); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests-context.xml index 8e7823889f..783010b44f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests-context.xml @@ -34,11 +34,9 @@ - - - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests.java index ab44932c62..43fb980a5f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/SelectorChainParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2016 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. @@ -56,6 +56,7 @@ public class SelectorChainParserTests { assertEquals(selector1, selectors.get(0)); assertEquals(selector2, selectors.get(1)); assertTrue(chain.accept(new GenericMessage("test"))); + assertTrue(this.context.containsBean("pojoSelector")); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/MessagingGatewayTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/MessagingGatewayTests.java index de92be9adc..c54ff35af6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/MessagingGatewayTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/MessagingGatewayTests.java @@ -213,7 +213,6 @@ public class MessagingGatewayTests { } }).when(requestChannel).send(Mockito.any(Message.class), Mockito.anyLong()); - // TODO: commenting the next line causes the test to hang this.messagingGateway.setReplyTimeout(100L); Message receiveMessage = this.messagingGateway.sendAndReceiveMessage("test"); assertSame(messageMock, receiveMessage); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java index b87a95fc42..3997b6dd86 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java @@ -286,8 +286,7 @@ public class MethodInvokingMessageProcessorTests { @Test public void testProcessMessageBadExpression() throws Exception { - // TODO: should this be MessageHandlingException or NumberFormatException? - expected.expect(new ExceptionCauseMatcher(Exception.class)); + expected.expect(MessageHandlingException.class); AnnotatedTestService service = new AnnotatedTestService(); Method method = service.getClass().getMethod("integerMethod", Integer.class); MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method); diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourceIntegrationTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourceIntegrationTests-context.xml index 875d06b419..f0195e7bb4 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourceIntegrationTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourceIntegrationTests-context.xml @@ -1,9 +1,9 @@ + http://www.springframework.org/schema/beans/spring-beans.xsd"> - - diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourcePersistentFilterIntegrationTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourcePersistentFilterIntegrationTests-context.xml index 1292e3905a..2a61a92f27 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourcePersistentFilterIntegrationTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourcePersistentFilterIntegrationTests-context.xml @@ -1,9 +1,9 @@ + http://www.springframework.org/schema/beans/spring-beans.xsd"> - - diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/FileToChannelIntegrationTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/FileToChannelIntegrationTests-context.xml index ed00347878..15a962eead 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/FileToChannelIntegrationTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/FileToChannelIntegrationTests-context.xml @@ -1,13 +1,18 @@ + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> - - - + + + @@ -39,18 +47,17 @@ - - - + - + - + - + diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml index abd65444f1..28f2915745 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml @@ -3,12 +3,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration" + xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/file - http://www.springframework.org/schema/integration/file/spring-integration-file.xsd"> + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + - - diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests-context.xml index 21c376e596..f895f75c75 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests-context.xml @@ -1,16 +1,19 @@ + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> - + + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> - + diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithQueueSizeTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithQueueSizeTests-context.xml index a9b5651106..c496be2621 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithQueueSizeTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithQueueSizeTests-context.xml @@ -1,13 +1,19 @@ + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + - - diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithRegexPatternParserTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithRegexPatternParserTests-context.xml index 36dab1d7be..286404dfdc 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithRegexPatternParserTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithRegexPatternParserTests-context.xml @@ -1,16 +1,19 @@ + http://www.springframework.org/schema/integration/file/spring-integration-file.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> - + - - - \ No newline at end of file + diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/recursive/FileInboundChannelAdapterWithRecursiveDirectoryTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/recursive/FileInboundChannelAdapterWithRecursiveDirectoryTests-context.xml index b35cc91a0b..250da45178 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/recursive/FileInboundChannelAdapterWithRecursiveDirectoryTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/recursive/FileInboundChannelAdapterWithRecursiveDirectoryTests-context.xml @@ -10,8 +10,6 @@ http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd"> - - received = Arrays.asList((Message) files.receive(), files.receive()); - //verify - //TODO assertThat(received, hasItems(hasPayload(siblingFile), hasPayload(childFile))); + assertThat(received, containsInAnyOrder(hasPayload(siblingFile), hasPayload(childFile))); } + } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformerTests.java index bc90e8b8a9..2d9320ccc3 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 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. @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.springframework.integration.test.matcher.HeaderMatcher; import org.springframework.messaging.Message; import org.springframework.integration.file.FileHeaders; import org.springframework.integration.support.MessageBuilder; @@ -35,6 +36,7 @@ import org.springframework.util.FileCopyUtils; /** * @author Alex Peters + * @author Artem Bilan */ public abstract class AbstractFilePayloadTransformerTests> { @@ -72,17 +74,14 @@ public abstract class AbstractFilePayloadTransformerTests result = transformer.transform(message); assertThat(result, is(notNullValue())); - // TODO: refactor to header matcher - assertThat(result.getHeaders().get(anyKey, String.class), is(anyValue)); + assertThat(result, HeaderMatcher.hasHeader(anyKey, anyValue)); } @Test public void transform_withFilePayload_filenameInHeaders() throws Exception { Message result = transformer.transform(message); assertThat(result, is(notNullValue())); - // TODO: refactor to header matcher - assertThat(result.getHeaders().get(FileHeaders.FILENAME, String.class), - is(sourceFile.getName())); + assertThat(result, HeaderMatcher.hasHeader(FileHeaders.FILENAME, sourceFile.getName())); } @Test diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToByteArrayTransformerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToByteArrayTransformerTests.java index ca6629ff59..3ebc7c1844 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToByteArrayTransformerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToByteArrayTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -20,6 +20,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; +import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload; import org.junit.Before; import org.junit.Test; @@ -29,6 +30,7 @@ import org.springframework.messaging.Message; /** * @author Alex Peters * @author Gunnar Hillert + * @author Artem Bilan */ public class FileToByteArrayTransformerTests extends AbstractFilePayloadTransformerTests { @@ -42,9 +44,9 @@ public class FileToByteArrayTransformerTests extends public void transform_withFilePayload_convertedToByteArray() throws Exception { Message result = transformer.transform(message); assertThat(result, is(notNullValue())); - // TODO: refactor to payload matcher - assertThat(result.getPayload(), is(instanceOf(byte[].class))); - assertThat((byte[]) result.getPayload(), is(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING))); + + assertThat(result, hasPayload(is(instanceOf(byte[].class)))); + assertThat(result, hasPayload(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING))); } } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToStringTransformerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToStringTransformerTests.java index 3193f16af0..bc0ddf5522 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToStringTransformerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToStringTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 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,9 +18,10 @@ package org.springframework.integration.file.transformer; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; +import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload; import org.junit.Before; import org.junit.Test; @@ -29,6 +30,7 @@ import org.springframework.messaging.Message; /** * @author Alex Peters + * @author Artem Bilan */ public class FileToStringTransformerTests extends AbstractFilePayloadTransformerTests { @@ -43,9 +45,8 @@ public class FileToStringTransformerTests extends public void transform_withFilePayload_convertedToString() throws Exception { Message result = transformer.transform(message); assertThat(result, is(notNullValue())); - // TODO: refactor to payload matcher - assertThat(result.getPayload(), is(instanceOf(String.class))); - assertThat((String) result.getPayload(), is(SAMPLE_CONTENT)); + assertThat(result, hasPayload(instanceOf(String.class))); + assertThat(result, hasPayload(SAMPLE_CONTENT)); } @Test @@ -53,9 +54,8 @@ public class FileToStringTransformerTests extends transformer.setCharset("ISO-8859-1"); Message result = transformer.transform(message); assertThat(result, is(notNullValue())); - // TODO: refactor to payload matcher - assertThat(result.getPayload(), is(instanceOf(String.class))); - assertThat((String) result.getPayload(), is(not(SAMPLE_CONTENT))); + assertThat(result, hasPayload(instanceOf(String.class))); + assertThat(result, hasPayload(not(SAMPLE_CONTENT))); } } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/multipart/SimpleMultipartFileReader.java b/spring-integration-http/src/main/java/org/springframework/integration/http/multipart/SimpleMultipartFileReader.java index 89c8f9b25d..419e14e950 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/multipart/SimpleMultipartFileReader.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/multipart/SimpleMultipartFileReader.java @@ -51,8 +51,7 @@ public class SimpleMultipartFileReader implements MultipartFileReader { public Object readMultipartFile(MultipartFile multipartFile) throws IOException { if (multipartFile.getContentType() != null && multipartFile.getContentType().startsWith("text")) { MediaType contentType = MediaType.parseMediaType(multipartFile.getContentType()); - // TODO there is no yet in the SF-4.3.RC1 a MediaType.getCharset() method - Charset charset = contentType.getCharSet(); + Charset charset = contentType.getCharset(); if (charset == null) { charset = this.defaultCharset; } diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/CrossOriginTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/CrossOriginTests.java index ced4ccafaf..1126404aa8 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/CrossOriginTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/CrossOriginTests.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Before; import org.junit.Test; @@ -37,8 +36,6 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.util.ClassUtils; -import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerExecutionChain; @@ -53,11 +50,6 @@ import org.springframework.web.servlet.HandlerInterceptor; @DirtiesContext public class CrossOriginTests { - // SPR-13130 - private static boolean isSpring43 = - ClassUtils.isPresent("org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping$HttpOptionsHandler", - CrossOriginTests.class.getClassLoader()); - @Autowired private IntegrationRequestMappingHandlerMapping handlerMapping; @@ -101,10 +93,10 @@ public class CrossOriginTests { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); CorsConfiguration config = getCorsConfiguration(chain, false); assertNotNull(config); - assertArrayEquals(new String[]{"GET"}, config.getAllowedMethods().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray()); + assertArrayEquals(new String[] { "GET" }, config.getAllowedMethods().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray()); assertTrue(config.getAllowCredentials()); - assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray()); assertNull(config.getExposedHeaders()); assertEquals(new Long(1800), config.getMaxAge()); } @@ -115,10 +107,10 @@ public class CrossOriginTests { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); CorsConfiguration config = getCorsConfiguration(chain, false); assertNotNull(config); - assertArrayEquals(new String[]{"DELETE"}, config.getAllowedMethods().toArray()); - assertArrayEquals(new String[]{"http://site1.com", "http://site2.com"}, config.getAllowedOrigins().toArray()); - assertArrayEquals(new String[]{"header1", "header2"}, config.getAllowedHeaders().toArray()); - assertArrayEquals(new String[]{"header3", "header4"}, config.getExposedHeaders().toArray()); + assertArrayEquals(new String[] { "DELETE" }, config.getAllowedMethods().toArray()); + assertArrayEquals(new String[] { "http://site1.com", "http://site2.com" }, config.getAllowedOrigins().toArray()); + assertArrayEquals(new String[] { "header1", "header2" }, config.getAllowedHeaders().toArray()); + assertArrayEquals(new String[] { "header3", "header4" }, config.getExposedHeaders().toArray()); assertEquals(new Long(123), config.getMaxAge()); assertEquals(false, config.getAllowCredentials()); } @@ -131,10 +123,10 @@ public class CrossOriginTests { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); CorsConfiguration config = getCorsConfiguration(chain, true); assertNotNull(config); - assertArrayEquals(new String[]{"GET"}, config.getAllowedMethods().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray()); + assertArrayEquals(new String[] { "GET" }, config.getAllowedMethods().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray()); assertTrue(config.getAllowCredentials()); - assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray()); assertNull(config.getExposedHeaders()); assertEquals(new Long(1800), config.getMaxAge()); } @@ -148,9 +140,9 @@ public class CrossOriginTests { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); CorsConfiguration config = getCorsConfiguration(chain, true); assertNotNull(config); - assertArrayEquals(new String[]{"*"}, config.getAllowedMethods().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedMethods().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray()); assertTrue(config.getAllowCredentials()); assertNull(config.getExposedHeaders()); assertNull(config.getMaxAge()); @@ -164,9 +156,9 @@ public class CrossOriginTests { HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request); CorsConfiguration config = getCorsConfiguration(chain, true); assertNotNull(config); - assertArrayEquals(new String[]{"*"}, config.getAllowedMethods().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray()); - assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedMethods().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray()); + assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray()); assertTrue(config.getAllowCredentials()); assertNull(config.getExposedHeaders()); assertNull(config.getMaxAge()); @@ -176,23 +168,13 @@ public class CrossOriginTests { public void testOptionsHeaderHandling() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/default"); request.addHeader(HttpHeaders.ORIGIN, "http://domain2.com"); - try { - HandlerExecutionChain handler = this.handlerMapping.getHandler(request); - if (isSpring43) { - // SPR-13130 - assertNotNull(handler); - Object handlerMethod = handler.getHandler(); - assertNotNull(handlerMethod); - assertThat(handlerMethod, instanceOf(HandlerMethod.class)); - assertThat(((HandlerMethod) handlerMethod).getBeanType().getName(), - containsString("HttpOptionsHandler")); - return; - } - fail("HttpRequestMethodNotSupportedException expected"); - } - catch (Exception e) { - assertThat(e, instanceOf(HttpRequestMethodNotSupportedException.class)); - } + HandlerExecutionChain handler = this.handlerMapping.getHandler(request); + assertNotNull(handler); + Object handlerMethod = handler.getHandler(); + assertNotNull(handlerMethod); + assertThat(handlerMethod, instanceOf(HandlerMethod.class)); + assertThat(((HandlerMethod) handlerMethod).getBeanType().getName(), + containsString("HttpOptionsHandler")); } private CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) { diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerParserTests-context.xml b/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerParserTests-context.xml index 5899d9f527..685ee9e609 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerParserTests-context.xml +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerParserTests-context.xml @@ -4,19 +4,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" - xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - - - diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerTests.java index f56bba77ed..55ef914316 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/management/IntegrationGraphControllerTests.java @@ -34,10 +34,8 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.integration.channel.DirectChannel; @@ -147,12 +145,6 @@ public class IntegrationGraphControllerTests { @EnableIntegrationGraphController(path = "/testIntegration") public static class ContextConfiguration { - // TODO SF-4.3.RC1 compatibility. See https://jira.spring.io/browse/SPR-14140 - @Bean - public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - return new PropertySourcesPlaceholderConfigurer(); - } - } } diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java index 75fa99a62c..0ca4705550 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -79,7 +80,9 @@ import org.springframework.web.client.RestTemplate; public class HttpRequestExecutingMessageHandlerTests { public static ParameterizedTypeReference> testParameterizedTypeReference() { - return new ParameterizedTypeReference>() { }; + return new ParameterizedTypeReference>() { + + }; } @Test @@ -637,8 +640,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void contentTypeIsNotSetForGetRequest() throws Exception { // GET - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( - "http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = + new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.GET); @@ -646,59 +649,54 @@ public class HttpRequestExecutingMessageHandlerTests { handler.afterPropertiesSet(); Message message = MessageBuilder.withPayload(mock(Source.class)).build(); - Exception exception = null; try { handler.handleMessage(message); + fail("An Exception expected"); } catch (Exception e) { - exception = e; + assertEquals("intentional", e.getCause().getMessage()); + assertNull(template.lastRequestEntity.get().getHeaders().getContentType()); } - assertEquals("intentional", exception.getCause().getMessage()); - HttpEntity request = template.lastRequestEntity.get(); - assertNull(request.getHeaders().getContentType()); - /* - * TODO: reconsider the inclusion of content-type for various HttpMethods (only - * ignoring for GET as of 2.0.5) uncomment code below accordingly (see INT-1951) - */ + //HEAD + handler.setHttpMethod(HttpMethod.HEAD); - /* - * //HEAD handler = new HttpRequestExecutingMessageHandler( - * "http://www.springsource.org/spring-integration"); template = new - * MockRestTemplate(); new - * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - * handler.setHttpMethod(HttpMethod.HEAD); - * - * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = - * null; try { handler.handleMessage(message); } catch (Exception e) { exception = - * e; } assertEquals("intentional", exception.getCause().getMessage()); request = - * template.lastRequestEntity.get(); - * assertNull(request.getHeaders().getContentType()); - * - * //DELETE handler = new HttpRequestExecutingMessageHandler( - * "http://www.springsource.org/spring-integration"); template = new - * MockRestTemplate(); new - * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - * handler.setHttpMethod(HttpMethod.DELETE); - * - * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = - * null; try { handler.handleMessage(message); } catch (Exception e) { exception = - * e; } assertEquals("intentional", exception.getCause().getMessage()); request = - * template.lastRequestEntity.get(); - * assertNull(request.getHeaders().getContentType()); - * - * //TRACE handler = new HttpRequestExecutingMessageHandler( - * "http://www.springsource.org/spring-integration"); template = new - * MockRestTemplate(); new - * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - * handler.setHttpMethod(HttpMethod.TRACE); - * - * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = - * null; try { handler.handleMessage(message); } catch (Exception e) { exception = - * e; } assertEquals("intentional", exception.getCause().getMessage()); request = - * template.lastRequestEntity.get(); - * assertNull(request.getHeaders().getContentType()); - */ + message = MessageBuilder.withPayload(mock(Source.class)).build(); + try { + handler.handleMessage(message); + fail("An Exception expected"); + } + catch (Exception e) { + assertEquals("intentional", e.getCause().getMessage()); + assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType()); + } + + + //DELETE + handler.setHttpMethod(HttpMethod.DELETE); + + message = MessageBuilder.withPayload(mock(Source.class)).build(); + try { + handler.handleMessage(message); + fail("An Exception expected"); + } + catch (Exception e) { + assertEquals("intentional", e.getCause().getMessage()); + assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType()); + } + + //TRACE + handler.setHttpMethod(HttpMethod.TRACE); + + message = MessageBuilder.withPayload(mock(Source.class)).build(); + try { + handler.handleMessage(message); + fail("An Exception expected"); + } + catch (Exception e) { + assertEquals("intentional", e.getCause().getMessage()); + assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType()); + } } @Test // INT-2275 diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelIntegrationTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelIntegrationTests-context.xml index 947f5c8a28..9de7188e78 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelIntegrationTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelIntegrationTests-context.xml @@ -1,72 +1,70 @@ + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + - - + + - + - + - - - + + + - + - + + input-channel="input" output-channel="output" + xmlns="http://www.springframework.org/schema/integration"> + class="org.springframework.integration.jdbc.JdbcMessageStoreChannelIntegrationTests$Service"/> - - + + - + - + - - - - - - + - + class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelOnePollerIntegrationTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelOnePollerIntegrationTests-context.xml index bea371c7b6..583f07ce63 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelOnePollerIntegrationTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelOnePollerIntegrationTests-context.xml @@ -1,16 +1,17 @@ + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> @@ -50,14 +51,10 @@ - - - - - - + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml index a6721e85d0..4bc2294e0e 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml @@ -1,12 +1,16 @@ + http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> @@ -42,12 +46,10 @@ - - - - - - + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreTests-context.xml index 26bb28c8e1..8d8db79285 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreTests-context.xml @@ -1,26 +1,26 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - + + - - - - - - + - + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml index 46144dec2d..4ff7bcdaef 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml @@ -1,18 +1,20 @@ + http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> @@ -28,12 +30,10 @@ - - - - - - + diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessagingGatewaySupportRegistrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessagingGatewaySupportRegistrationTests.java index d9c0020bb8..870c931af3 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessagingGatewaySupportRegistrationTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessagingGatewaySupportRegistrationTests.java @@ -66,8 +66,7 @@ public class MessagingGatewaySupportRegistrationTests { @Configuration @EnableIntegration - // TODO INT-3869 - @EnableIntegrationMBeanExport(server = "server") + @EnableIntegrationMBeanExport public static class ContextConfiguration { @Bean @@ -101,7 +100,7 @@ public class MessagingGatewaySupportRegistrationTests { } @Bean - public MBeanServerFactoryBean server() { + public static MBeanServerFactoryBean server() { MBeanServerFactoryBean fb = new MBeanServerFactoryBean(); fb.setLocateExistingServerIfPossible(true); return fb; diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml index 36b451f8c4..b8f86acf25 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml @@ -3,18 +3,11 @@ xmlns="http://www.springframework.org/schema/integration" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" - xmlns:util="http://www.springframework.org/schema/util" - xmlns:tool="http://www.springframework.org/schema/tool" - xmlns:lang="http://www.springframework.org/schema/lang" xmlns:sftp="http://www.springframework.org/schema/integration/sftp" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd - http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd - http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd"> @@ -38,69 +31,69 @@ + session-factory="sftpSessionFactory" + channel="requestChannel" + filename-regex="f[o]+\.txt" + remote-directory-expression="'/foo'" + local-directory="file:local-test-dir" + auto-create-local-directory="false" + remote-file-separator="." + local-filename-generator-expression="#this.toUpperCase() + '.a'" + temporary-file-suffix=".bar" + comparator="comparator" + local-filter="acceptAllFilter" + delete-remote-files="${delete.remote.files}" + preserve-timestamp="true"> - + - + - + + channel="requestChannel" + session-factory="sftpSessionFactory" + filter="filter" + remote-directory="/foo" + local-directory="file:local-test-dir" + auto-create-local-directory="true" + delete-remote-files="false"> + session-factory="sftpSessionFactory" + channel="requestChannel" + filename-pattern="pattern" + remote-directory="/foo" + local-directory="file:local-test-dir" + auto-create-local-directory="false" + delete-remote-files="false"> + session-factory="sftpSessionFactory" + channel="requestChannel" + filename-pattern="pattern" + remote-directory="/foo" + local-directory="file:foo" + auto-create-local-directory="true" + delete-remote-files="false"> @@ -109,16 +102,16 @@ + session-factory="sftpSessionFactory" + filter="filter" + remote-directory="/foo" + local-directory="file:foo" + auto-create-local-directory="false" + delete-remote-files="false"> - + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java index 9248544b53..ab1ca39a13 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java @@ -16,10 +16,12 @@ package org.springframework.integration.sftp.config; +import static org.hamcrest.Matchers.hasItem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.File; @@ -29,7 +31,6 @@ import java.util.concurrent.PriorityBlockingQueue; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.BeanCreationException; @@ -79,11 +80,13 @@ public class InboundChannelAdapterParserTests { (SftpInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source"); assertNotNull(source); - PriorityBlockingQueue blockingQueue = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class); + PriorityBlockingQueue blockingQueue = + TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class); Comparator comparator = blockingQueue.comparator(); assertNotNull(comparator); - SftpInboundFileSynchronizer synchronizer = (SftpInboundFileSynchronizer) TestUtils.getPropertyValue(source, "synchronizer"); + SftpInboundFileSynchronizer synchronizer = + TestUtils.getPropertyValue(source, "synchronizer", SftpInboundFileSynchronizer.class); assertEquals("'/foo'", TestUtils.getPropertyValue(synchronizer, "remoteDirectoryExpression", Expression.class) .getExpressionString()); assertNotNull(TestUtils.getPropertyValue(synchronizer, "localFilenameGeneratorExpression")); @@ -93,9 +96,12 @@ public class InboundChannelAdapterParserTests { assertNotNull(remoteFileSeparator); assertEquals(".", remoteFileSeparator); PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class); - assertNotNull(requestChannel.receive(2000)); + assertNotNull(requestChannel.receive(10000)); FileListFilter acceptAllFilter = context.getBean("acceptAllFilter", FileListFilter.class); - assertTrue(TestUtils.getPropertyValue(source, "fileSource.scanner.filter.fileFilters", Collection.class).contains(acceptAllFilter)); + @SuppressWarnings("unchecked") + Collection> filters = + TestUtils.getPropertyValue(source, "fileSource.scanner.filter.fileFilters", Collection.class); + assertThat(filters, hasItem(acceptAllFilter)); context.close(); } @@ -121,15 +127,6 @@ public class InboundChannelAdapterParserTests { new ClassPathXmlApplicationContext("InboundChannelAdapterParserTests-context-fail.xml", this.getClass()).close(); } - @Test @Ignore - public void testLocalFilesAreFound() throws Exception { - assertTrue(new File("target").exists()); - ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( - "InboundChannelAdapterParserTests-context.xml", this.getClass()); - assertTrue(new File("target").exists()); - context.close(); - } - @Test public void testLocalDirAutoCreated() throws Exception { assertFalse(new File("foo").exists()); diff --git a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceTests.java b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceTests.java index 99e66eb7fc..0d7afb142b 100644 --- a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceTests.java +++ b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceTests.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Properties; @@ -89,7 +88,8 @@ public class SearchReceivingMessageSourceTests { @Test public void testSearchReceivingMessageSourceInit() { - final SearchReceivingMessageSource messageSource = new SearchReceivingMessageSource(new TwitterTemplate("test"), "foo"); + final SearchReceivingMessageSource messageSource = + new SearchReceivingMessageSource(new TwitterTemplate("test"), "foo"); messageSource.setComponentName("twitterSearchMessageSource"); final Object metadataStore = TestUtils.getPropertyValue(messageSource, "metadataStore"); @@ -153,18 +153,11 @@ public class SearchReceivingMessageSourceTests { final SearchOperations so = mock(SearchOperations.class); - final Tweet tweet1 = new Tweet(1L, "1", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L, - "languageCode", "source"); - final Tweet tweet2 = new Tweet(2L, "2", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L, - "languageCode", "source"); - final Tweet tweet3 = new Tweet(3L, "3", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L, - "languageCode", "source"); - final List tweets = new ArrayList(); - tweets.add(tweet1); - tweets.add(tweet2); - tweets.add(tweet3); + tweets.add(mock(Tweet.class)); + tweets.add(mock(Tweet.class)); + tweets.add(mock(Tweet.class)); final SearchResults results = new SearchResults(tweets, new SearchMetadata(111, 111)); diff --git a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests.java b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests.java index ad25b16c1e..9a0f89925b 100644 --- a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests.java +++ b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -29,8 +30,6 @@ import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.junit.Before; import org.junit.Test; @@ -61,8 +60,6 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate; */ public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTests { - private final Log logger = LogFactory.getLog(getClass()); - private SourcePollingChannelAdapter twitterSearchAdapter; private AbstractTwitterMessageSource twitterMessageSource; @@ -143,21 +140,26 @@ public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTe } @Configuration - @ImportResource("classpath:org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml") + @ImportResource("org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml") static class SearchReceivingMessageSourceWithRedisTestsConfig { @Bean(name = "twitterTemplate") public TwitterTemplate twitterTemplate() { - final TwitterTemplate twitterTemplate = mock(TwitterTemplate.class); + TwitterTemplate twitterTemplate = mock(TwitterTemplate.class); - final SearchOperations so = mock(SearchOperations.class); + SearchOperations so = mock(SearchOperations.class); - final Tweet tweet3 = new Tweet(3L, "3", "first", new GregorianCalendar(2013, 2, 20).getTime(), "fromUser", - "profileImageUrl", 888L, 999L, "languageCode", "source"); - final Tweet tweet1 = new Tweet(1L, "1", "first", new GregorianCalendar(2013, 0, 20).getTime(), "fromUser", - "profileImageUrl", 888L, 999L, "languageCode", "source"); - final Tweet tweet2 = new Tweet(2L, "2", "first", new GregorianCalendar(2013, 1, 20).getTime(), "fromUser", - "profileImageUrl", 888L, 999L, "languageCode", "source"); + Tweet tweet3 = mock(Tweet.class); + given(tweet3.getId()).willReturn(3L); + given(tweet3.getCreatedAt()).willReturn(new GregorianCalendar(2013, 2, 20).getTime()); + + Tweet tweet1 = mock(Tweet.class); + given(tweet1.getId()).willReturn(1L); + given(tweet1.getCreatedAt()).willReturn(new GregorianCalendar(2013, 0, 20).getTime()); + + final Tweet tweet2 = mock(Tweet.class); + given(tweet2.getId()).willReturn(2L); + given(tweet2.getCreatedAt()).willReturn(new GregorianCalendar(2013, 1, 20).getTime()); final List tweets = new ArrayList(); diff --git a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGatewayTests.java b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGatewayTests.java index 8b4f0a8f73..2ca09099f1 100644 --- a/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGatewayTests.java +++ b/spring-integration-twitter/src/test/java/org/springframework/integration/twitter/outbound/TwitterSearchOutboundGatewayTests.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; import org.junit.Test; @@ -58,6 +57,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gary Russell + * @author Artem Bilan * @since 4.0 * */ @@ -77,7 +77,7 @@ public class TwitterSearchOutboundGatewayTests { @Test public void testStringQuery() { - Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz"); + Tweet tweet = mock(Tweet.class); SearchMetadata searchMetadata = mock(SearchMetadata.class); final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata); doAnswer(new Answer() { @@ -104,7 +104,7 @@ public class TwitterSearchOutboundGatewayTests { public void testStringQueryCustomLimit() { this.gateway.setSearchArgsExpression(new SpelExpressionParser() .parseExpression("{payload, 30}")); - Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz"); + Tweet tweet = mock(Tweet.class); SearchMetadata searchMetadata = mock(SearchMetadata.class); final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata); doAnswer(new Answer() { @@ -131,7 +131,7 @@ public class TwitterSearchOutboundGatewayTests { public void testStringQueryCustomExpression() { this.gateway.setSearchArgsExpression(new SpelExpressionParser() .parseExpression("{'bar', 1, 2, 3}")); - Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz"); + Tweet tweet = mock(Tweet.class); SearchMetadata searchMetadata = mock(SearchMetadata.class); final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata); doAnswer(new Answer() { @@ -158,7 +158,7 @@ public class TwitterSearchOutboundGatewayTests { @Test public void testSearchParamsQuery() { - Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz"); + Tweet tweet = mock(Tweet.class); SearchMetadata searchMetadata = mock(SearchMetadata.class); final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata); final SearchParameters parameters = new SearchParameters("bar"); @@ -185,7 +185,7 @@ public class TwitterSearchOutboundGatewayTests { public void testSearchParamsQueryCustomExpression() { this.gateway.setSearchArgsExpression(new SpelExpressionParser() .parseExpression("new SearchParameters('foo' + payload).count(5).sinceId(11)")); - Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz"); + Tweet tweet = mock(Tweet.class); SearchMetadata searchMetadata = mock(SearchMetadata.class); final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata); doAnswer(new Answer() { diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/ConsoleChatTests-context.xml b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/ConsoleChatTests-context.xml index c7add9dead..4a3c014ce9 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/ConsoleChatTests-context.xml +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/ConsoleChatTests-context.xml @@ -1,22 +1,17 @@ - - - + - - - + + expression="'Presence event from: ' + payload.getFrom() + ' - ' + payload.getMode()"/> diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/OutboundPresenceTests-context.xml b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/OutboundPresenceTests-context.xml index fbcebc12fc..2f2d8ed370 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/OutboundPresenceTests-context.xml +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/ignore/OutboundPresenceTests-context.xml @@ -1,22 +1,15 @@ + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - - + = - ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) { - ZookeeperMetadataStore.this.updateMap.remove(eventPath); + case CHILD_ADDED: + if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) { + if (event.getData().getStat().getVersion() >= + ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) { + ZookeeperMetadataStore.this.updateMap.remove(eventPath); + } } - } - for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { - listener.onAdd(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding)); - } - break; - case CHILD_UPDATED: - if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) { - if (event.getData().getStat().getVersion() >= - ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) { - ZookeeperMetadataStore.this.updateMap.remove(eventPath); + for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { + listener.onAdd(eventKey, IntegrationUtils.bytesToString(eventData, + ZookeeperMetadataStore.this.encoding)); } - } - for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { - listener.onUpdate(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding)); - } - break; - case CHILD_REMOVED: - ZookeeperMetadataStore.this.updateMap.remove(eventKey); - for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { - listener.onRemove(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding)); - } - break; - default: - // ignore all other events - break; + break; + case CHILD_UPDATED: + if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) { + if (event.getData().getStat().getVersion() >= + ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) { + ZookeeperMetadataStore.this.updateMap.remove(eventPath); + } + } + for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { + listener.onUpdate(eventKey, IntegrationUtils.bytesToString(eventData, + ZookeeperMetadataStore.this.encoding)); + } + break; + case CHILD_REMOVED: + ZookeeperMetadataStore.this.updateMap.remove(eventKey); + for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) { + listener.onRemove(eventKey, IntegrationUtils.bytesToString(eventData, + ZookeeperMetadataStore.this.encoding)); + } + break; + default: + // ignore all other events + break; } } } + } }