Examples of ExpectedLookupTemplate


Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  }

  @Test
  public void testLookupWithDefaultObjectAndExpectedTypeConversionViaBeanFactory() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
    jof.setJndiName("myFoo");
    jof.setExpectedType(Integer.class);
    jof.setDefaultObject("5");
    jof.setBeanFactory(new DefaultListableBeanFactory());
    jof.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  }

  @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");
    try {
      jof.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  @Test
  public void testLookupWithProxyInterface() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    TestBean tb = new TestBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
    jof.setJndiName("foo");
    jof.setProxyInterface(ITestBean.class);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() instanceof ITestBean);
    ITestBean proxy = (ITestBean) jof.getObject();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  @Test
  public void testLookupWithProxyInterfaceAndDefaultObject() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    TestBean tb = new TestBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
    jof.setJndiName("myFoo");
    jof.setProxyInterface(ITestBean.class);
    jof.setDefaultObject(Boolean.TRUE);
    try {
      jof.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  @Test
  public void testLookupWithProxyInterfaceAndExpectedTypeAndMatch() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    TestBean tb = new TestBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
    jof.setJndiName("foo");
    jof.setExpectedType(TestBean.class);
    jof.setProxyInterface(ITestBean.class);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() instanceof ITestBean);
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  @Test
  public void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    TestBean tb = new TestBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
    jof.setJndiName("foo");
    jof.setExpectedType(DerivedTestBean.class);
    jof.setProxyInterface(ITestBean.class);
    try {
      jof.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

*/
public class WebSphereUowTransactionManagerTests extends TestCase {

  public void testUowManagerFoundInJndi() {
    MockUOWManager manager = new MockUOWManager();
    ExpectedLookupTemplate jndiTemplate =
        new ExpectedLookupTemplate(WebSphereUowTransactionManager.DEFAULT_UOW_MANAGER_NAME, manager);
    WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager();
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  public void testUowManagerAndUserTransactionFoundInJndi() throws Exception {
    UserTransaction ut = mock(UserTransaction.class);
    given(ut.getStatus()).willReturn( Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);

    MockUOWManager manager = new MockUOWManager();
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    jndiTemplate.addObject(WebSphereUowTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut);
    jndiTemplate.addObject(WebSphereUowTransactionManager.DEFAULT_UOW_MANAGER_NAME, manager);
    WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager();
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

  @Test
  public void testResourceInjectionFromJndi() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
    SimpleJndiBeanFactory resourceFactory = new SimpleJndiBeanFactory();
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    TestBean tb = new TestBean();
    jndiTemplate.addObject("java:comp/env/testBean", tb);
    TestBean tb2 = new TestBean();
    jndiTemplate.addObject("java:comp/env/testBean2", tb2);
    resourceFactory.setJndiTemplate(jndiTemplate);
    bpp.setResourceFactory(resourceFactory);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ResourceInjectionBean.class));
View Full Code Here

Examples of org.springframework.tests.mock.jndi.ExpectedLookupTemplate

    else {
      given(tm.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
    }

    JtaTransactionManager ptm = new JtaTransactionManager();
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    if (defaultUt) {
      jndiTemplate.addObject("java:comp/UserTransaction", ut);
    }
    jndiTemplate.addObject(tmName, tm);
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    if (tmFound) {
      assertEquals(tm, ptm.getTransactionManager());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.