Skip to content

Commit 1f50b96

Browse files
committed
INT-4498: StreamUtils -> FileCopyUtils
JIRA: https://jira.spring.io/browse/INT-4498 * Use `FileCopyUtils` instead of `StreamUtils` in test-cases when we deal with `InputStream` s and files resources. * Fix reflection-based tests with AOP to use an `ArrayList` access instead of `LinkedList` since an optimization in SF: spring-projects/spring-framework@6d6aa72 **Cherry-pick to 5.0.x and 4.3.x** (cherry picked from commit a1f016a) # Conflicts: # spring-integration-file/src/test/java/org/springframework/integration/file/dsl/FileTests.java # spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java # spring-integration-ws/src/test/java/org/springframework/integration/ws/SimpleWebServiceOutboundGatewayTests.java
1 parent 963a2fb commit 1f50b96

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ public void checkConfigWithInnerBeanAndPoller() {
8282
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(adapter, "autoStartup"));
8383
MessageHandler handler = TestUtils.getPropertyValue(adapter, "handler", MessageHandler.class);
8484
assertTrue(AopUtils.isAopProxy(handler));
85-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
85+
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"),
8686
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
8787

8888
handler.handleMessage(new GenericMessage<>("foo"));

spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
4444
/**
4545
* @author Gary Russell
4646
* @author Artem Bilan
47+
*
4748
* @since 4.0
4849
*/
4950
@ContextConfiguration
@@ -81,7 +82,7 @@ public void testWithConverter() throws Exception {
8182

8283
assertSame(((Advised) handler).getTargetSource().getTarget(), this.withConverterHandler);
8384

84-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
85+
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"),
8586
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
8687
}
8788

spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public void validateConfiguration() {
8484

8585
assertTrue(AopUtils.isAopProxy(endpointHandler));
8686

87-
assertThat(TestUtils.getPropertyValue(endpointHandler, "h.advised.advisors.first.item.advice"),
87+
assertThat(TestUtils.getPropertyValue(endpointHandler, "h.advised.advisors[0].advice"),
8888
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
8989
}
9090

spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@
4545
* @author Artem Bilan
4646
* @author Gary Russell
4747
* @author Rainer Frey
48+
*
4849
* @since 3.0
4950
*/
5051
@ContextConfiguration
@@ -88,15 +89,17 @@ public void testInt3017DefaultConfig() throws Exception {
8889

8990
assertSame(((Advised) handler).getTargetSource().getTarget(), this.defaultAdapter);
9091

91-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
92+
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"),
9293
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
9394
assertTrue(TestUtils.getPropertyValue(this.defaultAdapter, "leftPush", Boolean.class));
9495
}
9596

9697
@Test
9798
public void testInt3017CustomConfig() {
98-
assertSame(this.customRedisConnectionFactory, TestUtils.getPropertyValue(this.customAdapter, "template.connectionFactory"));
99-
assertEquals("headers['redis_queue']", TestUtils.getPropertyValue(this.customAdapter, "queueNameExpression", Expression.class).getExpressionString());
99+
assertSame(this.customRedisConnectionFactory,
100+
TestUtils.getPropertyValue(this.customAdapter, "template.connectionFactory"));
101+
assertEquals("headers['redis_queue']",
102+
TestUtils.getPropertyValue(this.customAdapter, "queueNameExpression.expression"));
100103
assertFalse(TestUtils.getPropertyValue(this.customAdapter, "extractPayload", Boolean.class));
101104
assertTrue(TestUtils.getPropertyValue(this.customAdapter, "serializerExplicitlySet", Boolean.class));
102105
assertSame(this.serializer, TestUtils.getPropertyValue(this.customAdapter, "serializer"));

spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2007-2016 the original author or authors.
2+
* Copyright 2007-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ public void validateWithStringTemplate() throws Exception {
7373

7474
assertSame(((Advised) handler).getTargetSource().getTarget(), withStringTemplate);
7575

76-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
76+
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"),
7777
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
7878
}
7979

spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
4444
import org.springframework.core.io.ClassPathResource;
4545
import org.springframework.integration.file.remote.session.Session;
4646
import org.springframework.util.Base64Utils;
47-
import org.springframework.util.StreamUtils;
47+
import org.springframework.util.FileCopyUtils;
4848

4949
import com.jcraft.jsch.ChannelSftp.LsEntry;
5050

@@ -53,6 +53,7 @@
5353
* @author Gary Russell
5454
* @author David Liu
5555
* @author Artem Bilan
56+
*
5657
* @since 4.1
5758
*
5859
*/
@@ -115,7 +116,7 @@ private void testKeyExchange(String pubKey, String privKey, String passphrase)
115116
f.setUser("user");
116117
f.setAllowUnknownKeys(true);
117118
InputStream stream = new ClassPathResource(privKey).getInputStream();
118-
f.setPrivateKey(new ByteArrayResource(StreamUtils.copyToByteArray(stream)));
119+
f.setPrivateKey(new ByteArrayResource(FileCopyUtils.copyToByteArray(stream)));
119120
f.setPrivateKeyPassphrase(passphrase);
120121
Session<LsEntry> session = f.getSession();
121122
doTest(server, session);
@@ -127,7 +128,7 @@ private void testKeyExchange(String pubKey, String privKey, String passphrase)
127128

128129
private PublicKey decodePublicKey(String key) throws Exception {
129130
InputStream stream = new ClassPathResource(key).getInputStream();
130-
byte[] keyBytes = StreamUtils.copyToByteArray(stream);
131+
byte[] keyBytes = FileCopyUtils.copyToByteArray(stream);
131132
// strip any newline chars
132133
while (keyBytes[keyBytes.length - 1] == 0x0a || keyBytes[keyBytes.length - 1] == 0x0d) {
133134
keyBytes = Arrays.copyOf(keyBytes, keyBytes.length - 1);

0 commit comments

Comments
 (0)