Examples of ITestBean


Examples of org.springframework.beans.ITestBean

    jof.setProxyInterface(ITestBean.class);
    jof.setLookupOnStartup(false);
    jof.setCache(false);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() instanceof ITestBean);
    ITestBean proxy = (ITestBean) jof.getObject();
    assertNull(tb.getName());
    assertEquals(0, tb.getAge());
    proxy.returnsThis();
    assertEquals("tb", tb.getName());
    assertEquals(1, tb.getAge());
    proxy.returnsThis();
    assertEquals(2, tb.getAge());
    proxy.haveBirthday();
    assertEquals(4, tb.getAge());
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

    jof.setJndiName("foo");
    jof.setExpectedType(TestBean.class);
    jof.setProxyInterface(ITestBean.class);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() instanceof ITestBean);
    ITestBean proxy = (ITestBean) jof.getObject();
    assertEquals(0, tb.getAge());
    proxy.setAge(99);
    assertEquals(99, tb.getAge());
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

    jof.setJndiName("foo");
    jof.setProxyInterface(ITestBean.class);
    jof.setExposeAccessContext(true);
    jof.afterPropertiesSet();
    assertTrue(jof.getObject() instanceof ITestBean);
    ITestBean proxy = (ITestBean) jof.getObject();
    assertEquals(0, tb.getAge());
    proxy.setAge(99);
    assertEquals(99, tb.getAge());
    proxy.equals(proxy);
    proxy.hashCode();
    proxy.toString();
    ctxControl.verify();
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

    }
  }

  public void testGetFromScopeThroughDynamicProxy() throws Exception {
    String name = "requestScopedProxy";
    ITestBean bean = (ITestBean) this.beanFactory.getBean(name);
    assertTrue(AopUtils.isJdkDynamicProxy(bean));

    MockHttpServletRequest request = new MockHttpServletRequest();
    RequestAttributes requestAttributes = new ServletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);

    try {
      assertNull(request.getAttribute("scopedTarget." + name));
      assertEquals("scoped", bean.getName());
      assertNotNull(request.getAttribute("scopedTarget." + name));
      assertEquals(TestBean.class, request.getAttribute("scopedTarget." + name).getClass());
      assertEquals("scoped", ((TestBean) request.getAttribute("scopedTarget." + name)).getName());
      assertSame(bean, this.beanFactory.getBean(name));
    }
View Full Code Here

Examples of org.springframework.beans.ITestBean

            new ByteArrayInputStream(response.getContentAsByteArray()), config.getCodebaseUrl());
      }
    });

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    assertEquals("myname", proxy.getName());
    assertEquals(99, proxy.getAge());
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

            new ByteArrayInputStream(response.getContentAsByteArray()), config.getCodebaseUrl());
      }
    });

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    assertEquals("myname", proxy.getName());
    assertEquals(99, proxy.getAge());
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

        throw new IOException("argh");
      }
    });

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();

    // shouldn't go through to remote service
    assertTrue(proxy.toString().indexOf("HTTP invoker") != -1);
    assertTrue(proxy.toString().indexOf(serviceUrl) != -1);
    assertEquals(proxy.hashCode(), proxy.hashCode());
    assertTrue(proxy.equals(proxy));

    // should go through
    try {
      proxy.setAge(50);
      fail("Should have thrown RemoteAccessException");
    }
    catch (RemoteAccessException ex) {
      // expected
      assertTrue(ex.getCause() instanceof IOException);
View Full Code Here

Examples of org.springframework.beans.ITestBean

    this.getAgeMethod = ITestBean.class.getMethod("getAge", new Class[0]);
    this.setAgeMethod = ITestBean.class.getMethod("setAge", new Class[] {int.class});
  }

  public void testIsProxy() throws Exception {
    ITestBean bean = getTestBean();
    assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
  }
View Full Code Here

Examples of org.springframework.beans.ITestBean

    ITestBean bean = getTestBean();
    assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
  }

  public void testInvokeTransactional() throws Exception {
    ITestBean testBean = getTestBean();
    CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");

    // try with transactional
    assertEquals("Should not have any started transactions", 0, ptm.begun);
    testBean.getName();
    assertTrue(ptm.lastDefinition.isReadOnly());
    assertEquals("Should have 1 started transaction", 1, ptm.begun);
    assertEquals("Should have 1 committed transaction", 1, ptm.commits);

    // try with non-transaction
    testBean.haveBirthday();
    assertEquals("Should not have started another transaction", 1, ptm.begun);

    // try with exceptional
    try {
      testBean.exceptional(new IllegalArgumentException("foo"));
      fail("Should NEVER get here");
    }
    catch (Throwable throwable) {
      assertEquals("Should have another started transaction", 2, ptm.begun);
      assertEquals("Should have 1 rolled back transaction", 1, ptm.rollbacks);
View Full Code Here

Examples of org.springframework.beans.ITestBean

    if (explicitClassLoader) {
      ((BeanClassLoaderAware) pfb.getHttpInvokerRequestExecutor()).setBeanClassLoader(getClass().getClassLoader());
    }

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    assertEquals("myname", proxy.getName());
    assertEquals(99, proxy.getAge());
    proxy.setAge(50);
    assertEquals(50, proxy.getAge());
    proxy.setStringArray(new String[] {"str1", "str2"});
    assertTrue(Arrays.equals(new String[] {"str1", "str2"}, proxy.getStringArray()));

    try {
      proxy.exceptional(new IllegalStateException());
      fail("Should have thrown IllegalStateException");
    }
    catch (IllegalStateException ex) {
      // expected
    }
    try {
      proxy.exceptional(new IllegalAccessException());
      fail("Should have thrown IllegalAccessException");
    }
    catch (IllegalAccessException ex) {
      // expected
    }
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.