Package org.springframework.tests.mock.jndi

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


  }

  @Test
  public void testLookupWithDefaultObjectAndExpectedType() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
    jof.setJndiName("myFoo");
    jof.setExpectedType(String.class);
    jof.setDefaultObject("myString");
    jof.afterPropertiesSet();
    assertEquals("myString", jof.getObject());
View Full Code Here


  }

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

  }

  @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

  }

  @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

  @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

  @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

  @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

  @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

*/
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

  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

TOP

Related Classes of org.springframework.tests.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.