Package org.springframework.tests.mock.jndi

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


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


  @Test
  public void testLookupWithFullNameAndResourceRefFalse() 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(false);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() == o);
  }
View Full Code Here

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

  @Test
  public void testLookupWithSchemeNameAndResourceRefFalse() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    Object o = new Object();
    jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o));
    jof.setJndiName("java:foo");
    jof.setResourceRef(false);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() == o);
  }
View Full Code Here

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

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

  @Test
  public void testLookupWithArbitraryNameAndResourceRefFalse() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    Object o = new Object();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", o));
    jof.setJndiName("foo");
    jof.setResourceRef(false);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() == o);
  }
View Full Code Here

  @Test
  public void testLookupWithExpectedTypeAndMatch() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    String s = "";
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", s));
    jof.setJndiName("foo");
    jof.setExpectedType(String.class);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() == s);
  }
View Full Code Here

  }

  @Test
  public void testLookupWithExpectedTypeAndNoMatch() throws Exception {
    JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
    jof.setJndiTemplate(new ExpectedLookupTemplate("foo", new Object()));
    jof.setJndiName("foo");
    jof.setExpectedType(String.class);
    try {
      jof.afterPropertiesSet();
      fail("Should have thrown NamingException");
View Full Code Here

  }

  @Test
  public void testLookupWithDefaultObject() 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

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.