use of org.springframework.context.testfixture.jndi.ExpectedLookupTemplate in project spring-framework by spring-projects.
the class JndiObjectFactoryBeanTests method testLookupWithShortNameAndResourceRefFalse.
@Test
public void testLookupWithShortNameAndResourceRefFalse() throws Exception {
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
Object o = new Object();
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
jof.setJndiName("foo");
jof.setResourceRef(false);
assertThatExceptionOfType(NamingException.class).isThrownBy(jof::afterPropertiesSet);
}
use of org.springframework.context.testfixture.jndi.ExpectedLookupTemplate in project spring-framework by spring-projects.
the class JndiObjectFactoryBeanTests method testLookupWithSchemeNameAndResourceRefTrue.
@Test
public void testLookupWithSchemeNameAndResourceRefTrue() throws Exception {
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
Object o = new Object();
jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o));
jof.setJndiName("java:foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
}
use of org.springframework.context.testfixture.jndi.ExpectedLookupTemplate in project spring-framework by spring-projects.
the class JndiObjectFactoryBeanTests method testLookupWithDefaultObjectAndExpectedTypeNoMatch.
@Test
public void testLookupWithDefaultObjectAndExpectedTypeNoMatch() throws Exception {
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
jof.setJndiName("myFoo");
jof.setExpectedType(Boolean.class);
jof.setDefaultObject("5");
assertThatIllegalArgumentException().isThrownBy(jof::afterPropertiesSet);
}
use of org.springframework.context.testfixture.jndi.ExpectedLookupTemplate in project spring-framework by spring-projects.
the class JndiObjectFactoryBeanTests method testLookupWithFullNameAndResourceRefTrue.
@Test
public void testLookupWithFullNameAndResourceRefTrue() throws Exception {
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
Object o = new Object();
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
jof.setJndiName("java:comp/env/foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
}
use of org.springframework.context.testfixture.jndi.ExpectedLookupTemplate in project spring-framework by spring-projects.
the class JndiObjectFactoryBeanTests method testLookupWithShortNameAndResourceRefTrue.
@Test
public void testLookupWithShortNameAndResourceRefTrue() throws Exception {
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
Object o = new Object();
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
jof.setJndiName("foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
}
Aggregations