Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AKSW RDFUnit TestSourceBuilder Build

From Leeroopedia
Knowledge Sources
Domains Semantic_Web, Data_Access, Builder_Pattern
Last Updated 2026-10-16 00:00 GMT

Overview

Concrete builder for constructing TestSource instances (dump, dataset, or endpoint) with configurable querying parameters and schema references.

Description

The TestSourceBuilder provides a fluent API to construct `TestSource` instances. It supports three source types:

  • InMemSingle (DumpTestSource):*** Loads an RDF dump into an in-memory Jena model. Requires `setInMemReader()`.
  • InMemDataset (DatasetTestSource):*** Loads an RDF dataset (with named graphs) into an in-memory Jena dataset. Requires `setInMemReader()`.
  • Endpoint (EndpointTestSource):*** Connects to a remote SPARQL endpoint. Requires `setEndpoint()` with URI, graphs, and optional authentication.

All source types require `setPrefixUri()` for identification and `setReferenceSchemata()` for schema association. Querying parameters (cache TTL, query delay, limit, pagination) can be configured for endpoint sources.

Usage

  • Programmatic validation:*** Used by `RDFUnitStaticValidator.validate()` to build an in-memory test source from the input model.
  • CLI validation:*** Used by `RDFUnitConfiguration.getTestSource()` to build endpoint or dump sources from CLI arguments.
  • Custom pipelines:*** Build test sources for any data access pattern.

Code Reference

Source Location

  • Repository: AKSW/RDFUnit
  • File: rdfunit-core/src/main/java/org/aksw/rdfunit/sources/TestSourceBuilder.java

Signature

public class TestSourceBuilder {

    public TestSourceBuilder setPrefixUri(String prefix, String uri);
    public TestSourceBuilder setEndpoint(String sparqlEndpoint,
        Collection<String> endpointGraphs);
    public TestSourceBuilder setEndpoint(String sparqlEndpoint,
        Collection<String> endpointGraphs, String username, String password);
    public TestSourceBuilder setImMemSingle();
    public TestSourceBuilder setImMemDataset();
    public TestSourceBuilder setInMemReader(RdfReader reader);
    public TestSourceBuilder setInMemFromUri(String uri);
    public TestSourceBuilder setInMemFromPipe();
    public TestSourceBuilder setInMemFromCustomText(String text, String format);
    public TestSourceBuilder setReferenceSchemata(Collection<SchemaSource> referenceSchemata);
    public TestSourceBuilder setReferenceSchemata(SchemaSource referenceSchema);
    public TestSourceBuilder setCacheTTL(long cacheTTL);
    public TestSourceBuilder setQueryLimits(long queryLimit);
    public TestSourceBuilder setQueryDelay(long queryDelay);
    public TestSourceBuilder setPagination(long pagination);

    public TestSource build();
}

Import

import org.aksw.rdfunit.sources.TestSourceBuilder;

I/O Contract

Inputs

Name Type Required Description
prefix String Yes Prefix for the source
uri String Yes URI identifying the source
referenceSchemata Collection<SchemaSource> Yes Schemas associated with this source
inMemReader RdfReader Yes (in-mem) Reader for in-memory data
sparqlEndpoint String Yes (endpoint) SPARQL endpoint URI
endpointGraphs Collection<String> No Named graphs to query
username/password String No /// Endpoint basic auth credentials

Outputs

Name Type Description
build() returns TestSource DumpTestSource, DatasetTestSource, or EndpointTestSource

Usage Examples

Build In-Memory Source (Programmatic Validation)

import org.aksw.rdfunit.sources.TestSourceBuilder;
import org.aksw.rdfunit.io.reader.RdfModelReader;
import org.apache.jena.rdf.model.Model;

Model inputModel = ...;  // your RDF data

TestSource source = new TestSourceBuilder()
    .setPrefixUri("custom", "http://example.com/data")
    .setImMemDataset()
    .setInMemReader(new RdfModelReader(inputModel))
    .setReferenceSchemata(schemas)
    .build();

Build SPARQL Endpoint Source

import java.util.Collections;

TestSource source = new TestSourceBuilder()
    .setPrefixUri("dbpedia", "http://dbpedia.org")
    .setEndpoint("http://dbpedia.org/sparql",
        Collections.singletonList("http://dbpedia.org"),
        "user", "password")
    .setReferenceSchemata(schemas)
    .setCacheTTL(3600000)  // 1 hour cache
    .setQueryLimits(1000)   // max 1000 results per query
    .setQueryDelay(1)       // 1 second delay between queries
    .build();

Related Pages

Implements Principle

Requires Environment

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment