本文整理汇总了Java中org.dbunit.dataset.stream.IDataSetProducer类的典型用法代码示例。如果您正苦于以下问题:Java IDataSetProducer类的具体用法?Java IDataSetProducer怎么用?Java IDataSetProducer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDataSetProducer类属于org.dbunit.dataset.stream包,在下文中一共展示了IDataSetProducer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProduceDataSetUsingNotJsonStream
import org.dbunit.dataset.stream.IDataSetProducer; //导入依赖的package包/类
@Test
public void testProduceDataSetUsingNotJsonStream() throws DataSetException {
// GIVEN
final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
final IDataSetProducer producer = new JsonDataSetProducer(yamlStream);
producer.setConsumer(consumer);
// WHEN
try {
producer.produce();
fail("DataSetException expected");
} catch (final DataSetException e) {
// THEN
assertThat(e.getCause(), instanceOf(JsonSyntaxException.class));
}
}
示例2: testProduceDataSetFromEmptyFile
import org.dbunit.dataset.stream.IDataSetProducer; //导入依赖的package包/类
@Test
public void testProduceDataSetFromEmptyFile() throws DataSetException {
// GIVEN
final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
final IDataSetProducer producer = new YamlDataSetProducer(emptyStream);
producer.setConsumer(consumer);
// WHEN
producer.produce();
// THEN
verify(consumer).startDataSet();
verify(consumer, times(0)).startTable(any(ITableMetaData.class));
verify(consumer, times(0)).row(any(Object[].class));
verify(consumer, times(0)).endTable();
verify(consumer).endDataSet();
}
示例3: testProduceDataSetUsingNotYamlStream
import org.dbunit.dataset.stream.IDataSetProducer; //导入依赖的package包/类
@Test
public void testProduceDataSetUsingNotYamlStream() throws DataSetException {
// GIVEN
final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
final IDataSetProducer producer = new YamlDataSetProducer(jsonStream);
producer.setConsumer(consumer);
// WHEN
try {
producer.produce();
fail("DataSetException expected");
} catch (final DataSetException e) {
// THEN
assertThat(e.getCause(), instanceOf(ScannerException.class));
}
}
示例4: testProduceDataSetUsingValidStream
import org.dbunit.dataset.stream.IDataSetProducer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testProduceDataSetUsingValidStream() throws DataSetException {
// GIVEN
final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
final IDataSetProducer producer = new JsonDataSetProducer(jsonStream);
producer.setConsumer(consumer);
// WHEN
producer.produce();
// THEN
verify(consumer).startDataSet();
final ArgumentCaptor<ITableMetaData> tmdCaptor = ArgumentCaptor.forClass(ITableMetaData.class);
verify(consumer, times(2)).startTable(tmdCaptor.capture());
final List<ITableMetaData> tmdList = tmdCaptor.getAllValues();
final ITableMetaData tmd1 = tmdList.get(0);
final List<Column> table1Columns = Arrays.asList(tmd1.getColumns());
final ITableMetaData tmd2 = tmdList.get(1);
final List<Column> table2Columns = Arrays.asList(tmd2.getColumns());
assertThat(tmd1.getTableName(), equalTo("JSON_TABLE_1"));
assertThat(table1Columns.size(), equalTo(7));
assertThat(table1Columns, hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_1"),
columnWithName("value_2"), columnWithName("value_3"), columnWithName("value_4"), columnWithName("value_5")));
assertThat(tmd2.getTableName(), equalTo("JSON_TABLE_2"));
assertThat(table2Columns.size(), equalTo(4));
assertThat(table2Columns,
hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_6"), columnWithName("value_7")));
final ArgumentCaptor<Object[]> rowCaptor = ArgumentCaptor.forClass(Object[].class);
verify(consumer, times(4)).row(rowCaptor.capture());
final List<Object[]> allRows = rowCaptor.getAllValues();
final Map<String, String> record1 = rebuildRecord(table1Columns, allRows.get(0));
assertThat(record1.size(), equalTo(7));
assertThat(record1.get("id"), equalTo("1"));
assertThat(record1.get("version"), equalTo("Record 1 version"));
assertThat(record1.get("value_1"), equalTo("Record 1 Value 1"));
assertThat(record1.get("value_2"), equalTo("Record 1 Value 2"));
assertThat(record1.get("value_3"), nullValue());
assertThat(record1.get("value_4"), equalTo("Record 1 Value 4"));
assertThat(record1.get("value_5"), nullValue());
final Map<String, String> record2 = rebuildRecord(table1Columns, allRows.get(1));
assertThat(record2.size(), equalTo(7));
assertThat(record2.get("id"), equalTo("2"));
assertThat(record2.get("version"), equalTo("Record 2 version"));
assertThat(record2.get("value_1"), equalTo("Record 2 Value 1"));
assertThat(record2.get("value_2"), equalTo("Record 2 Value 2"));
assertThat(record2.get("value_3"), equalTo("Record 2 Value 3"));
assertThat(record2.get("value_4"), nullValue());
assertThat(record2.get("value_5"), nullValue());
final Map<String, String> record3 = rebuildRecord(table1Columns, allRows.get(2));
assertThat(record3.size(), equalTo(7));
assertThat(record3.get("id"), equalTo("3"));
assertThat(record3.get("version"), equalTo("Record 3 version"));
assertThat(record3.get("value_1"), nullValue());
assertThat(record3.get("value_2"), nullValue());
assertThat(record3.get("value_3"), nullValue());
assertThat(record3.get("value_4"), nullValue());
assertThat(record3.get("value_5"), equalTo("Record 3 Value 5"));
final Map<String, String> record4 = rebuildRecord(table2Columns, allRows.get(3));
assertThat(record4.size(), equalTo(4));
assertThat(record4.get("id"), equalTo("4"));
assertThat(record4.get("version"), equalTo("Record 4 version"));
assertThat(record4.get("value_6"), equalTo("Record 4 Value 6"));
assertThat(record4.get("value_7"), equalTo("Record 4 Value 7"));
verify(consumer, times(2)).endTable();
verify(consumer).endDataSet();
}
示例5: testProduceDataSetUsingValidStream
import org.dbunit.dataset.stream.IDataSetProducer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testProduceDataSetUsingValidStream() throws DataSetException {
// GIVEN
final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
final IDataSetProducer producer = new YamlDataSetProducer(yamlStream);
producer.setConsumer(consumer);
// WHEN
producer.produce();
// THEN
verify(consumer).startDataSet();
final ArgumentCaptor<ITableMetaData> tmdCaptor = ArgumentCaptor.forClass(ITableMetaData.class);
verify(consumer, times(2)).startTable(tmdCaptor.capture());
final List<ITableMetaData> tmdList = tmdCaptor.getAllValues();
final ITableMetaData tmd1 = tmdList.get(0);
final List<Column> table1Columns = Arrays.asList(tmd1.getColumns());
final ITableMetaData tmd2 = tmdList.get(1);
final List<Column> table2Columns = Arrays.asList(tmd2.getColumns());
assertThat(tmd1.getTableName(), equalTo("YAML_TABLE_1"));
assertThat(table1Columns.size(), equalTo(7));
assertThat(table1Columns, hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_1"),
columnWithName("value_2"), columnWithName("value_3"), columnWithName("value_4"), columnWithName("value_5")));
assertThat(tmd2.getTableName(), equalTo("YAML_TABLE_2"));
assertThat(table2Columns.size(), equalTo(4));
assertThat(table2Columns,
hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_6"), columnWithName("value_7")));
final ArgumentCaptor<Object[]> rowCaptor = ArgumentCaptor.forClass(Object[].class);
verify(consumer, times(4)).row(rowCaptor.capture());
final List<Object[]> allRows = rowCaptor.getAllValues();
final Map<String, String> record1 = rebuildRecord(table1Columns, allRows.get(0));
assertThat(record1.size(), equalTo(7));
assertThat(record1.get("id"), equalTo("1"));
assertThat(record1.get("version"), equalTo("Record 1 version"));
assertThat(record1.get("value_1"), equalTo("Record 1 Value 1"));
assertThat(record1.get("value_2"), equalTo("Record 1 Value 2"));
assertThat(record1.get("value_3"), nullValue());
assertThat(record1.get("value_4"), equalTo("Record 1 Value 4"));
assertThat(record1.get("value_5"), nullValue());
final Map<String, String> record2 = rebuildRecord(table1Columns, allRows.get(1));
assertThat(record2.size(), equalTo(7));
assertThat(record2.get("id"), equalTo("2"));
assertThat(record2.get("version"), equalTo("Record 2 version"));
assertThat(record2.get("value_1"), equalTo("Record 2 Value 1"));
assertThat(record2.get("value_2"), equalTo("Record 2 Value 2"));
assertThat(record2.get("value_3"), equalTo("Record 2 Value 3"));
assertThat(record2.get("value_4"), nullValue());
assertThat(record2.get("value_5"), nullValue());
final Map<String, String> record3 = rebuildRecord(table1Columns, allRows.get(2));
assertThat(record3.size(), equalTo(7));
assertThat(record3.get("id"), equalTo("3"));
assertThat(record3.get("version"), equalTo("Record 3 version"));
assertThat(record3.get("value_1"), nullValue());
assertThat(record3.get("value_2"), nullValue());
assertThat(record3.get("value_3"), nullValue());
assertThat(record3.get("value_4"), nullValue());
assertThat(record3.get("value_5"), equalTo("Record 3 Value 5"));
final Map<String, String> record4 = rebuildRecord(table2Columns, allRows.get(3));
assertThat(record4.size(), equalTo(4));
assertThat(record4.get("id"), equalTo("4"));
assertThat(record4.get("version"), equalTo("Record 4 version"));
assertThat(record4.get("value_6"), equalTo("Record 4 Value 6"));
assertThat(record4.get("value_7"), equalTo("Record 4 Value 7"));
verify(consumer, times(2)).endTable();
verify(consumer).endDataSet();
}