Package org.springframework.binding.support

Examples of org.springframework.binding.support.TestBean


    fm.setFormObject(new TestBean());
    assertEquals("1", p1.getSimpleProperty());
  }

  public void testCommitEvents() {
    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    TestCommitListener cl = new TestCommitListener();
    AbstractFormModel fm = getFormModel(pas, false);
    fm.addCommitListener(cl);
    ValueModel vm = fm.getValueModel("simpleProperty");
View Full Code Here


    assertEquals(1, cl.preEditCalls);
    assertEquals(1, cl.postEditCalls);
  }

  public void testCommitWritesBufferingThrough() {
    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    TestCommitListener cl = new TestCommitListener();
    AbstractFormModel fm = getFormModel(pas, true);
    fm.addCommitListener(cl);
    ValueModel vm = fm.getValueModel("simpleProperty");

    vm.setValue("1");
    fm.commit();
    assertEquals("1", p.getSimpleProperty());
  }
View Full Code Here

  public void testRevertWithoutBuffering() {
    testRevert(false);
  }

  public void testRevert(boolean buffering) {
    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    TestPropertyChangeListener pcl = new TestPropertyChangeListener(FormModel.DIRTY_PROPERTY);
    AbstractFormModel fm = getFormModel(pas, buffering);
    fm.addPropertyChangeListener(FormModel.DIRTY_PROPERTY, pcl);
    ValueModel vm = fm.getValueModel("simpleProperty");

    vm.setValue("1");
    fm.revert();

    assertEquals(null, vm.getValue());
    assertEquals(null, p.getSimpleProperty());

    TestBean tb2 = new TestBean();
    tb2.setSimpleProperty("tb2");
    fm.setFormObject(tb2);

    vm.setValue("1");
    fm.revert();

    assertEquals("tb2", vm.getValue());
    assertEquals("tb2", tb2.getSimpleProperty());
  }
View Full Code Here

    assertTrue(fm.isEnabled());
    assertEquals(4, pcl.eventCount());
  }

  public void testConvertingValueModels() {
    AbstractFormModel fm = getFormModel(new TestBean());
    TestConversionService cs = new TestConversionService();
    fm.setConversionService(cs);

    ValueModel vm = fm.getValueModel("simpleProperty", String.class);
    assertEquals(fm.getValueModel("simpleProperty"), vm);
View Full Code Here

    assertEquals(fm.getValueModel("simpleProperty", Integer.class), cvm);
    assertEquals(3, cs.calls);
  }

  public void testFieldMetadata() {
    AbstractFormModel fm = getFormModel(new TestBean());

    assertEquals(String.class, fm.getFieldMetadata("simpleProperty").getPropertyType());
    assertTrue(!fm.getFieldMetadata("simpleProperty").isReadOnly());

    assertEquals(Object.class, fm.getFieldMetadata("readOnly").getPropertyType());
View Full Code Here

    assertEquals(Object.class, fm.getFieldMetadata("readOnly").getPropertyType());
    assertTrue(fm.getFieldMetadata("readOnly").isReadOnly());
  }

  public void testSetFormObjectUpdatesDirtyState() {
    final AbstractFormModel fm = getFormModel(new TestBean());
    fm.add("simpleProperty");
    fm.add("singleSelectListProperty");

    assertTrue(!fm.isDirty());

    fm.getValueModel("simpleProperty").addValueChangeListener(new PropertyChangeListener() {

      public void propertyChange(PropertyChangeEvent evt) {
        fm.getValueModel("singleSelectListProperty").setValue(null);
      }
    });

    TestBean newBean = new TestBean();
    newBean.setSimpleProperty("simpleProperty");
    newBean.setSingleSelectListProperty("singleSelectListProperty");
    fm.setFormObject(newBean);
    assertEquals(null, fm.getValueModel("singleSelectListProperty").getValue());
    assertTrue(fm.isDirty());
    fm.getValueModel("singleSelectListProperty").setValue("singleSelectListProperty");
    assertTrue(!fm.isDirty());
View Full Code Here

    fm.getValueModel("singleSelectListProperty").setValue("singleSelectListProperty");
    assertTrue(!fm.isDirty());
  }

  public void testFormPropertiesAreAccessableFromFormObjectChangeEvents() {
    final AbstractFormModel fm = getFormModel(new TestBean());
    assertEquals(null, fm.getValueModel("simpleProperty").getValue());
    TestBean newTestBean = new TestBean();
    newTestBean.setSimpleProperty("NewValue");
    fm.getFormObjectHolder().addValueChangeListener(new PropertyChangeListener() {

      public void propertyChange(PropertyChangeEvent evt) {
        assertEquals("NewValue", fm.getValueModel("simpleProperty").getValue());
      }
View Full Code Here

    });
    fm.setFormObject(newTestBean);
  }

  public void testFormObjectChangeEventComesBeforePropertyChangeEvent() {
    final TestBean testBean = new TestBean();
    final AbstractFormModel fm = getFormModel(testBean);
    final TestBean newTestBean = new TestBean();
    newTestBean.setSimpleProperty("NewValue");
    final boolean[] formObjectChangeCalled = new boolean[1];
    fm.getFormObjectHolder().addValueChangeListener(new PropertyChangeListener() {

      public void propertyChange(PropertyChangeEvent evt) {
        formObjectChangeCalled[0] = true;
View Full Code Here

    });
    fm.setFormObject(newTestBean);
  }

  public void testFormObjectChangeEvents() {
    TestBean testBean = new TestBean();
    final AbstractFormModel fm = getFormModel(testBean);
    TestBean newTestBean = new TestBean();
    newTestBean.setSimpleProperty("NewValue");
    TestPropertyChangeListener testPCL = new TestPropertyChangeListener(ValueModel.VALUE_PROPERTY);
    fm.getFormObjectHolder().addValueChangeListener(testPCL);
    fm.setFormObject(newTestBean);
    assertEquals(1, testPCL.eventCount());
    assertEquals(testBean, testPCL.lastEvent().getOldValue());
View Full Code Here

   * not be dirty.
   * </p>
   */
  public void testBufferedFormModelSetFormObjectNotDirty() {
    String someString = "someString";
    FormModel model = getFormModel(new TestBean());
    ValueModel valueModel = model.getValueModel("simpleProperty");

    assertEquals("Initial check, formmodel not dirty.", false, model.isDirty());

    valueModel.setValue(someString);
    assertEquals("Value changed, model should be dirty.", true, model.isDirty());

    TestBean newFormObject = new TestBean();
    newFormObject.setSimpleProperty(someString);
    model.setFormObject(newFormObject);
    assertEquals("New formObject is set, model should not be dirty.", false, model.isDirty());
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.support.TestBean

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.