Examples of prepareTestInstance()


Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldUseSensibleDefaultsOnClassWithNoDbUnitConfiguration() throws Exception {
    addBean("dbUnitDatabaseConnection", this.databaseConnection);
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class);
    testContextManager.prepareTestInstance();
    assertSame(this.databaseConnection,
        testContextManager.getTestContextAttribute(DbUnitTestExecutionListener.CONNECTION_ATTRIBUTE));
    assertEquals(FlatXmlDataSetLoader.class,
        testContextManager.getTestContextAttribute(DbUnitTestExecutionListener.DATA_SET_LOADER_ATTRIBUTE)
            .getClass());
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  }

  private void testCommonBeanNames(Class<?> testClass) throws Exception {
    addBean("dataSource", this.dataSource);
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(testClass);
    testContextManager.prepareTestInstance();
    verify(this.applicationContext).containsBean("dbUnitDataSetLoader");
    verify(this.applicationContext).containsBean("dbUnitDatabaseConnection");
    verify(this.applicationContext).containsBean("dataSource");
    verify(this.applicationContext).getBean("dataSource");
    verifyNoMoreInteractions(this.applicationContext);
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldConvertDatasetDatabaseConnection() throws Exception {
    addBean("dataSource", this.dataSource);
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class);
    testContextManager.prepareTestInstance();
    Object connection = testContextManager
        .getTestContextAttribute(DbUnitTestExecutionListener.CONNECTION_ATTRIBUTE);
    assertEquals(DatabaseDataSourceConnection.class, connection.getClass());
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldFailIfNoDbConnectionBeanIsFound() throws Exception {
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class);
    try {
      testContextManager.prepareTestInstance();
    } catch (IllegalStateException e) {
      assertTrue(e.getMessage().startsWith("Unable to find a DB Unit database connection"));
    }
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldFailIfDatabaseConnectionOfWrongTypeIsFound() throws Exception {
    addBean("dbUnitDatabaseConnection", new Integer(0));
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class);
    try {
      testContextManager.prepareTestInstance();
    } catch (IllegalArgumentException e) {
      assertEquals("Object of class [java.lang.Integer] must be an instance of interface "
          + "org.dbunit.database.IDatabaseConnection", e.getMessage());
    }
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldSupportAllDbUnitConfigurationAttributes() throws Exception {
    addBean("customBean", this.databaseConnection);
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(CustomConfiguration.class);
    testContextManager.prepareTestInstance();
    verify(this.applicationContext).getBean("customBean");
    assertSame(this.databaseConnection,
        testContextManager.getTestContextAttribute(DbUnitTestExecutionListener.CONNECTION_ATTRIBUTE));
    assertEquals(CustomDataSetLoader.class,
        testContextManager.getTestContextAttribute(DbUnitTestExecutionListener.DATA_SET_LOADER_ATTRIBUTE)
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldFailIfDatasetLoaderCannotBeCreated() throws Exception {
    addBean("dbUnitDatabaseConnection", this.databaseConnection);
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NonCreatableDataSetLoader.class);
    try {
      testContextManager.prepareTestInstance();
    } catch (IllegalArgumentException e) {
      assertEquals("Unable to create data set loader instance for class "
          + "com.github.springtestdbunit.DbUnitTestExecutionListenerPrepareTests$"
          + "AbstractCustomDataSetLoader", e.getMessage());
    }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager.prepareTestInstance()

  @Test
  public void shouldSupportCustomLoaderBean() throws Exception {
    addBean("dataSource", this.dataSource);
    addBean("dbUnitDataSetLoader", new CustomDataSetLoader());
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(EmptyDbUnitConfiguration.class);
    testContextManager.prepareTestInstance();
    assertEquals(CustomDataSetLoader.class,
        testContextManager.getTestContextAttribute(DbUnitTestExecutionListener.DATA_SET_LOADER_ATTRIBUTE)
            .getClass());
  }
View Full Code Here

Examples of org.springframework.test.context.TestContextManager.prepareTestInstance()

    @Before
    public void setUpContext() throws Exception {
        //this is where the magic happens, we actually do "by hand" what the spring runner would do for us,
        // read the JavaDoc for the class bellow to know exactly what it does, the method names are quite accurate though
        TestContextManager testContextManager = new TestContextManager(getClass());
        testContextManager.prepareTestInstance(this);
    }
}
View Full Code Here

Examples of org.springframework.test.context.TestContextManager.prepareTestInstance()

                    applicationContext.getBean(MessageListeners.class).addMessageListener(webSocketTestEventListener);
                }
            };

            try {
                testContextManager.prepareTestInstance(null);
            } catch (Exception e) {
                log.error("Failed to load application context", e);
            }
        }
       
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.