Examples of BooleanTestBean


Examples of org.springframework.beans.BooleanTestBean

    assertEquals("prefixvalue", bw.getPropertyValue("touchy"));
    assertEquals("prefixvalue", tb.getTouchy());
  }

  public void testDefaultBooleanEditorForPrimitiveType() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);

    bw.setPropertyValue("bool1", "true");
    assertTrue("Correct bool1 value", Boolean.TRUE.equals(bw.getPropertyValue("bool1")));
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "false");
    assertTrue("Correct bool1 value", Boolean.FALSE.equals(bw.getPropertyValue("bool1")));
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "  true  ");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "  false  ");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "on");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "off");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "yes");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "no");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "1");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "0");
    assertTrue("Correct bool1 value", !tb.isBool1());

    try {
      bw.setPropertyValue("bool1", "argh");
      fail("Should have thrown BeansException");
    }
View Full Code Here

Examples of org.springframework.beans.BooleanTestBean

      // expected
    }
  }

  public void testDefaultBooleanEditorForWrapperType() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);

    bw.setPropertyValue("bool2", "true");
    assertTrue("Correct bool2 value", Boolean.TRUE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "false");
    assertTrue("Correct bool2 value", Boolean.FALSE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "on");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "off");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "yes");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "no");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "1");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "0");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "");
    assertNull("Correct bool2 value", tb.getBool2());
  }
View Full Code Here

Examples of org.springframework.beans.BooleanTestBean

    bw.setPropertyValue("bool2", "");
    assertNull("Correct bool2 value", tb.getBool2());
  }

  public void testCustomBooleanEditorWithAllowEmpty() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));

    bw.setPropertyValue("bool2", "true");
    assertTrue("Correct bool2 value", Boolean.TRUE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "false");
    assertTrue("Correct bool2 value", Boolean.FALSE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "on");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "off");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "yes");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "no");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "1");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "0");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "");
    assertTrue("Correct bool2 value", bw.getPropertyValue("bool2") == null);
    assertTrue("Correct bool2 value", tb.getBool2() == null);
  }
View Full Code Here

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

    assertEquals(Integer.class.toString(), tb.getName());
  }

  @Test
  public void testBooleanObject() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);

    bw.setPropertyValue("bool2", "true");
    assertTrue("Correct bool2 value", Boolean.TRUE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "false");
    assertTrue("Correct bool2 value", Boolean.FALSE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

  }
View Full Code Here

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

    assertEquals("prefixvalue", tb.getTouchy());
  }

  @Test
  public void testDefaultBooleanEditorForPrimitiveType() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);

    bw.setPropertyValue("bool1", "true");
    assertTrue("Correct bool1 value", Boolean.TRUE.equals(bw.getPropertyValue("bool1")));
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "false");
    assertTrue("Correct bool1 value", Boolean.FALSE.equals(bw.getPropertyValue("bool1")));
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "  true  ");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "  false  ");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "on");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "off");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "yes");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "no");
    assertTrue("Correct bool1 value", !tb.isBool1());

    bw.setPropertyValue("bool1", "1");
    assertTrue("Correct bool1 value", tb.isBool1());

    bw.setPropertyValue("bool1", "0");
    assertTrue("Correct bool1 value", !tb.isBool1());

    try {
      bw.setPropertyValue("bool1", "argh");
      fail("Should have thrown BeansException");
    }
View Full Code Here

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

    }
  }

  @Test
  public void testDefaultBooleanEditorForWrapperType() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);

    bw.setPropertyValue("bool2", "true");
    assertTrue("Correct bool2 value", Boolean.TRUE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "false");
    assertTrue("Correct bool2 value", Boolean.FALSE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "on");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "off");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "yes");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "no");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "1");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "0");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "");
    assertNull("Correct bool2 value", tb.getBool2());
  }
View Full Code Here

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

    assertNull("Correct bool2 value", tb.getBool2());
  }

  @Test
  public void testCustomBooleanEditorWithAllowEmpty() {
    BooleanTestBean tb = new BooleanTestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));

    bw.setPropertyValue("bool2", "true");
    assertTrue("Correct bool2 value", Boolean.TRUE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "false");
    assertTrue("Correct bool2 value", Boolean.FALSE.equals(bw.getPropertyValue("bool2")));
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "on");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "off");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "yes");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "no");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "1");
    assertTrue("Correct bool2 value", tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "0");
    assertTrue("Correct bool2 value", !tb.getBool2().booleanValue());

    bw.setPropertyValue("bool2", "");
    assertTrue("Correct bool2 value", bw.getPropertyValue("bool2") == null);
    assertTrue("Correct bool2 value", tb.getBool2() == null);
  }
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.