use of org.springframework.context.support.ClassPathXmlApplicationContext in project spring-framework by spring-projects.
the class ContextNamespaceHandlerTests method propertyPlaceholderIgnored.
@Test
public void propertyPlaceholderIgnored() throws Exception {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("contextNamespaceHandlerTests-replace-ignore.xml", getClass());
assertEquals("${bar}", applicationContext.getBean("string"));
assertEquals("null", applicationContext.getBean("nullString"));
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project spring-framework by spring-projects.
the class ContextNamespaceHandlerTests method propertyPlaceholderLocationWithSystemPropertyMissing.
@Test
public void propertyPlaceholderLocationWithSystemPropertyMissing() throws Exception {
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("contextNamespaceHandlerTests-location-placeholder.xml", getClass());
assertEquals("bar", applicationContext.getBean("foo"));
assertEquals("foo", applicationContext.getBean("bar"));
assertEquals("maps", applicationContext.getBean("spam"));
} catch (FatalBeanException ex) {
assertTrue(ex.getRootCause() instanceof FileNotFoundException);
}
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project spring-framework by spring-projects.
the class ContextNamespaceHandlerTests method propertyPlaceholderSystemProperties.
@Test
public void propertyPlaceholderSystemProperties() throws Exception {
String value = System.setProperty("foo", "spam");
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("contextNamespaceHandlerTests-system.xml", getClass());
assertEquals("spam", applicationContext.getBean("string"));
assertEquals("none", applicationContext.getBean("fallback"));
} finally {
if (value != null) {
System.setProperty("foo", value);
}
}
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method simpleEventXmlConfig.
@Test
public void simpleEventXmlConfig() {
this.context = new ClassPathXmlApplicationContext("org/springframework/context/event/simple-event-configuration.xml");
TestEvent event = new TestEvent(this, "test");
TestEventListener listener = this.context.getBean(TestEventListener.class);
this.eventCollector = getEventCollector(this.context);
this.eventCollector.assertNoEventReceived(listener);
this.context.publishEvent(event);
this.eventCollector.assertEvent(listener, event);
this.eventCollector.assertTotalEventsCount(1);
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project spring-framework by spring-projects.
the class AnnotationLazyInitMBeanTests method lazyNaming.
@Test
public void lazyNaming() throws Exception {
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/jmx/export/annotation/lazyNaming.xml");
try {
MBeanServer server = (MBeanServer) ctx.getBean("server");
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
assertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
assertEquals("Invalid name returned", "TEST", name);
} finally {
ctx.close();
}
}
Aggregations