use of org.springframework.tests.mock.jndi.SimpleNamingContext in project spring-framework by spring-projects.
the class JndiPropertySourceTests method nameBoundWithPrefix.
@Test
public void nameBoundWithPrefix() {
final SimpleNamingContext context = new SimpleNamingContext();
context.bind("java:comp/env/p1", "v1");
JndiTemplate jndiTemplate = new JndiTemplate() {
@Override
protected Context createInitialContext() throws NamingException {
return context;
}
};
JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
jndiLocator.setResourceRef(true);
jndiLocator.setJndiTemplate(jndiTemplate);
JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
assertThat(ps.getProperty("p1"), equalTo("v1"));
}
use of org.springframework.tests.mock.jndi.SimpleNamingContext in project spring-framework by spring-projects.
the class JndiPropertySourceTests method nameBoundWithoutPrefix.
@Test
public void nameBoundWithoutPrefix() {
final SimpleNamingContext context = new SimpleNamingContext();
context.bind("p1", "v1");
JndiTemplate jndiTemplate = new JndiTemplate() {
@Override
protected Context createInitialContext() throws NamingException {
return context;
}
};
JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
jndiLocator.setResourceRef(true);
jndiLocator.setJndiTemplate(jndiTemplate);
JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
assertThat(ps.getProperty("p1"), equalTo("v1"));
}
Aggregations