use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class SftpMessageHistoryTests method testMessageHistoryCompliance.
@Test
public void testMessageHistoryCompliance() {
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();
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration-samples by spring-projects.
the class FileTransferRenameAfterFailureDemo method main.
public static void main(String[] args) throws Exception {
LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n=========================================================");
final AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/expression-advice-context.xml");
context.registerShutdownHook();
@SuppressWarnings("unchecked") SessionFactory<FTPFile> sessionFactory = context.getBean(SessionFactory.class);
SourcePollingChannelAdapter fileInbound = context.getBean(SourcePollingChannelAdapter.class);
when(sessionFactory.getSession()).thenThrow(new RuntimeException("Force Failure"));
fileInbound.start();
LOGGER.info("\n=========================================================" + "\n " + "\n This is the Expression Advice Sample - " + "\n " + "\n Press 'Enter' to terminate. " + "\n " + "\n Place a file in " + System.getProperty("java.io.tmpdir") + "/adviceDemo ending " + "\n with .txt " + "\n The demo simulates a file transfer failure followed " + "\n by the Advice renaming the file; the result of the " + "\n rename is logged. " + "\n " + "\n=========================================================");
System.in.read();
context.close();
System.exit(0);
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration-samples by spring-projects.
the class FileTransferDeleteAfterSuccessDemo method main.
public static void main(String[] args) throws Exception {
LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n=========================================================");
final AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/expression-advice-context.xml");
context.registerShutdownHook();
@SuppressWarnings("unchecked") SessionFactory<FTPFile> sessionFactory = context.getBean(SessionFactory.class);
SourcePollingChannelAdapter fileInbound = context.getBean(SourcePollingChannelAdapter.class);
@SuppressWarnings("unchecked") Session<FTPFile> session = mock(Session.class);
when(sessionFactory.getSession()).thenReturn(session);
fileInbound.start();
LOGGER.info("\n=========================================================" + "\n " + "\n This is the Expression Advice Sample - " + "\n " + "\n Press 'Enter' to terminate. " + "\n " + "\n Place a file in ${java.io.tmpdir}/adviceDemo ending " + "\n with .txt " + "\n The demo simulates a file transfer followed by the " + "\n Advice deleting the file; the result of the deletion " + "\n is logged. " + "\n " + "\n=========================================================");
System.in.read();
context.close();
System.exit(0);
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class InboundChannelAdapterExpressionTests method testInt2867InnerExpression.
@Test
public void testInt2867InnerExpression() {
SourcePollingChannelAdapter adapter = context.getBean("expressionElement", SourcePollingChannelAdapter.class);
Expression expression = TestUtils.getPropertyValue(adapter, "source.expression", Expression.class);
assertEquals("'Hello World!'", expression.getExpressionString());
}
use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.
the class InboundChannelAdapterExpressionTests method fixedRate.
@Test
public void fixedRate() {
SourcePollingChannelAdapter adapter = context.getBean("fixedRateProducer", SourcePollingChannelAdapter.class);
assertFalse(adapter.isAutoStartup());
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
Trigger trigger = TestUtils.getPropertyValue(adapter, "trigger", Trigger.class);
assertEquals(PeriodicTrigger.class, trigger.getClass());
DirectFieldAccessor triggerAccessor = new DirectFieldAccessor(trigger);
assertEquals(5678L, triggerAccessor.getPropertyValue("period"));
assertEquals(Boolean.TRUE, triggerAccessor.getPropertyValue("fixedRate"));
assertEquals(context.getBean("fixedRateChannel"), adapterAccessor.getPropertyValue("outputChannel"));
Expression expression = TestUtils.getPropertyValue(adapter, "source.expression", Expression.class);
assertEquals("'fixedRateTest'", expression.getExpressionString());
}
Aggregations