Fix RemoteFileOutboundGWTests for the proper mock
This commit is contained in:
@@ -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.
|
||||
@@ -22,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.willReturn;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -804,14 +805,10 @@ public class RemoteFileOutboundGatewayTests {
|
||||
SessionFactory<TestLsEntry> sessionFactory = mock(SessionFactory.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Session<TestLsEntry> session = mock(Session.class);
|
||||
RemoteFileTemplate<TestLsEntry> template = new RemoteFileTemplate<TestLsEntry>(sessionFactory) {
|
||||
|
||||
@Override
|
||||
public boolean exists(String path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
willReturn(Boolean.TRUE)
|
||||
.given(session)
|
||||
.exists(anyString());
|
||||
RemoteFileTemplate<TestLsEntry> template = new RemoteFileTemplate<>(sessionFactory);
|
||||
template.setRemoteDirectoryExpression(new LiteralExpression("foo/"));
|
||||
template.setBeanFactory(mock(BeanFactory.class));
|
||||
template.afterPropertiesSet();
|
||||
@@ -932,7 +929,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(template, "mput", null);
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> gw.setRemoteDirectoryExpression(new LiteralExpression("testRemoteDirectory")))
|
||||
.withMessageContaining("The 'remoteDirectoryExpression' must be set on the externally provided");
|
||||
.withMessageContaining("The 'remoteDirectoryExpression' must be set on the externally provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -942,6 +939,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
Session<TestLsEntry> session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mput", "payload");
|
||||
gw.setRemoteDirectoryExpression(new LiteralExpression("foo/"));
|
||||
gw.setBeanFactory(mock(BeanFactory.class));
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
final AtomicReference<String> written = new AtomicReference<>();
|
||||
|
||||
Reference in New Issue
Block a user