Examples of ExpectedDatabase


Examples of com.github.springtestdbunit.annotation.ExpectedDatabase

      }
      return;
    }
    IDatabaseConnection connection = testContext.getConnection();
    for (int i = annotations.size() - 1; i >= 0; i--) {
      ExpectedDatabase annotation = annotations.get(i);
      String query = annotation.query();
      String table = annotation.table();
      IDataSet expectedDataSet = loadDataset(testContext, annotation.value());
      if (expectedDataSet != null) {
        if (logger.isDebugEnabled()) {
          logger.debug("Veriftying @DatabaseTest expectation using " + annotation.value());
        }
        DatabaseAssertion assertion = annotation.assertionMode().getDatabaseAssertion();
        if (StringUtils.hasLength(query)) {
          Assert.hasLength(table, "The table name must be specified when using a SQL query");
          ITable expectedTable = expectedDataSet.getTable(table);
          ITable actualTable = connection.createQueryTable(table, query);
          assertion.assertEquals(expectedTable, actualTable);
        } else if (StringUtils.hasLength(table)) {
          ITable actualTable = connection.createTable(table);
          ITable expectedTable = expectedDataSet.getTable(table);
          assertion.assertEquals(expectedTable, actualTable);
        } else {
          IDataSet actualDataSet = connection.createDataSet();
          assertion.assertEquals(expectedDataSet, actualDataSet);
        }
      }
      if (annotation.override()) {
        // No need to test any more
        return;
      }
    }
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.