org.dbunit.dataset.DataSetException Java Examples
The following examples show how to use
org.dbunit.dataset.DataSetException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataSetBuilderTest.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void shouldAddEmptyTable() throws IOException, DataSetException { DataSetBuilder builder = new DataSetBuilder(); IDataSet dataSet = builder. table("USER") .build(); File datasetFile = Files.createTempFile("rider-empty-dataset", ".xml").toFile(); FileOutputStream fos = new FileOutputStream(datasetFile); FlatXmlDataSet.write(dataSet, fos); assertThat(contentOf(datasetFile)). contains("<?xml version='1.0' encoding='UTF-8'?>"+NEW_LINE + "<dataset>"+NEW_LINE + " <USER/>"+NEW_LINE + "</dataset>"); }
Example #2
Source File: DataSetBuilderExporterIt.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void shouldExportJSONDataSetUsingColumnValuesSyntax() throws DataSetException { executor.createDataSet(new DataSetConfig("json/users.json")); IDataSet iDataSet = createDataSetFromDatabase(); File outputDir = Paths.get("target/FromJSONBuilder.java").toAbsolutePath().toFile(); new DataSetBuilderExporter().export(iDataSet, new BuilderExportConfig(BuilderType.COLUMNS_VALUES, outputDir)); assertThat(contentOf(outputDir)).isEqualTo("DataSetBuilder builder = new DataSetBuilder();" + NEW_LINE + "IDataSet dataSet = builder" + NEW_LINE + " .table(\"FOLLOWER\")" + NEW_LINE + " .columns(\"ID\", \"USER_ID\", \"FOLLOWER_ID\")" + NEW_LINE + " .values(1, 1, 2)" + NEW_LINE + " .table(\"SEQUENCE\")" + NEW_LINE + " .columns(\"SEQ_NAME\", \"SEQ_COUNT\")" + NEW_LINE + " .values(\"SEQ_GEN\", 0)" + NEW_LINE + " .table(\"TWEET\")" + NEW_LINE + " .columns(\"ID\", \"CONTENT\", \"DATE\", \"LIKES\", \"TIMESTAMP\", \"USER_ID\")" + NEW_LINE + " .values(\"abcdef12345\", \"dbunit rules json example\", \"" + "" + iDataSet.getTable("TWEET").getValue(0,"DATE") + "\", null, null, 1)" + NEW_LINE + " .table(\"USER\")" + NEW_LINE + " .columns(\"ID\", \"NAME\")" + NEW_LINE + " .values(1, \"@realpestano\")" + NEW_LINE + " .values(2, \"@dbunit\").build();"); }
Example #3
Source File: JSONWriter.java From database-rider with Apache License 2.0 | 6 votes |
@Override public void row(Object[] values) throws DataSetException { rowCount++; try { out.write(FOUR_SPACES+"{"+NEW_LINE); String sb = createSetFromValues(values); out.write(sb); if(dataSet.getTable(metaData.getTableName()).getRowCount() != rowCount ){ out.write(FOUR_SPACES+"},"+NEW_LINE); }else { out.write(FOUR_SPACES+"}"+NEW_LINE); } } catch (Exception e) { logger.warn("Could not write row.", e); } }
Example #4
Source File: DataSetBuilderExporterIt.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void shouldExportXMLDataSetUsingColumnValuesSyntax() throws DataSetException { IDataSet iDataSet = new FlatXmlDataSetBuilder().build(getDataSetStream("datasets/xml/users.xml")); File outputDir = Paths.get("target/FromXMlBuilder.java").toAbsolutePath().toFile(); new DataSetBuilderExporter().export(iDataSet, new BuilderExportConfig(BuilderType.COLUMNS_VALUES, outputDir)); assertThat(contentOf(outputDir)).isEqualTo("DataSetBuilder builder = new DataSetBuilder();" + NEW_LINE + "IDataSet dataSet = builder" + NEW_LINE + " .table(\"USER\")" + NEW_LINE + " .columns(\"id\", \"name\")" + NEW_LINE + " .values(\"1\", \"@realpestano\")" + NEW_LINE + " .values(\"2\", \"@dbunit\")" + NEW_LINE + " .table(\"TWEET\")" + NEW_LINE + " .columns(\"id\", \"content\", \"user_id\")" + NEW_LINE + " .values(\"abcdef12345\", \"dbunit rules flat xml example\", \"1\")" + NEW_LINE + " .table(\"FOLLOWER\")" + NEW_LINE + " .columns(\"id\", \"user_id\", \"follower_id\")" + NEW_LINE + " .values(\"1\", \"1\", \"2\").build();"); }
Example #5
Source File: SqlDbFeatureExecutorTest.java From jpa-unit with Apache License 2.0 | 6 votes |
@Test public void testLoadDataSetsUsingAvailableFilePaths() throws DataSetException { // GIVEN // WHEN final List<IDataSet> dataSetList = featureExecutor.loadDataSets(Arrays.asList("test-data.json", "test-data.json")); // THEN assertNotNull(dataSetList); assertThat(dataSetList.size(), equalTo(2)); final IDataSet ds1 = dataSetList.get(0); assertNotNull(ds1); assertThat(ds1.getTableNames().length, equalTo(2)); final IDataSet ds2 = dataSetList.get(0); assertNotNull(ds2); assertThat(ds2.getTableNames().length, equalTo(2)); assertThat(ds1, equalTo(ds2)); }
Example #6
Source File: DataSetBuilderExporterIt.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void shouldExportYamlDataSetUsingColumnValuesSyntax() throws DataSetException { executor.createDataSet(new DataSetConfig("yml/users.yml")); IDataSet iDataSet = createDataSetFromDatabase(); File outputDir = Paths.get("target/FromYamlBuilder.java").toAbsolutePath().toFile(); new DataSetBuilderExporter().export(iDataSet, new BuilderExportConfig(BuilderType.COLUMNS_VALUES, outputDir)); assertThat(contentOf(outputDir)).isEqualTo("DataSetBuilder builder = new DataSetBuilder();" + NEW_LINE + "IDataSet dataSet = builder" + NEW_LINE + " .table(\"FOLLOWER\")" + NEW_LINE + " .columns(\"ID\", \"USER_ID\", \"FOLLOWER_ID\")" + NEW_LINE + " .values(1, 1, 2)" + NEW_LINE + " .table(\"SEQUENCE\")" + NEW_LINE + " .columns(\"SEQ_NAME\", \"SEQ_COUNT\")" + NEW_LINE + " .values(\"SEQ_GEN\", 0)" + NEW_LINE + " .table(\"TWEET\")" + NEW_LINE + " .columns(\"ID\", \"CONTENT\", \"DATE\", \"LIKES\", \"TIMESTAMP\", \"USER_ID\")" + NEW_LINE + " .values(\"abcdef12345\", \"dbunit rules!\", \"" + "" + iDataSet.getTable("TWEET").getValue(0,"DATE") + "\", null, null, 1)" + NEW_LINE + " .table(\"USER\")" + NEW_LINE + " .columns(\"ID\", \"NAME\")" + NEW_LINE + " .values(1, \"@realpestano\")" + NEW_LINE + " .values(2, \"@dbunit\").build();"); }
Example #7
Source File: DataSetComparator.java From jpa-unit with Apache License 2.0 | 6 votes |
private List<String> extractColumnsToBeIgnored(final ITable expectedTableState, final ITable currentTableState) throws DataSetException { final List<String> columnsToIgnore = extractNotExpectedColumnNames(expectedTableState, currentTableState); final String tableName = expectedTableState.getTableMetaData().getTableName(); columnsToIgnore.addAll(toExclude.getColumns(tableName)); final List<String> nonExistingColumns = new ArrayList<>(columnsToIgnore); nonExistingColumns.removeAll(extractColumnNames(currentTableState.getTableMetaData().getColumns())); if (!nonExistingColumns.isEmpty()) { LOG.debug("Columns which are specified to be filtered out {} are not existing in the table {}", Arrays.toString(nonExistingColumns.toArray()), tableName); } return columnsToIgnore; }
Example #8
Source File: DataSetProviderIt.java From database-rider with Apache License 2.0 | 6 votes |
@Override public IDataSet provide() throws DataSetException { DataSetBuilder builder = new DataSetBuilder(); ColumnSpec id = ColumnSpec.of("ID"); ColumnSpec name = ColumnSpec.of("NAME"); builder.table("USER") .row() .column("ID", 1) .column(name, "@realpestano") .table("USER") .row() .column(id, 2).column("NAME", "@dbunit") .table("TWEET") .row() .column("ID", "abcdef12345") .column("CONTENT", "dbunit rules!") .column("DATE", "[DAY,NOW]") .column("USER_ID", 9999) .build(); return builder.build(); }
Example #9
Source File: ScriptableTableTest.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void testGetValue() throws DataSetException { // prepare when(iTable.getValue(0, "category")).thenReturn("POPE:01"); when(manager.getEngineByName(anyString())).thenReturn(null); // test Object value = scriptableTable.getValue(0, "category"); // assert/verify assertEquals("POPE:01", value); verify(ScriptableTable.log).warning("Could not find script engine by name 'POPE'"); verify(manager).getEngineByName("POPE"); verify(iTable).getValue(0, "category"); verifyNoMoreInteractions(ScriptableTable.log, manager, iTable); }
Example #10
Source File: DataSetBuilderTest.java From database-rider with Apache License 2.0 | 6 votes |
@Test public void shouldGeneratFlatXmlDataSetWithEmptyUserTableWithColumnValuesSyntax() throws DataSetException, IOException { DataSetBuilder builder = new DataSetBuilder(); builder .table("USER") .table("TWEET") .columns("ID","CONTENT","DATE") .values("abcdef12345", "dbunit rules!", "[DAY,NOW]") .table("FOLLOWER") .columns("ID", "USER_ID","FOLLOWER_ID") .values(1 , 1 , 2) .build(); IDataSet dataSet = builder.build(); File datasetFile = Files.createTempFile("rider-dataset", ".xml").toFile(); FileOutputStream fos = new FileOutputStream(datasetFile); FlatXmlDataSet.write(dataSet, fos); assertThat(contentOf(datasetFile)). contains("<?xml version='1.0' encoding='UTF-8'?>"+NEW_LINE + "<dataset>"+NEW_LINE + " <USER/>"+NEW_LINE + " <TWEET ID=\"abcdef12345\" CONTENT=\"dbunit rules!\" DATE=\"[DAY,NOW]\"/>"+NEW_LINE + " <FOLLOWER ID=\"1\" USER_ID=\"1\" FOLLOWER_ID=\"2\"/>"+NEW_LINE + "</dataset>"); }
Example #11
Source File: KylinTestBase.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
protected static void printResult(ITable resultTable) throws DataSetException { StringBuilder sb = new StringBuilder(); int columnCount = resultTable.getTableMetaData().getColumns().length; String[] columns = new String[columnCount]; for (int i = 0; i < columnCount; i++) { sb.append(resultTable.getTableMetaData().getColumns()[i].getColumnName()); sb.append("-"); sb.append(resultTable.getTableMetaData().getColumns()[i].getDataType()); sb.append("\t"); columns[i] = resultTable.getTableMetaData().getColumns()[i].getColumnName(); } sb.append("\n"); for (int i = 0; i < resultTable.getRowCount(); i++) { for (int j = 0; j < columns.length; j++) { sb.append(resultTable.getValue(i, columns[j])); sb.append("\t"); } sb.append("\n"); } System.out.println(sb.toString()); }
Example #12
Source File: HackedDbUnitAssert.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void compareDataContains(ITable expectedTable, ITable actualTable, ComparisonColumn[] comparisonCols, FailureHandler failureHandler) throws DataSetException { logger.debug("compareData(expectedTable={}, actualTable={}, " + "comparisonCols={}, failureHandler={}) - start", new Object[] { expectedTable, actualTable, comparisonCols, failureHandler }); if (expectedTable == null) { throw new NullPointerException("The parameter 'expectedTable' must not be null"); } if (actualTable == null) { throw new NullPointerException("The parameter 'actualTable' must not be null"); } if (comparisonCols == null) { throw new NullPointerException("The parameter 'comparisonCols' must not be null"); } if (failureHandler == null) { throw new NullPointerException("The parameter 'failureHandler' must not be null"); } for (int index = 0; index < actualTable.getRowCount(); index++) { if (!findRowInExpectedTable(expectedTable, actualTable, comparisonCols, failureHandler, index)) { throw new IllegalStateException(); } } }
Example #13
Source File: DataSetProviderIt.java From database-rider with Apache License 2.0 | 5 votes |
@Override public IDataSet provide() throws DataSetException { DataSetBuilder builder = new DataSetBuilder(); builder.table("TWEET") .row() .column("ID", "abcdef12345") .column("CONTENT", "dbrider rules!") .column("DATE", "[DAY,NOW]"); return builder.build(); }
Example #14
Source File: DataSetProviderIt.java From database-rider with Apache License 2.0 | 5 votes |
@Override public IDataSet provide() throws DataSetException { DataSetBuilder builder = new DataSetBuilder(); builder.table("user") .row() .column("id", 2) .column("name", "@dbrider"); return builder.build(); }
Example #15
Source File: DataSetComparator.java From jpa-unit with Apache License 2.0 | 5 votes |
private List<String> extractNotExpectedColumnNames(final ITable expectedTable, final ITable currentTable) throws DataSetException { final Set<String> actualColumnNames = new HashSet<>(); final Set<String> expectedColumnNames = new HashSet<>(); if (currentTable != null) { actualColumnNames.addAll(extractColumnNames(currentTable.getTableMetaData().getColumns())); } if (expectedTable != null) { expectedColumnNames.addAll(extractColumnNames(expectedTable.getTableMetaData().getColumns())); } actualColumnNames.removeAll(expectedColumnNames); return new ArrayList<>(actualColumnNames); }
Example #16
Source File: JsonDataSetProducer.java From jpa-unit with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected Map<String, List<Map<String, String>>> loadDataSet() throws DataSetException { try { return gson.fromJson(new InputStreamReader(input), Map.class); } catch (final Exception e) { throw new DataSetException("Error parsing json data set", e); } }
Example #17
Source File: DataSetProducer.java From jpa-unit with Apache License 2.0 | 5 votes |
@Override public void produce() throws DataSetException { consumer.startDataSet(); final Map<String, List<Map<String, String>>> dataset = loadDataSet(); for (final Map.Entry<String, List<Map<String, String>>> entry : dataset.entrySet()) { // an entry represents a table final List<Map<String, String>> rows = entry.getValue(); // each row represents a record in a table final Collection<String> columnNames = extractColumnNames(rows); final ITableMetaData tableMetaData = new DefaultTableMetaData(entry.getKey(), createColumns(columnNames)); consumer.startTable(tableMetaData); for (final Map<String, String> row : rows) { final List<String> values = new ArrayList<>(); for (final Column column : tableMetaData.getColumns()) { final Object rawValue = row.get(column.getColumnName()); final String value = rawValue == null ? null : String.valueOf(rawValue); values.add(value); } consumer.row(values.toArray()); } consumer.endTable(); } consumer.endDataSet(); }
Example #18
Source File: ScriptableTable.java From database-rider with Apache License 2.0 | 5 votes |
@Override public Object getValue(int row, String column) throws DataSetException { Object value = delegate.getValue(row, column); if (value != null && scriptEnginePattern.matcher(value.toString()).matches()) { ScriptEngine engine = getScriptEngine(value.toString().trim()); if (engine != null) { try { return getScriptResult(value.toString(), engine); } catch (Exception e) { log.log(Level.WARNING,String.format("Could not evaluate script expression for table '%s', column '%s'. The original value will be used.", getTableMetaData().getTableName(), column),e); } } } return value; }
Example #19
Source File: AbstractDbUnitTestCase.java From wetech-cms with MIT License | 5 votes |
protected void backupCustomTable(String[] tname) throws DataSetException, IOException { QueryDataSet ds = new QueryDataSet(dbunitCon); for(String str:tname) { ds.addTable(str); } writeBackupFile(ds); }
Example #20
Source File: DataSetComparator.java From jpa-unit with Apache License 2.0 | 5 votes |
private List<String> defineColumnsForSorting(final IDataSet currentDataSet, final IDataSet expectedDataSet, final String tableName) throws DataSetException { final List<String> additionalColumns = additionalColumnsForSorting(expectedDataSet.getTable(tableName), currentDataSet.getTable(tableName)); final List<String> result = new ArrayList<>(); result.addAll(orderBy.getColumns(tableName)); result.addAll(additionalColumns); return result; }
Example #21
Source File: DataSetBuilderExporterIt.java From database-rider with Apache License 2.0 | 5 votes |
@Test public void shouldExportJSONDataSetUsingDefaultSyntax() throws DataSetException { executor.createDataSet(new DataSetConfig("json/users.json")); IDataSet iDataSet = createDataSetFromDatabase(); File outputDir = Paths.get("target/FromJSONDefaultBuilder.java").toAbsolutePath().toFile(); new DataSetBuilderExporter().export(iDataSet, new BuilderExportConfig(BuilderType.DEFAULT, outputDir)); assertThat(contentOf(outputDir)).isEqualTo("DataSetBuilder builder = new DataSetBuilder();" + NEW_LINE + "IDataSet dataSet = builder" + NEW_LINE + " .table(\"FOLLOWER\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 1)" + NEW_LINE + " .column(\"USER_ID\", 1)" + NEW_LINE + " .column(\"FOLLOWER_ID\", 2)" + NEW_LINE + " .table(\"SEQUENCE\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"SEQ_NAME\", \"SEQ_GEN\")" + NEW_LINE + " .column(\"SEQ_COUNT\", 0)" + NEW_LINE + " .table(\"TWEET\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", \"abcdef12345\")" + NEW_LINE + " .column(\"CONTENT\", \"dbunit rules json example\")" + NEW_LINE + " .column(\"DATE\", \"" + iDataSet.getTable("TWEET").getValue(0,"DATE") + "\")" + NEW_LINE + " .column(\"LIKES\", null)" + NEW_LINE + " .column(\"TIMESTAMP\", null)" + NEW_LINE + " .column(\"USER_ID\", 1)" + NEW_LINE + " .table(\"USER\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 1)" + NEW_LINE + " .column(\"NAME\", \"@realpestano\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 2)" + NEW_LINE + " .column(\"NAME\", \"@dbunit\").build();"); }
Example #22
Source File: AbstractDbUnitTestCase.java From wetech-cms with MIT License | 5 votes |
protected void backupCustomTable(String[] tname) throws DataSetException, IOException { QueryDataSet ds = new QueryDataSet(dbunitCon); for(String str:tname) { ds.addTable(str); } writeBackupFile(ds); }
Example #23
Source File: AbstractDbUnitTestCase.java From wetech-cms with MIT License | 5 votes |
protected IDataSet createDateSet(String tname) throws DataSetException, FileNotFoundException, IOException { InputStream is = AbstractDbUnitTestCase .class .getClassLoader().getResourceAsStream(tname+".xml"); Assert.assertNotNull("dbunit的基本数据文件不存在",is); //通过dtd和传入的文件创建测试的IDataSet return new FlatXmlDataSet(new FlatXmlProducer(new InputSource(is),new FlatDtdDataSet(new FileReader(dtdFile)))); }
Example #24
Source File: DataSetComparator.java From jpa-unit with Apache License 2.0 | 5 votes |
private List<String> additionalColumnsForSorting(final ITable expectedTableState, final ITable currentTableState) throws DataSetException { final List<String> columnsForSorting = new ArrayList<>(); final Set<String> allColumns = new HashSet<>(extractColumnNames(expectedTableState.getTableMetaData().getColumns())); final Set<String> columnsToIgnore = new HashSet<>(extractColumnsToBeIgnored(expectedTableState, currentTableState)); for (final String column : allColumns) { if (!columnsToIgnore.contains(column)) { columnsForSorting.add(column); } } return columnsForSorting; }
Example #25
Source File: DataSetLoaderProviderTest.java From jpa-unit with Apache License 2.0 | 5 votes |
@Test(expected = NullPointerException.class) public void testXlsLoaderLoadUsingNullFileName() throws IOException, DataSetException { // WHEN final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.xlsLoader(); // THEN assertThat(loader, notNullValue()); // WHEN loader.load(null); // THEN // IOException is thrown }
Example #26
Source File: DataSetExecutorImplTest.java From database-rider with Apache License 2.0 | 5 votes |
@Test(expected = RuntimeException.class) public void shouldFailLoadingDatasetFromHttp() throws IOException, DataSetException { DataSetExecutorImpl dse = DataSetExecutorImpl.instance(new ConnectionHolder() { private static final long serialVersionUID = 1L; @Override public Connection getConnection() { return null; } }); dse.loadDataSet("http://somewhere.de/test.csv"); }
Example #27
Source File: DataSetBuilderTest.java From database-rider with Apache License 2.0 | 5 votes |
@Test public void shouldGenerateDataSetUsingMetaModel() throws DataSetException, IOException { EntityManagerProvider.instance("contactPU"); DataSetBuilder builder = new DataSetBuilder(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, 1); Date date = new Date(); IDataSet dataSet = builder.table("CONTACT") .row() .column(Contact_.id, 1) .column(Contact_.name, "dbrider") .column(Contact_.date,date ) .column(Contact_.calendar, calendar) .build(); File datasetFile = Files.createTempFile("rider-dataset", ".yml").toFile(); FileOutputStream fos = new FileOutputStream(datasetFile); new YMLWriter(fos).write(dataSet); assertThat(contentOf(datasetFile)). contains("CONTACT:" + NEW_LINE + " - ID: \"1\"" + NEW_LINE + " NAME: \"dbrider\"" + NEW_LINE + " DATE: \"" + DateUtils.format(date) +"\"" + NEW_LINE + " CALENDAR: \"" + DateUtils.format(calendar.getTime()) +"\"" + NEW_LINE + ""); }
Example #28
Source File: DataSetBuilderExporterIt.java From database-rider with Apache License 2.0 | 5 votes |
@Test public void shouldExportYamlDataSetUsingDefaultSyntax() throws DataSetException { executor.createDataSet(new DataSetConfig("yml/users.yml")); IDataSet iDataSet = createDataSetFromDatabase(); File outputDir = Paths.get("target/FromYamlDefaultBuilder.java").toAbsolutePath().toFile(); new DataSetBuilderExporter().export(iDataSet, new BuilderExportConfig(BuilderType.DEFAULT, outputDir)); assertThat(contentOf(outputDir)).isEqualTo("DataSetBuilder builder = new DataSetBuilder();" + NEW_LINE + "IDataSet dataSet = builder" + NEW_LINE + " .table(\"FOLLOWER\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 1)" + NEW_LINE + " .column(\"USER_ID\", 1)" + NEW_LINE + " .column(\"FOLLOWER_ID\", 2)" + NEW_LINE + " .table(\"SEQUENCE\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"SEQ_NAME\", \"SEQ_GEN\")" + NEW_LINE + " .column(\"SEQ_COUNT\", 0)" + NEW_LINE + " .table(\"TWEET\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", \"abcdef12345\")" + NEW_LINE + " .column(\"CONTENT\", \"dbunit rules!\")" + NEW_LINE + " .column(\"DATE\", \"" + "" + iDataSet.getTable("TWEET").getValue(0,"DATE") + "\")" + NEW_LINE + " .column(\"LIKES\", null)" + NEW_LINE + " .column(\"TIMESTAMP\", null)" + NEW_LINE + " .column(\"USER_ID\", 1)" + NEW_LINE + " .table(\"USER\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 1)" + NEW_LINE + " .column(\"NAME\", \"@realpestano\")" + NEW_LINE + " .row()" + NEW_LINE + " .column(\"ID\", 2)" + NEW_LINE + " .column(\"NAME\", \"@dbunit\").build();"); }
Example #29
Source File: DataSetLoaderProviderTest.java From jpa-unit with Apache License 2.0 | 5 votes |
@Test(expected = NullPointerException.class) public void testXmlLoaderLoadUsingNullFileName() throws IOException, DataSetException { // WHEN final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.xmlLoader(); // THEN assertThat(loader, notNullValue()); // WHEN loader.load(null); // THEN // IOException is thrown }
Example #30
Source File: DataSetBuilderTest.java From database-rider with Apache License 2.0 | 5 votes |
@Test public void shouldGenerateDataSetcolumnDateColumn() throws DataSetException, IOException { DataSetBuilder builder = new DataSetBuilder(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, 1); Date date = new Date(); IDataSet dataSet = builder.table("USER") .row() .column("ID", 1) .column("DATE", date) .column("CALENDAR", calendar) .build(); File datasetFile = Files.createTempFile("rider-dataset", ".yml").toFile(); FileOutputStream fos = new FileOutputStream(datasetFile); new YMLWriter(fos).write(dataSet); assertThat(contentOf(datasetFile)). contains("USER:" + NEW_LINE + " - ID: \"1\"" + NEW_LINE + " DATE: \"" + DateUtils.format(date) +"\"" + NEW_LINE + " CALENDAR: \"" + DateUtils.format(calendar.getTime()) +"\"" + NEW_LINE + ""); }