File Cleanup - Scripting to Twitter
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.sftp;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Josh Long
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class TestInboundSftp {
|
||||
|
||||
private TestInboundSftp() {
|
||||
super();
|
||||
}
|
||||
|
||||
static public void main(String[] args) throws Throwable {
|
||||
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("TestInboundSftp.xml");
|
||||
classPathXmlApplicationContext.start();
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
<channel id="requestChannel">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
|
||||
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
|
||||
<beans:property name="host" value="loclahost"/>
|
||||
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
|
||||
@@ -57,5 +57,5 @@
|
||||
auto-startup="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
|
||||
|
||||
<channel id="requestChannel"/>
|
||||
|
||||
|
||||
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
|
||||
<beans:property name="host" value="loclahost"/>
|
||||
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<beans:property name="port" value="2222"/>
|
||||
<beans:property name="user" value="oleg"/>
|
||||
</beans:bean>
|
||||
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterNoAutoCreate"
|
||||
channel="requestChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
@@ -39,7 +39,7 @@
|
||||
delete-remote-files="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
|
||||
<beans:bean id="filter" class="org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter">
|
||||
<beans:constructor-arg value="."/>
|
||||
</beans:bean>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
|
||||
|
||||
<channel id="requestChannel"/>
|
||||
|
||||
|
||||
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SimpleSftpSessionFactory">
|
||||
<beans:property name="host" value="loclahost"/>
|
||||
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<beans:property name="port" value="2222"/>
|
||||
<beans:property name="user" value="oleg"/>
|
||||
</beans:bean>
|
||||
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterNoAutoCreate"
|
||||
channel="requestChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
@@ -40,7 +40,7 @@
|
||||
auto-delete-remote-files-on-sync="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
|
||||
<beans:bean id="filter" class="org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter">
|
||||
<beans:constructor-arg value="."/>
|
||||
</beans:bean>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
|
||||
|
||||
<channel id="inboundFilesChannel"/>
|
||||
|
||||
|
||||
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
|
||||
<beans:property name="host" value="loclahost"/>
|
||||
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<property name="port" value="2222"/>
|
||||
<property name="user" value="oleg"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<int:channel id="inputChannel"/>
|
||||
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
@@ -26,8 +26,8 @@
|
||||
remote-filename-generator="fileNameGenerator"
|
||||
remote-directory="foo/bar"
|
||||
remote-directory-expression="'foo'"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</bean>
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
<property name="port" value="2222"/>
|
||||
<property name="user" value="oleg"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<int:channel id="requestChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
|
||||
<int-sftp:inbound-channel-adapter id="sftpAutoStartup"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package org.springframework.integration.sftp.config;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousy
|
||||
* @author Gunnar Hillert
|
||||
@@ -55,18 +55,20 @@ public class SftpInboundOutboundSanitySample {
|
||||
fileB.delete();
|
||||
}
|
||||
|
||||
new ClassPathXmlApplicationContext("SftpInboundReceiveSample-ignored.xml", this.getClass());
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"SftpInboundReceiveSample-ignored.xml", this.getClass());
|
||||
Thread.sleep(5000);
|
||||
fileA = new File("local-test-dir/a.test");
|
||||
fileB = new File("local-test-dir/b.test");
|
||||
assertTrue(fileA.exists());
|
||||
assertTrue(fileB.exists());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testOutbound() throws Exception {
|
||||
ApplicationContext ac =
|
||||
ClassPathXmlApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("SftpOutboundTransferSample-ignored.xml", this.getClass());
|
||||
File fileA = new File("local-test-dir/a.test");
|
||||
File fileB = new File("local-test-dir/b.test");
|
||||
@@ -78,5 +80,7 @@ public class SftpInboundOutboundSanitySample {
|
||||
fileB = new File("remote-target-dir/b.test-foo");
|
||||
assertTrue(fileA.exists());
|
||||
assertTrue(fileB.exists());
|
||||
ac.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
</bean>
|
||||
|
||||
<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
|
||||
channel="receiveChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="receiveChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
local-directory="file:local-test-dir"
|
||||
remote-directory="/Users/ozhurakousky/workspace-sts-2.3.3.M2/si/spring-integration/spring-integration-sftp/remote-test-dir"
|
||||
auto-startup="true"
|
||||
@@ -32,7 +32,7 @@
|
||||
<int:channel id="receiveChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
|
||||
<task:executor id="executor" pool-size="15"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -19,21 +19,25 @@ package org.springframework.integration.sftp.config;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class SftpMessageHistoryTests {
|
||||
|
||||
@Test
|
||||
public void testMessageHistoryCompliance() {
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("MessageHistory-context.xml", SftpMessageHistoryTests.class);
|
||||
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("MessageHistory-context.xml",
|
||||
SftpMessageHistoryTests.class);
|
||||
SourcePollingChannelAdapter spca = ac.getBean("sftpAdapter", SourcePollingChannelAdapter.class);
|
||||
assertEquals("sftpAdapter", spca.getComponentName());
|
||||
assertEquals("sftp:inbound-channel-adapter", spca.getComponentType());
|
||||
ac.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
<property name="user" value="ozhurakousky"/>
|
||||
<property name="password" value="password"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<int:channel id="ftpChannel"/>
|
||||
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="ftpChannel"
|
||||
@@ -26,5 +26,5 @@
|
||||
remote-filename-generator-expression="payload.getName() + '-foo'"
|
||||
auto-create-directory="true"
|
||||
remote-directory="spring-integration-sftp/remote-target-dir/bar/baz"/>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1 +1 @@
|
||||
delete.remote.files=false
|
||||
delete.remote.files=false
|
||||
|
||||
@@ -64,6 +64,7 @@ public class SftpPersistentAcceptOnceFileListFilterTests {
|
||||
assertEquals("baz", now.get(1).getFilename());
|
||||
now = filter.filterFiles(files);
|
||||
assertEquals(0, now.size());
|
||||
filter.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,6 +83,7 @@ public class SftpPersistentAcceptOnceFileListFilterTests {
|
||||
assertEquals(2, now.size());
|
||||
assertEquals("foo", now.get(0).getFilename());
|
||||
assertEquals("bar", now.get(1).getFilename());
|
||||
filter.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
@@ -163,17 +162,20 @@ public class SftpOutboundTests {
|
||||
File destFile = new File(targetDir, srcFile.getName());
|
||||
destFile.deleteOnExit();
|
||||
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("SftpOutboundInsideChainTests-context.xml", getClass());
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"SftpOutboundInsideChainTests-context.xml", getClass());
|
||||
|
||||
MessageChannel channel = context.getBean("outboundChannelAdapterInsideChain", MessageChannel.class);
|
||||
|
||||
channel.send(new GenericMessage<File>(srcFile));
|
||||
assertTrue("destination file was not created", destFile.exists());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test //INT-2275
|
||||
public void testFtpOutboundGatewayInsideChain() throws Exception {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("SftpOutboundInsideChainTests-context.xml", getClass());
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"SftpOutboundInsideChainTests-context.xml", getClass());
|
||||
|
||||
MessageChannel channel = context.getBean("outboundGatewayInsideChain", MessageChannel.class);
|
||||
|
||||
@@ -191,6 +193,7 @@ public class SftpOutboundTests {
|
||||
for (FileInfo<?> remoteFile : remoteFiles) {
|
||||
assertTrue(files.contains(remoteFile.getFilename()));
|
||||
}
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test //INT-2954
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2010 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.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans:beans
|
||||
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">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.sftp"/>
|
||||
|
||||
<context:property-placeholder
|
||||
location="file://${user.home}/Desktop/sftp.properties"
|
||||
ignore-unresolvable="true"/>
|
||||
|
||||
<channel id="inboundFilesChannel"/>
|
||||
|
||||
<sftp:inbound-channel-adapter
|
||||
key-file="${sftp.key}"
|
||||
remote-directory="${sftp.remote-dir}"
|
||||
channel="inboundFilesChannel"
|
||||
filename-pattern=".*?jpg"
|
||||
username="${sftp.username}"
|
||||
auto-create-directories="true"
|
||||
auto-delete-remote-files-on-sync="true"
|
||||
host="${sftp.host}">
|
||||
<poller>
|
||||
<interval-trigger interval="1000" time-unit="MILLISECONDS"/>
|
||||
</poller>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<service-activator ref="sftpAnnouncer" input-channel="inboundFilesChannel"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2010 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.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans:beans
|
||||
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">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.sftp"/>
|
||||
|
||||
<channel id="inboundFilesChannel"/>
|
||||
|
||||
<sftp:outbound-channel-adapter
|
||||
key-file="/home/user/user.pem"
|
||||
remote-directory="/home/ubuntu/remote_mount_key"
|
||||
auto-create-directories="true"
|
||||
channel="inboundFilesChannel"
|
||||
username="ubuntu"
|
||||
host="siteonec2usingubuntuami.com"
|
||||
/>
|
||||
|
||||
<service-activator input-channel="inboundFilesChannel" ref="sftpAnnouncer"/>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user