Package org.springframework.tests.sample.beans

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


    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, "array", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        DerivedTestBean tb = new DerivedTestBean();
        tb.setName("array" + text);
        setValue(tb);
      }
      @Override
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here


    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, "map[key0]", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        DerivedTestBean tb = new DerivedTestBean();
        tb.setName("array" + text);
        setValue(tb);
      }
      @Override
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here

    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        DerivedTestBean tb = new DerivedTestBean();
        tb.setName("array" + text);
        setValue(tb);
      }
      @Override
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here

    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        DerivedTestBean tb = new DerivedTestBean();
        tb.setName("array" + text);
        setValue(tb);
      }
      @Override
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here

    assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
  }

  @Test
  public void testCopyPropertiesWithDifferentTypes1() throws Exception {
    DerivedTestBean tb = new DerivedTestBean();
    tb.setName("rod");
    tb.setAge(32);
    tb.setTouchy("touchy");
    TestBean tb2 = new TestBean();
    assertTrue("Name empty", tb2.getName() == null);
    assertTrue("Age empty", tb2.getAge() == 0);
    assertTrue("Touchy empty", tb2.getTouchy() == null);
    BeanUtils.copyProperties(tb, tb2);
    assertTrue("Name copied", tb2.getName().equals(tb.getName()));
    assertTrue("Age copied", tb2.getAge() == tb.getAge());
    assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
  }
View Full Code Here

  public void testCopyPropertiesWithDifferentTypes2() throws Exception {
    TestBean tb = new TestBean();
    tb.setName("rod");
    tb.setAge(32);
    tb.setTouchy("touchy");
    DerivedTestBean tb2 = new DerivedTestBean();
    assertTrue("Name empty", tb2.getName() == null);
    assertTrue("Age empty", tb2.getAge() == 0);
    assertTrue("Touchy empty", tb2.getTouchy() == null);
    BeanUtils.copyProperties(tb, tb2);
    assertTrue("Name copied", tb2.getName().equals(tb.getName()));
    assertTrue("Age copied", tb2.getAge() == tb.getAge());
    assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
  }
View Full Code Here

    MockRenderRequest request = new MockRenderRequest();
    PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);
    try {
      assertNull(request.getAttribute(NAME));
      DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
      assertSame(bean, request.getAttribute(NAME));
      assertSame(bean, ac.getBean(NAME));
      requestAttributes.requestCompleted();
      assertTrue(bean.wasDestroyed());
    }
    finally {
      RequestContextHolder.setRequestAttributes(null);
    }
  }
View Full Code Here

    MockRenderRequest request = new MockRenderRequest();
    PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);
    try {
      assertNull(request.getPortletSession().getAttribute(NAME));
      DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
      assertSame(bean, request.getPortletSession().getAttribute(NAME));
      assertSame(bean, ac.getBean(NAME));
      request.getPortletSession().invalidate();
      assertTrue(bean.wasDestroyed());
    }
    finally {
      RequestContextHolder.setRequestAttributes(null);
    }
  }
View Full Code Here

    MockRenderRequest request = new MockRenderRequest();
    PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);
    try {
      assertNull(request.getPortletSession().getAttribute(NAME, PortletSession.APPLICATION_SCOPE));
      DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
      assertSame(bean, request.getPortletSession().getAttribute(NAME, PortletSession.APPLICATION_SCOPE));
      assertSame(bean, ac.getBean(NAME));
      request.getPortletSession().invalidate();
      assertTrue(bean.wasDestroyed());
    }
    finally {
      RequestContextHolder.setRequestAttributes(null);
    }
  }
View Full Code Here

  @Test
  public void testApplicationScope() {
    ConfigurablePortletApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
    assertNull(ac.getPortletContext().getAttribute(NAME));
    DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
    assertSame(bean, ac.getPortletContext().getAttribute(NAME));
    assertSame(bean, ac.getBean(NAME));
    new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
    assertTrue(bean.wasDestroyed());
  }
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.beans.DerivedTestBean

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.