Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,24 @@ tasks.withType<Javadoc>() {
tasks {
test {
useJUnitPlatform()
// Configuration d'affichage détaillé des tests

// Set up the detailed display of test results
testLogging {
events("started", "passed", "skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = false
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.SHORT
displayGranularity = 2
showStandardStreams = false
showStandardStreams = true
}
// Force l'affichage des statistiques de test

// Force the display of test statistics
finalizedBy("displayTestResults")
}
}

// Task personnalisé pour afficher un résumé propre des tests
// Personalized task to display a clean summary of test results
tasks.register("displayTestResults") {
doLast {
val testTask = tasks.getByName("test") as Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.FileReader;
import java.net.URI;

import com.apicatalog.jsonld.JsonLdVersion;
import fr.inria.corese.core.next.impl.io.option.TitaniumJSONLDProcessorOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -13,7 +15,6 @@
import fr.inria.corese.w3c.junit.dynamic.executor.TestExecutor;
import fr.inria.corese.w3c.junit.dynamic.model.TestType;
import fr.inria.corese.w3c.junit.dynamic.model.W3cTestCase;
import fr.inria.corese.w3c.junit.dynamic.utils.RdfFormatDetector;
import fr.inria.corese.w3c.junit.dynamic.utils.RDFTestUtils;

/**
Expand Down Expand Up @@ -48,9 +49,36 @@ public void execute(W3cTestCase testCase) throws Exception {

// Get format and create parser
Model actionModel = RDFTestUtils.createModel();
RDFFormat actionFormat = RdfFormatDetector.getRdfFormatFromTestType(testType);
RDFFormat actionFormat = RDFTestUtils.guessFileFormat(actionFileUri);
RDFParser actionParser = RDFTestUtils.createParser(actionFormat, actionModel);

// Parser config for JSON-LD format
if(actionFormat == RDFFormat.JSONLD) {
TitaniumJSONLDProcessorOption.Builder optionBuilder = new TitaniumJSONLDProcessorOption.Builder();
if(testCase.getProperty("baseUri", String.class) != null) {
String baseUri = testCase.getProperty("baseUri", String.class);
optionBuilder.base(baseUri);
}
if(testCase.getProperty("specVersion", String.class) != null) {
String specVersion = testCase.getProperty("specVersion", String.class);
if(specVersion.equals("json-ld-1.0")) {
optionBuilder.processingMode(JsonLdVersion.V1_0);
}
if(specVersion.equals("json-ld-1.1")) {
optionBuilder.processingMode(JsonLdVersion.V1_1);
}
}
if(testCase.getProperty("useNativeTypes", Boolean.class) != null) {
boolean usesNativeTypes = testCase.getProperty("useNativeTypes", Boolean.class);
optionBuilder.useNativeTypes(usesNativeTypes);
}
if(testCase.getProperty("useRdfType", Boolean.class) != null) {
boolean useRdfType = testCase.getProperty("useRdfType", Boolean.class);
optionBuilder.useRdfType(useRdfType);
}
actionParser.setConfig(optionBuilder.build());
}

// Attempt to parse the input file
try (FileReader reader = new FileReader(actionFilePath)) {
actionParser.parse(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.FileReader;
import java.net.URI;

import com.apicatalog.jsonld.JsonLdVersion;
import fr.inria.corese.core.next.impl.io.option.TitaniumJSONLDProcessorOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -13,7 +15,6 @@
import fr.inria.corese.w3c.junit.dynamic.executor.TestExecutor;
import fr.inria.corese.w3c.junit.dynamic.model.TestType;
import fr.inria.corese.w3c.junit.dynamic.model.W3cTestCase;
import fr.inria.corese.w3c.junit.dynamic.utils.RdfFormatDetector;
import fr.inria.corese.w3c.junit.dynamic.utils.RDFTestUtils;

/**
Expand Down Expand Up @@ -46,31 +47,60 @@ public void execute(W3cTestCase testCase) throws Exception {
URI resultFileUri = testCase.getResultFileUri();

try {
// Action Model //

// Load the action file
String actionFilePath = RDFTestUtils.loadFile(actionFileUri);

// Get format and create parser
Model actionModel = RDFTestUtils.createModel();
RDFFormat actionFormat = RdfFormatDetector.getRdfFormatFromTestType(testType);
RDFFormat actionFormat = RDFTestUtils.guessFileFormat(actionFileUri);
RDFParser actionParser = RDFTestUtils.createParser(actionFormat, actionModel);

// Parse the input file
try (FileReader reader = new FileReader(actionFilePath)) {
actionParser.parse(reader);
}

// Result Model //

// Load the result file
String resultFilePath = RDFTestUtils.loadFile(resultFileUri);

// Detect format of result file and create parser
Model resultModel = RDFTestUtils.createModel();
RDFFormat resultFormat = RdfFormatDetector.detectFromFileExtension(resultFileUri);
RDFFormat resultFormat = RDFTestUtils.guessFileFormat(resultFileUri);
RDFParser resultParser = RDFTestUtils.createParser(resultFormat, resultModel);

// Parser config for JSON-LD format
if(actionFormat == RDFFormat.JSONLD || resultFormat == RDFFormat.JSONLD) {
TitaniumJSONLDProcessorOption.Builder optionBuilder = new TitaniumJSONLDProcessorOption.Builder();
if(testCase.getProperty("baseUri", String.class) != null) {
String baseUri = testCase.getProperty("baseUri", String.class);
optionBuilder.base(baseUri);
}
if(testCase.getProperty("specVersion", String.class) != null) {
String specVersion = testCase.getProperty("specVersion", String.class);
if(specVersion.equals("json-ld-1.0")) {
optionBuilder.processingMode(JsonLdVersion.V1_0);
}
if(specVersion.equals("json-ld-1.1")) {
optionBuilder.processingMode(JsonLdVersion.V1_1);
}
}
if(testCase.getProperty("useNativeTypes", Boolean.class) != null) {
boolean usesNativeTypes = testCase.getProperty("useNativeTypes", Boolean.class);
optionBuilder.useNativeTypes(usesNativeTypes);
}
if(testCase.getProperty("useRdfType", Boolean.class) != null) {
boolean useRdfType = testCase.getProperty("useRdfType", Boolean.class);
optionBuilder.useRdfType(useRdfType);
}

if(actionFormat == RDFFormat.JSONLD) {
actionParser.setConfig(optionBuilder.build());
}
if (resultFormat == RDFFormat.JSONLD) {
resultParser.setConfig(optionBuilder.build());
}
}

// Parse the input file
try (FileReader reader = new FileReader(actionFilePath)) {
actionParser.parse(reader);
}

// Parse the result file
try (FileReader reader = new FileReader(resultFilePath)) {
resultParser.parse(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.FileReader;
import java.net.URI;

import com.apicatalog.jsonld.JsonLdVersion;
import fr.inria.corese.core.next.impl.io.option.TitaniumJSONLDProcessorOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -13,7 +15,6 @@
import fr.inria.corese.w3c.junit.dynamic.executor.TestExecutor;
import fr.inria.corese.w3c.junit.dynamic.model.TestType;
import fr.inria.corese.w3c.junit.dynamic.model.W3cTestCase;
import fr.inria.corese.w3c.junit.dynamic.utils.RdfFormatDetector;
import fr.inria.corese.w3c.junit.dynamic.utils.RDFTestUtils;

/**
Expand Down Expand Up @@ -47,10 +48,37 @@ public void execute(W3cTestCase testCase) throws Exception {
String actionFilePath = RDFTestUtils.loadFile(actionFileUri);

// Detect format and create parser
RDFFormat actionFormat = RdfFormatDetector.getRdfFormatFromTestType(testType);
RDFFormat actionFormat = RDFTestUtils.guessFileFormat(actionFileUri);
Model actionModel = RDFTestUtils.createModel();
RDFParser actionParser = RDFTestUtils.createParser(actionFormat, actionModel);

// Parser config for JSON-LD format
if(actionFormat == RDFFormat.JSONLD) {
TitaniumJSONLDProcessorOption.Builder optionBuilder = new TitaniumJSONLDProcessorOption.Builder();
if(testCase.getProperty("baseUri", String.class) != null) {
String baseUri = testCase.getProperty("baseUri", String.class);
optionBuilder.base(baseUri);
}
if(testCase.getProperty("specVersion", String.class) != null) {
String specVersion = testCase.getProperty("specVersion", String.class);
if(specVersion.equals("json-ld-1.0")) {
optionBuilder.processingMode(JsonLdVersion.V1_0);
}
if(specVersion.equals("json-ld-1.1")) {
optionBuilder.processingMode(JsonLdVersion.V1_1);
}
}
if(testCase.getProperty("useNativeTypes", Boolean.class) != null) {
boolean usesNativeTypes = testCase.getProperty("useNativeTypes", Boolean.class);
optionBuilder.useNativeTypes(usesNativeTypes);
}
if(testCase.getProperty("useRdfType", Boolean.class) != null) {
boolean useRdfType = testCase.getProperty("useRdfType", Boolean.class);
optionBuilder.useRdfType(useRdfType);
}
actionParser.setConfig(optionBuilder.build());
}

// Parse the input file
try (FileReader reader = new FileReader(actionFilePath)) {
actionParser.parse(reader);
Expand Down
Loading