public void XmlParser_must_properly_parse_chunks_bigger_than_its_buffer_size() { var documentStream = Source .Single("<doc>") .Concat(Source.Single( @" <elem> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> </elem>" )) .Concat(Source.Single("</doc>")); var fut = documentStream .Select(ByteString.FromString) .Via(XmlParsing.Parser(bufferSize: 64)) .RunWith(Sink.Seq <IParseEvent>(), _materializer); fut.Invoking(f => f.Wait(TimeSpan.FromSeconds(3))).ShouldNotThrow(); }
public XmlProcessingTest(ITestOutputHelper output) : base(output: output) { _materializer = Sys.Materializer(); _parser = Flow.Create <string>() .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .ToMaterialized(Sink.Seq <IParseEvent>(), Keep.Right); }
public XmlSubsliceTest(ITestOutputHelper output) : base(output: output) { _materializer = Sys.Materializer(); _parser = Flow.Create <string>() .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .Via(XmlParsing.Subslice(new [] { "doc", "elem", "item" }.ToImmutableArray())) .ToMaterialized(Sink.Seq <IParseEvent>(), Keep.Right); }
public void XmlParser_must_properly_parse_large_XML() { var elements = Enumerable.Range(0, 10).Select(i => i.ToString()).ToImmutableArray(); var documentStream = Source .Single("<doc>") .Concat(Source.FromEnumerator(elements.Select(s => $"<elem>{s}</elem>").GetEnumerator)) .Concat(Source.Single("</doc>")); var fut = documentStream .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .Collect(evt => evt is Characters ? evt : null) .Collect(evt => ((Characters)evt).Text) .RunWith(Sink.Seq <string>(), _materializer); fut.Wait(TimeSpan.FromSeconds(3)); fut.Result.ShouldAllBeEquivalentTo(elements); }