use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testCircularReferenceWithChannel.
@Test
public void testCircularReferenceWithChannel() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "oref-channel.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testSelfDestruction.
@Test
public void testSelfDestruction() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "self-destruction-context.xml");
SourcePollingChannelAdapter adapter = context.getBean(SourcePollingChannelAdapter.class);
adapter.start();
int n = 0;
while (adapter.isRunning()) {
n += 10;
if (n > 10000) {
fail("Adapter failed to stop");
}
Thread.sleep(10);
}
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testDuplicateComponentNames.
@Test
public void testDuplicateComponentNames() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "duplicate-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=ManagedEndpoint,*"), null);
assertEquals(2, names.size());
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testLifecycleInEndpointWithoutMessageSource.
@Test
public void testLifecycleInEndpointWithoutMessageSource() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "lifecycle-no-source.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=ManagedEndpoint,*"), null);
assertEquals(1, names.size());
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=gateway,*"), null);
assertEquals(1, names.size());
MBeanOperationInfo[] operations = server.getMBeanInfo(names.iterator().next()).getOperations();
String startName = null;
for (MBeanOperationInfo info : operations) {
String name = info.getName();
if (name.startsWith("start")) {
startName = name;
}
}
// Lifecycle method name
assertEquals("start", startName);
context.close();
context = new GenericXmlApplicationContext(getClass(), "lifecycle-no-source.xml");
server = context.getBean(MBeanServer.class);
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null);
assertEquals(1, names.size());
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=gateway,*"), null);
assertEquals(1, names.size());
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testLifecycleInEndpointWithMessageSource.
@Test
public void testLifecycleInEndpointWithMessageSource() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "lifecycle-source.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=ManagedEndpoint,*"), null);
assertEquals(2, names.size());
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=explicit,*"), null);
assertEquals(1, names.size());
MBeanOperationInfo[] operations = server.getMBeanInfo(names.iterator().next()).getOperations();
String startName = null;
for (MBeanOperationInfo info : operations) {
String name = info.getName();
if (name.startsWith("start")) {
startName = name;
}
}
// Lifecycle method name
assertEquals("start", startName);
assertTrue((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null));
messageChannelsMonitor.stopActiveComponents(3000);
assertFalse((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null));
ActiveChannel activeChannel = context.getBean("activeChannel", ActiveChannel.class);
assertTrue(activeChannel.isStopCalled());
OtherActiveComponent otherActiveComponent = context.getBean(OtherActiveComponent.class);
assertTrue(otherActiveComponent.isBeforeCalled());
assertTrue(otherActiveComponent.isAfterCalled());
assertTrue(otherActiveComponent.isRunning());
assertFalse(context.getBean(AMessageProducer.class).isRunning());
// check pollers are still running
QueueChannel input = (QueueChannel) extractTarget(context.getBean("input"));
QueueChannel input2 = (QueueChannel) extractTarget(context.getBean("input2"));
input.purge(null);
input2.purge(null);
input.send(new GenericMessage<String>("foo"));
assertNotNull(input2.receive(10000));
}
Aggregations