Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/aot-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
target/graalvm-native-image/jelly-cli \
rdf from-jelly --out-format=jsonld out.jelly > out.json && \
[ -s out.json ]
echo '{"@graph":[{"@id":"http://e.org/r","http://e.org/p":{"@value":"v"}}]}' | \
target/graalvm-native-image/jelly-cli rdf to-jelly --in-format "jsonld" > jsonld.jelly && \
[ -s jsonld.jelly ]

- name: Upload binary
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ lazy val graalOptions = Seq(
).flatten ++ Seq(
"--features=eu.neverblink.jelly.cli.graal.ProtobufFeature",
"-H:ReflectionConfigurationFiles=" + file("graal.json").getAbsolutePath,
"-H:+AddAllCharsets", // TODO: only add necessary charsets github.com/Jelly-RDF/cli/issues/154
)

lazy val root = (project in file("."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable
JellyStreamWriter(JenaConverterFactory.getInstance(), variant, outputStream)

RDFParser.source(inputStream).lang(jenaLang).parse(jellyWriter)
jellyWriter.finish()

/** Convert Jelly text to Jelly binary.
* @param inputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
// Make sure it's written in the delimited format
IoUtils.autodetectDelimiting(new ByteArrayInputStream(bytes)).isDelimited should be(true)
val content = translateJellyBack(ByteArrayInputStream(bytes))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
}

"a file to file" in withFullJenaFile { f =>
withEmptyJellyFile { j =>
val (out, err) =
RdfToJelly.runTestCommand(List("rdf", "to-jelly", "--to", j, f))
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
}
}

Expand All @@ -71,7 +75,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(tripleModel.listStatements())
content.containsAll(tripleModel.listStatements()) shouldBe true
}

"input stream to output stream, generalized RDF (N-Triples)" in {
Expand Down Expand Up @@ -160,7 +164,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
val tripleModel = DataGenHelper.generateTripleModel(testCardinality)
val (out, err) = RdfToJelly.runTestCommand(List("rdf", "to-jelly", "--to", j))
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(tripleModel.listStatements())
content.containsAll(tripleModel.listStatements()) shouldBe true
}

"a file to file, modified stream options" in withFullJenaFile { f =>
Expand All @@ -183,7 +187,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
val opts = frames.head.getRows.asScala.head.getOptions
opts.getStreamName should be("testName")
Expand Down Expand Up @@ -211,7 +217,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
val opts = frames.head.getRows.asScala.head.getOptions
opts.getStreamName should be("")
Expand Down Expand Up @@ -241,7 +249,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
val opts = frames.head.getRows.asScala.head.getOptions
opts.getStreamName should be("")
Expand Down Expand Up @@ -270,7 +280,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
frames.size should be > 3
for frame <- frames do
Expand All @@ -294,7 +306,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
// Note: no actual namespace declarations are present in the test data, because it's
// N-Quads.
// TODO: test if the namespace declarations are preserved with Turtle or RDF/XML input.
Expand Down Expand Up @@ -336,7 +350,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
}
"a file to file, physical type set to TRIPLES, logical type to GRAPHS" in withFullJenaFile(
testCode = { f =>
Expand All @@ -356,7 +372,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
)
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
val opts = frames.head.getRows.asScala.head.getOptions
opts.getStreamName should be("")
Expand Down Expand Up @@ -392,7 +408,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
val content = translateJellyBack(new FileInputStream(j))
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
)
) shouldBe true
val frames = readJellyFile(new FileInputStream(j))
val opts = frames.head.getRows.asScala.head.getOptions
opts.getStreamName should be("")
Expand Down Expand Up @@ -422,15 +438,19 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
}
"TriG" in withFullJenaFile(
testCode = { f =>
val (out, err) =
RdfToJelly.runTestCommand(List("rdf", "to-jelly", f))
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
},
jenaLang = RDFLanguages.TRIG,
)
Expand All @@ -442,7 +462,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
},
jenaLang = RDFLanguages.RDFPROTO,
)
Expand All @@ -452,7 +474,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
RdfToJelly.runTestCommand(List("rdf", "to-jelly", f))
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
},
jenaLang = RDFLanguages.RDFTHRIFT,
)
Expand All @@ -464,7 +488,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
},
jenaLang = RDFLanguages.RDFXML,
)
Expand All @@ -476,7 +502,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
)
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
},
jenaLang = RDFLanguages.JSONLD,
)
Expand All @@ -494,7 +522,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(outFile))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
RdfToJelly.getErrString should include("WARNING: The Jelly text format is not stable")
}
}
Expand Down Expand Up @@ -530,7 +560,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
),
)
val content = translateJellyBack(new FileInputStream(outFile))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
content.containsAll(
DataGenHelper.generateTripleModel(testCardinality).listStatements(),
) shouldBe true
}
}

Expand Down