Main Content


Test custom file adapter by reading from source

Since R2022b



    readFromSource(testerObj) tests the getData method of a custom external file adapter derived from the base class. When you create the object, testerObj, you open a connection to a test file by using an instance of a custom file adapter. The object function reads data from that test file.


    collapse all

    Use a object to test the getData method of an XML file adapter derived from a base class. For an example of an XML file adapter, see .

    The getData method reads data from an XML file test.xml with the following format.


    Create an instance of your file adapter.

    adapterInstance = myXMLAdapter;

    Create an instance of the file adapter tester object using the test file specified above.

    adapterTester =,...
                                                             'test.xml','XML Adapter');

    Use adapterTester to read the data from your XML file. Then, check the data in the WorkspaceVariables property.

    variables = adapterTester.WorkspaceVariables
    variables = 
      Map with properties:
        Count: 2
        KeyType: char
        ValueType: double

    Check the data in the WorkspaceVariables map object.

    ans = 
      1x2 cell array
        {"x"}  {"y"}

    Finally, clear the workspace variables.


    Input Arguments

    collapse all

    File adapter tester, specified as a object.

    Version History

    Introduced in R2022b