use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MessageIdGenerationTests method testCustomIdGenerationWithParentChildIndependentCreation.
@Test
public void testCustomIdGenerationWithParentChildIndependentCreation() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context-withGenerator.xml", this.getClass());
GenericXmlApplicationContext child = new GenericXmlApplicationContext();
child.load("classpath:/org/springframework/integration/core/MessageIdGenerationTests-context.xml");
child.setParent(parent);
child.refresh();
IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class);
MessageChannel inputChannel = child.getBean("input", MessageChannel.class);
inputChannel.send(new GenericMessage<Integer>(0));
verify(idGenerator, atLeastOnce()).generateId();
child.close();
parent.close();
this.assertDestroy();
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class InnerPollerParserTests method testRefExtraAttributeAndDefaultFalse.
@Test
public void testRefExtraAttributeAndDefaultFalse() {
try {
// Load context from a String to avoid IDEs reporting the invalid configuration
String badContext = "<?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:int=\"http://www.springframework.org/schema/integration\"" + " xmlns:int-jdbc=\"http://www.springframework.org/schema/integration/jdbc\"" + " xsi:schemaLocation=\"http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd" + " http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd" + " http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd\">" + "" + " <int:poller id=\"outer\" fixed-rate=\"5000\"/>" + "" + " <int:channel id=\"someChannel\"/>" + "" + " <int-jdbc:inbound-channel-adapter channel=\"someChannel\" jdbc-operations=\"ops\"" + " query=\"select 1\">" + // <<<<< fixed-rate not allowed here
" <int:poller ref=\"outer\" default=\"false\" fixed-rate=\"1000\"/>" + " </int-jdbc:inbound-channel-adapter>" + "" + " <bean id=\"ops\" class=\"org.mockito.Mockito\" factory-method=\"mock\">" + " <constructor-arg value=\"org.springframework.jdbc.core.JdbcOperations\"/>" + " </bean>" + "</beans>";
Resource resource = new ByteArrayResource(badContext.getBytes());
new GenericXmlApplicationContext(resource).close();
fail("Expected Failure to load ApplicationContext");
} catch (BeanDefinitionParsingException bdpe) {
assertTrue(bdpe.getMessage().startsWith("Configuration problem: A 'poller' element that provides a 'ref' must have no other attributes."));
}
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testCircularReferenceWithChannelInFactoryBean.
@Test
public void testCircularReferenceWithChannelInFactoryBean() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "oref-factory-channel.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
assertTrue(Arrays.asList(messageChannelsMonitor.getChannelNames()).contains("anonymous"));
MBeanServer server = context.getBean(MBeanServer.class);
assertEquals(1, server.queryNames(ObjectName.getInstance("com.foo:*"), null).size());
assertEquals(1, server.queryNames(ObjectName.getInstance("org.springframework.integration:name=anonymous,*"), null).size());
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testComponentNames.
@Test
public void testComponentNames() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "excluded-components.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
MBeanServer server = context.getBean(MBeanServer.class);
Set<ObjectName> names = server.queryNames(ObjectName.getInstance("org.springframework.integration:type=MessageChannel,*"), null);
// Only one registered (out of >2 available)
assertEquals(1, names.size());
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:type=MessageHandler,*"), null);
assertEquals(0, names.size());
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testCircularReferenceNoChannelInFactoryBean.
@Test
public void testCircularReferenceNoChannelInFactoryBean() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "oref-factory-nonchannel.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
}
Aggregations