Search in sources :

Example 1 with SearchTermStrategy

use of org.springframework.integration.mail.SearchTermStrategy in project spring-integration by spring-projects.

the class ImapIdleChannelAdapterParserTests method customAdapter.

@Test
public void customAdapter() {
    Object adapter = context.getBean("customAdapter");
    assertEquals(ImapIdleChannelAdapter.class, adapter.getClass());
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
    Object channel = context.getBean("channel");
    assertSame(channel, adapterAccessor.getPropertyValue("outputChannel"));
    assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
    Object receiver = adapterAccessor.getPropertyValue("mailReceiver");
    assertEquals(ImapMailReceiver.class, receiver.getClass());
    DirectFieldAccessor receiverAccessor = new DirectFieldAccessor(receiver);
    Object url = receiverAccessor.getPropertyValue("url");
    assertEquals(new URLName("imap:foo"), url);
    Properties properties = (Properties) receiverAccessor.getPropertyValue("javaMailProperties");
    assertEquals("bar", properties.getProperty("foo"));
    assertEquals(Boolean.FALSE, receiverAccessor.getPropertyValue("shouldDeleteMessages"));
    SearchTermStrategy stStrategy = context.getBean("searchTermStrategy", SearchTermStrategy.class);
    assertEquals(stStrategy, TestUtils.getPropertyValue(adapter, "mailReceiver.searchTermStrategy"));
}
Also used : SearchTermStrategy(org.springframework.integration.mail.SearchTermStrategy) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) URLName(javax.mail.URLName) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with SearchTermStrategy

use of org.springframework.integration.mail.SearchTermStrategy in project spring-integration by spring-projects.

the class InboundChannelAdapterParserTests method imapWithSearchTermStrategy.

// ==================== INT-2800 ====================
@Test
public void imapWithSearchTermStrategy() {
    AbstractMailReceiver receiver = this.getReceiver("imapWithSearch");
    assertEquals(ImapMailReceiver.class, receiver.getClass());
    DirectFieldAccessor receiverAccessor = new DirectFieldAccessor(receiver);
    Object sts = receiverAccessor.getPropertyValue("searchTermStrategy");
    assertNotNull(sts);
    assertSame(context.getBean(SearchTermStrategy.class), sts);
    assertEquals("flagged", receiverAccessor.getPropertyValue("userFlag"));
}
Also used : AbstractMailReceiver(org.springframework.integration.mail.AbstractMailReceiver) SearchTermStrategy(org.springframework.integration.mail.SearchTermStrategy) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 SearchTermStrategy (org.springframework.integration.mail.SearchTermStrategy)2 Properties (java.util.Properties)1 URLName (javax.mail.URLName)1 AbstractMailReceiver (org.springframework.integration.mail.AbstractMailReceiver)1