Examples of ITestBean


Examples of org.springframework.beans.ITestBean

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

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    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

        return new GZIPInputStream(is);
      }
    });

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    assertEquals("myname", proxy.getName());
    assertEquals(99, proxy.getAge());
    proxy.setAge(50);
    assertEquals(50, proxy.getAge());

    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

Examples of org.springframework.beans.ITestBean

        return ((TestRemoteInvocationResultWrapper) obj).remoteInvocationResult;
      }
    });

    pfb.afterPropertiesSet();
    ITestBean proxy = (ITestBean) pfb.getObject();
    assertEquals("myname", proxy.getName());
    assertEquals(99, proxy.getAge());
    proxy.setAge(50);
    assertEquals(50, proxy.getAge());

    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

Examples of org.springframework.tests.sample.beans.ITestBean

  @Test
  public void simpleBeanConfigured() throws Exception {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
        new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
    ITestBean rob = (TestBean) beanFactory.getBean("rob");
    ITestBean sally = (TestBean) beanFactory.getBean("sally");
    assertEquals("Rob Harrop", rob.getName());
    assertEquals(24, rob.getAge());
    assertEquals(rob.getSpouse(), sally);
  }
View Full Code Here

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

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();

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

Examples of org.springmodules.beans.ITestBean

    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

Examples of org.springmodules.beans.ITestBean

    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

Examples of org.springmodules.beans.ITestBean

    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

Examples of org.springmodules.beans.ITestBean

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