Skip to content

Commit c59af62

Browse files
committed
Consolidated bats tests
1 parent 8dba3d5 commit c59af62

27 files changed

Lines changed: 95 additions & 139 deletions

cli-tests/integrate/README.md

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@ This directory contains CLI tests for the RDF Processing Toolkit's `rpt integrat
66

77
```
88
cli-tests/integrate/
9-
├── test01-mem/ # Tests for in-memory engine (Jena mem)
10-
├── test02-tdb2/ # Tests for TDB2 disk-based engine
11-
├── test03-read-only/ # Tests for read-only server mode
12-
└── test04-server/ # Tests for server HTTP endpoints
9+
├── resources/ # Centralized test data (shared across all tests)
10+
│ ├── input-triples.ttl
11+
│ ├── input-triples-small.ttl
12+
│ ├── query-construct-triples.sparql
13+
│ ├── expected-turtle.ttl
14+
│ ├── expected-ntriples.nt
15+
│ ├── expected-nquads.nq
16+
│ └── expected-trig.trig
17+
├── test01-mem/ # Tests for in-memory engine (Jena mem)
18+
├── test02-tdb2/ # Tests for TDB2 disk-based engine
19+
├── test03-read-only/ # Tests for read-only server mode
20+
├── test04-server/ # Tests for server HTTP endpoints
21+
└── test05-qlever/ # Tests for QLever engine
1322
```
1423

