<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mail="http://www.springframework.org/schema/integration/mail"
	xmlns:integration="http://www.springframework.org/schema/integration"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
			https://www.springframework.org/schema/beans/spring-beans.xsd
			http://www.springframework.org/schema/task
			https://www.springframework.org/schema/task/spring-task.xsd
			http://www.springframework.org/schema/context
			https://www.springframework.org/schema/context/spring-context.xsd
			http://www.springframework.org/schema/util
			https://www.springframework.org/schema/util/spring-util.xsd
			http://www.springframework.org/schema/integration
			https://www.springframework.org/schema/integration/spring-integration.xsd
			http://www.springframework.org/schema/integration/mail
			https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">

	<integration:message-history/>

	<context:property-placeholder properties-ref="configProperties"/>

	<util:properties id="configProperties">
		<prop key="mail.delete">false</prop>
	</util:properties>

	<integration:channel id="channel">
		<integration:queue/>
	</integration:channel>

	<mail:imap-idle-channel-adapter id="simpleAdapter"
			store-uri="imap:foo"
			channel="channel"
			auto-startup="false"
			header-mapper="mapper"
			simple-content="true"
			embedded-parts-as-bytes="false"
			auto-close-folder="false"
			should-delete-messages="true"
			cancel-idle-interval="202"/>

	<bean id="mapper" class="org.springframework.integration.mail.support.DefaultMailHeaderMapper" />

	<mail:imap-idle-channel-adapter id="simpleAdapterWithErrorChannel"
			store-uri="imap:foo"
			channel="channel"
			error-channel="errorChannel"
			auto-startup="false"
			should-delete-messages="true"/>

	<mail:imap-idle-channel-adapter id="simpleAdapterMarkAsRead"
			store-uri="imap:foo"
			channel="channel"
			auto-startup="false"
			should-delete-messages="true"
			user-flag="flagged"
			should-mark-messages-as-read="true"/>

	<mail:imap-idle-channel-adapter id="simpleAdapterMarkAsReadFalse"
			store-uri="imap:foo"
			channel="channel"
			auto-startup="false"
			should-delete-messages="true"
			should-mark-messages-as-read="false"/>

	<mail:imap-idle-channel-adapter id="customAdapter"
			store-uri="imap:foo"
			channel="channel"
			auto-startup="false"
			java-mail-properties="javaMailProperties"
			should-delete-messages="${mail.delete}"
			search-term-strategy="searchTermStrategy"/>

	<mail:imap-idle-channel-adapter id="transactionalAdapter"
			store-uri="imap:foo"
			channel="channel"
			auto-startup="false"
			should-delete-messages="true">
		<mail:transactional synchronization-factory="syncFactory" />
	</mail:imap-idle-channel-adapter>

	<integration:transaction-synchronization-factory id="syncFactory">
		<integration:after-commit expression="'foo'" />
	</integration:transaction-synchronization-factory>

	<bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager" />

	<bean id="searchTermStrategy" class="org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests.TestSearchTermStrategy"/>

	<util:properties id="javaMailProperties">
		<prop key="foo">bar</prop>
	</util:properties>

	<task:executor id="executor" pool-size="5"/>

	<mail:imap-idle-channel-adapter
			id="autoChannel"
			store-uri="imap:foo"
			auto-startup="false"
			should-delete-messages="true"/>

	<integration:bridge input-channel="autoChannel" output-channel="nullChannel" />

</beans>
