Package org.springframework.mock.jndi

Examples of org.springframework.mock.jndi.ExpectedLookupTemplate


    EntityManagerFactoryWithInfo mockEmf2 = (EntityManagerFactoryWithInfo) emf2Mc.getMock();

    Map<String, String> persistenceUnits = new HashMap<String, String>();
    persistenceUnits.put("", "pu1");
    persistenceUnits.put("Person", "pu2");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pu1", mockEmf);
    jt.addObject("java:comp/env/pu2", mockEmf2);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceUnits(persistenceUnits);
    bpp.setJndiTemplate(jt);
View Full Code Here


    EntityManagerFactoryWithInfo mockEmf2 = (EntityManagerFactoryWithInfo) emf2Mc.getMock();

    Map<String, String> persistenceUnits = new HashMap<String, String>();
    persistenceUnits.put("System", "pu1");
    persistenceUnits.put("Person", "pu2");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pu1", mockEmf);
    jt.addObject("java:comp/env/pu2", mockEmf2);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceUnits(persistenceUnits);
    bpp.setDefaultPersistenceUnitName("System");
View Full Code Here

  }

  public void testSinglePersistenceUnitFromJndi() {
    Map<String, String> persistenceUnits = new HashMap<String, String>();
    persistenceUnits.put("Person", "pu1");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pu1", mockEmf);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceUnits(persistenceUnits);
    bpp.setJndiTemplate(jt);
View Full Code Here

    Map<String, String> persistenceContexts = new HashMap<String, String>();
    persistenceContexts.put("", "pc1");
    persistenceContexts.put("Person", "pc2");
    Map<String, String> extendedPersistenceContexts = new HashMap<String, String>();
    extendedPersistenceContexts .put("", "pc3");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pc1", mockEm);
    jt.addObject("java:comp/env/pc2", mockEm2);
    jt.addObject("java:comp/env/pc3", mockEm3);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceContexts(persistenceContexts);
    bpp.setExtendedPersistenceContexts(extendedPersistenceContexts);
View Full Code Here

    Map<String, String> persistenceContexts = new HashMap<String, String>();
    persistenceContexts.put("System", "pc1");
    persistenceContexts.put("Person", "pc2");
    Map<String, String> extendedPersistenceContexts = new HashMap<String, String>();
    extendedPersistenceContexts .put("System", "pc3");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pc1", mockEm);
    jt.addObject("java:comp/env/pc2", mockEm2);
    jt.addObject("java:comp/env/pc3", mockEm3);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceContexts(persistenceContexts);
    bpp.setExtendedPersistenceContexts(extendedPersistenceContexts);
View Full Code Here

    Map<String, String> persistenceContexts = new HashMap<String, String>();
    persistenceContexts.put("System", "pc1");
    Map<String, String> extendedPersistenceContexts = new HashMap<String, String>();
    extendedPersistenceContexts .put("System", "pc2");
    ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
    jt.addObject("java:comp/env/pc1", mockEm);
    jt.addObject("java:comp/env/pc2", mockEm2);

    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    PersistenceAnnotationBeanPostProcessor bpp = new PersistenceAnnotationBeanPostProcessor();
    bpp.setPersistenceContexts(persistenceContexts);
    bpp.setExtendedPersistenceContexts(extendedPersistenceContexts);
View Full Code Here

      tmControl.setVoidCallable(1);
    }
    tmControl.replay();

    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

    TransactionManager tm = (TransactionManager) tmControl.getMock();

    JtaTransactionManager ptm = new JtaTransactionManager();
    ptm.setUserTransactionName("jndi-ut");
    ptm.setTransactionManagerName("jndi-tm");
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    jndiTemplate.addObject("jndi-ut", ut);
    jndiTemplate.addObject("jndi-tm", tm);
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    assertEquals(ut, ptm.getUserTransaction());
    assertEquals(tm, ptm.getTransactionManager());
View Full Code Here

    ut2.commit();
    ut2Control.setVoidCallable(1);
    ut2Control.replay();

    JtaTransactionManager ptm = new JtaTransactionManager();
    ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut));
    ptm.setCacheUserTransaction(false);
    ptm.afterPropertiesSet();

    assertEquals(ut, ptm.getUserTransaction());

    TransactionTemplate tt = new TransactionTemplate(ptm);
    assertEquals(JtaTransactionManager.SYNCHRONIZATION_ALWAYS, ptm.getTransactionSynchronization());
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        // something transactional
        assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
        assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
      }
    });

    ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut2));
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        // something transactional
        assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
        assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
View Full Code Here

  }
 
  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();
    assertTrue(jof.getObject() == o);
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.jndi.ExpectedLookupTemplate

Copyright © 2018 www.massapicom. 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.