Package org.springframework.test

Examples of org.springframework.test.AssertThrows


      }
    }.runTest();
  }

  public void testCtorWithNonCollectionType() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        new CustomCollectionEditor(String.class);
      }
    }.runTest();
  }
View Full Code Here


      }
    }.runTest();
  }

  public void testWithCollectionTypeThatDoesNotExposeAPublicNoArgCtor() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        CustomCollectionEditor editor = new CustomCollectionEditor(CollectionTypeWithNoNoArgCtor.class);
        editor.setValue("1");
      }
    }.runTest();
View Full Code Here

    assertTrue("Correct bigDecimal value", new BigDecimal("4.5").equals(bw.getPropertyValue("bigDecimal")));
    assertTrue("Correct bigDecimal value", new BigDecimal("4.5").equals(tb.getBigDecimal()));
  }

  public void testCustomNumberEditorCtorWithNullNumberType() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        new CustomNumberEditor(null, true);
      }
    }.runTest();
  }
View Full Code Here

      }
    }.runTest();
  }

  public void testCustomNumberEditorCtorWithNonNumberType() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        new CustomNumberEditor(String.class, true);
      }
    }.runTest();
  }
View Full Code Here

    bw.setPropertyValue("bigDecimal", "1 000,5");
    assertEquals(1000.5f, tb.getBigDecimal().floatValue(), 0f);
  }

  public void testParseShortGreaterThanMaxValueWithoutNumberFormat() {
    new AssertThrows(NumberFormatException.class, Short.MAX_VALUE + 1 + " is greater than max value") {
      public void test() throws Exception {
        CustomNumberEditor editor = new CustomNumberEditor(Short.class, true);
        editor.setAsText(String.valueOf(Short.MAX_VALUE + 1));
      }
    }.runTest();
View Full Code Here

    bw.setPropertyValue("myCharacter", "");
    assertNull(cb.getMyCharacter());
  }

  public void testCharacterEditorSetAsTextWithStringLongerThanOneCharacter() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        PropertyEditor charEditor = new CharacterEditor(false);
        charEditor.setAsText("ColdWaterCanyon");
      }
    }.runTest();
View Full Code Here

    charEditor.setAsText(" ");
    assertEquals(" ", charEditor.getAsText());
  }

  public void testCharacterEditorSetAsTextWithNullNotAllowingEmptyAsNull() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        PropertyEditor charEditor = new CharacterEditor(false);
        charEditor.setAsText(null);
      }
    }.runTest();
View Full Code Here

    classEditor.setAsText("\t  ");
    assertEquals("", classEditor.getAsText());
  }

  public void testClassEditorWithNonExistentClass() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        PropertyEditor classEditor = new ClassEditor();
        classEditor.setAsText("hairdresser.on.Fire");
      }
    }.runTest();
View Full Code Here

    File file = (File) value;
    assertTrue(file.exists());
  }

  public void testWithNonExistentResource() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {

      public void test() throws Exception {
        PropertyEditor propertyEditor = new FileEditor();
        propertyEditor.setAsText("classpath:no_way_this_file_is_found.doc");
      }
View Full Code Here

   * be autowired <em>by name</em>, as &amp; is an illegal character in
   * Java method names. In other words, you can't name a method
   * <code>set&amp;FactoryBean(...)</code>.
   */
  public void testAutowireBeanWithFactoryBeanByName() {
    new AssertThrows(TypeMismatchException.class) {
      public void test() throws Exception {
        DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
        RootBeanDefinition bd = new RootBeanDefinition(LazyInitFactory.class, new MutablePropertyValues());
        lbf.registerBeanDefinition("factoryBean", bd);
        LazyInitFactory factoryBean = (LazyInitFactory) lbf.getBean("&factoryBean");
View Full Code Here

TOP

Related Classes of org.springframework.test.AssertThrows

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.