File Cleanup - Scripting to Twitter

This commit is contained in:
Gary Russell
2016-06-04 12:36:10 -04:00
parent 6016a70cd5
commit dd1d2ecab4
35 changed files with 123 additions and 244 deletions

View File

@@ -16,6 +16,8 @@
package org.springframework.integration.scripting.config.jsr223;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -26,18 +28,17 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.scripting.ScriptVariableGenerator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -132,13 +133,13 @@ public class Jsr223ServiceActivatorTests {
}
String payload = (String) replyChannel.receive(0).getPayload();
assertThat(payload, Matchers.startsWith("inline-test-1 - FOO"));
assertThat(payload, startsWith("inline-test-1 - FOO"));
payload = (String) replyChannel.receive(0).getPayload();
assertThat(payload, Matchers.startsWith("inline-test-2 - FOO"));
assertThat(payload, startsWith("inline-test-2 - FOO"));
payload = (String) replyChannel.receive(0).getPayload();
assertThat(payload, Matchers.startsWith("inline-test-3 - FOO"));
assertThat(payload, startsWith("inline-test-3 - FOO"));
assertTrue(payload.substring(payload.indexOf(":") + 1).matches(".+\\d{2}:\\d{2}:\\d{2}.+"));
assertNull(replyChannel.receive(0));
@@ -148,26 +149,30 @@ public class Jsr223ServiceActivatorTests {
@Test
public void variablesAndScriptVariableGenerator() throws Exception {
try {
new ClassPathXmlApplicationContext("Jsr223ServiceActivatorTests-fail-withgenerator-context.xml", this.getClass());
new ClassPathXmlApplicationContext("Jsr223ServiceActivatorTests-fail-withgenerator-context.xml",
this.getClass()).close();
fail("BeansException expected.");
}
catch (BeansException e) {
assertThat(e.getMessage(), Matchers.containsString("'script-variable-generator' and 'variable' sub-elements are mutually exclusive."));
assertThat(e.getMessage(),
containsString("'script-variable-generator' and 'variable' sub-elements are mutually exclusive."));
}
}
@Test
public void testDuplicateVariable() throws Exception {
try {
new ClassPathXmlApplicationContext("Jsr223ServiceActivatorTests-fail-duplicated-variable-context.xml", this.getClass());
new ClassPathXmlApplicationContext("Jsr223ServiceActivatorTests-fail-duplicated-variable-context.xml",
this.getClass()).close();
fail("BeansException expected.");
}
catch (BeansException e) {
assertThat(e.getMessage(), Matchers.containsString("Duplicated variable: foo"));
assertThat(e.getMessage(), containsString("Duplicated variable: foo"));
}
}
public static class SampleScriptVariSource implements ScriptVariableGenerator {
@Override
public Map<String, Object> generateScriptVariables(Message<?> message) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("foo", "foo");

View File

@@ -1 +1 @@
"ruby-#{payload}-#{foo} - #{bar} - #{date}"
"ruby-#{payload}-#{foo} - #{bar} - #{date}"

View File

@@ -4,4 +4,4 @@ class Transformer
end
end
Transformer.new.transform(payload)
Transformer.new.transform(payload)

View File

@@ -6,4 +6,4 @@ class RubyHello
"hello,world"
end
end
RubyHello.new
RubyHello.new

View File

@@ -9,4 +9,4 @@ if headers
headers.each {|key, value| puts "#{key} is #{value}" }
end
puts "#{$one} #{$two} #{$three}"
payload
payload

View File

@@ -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();
}
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"/>

View File

@@ -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>

View File

@@ -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"

View File

@@ -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();
}
}

View File

@@ -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>

View File

@@ -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();
}
}

View File

@@ -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>

View File