24+
### Test Directories
25+
26+
- **test01-mem/** - 4 tests: turtle, nt, nq, trig output formats
27+
- **test02-tdb2/** - 2 tests: turtle, nt output formats
28+
- **test03-read-only/** - 2 tests: server start, UPDATE rejection
29+
- **test04-server/** - 1 test: server startup verification
30+
- **test05-qlever/** - 2 tests: turtle, nt output formats (no quads/trig support)
31+
1532
## JUnit Tests
1633

1734
Located in `rdf-processing-toolkit-cli/src/test/java/org/aksw/sparql_integrate/integrate/`
@@ -46,15 +63,11 @@ bats cli-tests/integrate/test02-tdb2/
4663
bats cli-tests/integrate/test01-mem/test-engine-mem.bats
4764
```
4865

49-
## Test Data
66+
### Test Data Location
5067

51-
Each test directory contains:
52-
- `input-triples.ttl` - Simple triple data
53-
- `input-triples-small.ttl` - Minimal test data (1 triple)
54-
- `input-quads.trig` - Data with named graphs
55-
- `query-construct-triples.sparql` - CONSTRUCT query for triples
56-
- `query-construct-quads.sparql` - CONSTRUCT query for quads
57-
- `expected-*` - Expected output files
68+
All test data is centralized in the `resources/` directory. Tests reference input files and expected outputs via relative paths to `resources/`. All output files are written to temporary directories (created per-test) and cleaned up after test completion.
69+
70+
**Note:** The QLever engine doesn't support CONSTRUCT quads, so test05-qlever only tests turtle and ntriples output formats.
5871

5972
## Supported Output Formats
6073

@@ -73,34 +86,51 @@ Tested with:
7386
- Fast, no disk I/O
7487
- Default engine
7588
- Ideal for CI/CD
89+
- Supports all output formats (turtle, nt, nq, trig)
7690

7791
### tdb2 (TDB2 Disk-Based)
7892
- Persists data to disk
7993
- Supports larger datasets
8094
- Test verifies database file creation
95+
- Supports turtle and nt output formats
96+
97+
### qlever (QLever Engine)
98+
- SPARQL 1.1 compliant query engine
99+
- Supports turtle and nt output formats
100+
- Does NOT support CONSTRUCT quads (no nq/trig)
81101

82102
## Test Coverage
83103

84104
### JUnit Tests (4 tests)
85105
- `TestIntegrateMem`: mem engine with Turtle and N-Triples output
86106
- `TestIntegrateTdb2`: tdb2 engine with Turtle and N-Triples output
87107

88-
### BATS Tests (9 tests)
108+
### BATS Tests (11 tests)
89109
- **mem engine**: Turtle, N-Triples, N-Quads, TriG output formats
90110
- **tdb2 engine**: Turtle, N-Triples output formats
91111
- **read-only server**: HTTP endpoint access, UPDATE query rejection
92112
- **server mode**: Server startup verification
113+
- **qlever engine**: Turtle, N-Triples output formats (no quads)
93114

94115
## Adding New Tests
95116

96-
1. Create test data files in appropriate directory
97-
2. Write JUnit test in `TestIntegrate*.java`
98-
3. Write BATS test in `*.bats`
99-
4. Run tests to verify
100-
101-
## Adding New Tests
102-
103-
1. Create test data files in appropriate directory
104-
2. Write JUnit test in `TestIntegrate*.java`
105-
3. Write BATS test in `*.bats`
106-
4. Run tests to verify
117+
1. Add test data files to `resources/` directory
118+
2. Write BATS test in appropriate `test-*/` directory
119+
3. Reference files via `$RESOURCES_DIR` (see existing tests for examples)
120+
4. Write all outputs to `$TEMP_DIR` (created in `setup()`)
121+
5. Clean up temp directory in `teardown()`
122+
6. Run tests to verify
123+
124+
## Adding New Engine Tests
125+
126+
When adding a new engine test directory:
127+
128+
1. Create new directory: `testXX-engine/`
129+
2. Copy relevant test data from `resources/` (if needed for engine-specific data)
130+
3. Create `.bats` file with appropriate tests
131+
4. Follow these conventions:
132+
- Use `SCRIPT_DIR` and `RESOURCES_DIR` for paths
133+
- Use `TEMP_DIR=$(mktemp -d)` for outputs
134+
- Clean up in `teardown()`
135+
- Skip unsupported formats (e.g., qlever doesn't support nq/trig)
136+
5. Update this README.md to document the new test directory
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cli-tests/integrate/test01-mem/input-triples-small.ttl renamed to cli-tests/integrate/resources/input-triples-small.ttl

File renamed without changes.
File renamed without changes.

cli-tests/integrate/test01-mem/query-construct-triples.sparql renamed to cli-tests/integrate/resources/query-construct-triples.sparql

File renamed without changes.
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
#!/usr/bin/env bats
22

33
setup() {
4-
TEST_DIR="$BATS_TEST_DIRNAME"
4+
SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_DIRNAME")" && pwd)"
5+
RESOURCES_DIR="$SCRIPT_DIR/resources"
6+
TEMP_DIR=$(mktemp -d)
57
}
68

79
@test "mem: load turtle data and output turtle" {
8-
run rpt integrate -e mem "$TEST_DIR/input-triples.ttl" "$TEST_DIR/query-construct-triples.sparql" -o "$TEST_DIR/output.ttl"
10+
run rpt integrate -e mem "$RESOURCES_DIR/input-triples.ttl" "$RESOURCES_DIR/query-construct-triples.sparql" -o "$TEMP_DIR/output.ttl"
911
[ "$status" -eq 0 ]
10-
[ -f "$TEST_DIR/output.ttl" ]
12+
[ -f "$TEMP_DIR/output.ttl" ]
1113

12-
expected=$(cat "$TEST_DIR/expected-turtle.ttl")
13-
actual=$(cat "$TEST_DIR/output.ttl")
14+
expected=$(cat "$RESOURCES_DIR/expected-turtle.ttl")
15+
actual=$(cat "$TEMP_DIR/output.ttl")
1416
[ "$expected" = "$actual" ]
1517
}
1618

1719
@test "mem: load turtle data and output ntriples" {
18-
run rpt integrate -e mem "$TEST_DIR/input-triples.ttl" "$TEST_DIR/query-construct-triples.sparql" -o "$TEST_DIR/output.nt"
20+
run rpt integrate -e mem "$RESOURCES_DIR/input-triples.ttl" "$RESOURCES_DIR/query-construct-triples.sparql" -o "$TEMP_DIR/output.nt"
1921
[ "$status" -eq 0 ]
20-
[ -f "$TEST_DIR/output.nt" ]
22+
[ -f "$TEMP_DIR/output.nt" ]
2123

22-
expected=$(cat "$TEST_DIR/expected-ntriples.nt")
23-
actual=$(cat "$TEST_DIR/output.nt")
24+
expected=$(cat "$RESOURCES_DIR/expected-ntriples.nt")
25+
actual=$(cat "$TEMP_DIR/output.nt")
2426
[ "$expected" = "$actual" ]
2527
}
2628

2729
@test "mem: load turtle data and output nquads" {
28-
run rpt integrate -e mem "$TEST_DIR/input-triples.ttl" "$TEST_DIR/query-construct-triples.sparql" -o "$TEST_DIR/output.nq"
30+
run rpt integrate -e mem "$RESOURCES_DIR/input-triples.ttl" "$RESOURCES_DIR/query-construct-triples.sparql" -o "$TEMP_DIR/output.nq"
2931
[ "$status" -eq 0 ]
30-
[ -f "$TEST_DIR/output.nq" ]
32+
[ -f "$TEMP_DIR/output.nq" ]
3133

32-
expected=$(cat "$TEST_DIR/expected-nquads.nq")
33-
actual=$(cat "$TEST_DIR/output.nq")
34+
expected=$(cat "$RESOURCES_DIR/expected-nquads.nq")
35+
actual=$(cat "$TEMP_DIR/output.nq")
3436
[ "$expected" = "$actual" ]
3537
}
3638

3739
@test "mem: load turtle data and output trig" {
38-
run rpt integrate -e mem "$TEST_DIR/input-triples.ttl" "$TEST_DIR/query-construct-triples.sparql" -o "$TEST_DIR/output.trig"
40+
run rpt integrate -e mem "$RESOURCES_DIR/input-triples.ttl" "$RESOURCES_DIR/query-construct-triples.sparql" -o "$TEMP_DIR/output.trig"
3941
[ "$status" -eq 0 ]
40-
[ -f "$TEST_DIR/output.trig" ]
42+
[ -f "$TEMP_DIR/output.trig" ]
4143

42-
expected=$(cat "$TEST_DIR/expected-trig.trig")
43-
actual=$(cat "$TEST_DIR/output.trig")
44+
expected=$(cat "$RESOURCES_DIR/expected-trig.trig")
45+
actual=$(cat "$TEMP_DIR/output.trig")
4446
[ "$expected" = "$actual" ]
4547
}
4648

4749
teardown() {
48-
rm -f "$TEST_DIR/output.ttl" "$TEST_DIR/output.nt" "$TEST_DIR/output.nq" "$TEST_DIR/output.trig"
50+
rm -rf "$TEMP_DIR"
4951
}

cli-tests/integrate/test02-tdb2/expected-nquads.nq

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)