Examples of ExtendedTestContextManager


Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager

  }

  @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());
    assertEquals(
        DefaultDatabaseOperationLookup.class,
        testContextManager.getTestContextAttribute(
            DbUnitTestExecutionListener.DATABASE_OPERATION_LOOKUP_ATTRIBUTE).getClass());
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager

    testCommonBeanNames(EmptyDbUnitConfiguration.class);
  }

  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

  }

  @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

    assertEquals(DatabaseDataSourceConnection.class, connection.getClass());
  }

  @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

  }

  @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

  }

  @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)
            .getClass());
    assertEquals(
        CustomDatabaseOperationLookup.class,
        testContextManager.getTestContextAttribute(
            DbUnitTestExecutionListener.DATABASE_OPERATION_LOOKUP_ATTRIBUTE).getClass());
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager

  }

  @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

  @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 com.github.springtestdbunit.testutils.ExtendedTestContextManager

  private FlatXmlDataSetLoader loader;

  @Before
  public void setup() throws Exception {
    this.loader = new FlatXmlDataSetLoader();
    ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass());
    this.testContext = manager.accessTestContext();
  }
View Full Code Here

Examples of com.github.springtestdbunit.testutils.ExtendedTestContextManager

  private ReplacementDataSetLoader loader;

  @Before
  public void setup() throws Exception {
    this.loader = new ReplacementDataSetLoader();
    ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass());
    this.testContext = manager.accessTestContext();
  }
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.