Testing DPUs

This section contains a short guide on how to test your DPUs.

There is module-test in UnifiedViews/Core, which contains classes which may be used for testing the DPU outside of UnifiedViews environment.

The DPU tests use JUnit as an environment. The base class for testing is TestEnvironment. This class provides the environment in which DPUs can be executed.

The preparation of the test environment consists of several steps:

  1. Create a new testing environment.

  2. Prepare DPU's configuration.

  3. Prepare DPU instance and configure it.

  4. Add input and output data units.

  5. Run the execution.

  6. Check the results.

The code sample below shows how to test a DPU, which has an input file data unit and an output RDF data unit.

It runs the DPU and afterwards there is a possibility to get outputted triples and check that such triples correspond to the expected result.

public class MyDpuTest {

    public void execute() throws Exception {
        // Prepare config.
        MyDpuConfig_V1 config = new MyDpuConfig_V1();

        // Prepare DPU.
        MyDpu dpuInstance = new MyDpu();
        dpuInstance.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

        // Prepare test environment.
        TestEnvironment environment = new TestEnvironment();

        // Prepare data unit.
        FilesDataUnit filesInput = environment.createFilesInputFromResource("input", "cities.csv");
        WritableRDFDataUnit rdfOutput = environment.createRdfOutput("rdfOutput",false);

        try {
            // Run.

            //check the output, if it satisfies your requirements. You standard approaches for examining data units.   
            RepositoryConnection connection = null;
            try {
                connection = rdfOutput.getConnection();
                RepositoryResult<Statement> statements = connection.getStatements(null, null, null, false);
                while(statements.hasNext()) {
                    //TODO Assert
            } finally {
                if (connection != null) {
        } finally {
            // Release resources.


Configure Certain File Content as Input to the DPU

In this case cities.csv will be the only entry in the input file data unit; such a cities.csv file has to be available at: src/test/resources/:

FilesDataUnit filesInput = environment.createFilesInputFromResource("input", "cities.csv");

Configure Certain RDF Data Input Entry to Contain Triples

Triples loaded from a file 'input.tt':

WritableRDFDataUnit input = env.createRdfInput("rdfConfig", false);
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("input.ttl");
URI graph = input.addNewDataGraph("test"); 
RepositoryConnection connection = input.getConnection();
connection.add(inputStream, "", RDFFormat.TURTLE, graph);


Such a file has to be available at: src/test/resources/

For further examples of such testing, see:


  • Files to be loaded as input files should appear in 'src/test/resources'. Then they can be loaded via FilesDataUnit filesInput = environment.createFilesInputFromResource("input", "fileName");

  • Use ConfigurationBuilder to convert configuration into string form, so it can be set do DPU.

    Find an example here.