Search in sources :

Example 1 with MongoDbStoringMessageHandler

use of org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler in project spring-integration by spring-projects.

the class MongoDbOutboundChannelAdapterParserTests method fullConfigWithCollection.

@Test
public void fullConfigWithCollection() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-parser-config.xml", this.getClass());
    MongoDbStoringMessageHandler handler = TestUtils.getPropertyValue(context.getBean("fullConfigWithCollection.adapter"), "handler", MongoDbStoringMessageHandler.class);
    assertEquals("fullConfigWithCollection.adapter", TestUtils.getPropertyValue(handler, "componentName"));
    assertEquals(false, TestUtils.getPropertyValue(handler, "shouldTrack"));
    assertNotNull(TestUtils.getPropertyValue(handler, "mongoTemplate"));
    assertEquals(context.getBean("mongoDbFactory"), TestUtils.getPropertyValue(handler, "mongoDbFactory"));
    assertNotNull(TestUtils.getPropertyValue(handler, "evaluationContext"));
    assertTrue(TestUtils.getPropertyValue(handler, "collectionNameExpression") instanceof LiteralExpression);
    assertEquals("foo", TestUtils.getPropertyValue(handler, "collectionNameExpression.literalValue"));
    context.close();
}
Also used : MongoDbStoringMessageHandler(org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) LiteralExpression(org.springframework.expression.common.LiteralExpression) Test(org.junit.Test)

Example 2 with MongoDbStoringMessageHandler

use of org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler in project spring-integration by spring-projects.

the class MongoDbOutboundChannelAdapterParserTests method fullConfigWithCollectionExpression.

@Test
public void fullConfigWithCollectionExpression() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-parser-config.xml", this.getClass());
    MongoDbStoringMessageHandler handler = TestUtils.getPropertyValue(context.getBean("fullConfigWithCollectionExpression.adapter"), "handler", MongoDbStoringMessageHandler.class);
    assertEquals("fullConfigWithCollectionExpression.adapter", TestUtils.getPropertyValue(handler, "componentName"));
    assertEquals(false, TestUtils.getPropertyValue(handler, "shouldTrack"));
    assertNotNull(TestUtils.getPropertyValue(handler, "mongoTemplate"));
    assertEquals(context.getBean("mongoDbFactory"), TestUtils.getPropertyValue(handler, "mongoDbFactory"));
    assertNotNull(TestUtils.getPropertyValue(handler, "evaluationContext"));
    assertTrue(TestUtils.getPropertyValue(handler, "collectionNameExpression") instanceof SpelExpression);
    assertEquals("headers.collectionName", TestUtils.getPropertyValue(handler, "collectionNameExpression.expression"));
    context.close();
}
Also used : MongoDbStoringMessageHandler(org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Test(org.junit.Test)

Example 3 with MongoDbStoringMessageHandler

use of org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler in project spring-integration by spring-projects.

the class MongoDbOutboundChannelAdapterParserTests method minimalConfig.

@Test
public void minimalConfig() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-parser-config.xml", this.getClass());
    MongoDbStoringMessageHandler handler = TestUtils.getPropertyValue(context.getBean("minimalConfig.adapter"), "handler", MongoDbStoringMessageHandler.class);
    assertEquals("minimalConfig.adapter", TestUtils.getPropertyValue(handler, "componentName"));
    assertEquals(false, TestUtils.getPropertyValue(handler, "shouldTrack"));
    assertNotNull(TestUtils.getPropertyValue(handler, "mongoTemplate"));
    assertEquals(context.getBean("mongoDbFactory"), TestUtils.getPropertyValue(handler, "mongoDbFactory"));
    assertNotNull(TestUtils.getPropertyValue(handler, "evaluationContext"));
    assertTrue(TestUtils.getPropertyValue(handler, "collectionNameExpression") instanceof LiteralExpression);
    assertEquals("data", TestUtils.getPropertyValue(handler, "collectionNameExpression.literalValue"));
    context.close();
}
Also used : MongoDbStoringMessageHandler(org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) LiteralExpression(org.springframework.expression.common.LiteralExpression) Test(org.junit.Test)

Example 4 with MongoDbStoringMessageHandler

use of org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler in project spring-integration by spring-projects.

the class MongoDbOutboundChannelAdapterParserTests method fullConfigWithMongoTemplate.

@Test
public void fullConfigWithMongoTemplate() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-parser-config.xml", this.getClass());
    MongoDbStoringMessageHandler handler = TestUtils.getPropertyValue(context.getBean("fullConfigWithMongoTemplate.adapter"), "handler", MongoDbStoringMessageHandler.class);
    assertEquals("fullConfigWithMongoTemplate.adapter", TestUtils.getPropertyValue(handler, "componentName"));
    assertEquals(false, TestUtils.getPropertyValue(handler, "shouldTrack"));
    assertNotNull(TestUtils.getPropertyValue(handler, "mongoTemplate"));
    assertNotNull(TestUtils.getPropertyValue(handler, "evaluationContext"));
    assertTrue(TestUtils.getPropertyValue(handler, "collectionNameExpression") instanceof LiteralExpression);
    assertEquals("foo", TestUtils.getPropertyValue(handler, "collectionNameExpression.literalValue"));
    context.close();
}
Also used : MongoDbStoringMessageHandler(org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) LiteralExpression(org.springframework.expression.common.LiteralExpression) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)4 MongoDbStoringMessageHandler (org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler)4 LiteralExpression (org.springframework.expression.common.LiteralExpression)3 SpelExpression (org.springframework.expression.spel.standard.SpelExpression)1