Skip to content

Commit

Permalink
Jena, RDF4J, stream tests
Browse files Browse the repository at this point in the history
Only integration-tests left now
  • Loading branch information
Ostrzyciel committed Dec 20, 2024
1 parent d2aa7ad commit d6b8e96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ final class JellyStreamWriterAutodetectType(opt: JellyFormatVariant, out: Output
// Not supported
override def base(base: String): Unit = ()

override def prefix(prefix: String, iri: String): Unit = inner.prefix(prefix, iri)
override def prefix(prefix: String, iri: String): Unit =
if inner != null then
inner.prefix(prefix, iri)

override def finish(): Unit =
if inner != null then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ class JellyWriterFactorySpec extends AnyWordSpec, Matchers, JenaTest:

for (factoryName, streamType, factory) <- factories do
f"$factoryName ($streamType)" should {
for (presetName <- JellyLanguage.presets.keys) do
f"write a header with the $presetName preset set in the context" in {
for
presetName <- JellyLanguage.presets.keys
enableNsDecls <- Seq(Some(true), Some(false), None)
do
f"write a header with the $presetName preset set in the context, NS declarations $enableNsDecls" in {
val os = new ByteArrayOutputStream()
val format = RDFFormat(JellyLanguage.JELLY)
val ctx = new Context()
ctx.set(JellyLanguage.SYMBOL_PRESET, presetName)
enableNsDecls.foreach(ctx.set(JellyLanguage.SYMBOL_ENABLE_NAMESPACE_DECLARATIONS, _))
factory(format, ctx, os)
val bytes = os.toByteArray
bytes should not be empty
Expand All @@ -91,6 +95,9 @@ class JellyWriterFactorySpec extends AnyWordSpec, Matchers, JenaTest:
options.maxNameTableSize should be(expOpt.maxNameTableSize)
options.maxPrefixTableSize should be(expOpt.maxPrefixTableSize)
options.maxDatatypeTableSize should be(expOpt.maxDatatypeTableSize)
options.version should be(Constants.protoVersion)
if enableNsDecls.isDefined && enableNsDecls.get then
options.version should be(Constants.protoVersion)
else
options.version should be (Constants.protoVersionNoNsDecl)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package eu.ostrzyciel.jelly.stream
import eu.ostrzyciel.jelly.core.helpers.Assertions.*
import eu.ostrzyciel.jelly.core.helpers.MockConverterFactory
import eu.ostrzyciel.jelly.core.proto.v1.*
import eu.ostrzyciel.jelly.core.{JellyOptions, ProtoTestCases}
import eu.ostrzyciel.jelly.core.{Constants, JellyOptions, ProtoTestCases}
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.scaladsl.*
import org.scalatest.concurrent.ScalaFutures
Expand Down Expand Up @@ -31,6 +31,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.FLAT_TRIPLES)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (1)
Expand All @@ -47,6 +48,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.FLAT_TRIPLES)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (3)
Expand All @@ -63,6 +65,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.FLAT_TRIPLES)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (4)
Expand All @@ -82,6 +85,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.FLAT_TRIPLES)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (2)
Expand All @@ -101,6 +105,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.FLAT_TRIPLES)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (5)
Expand All @@ -125,6 +130,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Triples1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.TRIPLES)
.withLogicalType(LogicalStreamType.GRAPHS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be(2)
Expand All @@ -145,6 +151,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Quads1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.QUADS)
.withLogicalType(LogicalStreamType.FLAT_QUADS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (1)
Expand All @@ -164,6 +171,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Quads1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.QUADS)
.withLogicalType(LogicalStreamType.FLAT_QUADS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (2)
Expand All @@ -185,6 +193,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Quads1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.QUADS)
.withLogicalType(LogicalStreamType.DATASETS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be(2)
Expand All @@ -205,6 +214,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Graphs1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.GRAPHS)
.withLogicalType(LogicalStreamType.NAMED_GRAPHS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (2)
Expand All @@ -221,6 +231,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Graphs1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.GRAPHS)
.withLogicalType(LogicalStreamType.NAMED_GRAPHS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
// 1 additional split due to split by graph
Expand All @@ -241,6 +252,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Graphs1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.GRAPHS)
.withLogicalType(LogicalStreamType.DATASETS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (1)
Expand All @@ -258,6 +270,7 @@ class EncoderFlowSpec extends AnyWordSpec, Matchers, ScalaFutures:
Graphs1.encoded(JellyOptions.smallGeneralized
.withPhysicalType(PhysicalStreamType.GRAPHS)
.withLogicalType(LogicalStreamType.DATASETS)
.withVersion(Constants.protoVersionNoNsDecl)
)
)
encoded.size should be (4)
Expand Down

0 comments on commit d6b8e96

Please sign in to comment.