Package org.springframework.test

Examples of org.springframework.test.AssertThrows


  public void testSetField() {
    final TestBeanSubclassWithNewField testBean = new TestBeanSubclassWithNewField();
    final Field field = ReflectionUtils.findField(TestBeanSubclassWithNewField.class, "name", String.class);

    new AssertThrows(IllegalStateException.class,
        "Calling setField() with on a private field without making it accessible should throw an IllegalStateException.") {

      public void test() throws Exception {
        ReflectionUtils.setField(field, testBean, "FooBar");
      }
View Full Code Here


* @author Rick Evans
*/
public class EventPublicationInterceptorTests extends TestCase {

  public void testWithNoApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.afterPropertiesSet();
View Full Code Here

      }
    }.runTest();
  }

  public void testWithNonApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(getClass());
View Full Code Here

      }
    }.runTest();
  }

  public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(ApplicationEvent.class);
View Full Code Here

      }
    }.runTest();
  }

  public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(TestEventWithNoValidOneArgObjectCtor.class);
View Full Code Here

    assertNotNull(string);
    assertEquals("bing", string);
  }

  public void testOneArgCtorWithNull() throws Exception {
    new AssertThrows(IllegalArgumentException.class, "Null model arguments added without a name being explicitly supplied are not allowed.") {
      public void test() throws Exception {
        new ModelMap(null);
      }
    }.runTest();
  }
View Full Code Here

    // must not add if collection is empty...
    assertEquals(0, model.size());
  }

  public void testAddObjectWithNull() throws Exception {
    new AssertThrows(IllegalArgumentException.class, "Null model arguments added without a name being explicitly supplied are not allowed.") {
      public void test() throws Exception {
        ModelMap model = new ModelMap();
        model.addAttribute(null);
      }
    }.runTest();
View Full Code Here

    model.addAllAttributes((Collection) null);
    assertEquals(0, model.size());
  }

  public void testAddAllObjectsWithSparseArrayList() throws Exception {
    new AssertThrows(IllegalArgumentException.class, "Null model arguments added without a name being explicitly supplied are not allowed.") {
      public void test() throws Exception {
        ModelMap model = new ModelMap();
        ArrayList list = new ArrayList();
        list.add("bing");
        list.add(null);
View Full Code Here

    assertEquals(1, mc.getApplicationListeners().size());
    assertEquals(ArrayList.class, mc.getApplicationListeners().getClass());
  }

  public void testMulticasterInvalidCollectionClass_NotEvenACollectionType() {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        AbstractApplicationEventMulticaster mc = getMulticaster();
        mc.setCollectionClass(ApplicationContextEventTests.class);
      }
    }.runTest();
View Full Code Here

      }
    }.runTest();
  }

  public void testMulticasterInvalidCollectionClass_PassingAnInterfaceNotAConcreteClass() {
    new AssertThrows(FatalBeanException.class) {
      public void test() throws Exception {
        AbstractApplicationEventMulticaster mc = getMulticaster();
        mc.setCollectionClass(List.class);
      }
    }.runTest();
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.