Package org.springmodules.beans

Examples of org.springmodules.beans.ITestBean


    JavaSpaceInterceptor si = new JavaSpaceInterceptor(template);
    ProxyFactory pf = new ProxyFactory(new Class[] { ITestBean.class });
    pf.addAdvice(new PerformanceMonitorInterceptor());
    pf.addAdvice(si);

    ITestBean proxy = (ITestBean) pf.getProxy();

    String oldName = proxy.getName();

    for (int i = 0; i < 2; i++) {
      String name = "john" + i;
      proxy.setName(name);
      assertEquals(name, proxy.getName());
    }
    proxy.setName(oldName);
  }
View Full Code Here


    JavaSpaceInterceptor si = new JavaSpaceInterceptor(template);
    ProxyFactory pf = new ProxyFactory(new Class[] { ITestBean.class });
    pf.addAdvice(new PerformanceMonitorInterceptor());
    pf.addAdvice(si);

    ITestBean proxy = (ITestBean) pf.getProxy();

    try {
      proxy.exceptional(t);
      fail("Should have aborted with exception");
    }
    catch (Throwable got) {
      if (got.getClass().equals(t.getClass())) {
        // Ok
View Full Code Here

    si.setSynchronous(false);
    ProxyFactory pf = new ProxyFactory(new Class[] { ITestBean.class });
    pf.addAdvice(new PerformanceMonitorInterceptor());
    pf.addAdvice(si);

    ITestBean proxy = (ITestBean) pf.getProxy();
    Object result;
    try {
      result = proxy.getName();
      fail("cglib can't proxy final classes");
    }
    catch (IllegalArgumentException e) {
      // can't proxy strings
    }
View Full Code Here

    JavaSpaceInterceptor si = new JavaSpaceInterceptor(template);
    si.setSynchronous(false);
    ProxyFactory pf = new ProxyFactory(new Class[] { ITestBean.class });
    pf.addAdvice(new PerformanceMonitorInterceptor());
    pf.addAdvice(si);
    ITestBean proxy = (ITestBean) pf.getProxy();

    // nothing before the call
    assertNull(template.getSpace().readIfExists(new MethodResultEntry(), template.getCurrentTransaction(), 100));
    ITestBean lazyResult = proxy.getSpouse();
    System.out.println("spouse name is " + lazyResult.getClass());
    assertTrue(AopUtils.isCglibProxyClass(lazyResult.getClass()));
    System.out.println("should not be initialized");
    System.out.println(lazyResult.getClass());
    System.out.println(lazyResult.hashCode());
    System.out.println("should not be initialized");
    System.out.println(lazyResult);
    System.out.println("should be initialized");
    assertEquals("kerry", lazyResult.getName());
  }
View Full Code Here

    killWorkerThreads();
  }

  public void testSuccessfulInvocations() throws Exception {
    //template.clean();
    ITestBean proxy =  (ITestBean)applicationContext.getBean("proxy");
    for (int i = 0; i < 2; i++) {
      String name = "john" + i;
      proxy.setName(name);
      assertEquals(name, proxy.getName());
    }
  }
View Full Code Here

//    return new String[] {"/config/common.xml"};
  }

  public void testLazyTest() throws Throwable {
    //template.clean();
        ITestBean proxy =  (ITestBean)applicationContext.getBean("proxy");
    GigaSpacesInterceptor gigaSpacesInterceptor = (GigaSpacesInterceptor)applicationContext.getBean("javaSpaceInterceptor");
    gigaSpacesInterceptor.setSynchronous(false);
    ITestBean lazyResult = proxy.getSpouse();
   
    System.out.println("should not be initialized");
    System.out.println(lazyResult.getClass());
    System.out.println(lazyResult.hashCode());
    System.out.println("should not be initialized");
    System.out.println("classname is " + lazyResult.getClass());
    assertTrue(AopUtils.isCglibProxyClass(lazyResult.getClass()));

    System.out.println("The lazy result"+lazyResult);
    System.out.println("should be initialized");
    System.out.println("the name " +lazyResult.getName());
    assertEquals("kerry", lazyResult.getName());
  }
View Full Code Here

    assertEquals("kerry", lazyResult.getName());
  }

  public void testAsynchInterceptor() throws Throwable {
    template.clean();
    ITestBean proxy =  (ITestBean)applicationContext.getBean("proxy");
    GigaSpacesInterceptor gigaSpacesInterceptor = (GigaSpacesInterceptor)applicationContext.getBean("javaSpaceInterceptor");
    gigaSpacesInterceptor.setSynchronous(false);
    try {
      proxy.getName();
      fail("cglib can't proxy final classes");
    }
    catch (IllegalArgumentException e) {
      // can't proxy strings
      // expected
View Full Code Here

    }

    }
   
    public void testCallITestBeanMethod() throws Exception {
        ITestBean proxy = (ITestBean) applicationContext.getBean("proxy");
        assertEquals("rod", proxy.getName());
    }
View Full Code Here

TOP

Related Classes of org.springmodules.beans.ITestBean

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.