public class XMLDataLoader extends Object implements Loader
Loader for the XML based files. This Loader is responsible for reading a list of XML
Files based on the testDataSchema.xsd file of EasyTest and converting them into a data structure which is
understandable by the EasyTest framework. The Loader is also responsible for writing the output data back to the file.
<easytest:InputTestData xmlns:easytest="urn:org:easetech:easytest:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:easetech:easytest:1.0 testDataSchema.xsd">
<TestMethod name="getSimpleData">
<TestRecord id="1">
<InputData>
<Entry key="libraryId" value="91475" />
<Entry key="itemId" value="12" />
<Entry key="itemType" value="book" />
</InputData>
</TestRecord>
<TestRecord id="2">
<InputData>
<Entry key="libraryId" value="234" />
<Entry key="itemId" value="1452" />
<Entry key="itemType" value="journal" />
</InputData>
</TestRecord>
</TestMethod>
<TestMethod name="getAnotherData">
<TestRecord id="3">
<InputData>
<Entry key="picId" value="1111" />
<Entry key="picNum" value="12" />
<Entry key="picFormat" value="jpeg" />
</InputData>
</TestRecord>
<TestRecord id="4">
<InputData>
<Entry key="picId" value="1561" />
<Entry key="picNum" value="178" />
<Entry key="picFormat" value="raw" />
</InputData>
</TestRecord>
</TestMethod>
</easytest:InputTestData>
As you can guess, the root element is InputTestData that can have multiple TestMethod elements in it.
Each TestMethod element identifies a method to test with its name attribute.
Each TestMethod can have many TestRecords. Each Record identifies data for a single test execution.
Each TestRecord element has an id attribute. This id attribute has to be unique in the entire XML file.
So you should not have the id = 1 for more than one test record. If you do, then the behavior is undefined in such a scenario.
TestRecord contains InputData element as well as OutputData element. A user never specifies an OutputData element.
If it is specified, it will be ignored by the Loader. OutputData is used internally by the XMLDataLoader to write output data back to the file.
Each Entry element identifies a method parameter.| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG
An instance of logger associated with the test framework.
|
ACTUAL_RESULT, AMPERSAND, COMMA, DOUBLE_QUOTE, DURATION, EMPTY_STRING, EXPECTED_RESULT, SINGLE_QUOTE, TEST_FAILED, TEST_PASSED, TEST_STATUS| Constructor and Description |
|---|
XMLDataLoader() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,List<Map<String,Object>>> |
loadData(Resource resource)
Load the data from the given resource
|
void |
writeData(Resource resource,
Map<String,List<Map<String,Object>>> actualData,
String... methodNames)
Write Data to the existing XML File.
|
protected static final org.slf4j.Logger LOG
Copyright © 2014. All rights reserved.