@@ -1 +1 @@
delete.remote.files=false
delete.remote.files=false

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -72,6 +72,7 @@ public class ConsoleInboundChannelAdapterParserTests {
Message<?> message = source.receive();
assertNotNull(message);
assertEquals("foo", message.getPayload());
context.close();
}
@Test
@@ -92,14 +93,15 @@ public class ConsoleInboundChannelAdapterParserTests {
Message<?> message = source.receive();
assertNotNull(message);
assertEquals("foo", message.getPayload());
context.close();
}
@Test
public void testConsoleSourceWithInvalidCharset() {
BeanCreationException beanCreationException = null;
try {
new ClassPathXmlApplicationContext(
"invalidConsoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class);
new ClassPathXmlApplicationContext("invalidConsoleInboundChannelAdapterParserTests.xml",
ConsoleInboundChannelAdapterParserTests.class).close();
}
catch (BeanCreationException e) {
beanCreationException = e;

View File

@@ -33,17 +33,18 @@ import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.MessageHandlerChain;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.stream.CharacterStreamWritingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -127,8 +128,8 @@ public class ConsoleOutboundChannelAdapterParserTests {
public void stdoutAdapterWithInvalidCharset() {
BeanCreationException beanCreationException = null;
try {
new ClassPathXmlApplicationContext(
"invalidConsoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class);
new ClassPathXmlApplicationContext("invalidConsoleOutboundChannelAdapterParserTests.xml",
ConsoleOutboundChannelAdapterParserTests.class).close();
}
catch (BeanCreationException e) {
beanCreationException = e;

View File

@@ -9,7 +9,7 @@
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
<integration:message-history/>
<stdin-channel-adapter id="adapterWithDefaultCharset" auto-startup="false"/>
@@ -18,4 +18,4 @@
<integration:poller id="poller" default="true" fixed-rate="3000"/>
</beans:beans>
</beans:beans>

View File

@@ -12,4 +12,4 @@
<stdin-channel-adapter id="adapterWithInvalidCharset" charset="invalid-charset-name"/>
</beans:beans>
</beans:beans>

View File

@@ -12,4 +12,4 @@
<stdout-channel-adapter id="adapterWithInvalidCharset" charset="invalid-charset-name"/>
</beans:beans>
</beans:beans>

View File

@@ -164,19 +164,21 @@ public class SyslogReceivingChannelAdapterParserTests {
@Test
public void testPortOnUdpChild() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass());
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass())
.close();
fail("Expected exception");
}
catch (BeanDefinitionParsingException e) {
assertTrue(e.getMessage().startsWith(
"Configuration problem: When child element 'udp-attributes' is present, 'port' must be defined there"));
"Configuration problem: When child element 'udp-attributes' is present, 'port' must be defined there"));
}
}
@Test
public void testPortWithTCPFactory() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass());
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass())
.close();
fail("Expected exception");
}
catch (BeanCreationException e) {
@@ -187,7 +189,8 @@ public class SyslogReceivingChannelAdapterParserTests {
@Test
public void testUdpChildWithTcp() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail3-context.xml", this.getClass());
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail3-context.xml", this.getClass())
.close();
fail("Expected exception");
}
catch (BeanCreationException e) {
@@ -200,11 +203,13 @@ public class SyslogReceivingChannelAdapterParserTests {
@Test
public void testUDPWithTCPFactory() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail4-context.xml", this.getClass());
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail4-context.xml", this.getClass())
.close();
fail("Expected exception");
}
catch (BeanCreationException e) {
assertEquals("Cannot specifiy 'connection-factory' unless the protocol is 'tcp'", e.getCause().getMessage());
assertEquals("Cannot specifiy 'connection-factory' unless the protocol is 'tcp'",
e.getCause().getMessage());
}
}

View File

@@ -20,32 +20,32 @@
<beans:bean id="twitter" class="org.mockito.Mockito" factory-method="mock">
<beans:constructor-arg value="org.springframework.social.twitter.api.Twitter"/>
</beans:bean>
<channel id="inbound_mentions"/>
<twitter:mentions-inbound-channel-adapter id="mentionAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="23"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:mentions-inbound-channel-adapter>
<twitter:dm-inbound-channel-adapter id="dmAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="45"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:dm-inbound-channel-adapter>
<twitter:inbound-channel-adapter id="updateAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="67"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:inbound-channel-adapter>
<twitter:mentions-inbound-channel-adapter id="mentionAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="23"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:mentions-inbound-channel-adapter>
<twitter:dm-inbound-channel-adapter id="dmAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="45"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:dm-inbound-channel-adapter>
<twitter:inbound-channel-adapter id="updateAdapter"
twitter-template="twitter"
channel="inbound_mentions"
page-size="67"
auto-startup="false">
<poller fixed-rate="5000" max-messages-per-poll="3"/>
</twitter:inbound-channel-adapter>
</beans:beans>

View File

@@ -23,7 +23,7 @@
<channel id="inbound_mentions"/>
<channel id="inputChannel"/>
<channel id="inputChannel"/>
<twitter:dm-outbound-channel-adapter id="dmAdapter" order="23"
twitter-template="twitter"

View File

@@ -68,7 +68,8 @@ public class TestSendingMessageHandlerParserTests {
@Test
public void testInt2718FailForOutboundAdapterWithRequestHandlerAdviceChainWithinChainConfig() {
try {
new ClassPathXmlApplicationContext("OutboundAdapterWithRHACWithinChain-fail-context.xml", this.getClass());
new ClassPathXmlApplicationContext("OutboundAdapterWithRHACWithinChain-fail-context.xml", this.getClass())
.close();
fail("Expected BeanDefinitionParsingException");
}
catch (BeansException e) {

View File

@@ -17,10 +17,10 @@
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
<context:property-placeholder
<context:property-placeholder
location="classpath:twitter.receiver.properties"
ignore-unresolvable="true"/>
<beans:bean id="twitterTemplate" class="org.springframework.social.twitter.api.impl.TwitterTemplate">
<beans:constructor-arg value="${twitter.oauth.consumerKey}"/>
<beans:constructor-arg value="${twitter.oauth.consumerSecret}"/>

View File

@@ -2,4 +2,4 @@ twitter.oauth.consumerKey=
twitter.oauth.consumerSecret=
twitter.oauth.accessToken=
twitter.oauth.accessTokenSecret=
twitter.oauth.pin=
twitter.oauth.pin=