use of org.springframework.context.support.GenericApplicationContext in project spring-integration by spring-projects.
the class ExpressionUtilsTests method testEvaluationContext.
@Test
public void testEvaluationContext() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBeanDefinition(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, new RootBeanDefinition(IntegrationEvaluationContextFactoryBean.class));
context.registerBeanDefinition(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, new RootBeanDefinition(ConversionServiceFactoryBean.class));
context.refresh();
StandardEvaluationContext evalContext = ExpressionUtils.createStandardEvaluationContext(context);
assertNotNull(evalContext.getBeanResolver());
assertNotNull(evalContext.getTypeConverter());
IntegrationEvaluationContextFactoryBean factory = context.getBean("&" + IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, IntegrationEvaluationContextFactoryBean.class);
assertSame(evalContext.getTypeConverter(), TestUtils.getPropertyValue(factory, "typeConverter"));
}
use of org.springframework.context.support.GenericApplicationContext in project spring-integration by spring-projects.
the class ExpressionUtilsTests method testEvaluationContextDefaultTypeConverter.
@Test
public void testEvaluationContextDefaultTypeConverter() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBeanDefinition(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, new RootBeanDefinition(IntegrationEvaluationContextFactoryBean.class));
context.refresh();
StandardEvaluationContext evalContext = ExpressionUtils.createStandardEvaluationContext(context);
assertNotNull(evalContext.getBeanResolver());
TypeConverter typeConverter = evalContext.getTypeConverter();
assertNotNull(typeConverter);
assertSame(DefaultConversionService.getSharedInstance(), TestUtils.getPropertyValue(typeConverter, "conversionService"));
}
use of org.springframework.context.support.GenericApplicationContext in project spring-integration by spring-projects.
the class GatewayParserTests method testFactoryBeanObjectTypeWithNoServiceInterface.
@Test
public void testFactoryBeanObjectTypeWithNoServiceInterface() throws Exception {
ConfigurableListableBeanFactory beanFactory = ((GenericApplicationContext) context).getBeanFactory();
Object attribute = beanFactory.getMergedBeanDefinition("&defaultConfig").getAttribute(IntegrationConfigUtils.FACTORY_BEAN_OBJECT_TYPE);
assertEquals(RequestReplyExchanger.class.getName(), attribute);
}
use of org.springframework.context.support.GenericApplicationContext in project spring-integration by spring-projects.
the class IdempotentReceiverParserTests method bootStrap.
private ApplicationContext bootStrap(String configProperty) throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(new ClassPathResource("org/springframework/integration/config/xml/idempotent-receiver-configs.properties"));
pfb.afterPropertiesSet();
Properties prop = pfb.getObject();
ByteArrayInputStream stream = new ByteArrayInputStream((prop.getProperty("xmlheaders") + prop.getProperty(configProperty) + prop.getProperty("xmlfooter")).getBytes());
GenericApplicationContext ac = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
reader.loadBeanDefinitions(new InputStreamResource(stream));
ac.refresh();
return ac;
}
use of org.springframework.context.support.GenericApplicationContext in project spring-integration by spring-projects.
the class SubscriberOrderTests method directChannelAndFailoverDispatcherWithSingleCallPerMethod.
@Test
public void directChannelAndFailoverDispatcherWithSingleCallPerMethod() {
GenericApplicationContext context = TestUtils.createTestApplicationContext();
context.registerBeanDefinition("postProcessor", new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
RootBeanDefinition channelDefinition = new RootBeanDefinition(DirectChannel.class);
context.registerBeanDefinition("input", channelDefinition);
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(1);
context.registerBeanDefinition("testBean", testBeanDefinition);
context.refresh();
TestBean testBean = (TestBean) context.getBean("testBean");
MessageChannel channel = (MessageChannel) context.getBean("input");
channel.send(new GenericMessage<String>("test-1"));
channel.send(new GenericMessage<String>("test-2"));
channel.send(new GenericMessage<String>("test-3"));
channel.send(new GenericMessage<String>("test-4"));
channel.send(new GenericMessage<String>("test-5"));
List<Integer> calls = testBean.calls;
assertEquals(5, calls.size());
assertEquals(1, calls.get(0).intValue());
assertEquals(2, calls.get(1).intValue());
assertEquals(3, calls.get(2).intValue());
assertEquals(4, calls.get(3).intValue());
assertEquals(5, calls.get(4).intValue());
context.close();
}
Aggregations