Bundle: redb-route / tests/redb.Route.Tests.DataFormats (tests.redb.Route.Tests.DataFormats.txt), 41 files Snapshot: development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Index: https://redbase.app/src/dev-2026-12-06/redb-route/_index.txt ==== Path: redb-route/tests/redb.Route.Tests.DataFormats/AvroDataFormatTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/AvroDataFormatTests.cs ---- using redb.Route.Core; using redb.Route.DataFormats.Avro; using redb.Route.TestKit; namespace redb.Route.Tests.DataFormats; public class AvroDataFormatTests { private static readonly OrderRow Sample = new() { Id = 7, Customer = "acme", Amount = 12.5m }; [Fact] public void RoundTrip_SchemaBuiltFromClrType() { var format = new AvroDataFormat(); var bytes = format.Serialize(Sample); var back = format.Deserialize(bytes); bytes.Should().NotBeEmpty(); back.Should().Be(Sample); format.SchemaFor(typeof(OrderRow)).Should().BeOfType(); } [Fact] public void RoundTrip_List() { var format = new AvroDataFormat(); var list = new List { Sample, new() { Id = 8, Customer = "b", Amount = 1m } }; format.Deserialize>(format.Serialize(list)).Should().Equal(list); } [Fact] public void ExplicitSchema_IsUsed() { const string schema = """ {"type":"record","name":"OrderRow","fields":[ {"name":"Id","type":"int"}, {"name":"Customer","type":"string"}, {"name":"Amount","type":{"type":"bytes","logicalType":"decimal","precision":29,"scale":14}} ]} """; var format = new AvroDataFormat(new AvroDataFormatOptions { Schema = schema }); format.Deserialize(format.Serialize(Sample)).Should().Be(Sample); format.SchemaFor(typeof(OrderRow)).Should().BeOfType().Which.Name.Should().Be("OrderRow"); } [Fact] public void ConfluentWireFormat_FramesAndUnframes() { var format = new AvroDataFormat(new AvroDataFormatOptions { ConfluentWireFormat = true, SchemaId = 7 }); var framed = format.Serialize(Sample); framed.Take(5).Should().Equal(0, 0, 0, 0, 7); format.Deserialize(framed).Should().Be(Sample); var act = () => format.Deserialize([1, 2, 3, 4, 5, 6]); act.Should().Throw().WithMessage("Avro data format:*wire format*"); } [Fact] public void Garbage_FailsNamingTheFormat() { var act = () => new AvroDataFormat().Deserialize([0xFF]); act.Should().Throw().WithMessage("Avro data format:*"); } [Fact] public async Task Dsl_And_Registry() { await using var ctx = new RouteContext(); ctx.AddAvroDataFormat(); ctx.AddRoutes(b => { b.From("direct://sugar").MarshalAvro().To("mock://wire").UnmarshalAvro(); b.From("direct://named").Marshal("application/avro").Unmarshal("avro/binary"); }); await ctx.Start(); (await ctx.RequestBody("direct://sugar", Sample)).Should().Be(Sample); (await ctx.RequestBody("direct://named", Sample)).Should().Be(Sample); ctx.Mock("mock://wire").ReceivedExchanges[0].In.ContentType.Should().Be("application/avro"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/CoreWrapperFormatsTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/CoreWrapperFormatsTests.cs ---- using System.IO.Compression; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Serialization; using redb.Route.TestKit; namespace redb.Route.Tests.DataFormats; /// Base64 / GZip / Zip ship with the core and are registered by default. public class CoreWrapperFormatsTests { [Theory] [InlineData("application/base64", typeof(Base64MessageSerializer))] [InlineData("application/gzip", typeof(GZipMessageSerializer))] [InlineData("application/x-gzip", typeof(GZipMessageSerializer))] [InlineData("application/zip", typeof(ZipMessageSerializer))] public void RegisteredByDefault(string contentType, Type serializer) { using var ctx = new RouteContext(); ctx.GetService()!.GetSerializer(contentType).Should().BeOfType(serializer); } [Fact] public void Base64_RoundTrip_AndInvalidInput() { var b64 = new Base64MessageSerializer(); var encoded = b64.Serialize("hello, world"); System.Text.Encoding.ASCII.GetString(encoded).Should().Be("aGVsbG8sIHdvcmxk"); b64.Deserialize(encoded).Should().Be("hello, world"); b64.Deserialize(encoded).Should().Equal("hello, world"u8.ToArray()); b64.Deserialize("YR=="u8.ToArray()).Should().Equal(new byte[] { 0x61 }, "unused bits of the last character are read as zero on every runtime"); var act = () => b64.Deserialize("not base64!"u8.ToArray()); act.Should().Throw().WithMessage("Base64 data format:*"); } [Fact] public void GZip_RoundTrip_ProducesGZipMagic() { var gzip = new GZipMessageSerializer(); var payload = new string('x', 10_000); var compressed = gzip.Serialize(payload); compressed.Take(2).Should().Equal(0x1F, 0x8B); compressed.Length.Should().BeLessThan(payload.Length); gzip.Deserialize(compressed).Should().Be(payload); gzip.Deserialize(compressed).Should().BeReadable(); } [Fact] public void Zip_RoundTrip_SingleEntry() { var zip = new ZipMessageSerializer("payload.txt"); var bytes = zip.Serialize("inside"); using (var archive = new ZipArchive(new MemoryStream(bytes))) archive.Entries.Should().ContainSingle().Which.Name.Should().Be("payload.txt"); zip.Deserialize(bytes).Should().Be("inside"); } [Fact] public void WrongShapes_FailNamingTheFormat() { var gzip = new GZipMessageSerializer(); var marshal = () => gzip.Serialize(new OrderRow()); var unmarshal = () => gzip.Deserialize(gzip.Serialize("1")); marshal.Should().Throw().WithMessage("GZip data format*byte[], string or Stream*"); unmarshal.Should().Throw().WithMessage("GZip data format*byte[], string or Stream*"); } [Fact] public async Task Dsl_MarshalByContentType_RoundTrip() { await using var ctx = new RouteContext().AddRoutes(b => { b.From("direct://gz").Marshal("application/gzip").To("mock://wire"); b.From("direct://gunzip").Unmarshal("application/gzip"); }); await ctx.Start(); await ctx.SendBody("direct://gz", "compress me"); var wire = ctx.Mock("mock://wire").ReceivedExchanges[0].In; wire.ContentType.Should().Be("application/gzip"); var compressed = (byte[])wire.Body!; compressed.Take(2).Should().Equal(0x1F, 0x8B); (await ctx.RequestBody("direct://gunzip", compressed)).Should().Be("compress me"); } // Code review 2026-09-01 (the wrapper formats and the Zip entry item). [Fact] public async Task Dsl_Marshal_CompressesAnAlreadyMarshalledBody() { await using var ctx = new RouteContext().AddRoutes(b => b.From("direct://json-gz").Marshal("application/json").Marshal("application/gzip").To("mock://json-gz")); await ctx.Start(); await ctx.SendBody("direct://json-gz", new { id = 7 }); var wire = ctx.Mock("mock://json-gz").ReceivedExchanges[0].In; wire.ContentType.Should().Be("application/gzip", "a byte wrapper takes a byte[] body as its payload; Marshal must not pass it through"); using var gunzip = new GZipStream(new MemoryStream((byte[])wire.Body!), CompressionMode.Decompress); using var reader = new StreamReader(gunzip); (await reader.ReadToEndAsync()).Should().Contain("\"id\":7"); } [Fact] public void Zip_SkipsDirectoryEntries_AndRefusesAMultiEntryArchive() { using var withDir = new MemoryStream(); using (var archive = new ZipArchive(withDir, ZipArchiveMode.Create, leaveOpen: true)) { archive.CreateEntry("dir/"); using var w = new StreamWriter(archive.CreateEntry("dir/body.txt").Open()); w.Write("payload"); } new ZipMessageSerializer().Deserialize(withDir.ToArray()).Should().Be("payload", "a directory entry carries no data"); using var two = new MemoryStream(); using (var archive = new ZipArchive(two, ZipArchiveMode.Create, leaveOpen: true)) { using (var a = new StreamWriter(archive.CreateEntry("a.txt").Open())) a.Write("a"); using (var b = new StreamWriter(archive.CreateEntry("b.txt").Open())) b.Write("b"); } var act = () => new ZipMessageSerializer().Deserialize(two.ToArray()); act.Should().Throw().WithMessage("*2 entries*"); } [Fact] public async Task PositionedStreamBody_IsReadFromItsPosition() { var gz = new GZipMessageSerializer().Serialize("positioned"); var stream = new MemoryStream(); // expandable: exposes its buffer, the shortcut's case stream.Write([0xFF, 0xFF, .. gz]); stream.Position = 2; // two bytes of framing already consumed by an earlier step await using var ctx = new RouteContext().AddRoutes(b => b.From("direct://pos").Unmarshal("application/gzip")); await ctx.Start(); (await ctx.RequestBody("direct://pos", stream)).Should().Be("positioned", "the MemoryStream shortcut must not hand over bytes before the position"); } [Fact] public async Task Marshal_WithInstance_AllowsPerNodeOptions() { await using var ctx = new RouteContext().AddRoutes(b => b .From("direct://zip") .Marshal(new ZipMessageSerializer("report.csv")) .Unmarshal(new ZipMessageSerializer())); await ctx.Start(); (await ctx.RequestBody("direct://zip", "a,b")).Should().Be("a,b"); } [Fact] public async Task StreamBody_IsUnmarshalled() { await using var ctx = new RouteContext().AddRoutes(b => b .From("direct://stream").Unmarshal("application/base64")); await ctx.Start(); var back = await ctx.RequestBody("direct://stream", new MemoryStream("aGk="u8.ToArray())); back.Should().Be("hi"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/CsvDataFormatTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/CsvDataFormatTests.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.DataFormats.Csv; using redb.Route.TestKit; namespace redb.Route.Tests.DataFormats; public class CsvDataFormatTests { private static readonly List Rows = [ new() { Id = 1, Customer = "Smith, \"Bob\"\nJr", Amount = 10.5m }, new() { Id = 2, Customer = "", Amount = 0m }, new() { Id = 3, Customer = "Ünïcödé", Amount = 1234567.89m }, ]; [Fact] public void RoundTrip_PocoList_QuotesNewlinesEmptyUnicode() { var csv = new CsvDataFormat(); var bytes = csv.Serialize(Rows); var text = System.Text.Encoding.UTF8.GetString(bytes); var back = csv.Deserialize>(bytes); text.Should().StartWith("Id,Customer,Amount"); text.Should().Contain("\"Smith, \"\"Bob\"\"\nJr\"", "RFC 4180 quoting"); back.Should().Equal(Rows); } [Fact] public void RoundTrip_Array_And_IEnumerable_Targets() { var csv = new CsvDataFormat(); var bytes = csv.Serialize(Rows); csv.Deserialize(bytes).Should().Equal(Rows); csv.Deserialize>(bytes).Should().Equal(Rows); csv.Deserialize(bytes).Should().Be(Rows[0], "a single target takes the first record"); } [Fact] public void Maps_WithHeader_AndRows_WithoutHeader() { var withHeader = new CsvDataFormat(); var maps = withHeader.Deserialize>>("Id,Name\n1,a\n2,b\n"u8.ToArray())!; maps.Should().HaveCount(2); maps[1]["Name"].Should().Be("b"); var noHeader = new CsvDataFormat(new CsvDataFormatOptions { HasHeaderRecord = false }); var rows = noHeader.Deserialize>("1,a\n2,b\n"u8.ToArray())!; rows.Should().HaveCount(2); rows[0].Should().Equal("1", "a"); var back = System.Text.Encoding.UTF8.GetString(withHeader.Serialize(maps)); back.Should().StartWith("Id,Name").And.Contain("2,b"); var rawBack = System.Text.Encoding.UTF8.GetString(noHeader.Serialize(new List { new[] { "x", "y" } })); rawBack.Trim().Should().Be("x,y"); } [Fact] public void Delimiter_Option() { var csv = new CsvDataFormat(new CsvDataFormatOptions { Delimiter = ";" }); var text = System.Text.Encoding.UTF8.GetString(csv.Serialize(Rows.Take(1))); text.Should().StartWith("Id;Customer;Amount"); csv.Deserialize>(System.Text.Encoding.UTF8.GetBytes(text))![0].Should().Be(Rows[0]); } [Fact] public void BadInput_FailsNamingTheFormat() { var csv = new CsvDataFormat(); var act = () => csv.Deserialize>("Id,Customer,Amount\nnot-a-number,x,1\n"u8.ToArray()); act.Should().Throw().WithMessage("CSV data format:*"); } [Fact] public async Task Dsl_PerNodeOptions_RoundTripThroughRoute() { await using var ctx = new RouteContext().AddRoutes(b => b .From("direct://csv") .MarshalCsv(o => o.Delimiter = ";") .To("mock://wire") .UnmarshalCsv>(o => o.Delimiter = ";") .To("mock://out")); await ctx.Start(); await ctx.SendBody("direct://csv", Rows); var wire = ctx.Mock("mock://wire").ReceivedExchanges[0].In; wire.ContentType.Should().Be("text/csv"); wire.Headers["Content-Type"].Should().Be("text/csv"); ctx.Mock("mock://out").ReceivedExchanges[0].In.Body.Should().BeEquivalentTo(Rows); } [Fact] public async Task Registry_ContentTypeAddressing_And_ContentTypeDrivenUnmarshal() { await using var ctx = new RouteContext(); ctx.AddCsvDataFormat(); ctx.AddRoutes(b => { b.From("direct://by-name").Marshal("text/csv").Unmarshal>("text/csv"); b.From("direct://by-content-type").Marshal("text/csv").Unmarshal>(); // driven by ContentType = text/csv }); await ctx.Start(); (await ctx.RequestBody>("direct://by-name", Rows)).Should().Equal(Rows); (await ctx.RequestBody>("direct://by-content-type", Rows)).Should().Equal(Rows); var registry = ctx.GetService()!; registry.GetSerializer("text/csv; charset=utf-8").Should().BeOfType(); registry.GetSerializer("application/csv").Should().BeOfType(); } [Fact] public async Task UnregisteredFormat_FailsStart() { await using var ctx = new RouteContext().AddRoutes(b => b.From("direct://nf").Marshal("text/csv")); var act = () => ctx.Start(); await act.Should().ThrowAsync().WithMessage("*'text/csv' is not registered*"); } [Fact] public async Task StringBody_IsUnmarshalled() { await using var ctx = new RouteContext().AddRoutes(b => b .From("direct://text").UnmarshalCsv>>()); await ctx.Start(); var maps = await ctx.RequestBody>>("direct://text", "a,b\n1,2\n"); maps.Should().ContainSingle().Which["b"].Should().Be("2"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/CsvReviewTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/CsvReviewTests.cs ---- using System.Text; using redb.Route.DataFormats.Csv; namespace redb.Route.Tests.DataFormats; /// Code review 2026-09-01, fourth batch: the header line is not a data row, and the header of dictionary rows is the union of their keys. public class CsvReviewTests { [Fact] public void RawRows_SkipTheHeaderLine_WhenAHeaderIsConfigured() { var rows = new CsvDataFormat().Deserialize>("a,b\n1,2\n3,4\n"u8.ToArray())!; rows.Should().HaveCount(2); rows[0].Should().Equal("1", "2"); rows[1].Should().Equal("3", "4"); } [Fact] public void DictionaryRows_HeaderIsTheUnionOfEveryRowsKeys() { var rows = new List> { new() { ["a"] = 1, ["b"] = 2 }, new() { ["a"] = 3, ["b"] = 4, ["c"] = 5 }, }; var text = Encoding.UTF8.GetString(new CsvDataFormat().Serialize(rows)); var lines = text.Split(["\r\n", "\n"], StringSplitOptions.RemoveEmptyEntries); lines.Should().Equal("a,b,c", "1,2,", "3,4,5"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/DataFormatNameTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/DataFormatNameTests.cs ---- using AwesomeAssertions; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.DataFormats.Avro; using redb.Route.DataFormats.Csv; using redb.Route.DataFormats.Mime; using redb.Route.DataFormats.Protobuf; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.Yaml; namespace redb.Route.Tests.DataFormats; /// /// Every data format package registers its name, as Apache Camel names it, beside its content type: after /// AddCsvDataFormat(), <marshal format="csv"/> finds it. Until 4.7.0 a name was registered only /// through <dataFormat name="...">. /// public sealed class DataFormatNameTests { public static TheoryData, Type> Formats => new() { { "csv", c => c.AddCsvDataFormat(), typeof(CsvDataFormat) }, { "yaml", c => c.AddYamlDataFormat(), typeof(YamlDataFormat) }, { "avro", c => c.AddAvroDataFormat(), typeof(AvroDataFormat) }, { "protobuf", c => c.AddProtobufDataFormat(), typeof(ProtobufDataFormat) }, { "mimeMultipart", c => c.AddMimeMultipartDataFormat(), typeof(MimeMultipartDataFormat) }, { "xmljson", c => c.AddXmlJsonDataFormat(), typeof(XmlJsonDataFormat) }, }; [Theory] [MemberData(nameof(Formats))] public async Task TheNameResolves_AfterTheRegistrationExtension(string name, Action register, Type type) { await using var context = new RouteContext(); register(context); context.GetService()!.GetSerializer(name).Should().BeOfType(type); type.GetField("Name")!.GetRawConstantValue().Should().Be(name); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/DecompressionLimitTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/DecompressionLimitTests.cs ---- using redb.Route.Serialization; namespace redb.Route.Tests.DataFormats; /// /// Code review 2026-09-01: GZip and Zip refuse a body that expands past the configured cap, so a /// small compressed message cannot exhaust the process memory. The default cap is 128 MB; a format /// instance can be given its own. /// public class DecompressionLimitTests { [Fact] public void GZip_RefusesABodyThatExpandsPastTheLimit() { var bomb = new GZipMessageSerializer().Serialize(new byte[2 * 1024 * 1024]); // 2 MB of zeros, a few KB on the wire var capped = new GZipMessageSerializer(maxDecodedBytes: 1024 * 1024); var act = () => capped.Deserialize(bomb); act.Should().Throw().WithMessage("*exceeds the limit*"); new GZipMessageSerializer().Deserialize(bomb).Should().HaveCount(2 * 1024 * 1024, "the default cap is far above 2 MB"); } [Fact] public void Zip_RefusesAnEntryThatExpandsPastTheLimit() { var bomb = new ZipMessageSerializer().Serialize(new byte[2 * 1024 * 1024]); var capped = new ZipMessageSerializer(maxDecodedBytes: 1024 * 1024); var act = () => capped.Deserialize(bomb); act.Should().Throw().WithMessage("*exceeds the limit*"); } [Fact] public void ANonPositiveLimit_IsRefused() { var gzip = () => new GZipMessageSerializer(maxDecodedBytes: 0); var zip = () => new ZipMessageSerializer(maxDecodedBytes: -1); gzip.Should().Throw(); zip.Should().Throw(); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/SOURCES.md Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/SOURCES.md ---- # xmljson test fixtures: sources Public schemas used by `XmlJsonRealSchemaTests`, downloaded on 2026-11-05. Each file keeps the copyright notice it was published with. The only change: absolute `schemaLocation` URLs of imports were made local file names, because xmljson reads a schema and its imports from the package only, never from the network. | File | Source | |---|---| | `ebms/ebms-header-3_0-200704.xsd` | https://docs.oasis-open.org/ebxml-msg/ebms/v3.0/core/ebms-header-3_0-200704.xsd (OASIS) | | `ebms/xmldsig-core-schema.xsd` | https://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd (W3C) | | `ebms/oasis-200401-wss-wssecurity-secext-1.0.xsd` | https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd (OASIS) | | `ebms/oasis-200401-wss-wssecurity-utility-1.0.xsd` | https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd (OASIS) | | `ebms/soap11-envelope.xsd` | http://schemas.xmlsoap.org/soap/envelope/ | | `ebms/soap12-envelope.xsd` | https://www.w3.org/2003/05/soap-envelope/ (W3C) | | `ebms/xml.xsd` | https://www.w3.org/2001/xml.xsd (W3C) | | `ubl/maindoc/UBL-Invoice-2.1.xsd`, `ubl/common/*.xsd`, `ubl/xml/UBL-Invoice-2.1-Example.xml` | https://docs.oasis-open.org/ubl/os-UBL-2.1/UBL-2.1.zip (OASIS), unchanged | Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/ebms-header-3_0-200704.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/ebms-header-3_0-200704.xsd ---- Schema for ebMS-3 XML Infoset This schema defines the XML Infoset of ebMS-3 headers. These headers are placed within the SOAP Header element of either a SOAP 1.1 or SOAP 1.2 message. The eb:Messaging element is the top element of ebMS-3 headers, and it is placed within the SOAP Header element (either SOAP 1.1 or SOAP 1.2). The eb:Messaging element may contain several instances of eb:SignalMessage and eb:UserMessage elements. However in the core part of the ebMS-3 specification, only one instance of either eb:UserMessage or eb:SignalMessage must be present. The second part of ebMS-3 specification may need to include multiple instances of either eb:SignalMessage, eb:UserMessage or both. Therefore, this schema is allowing multiple instances of eb:SignalMessage and eb:UserMessage elements for part 2 of the ebMS-3 specification. Note that the eb:Messaging element cannot be empty (at least one of eb:SignalMessage or eb:UserMessage element must present). In the core part of ebMS-3 specification, an eb:Signal Message is allowed to contain eb:MessageInfo and at most one Receipt Signal, at most one eb:PullRequest element, and/or a series of eb:Error elements. In part 2 of the ebMS-3 specification, new signals may be introduced, and for this reason, an extensibility point is added here to the eb:SignalMessage element to allow it to contain any elements. if SOAP 1.1 is being used, this attribute is required if SOAP 1.2 is being used, this attribute is required Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/oasis-200401-wss-wssecurity-secext-1.0.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/oasis-200401-wss-wssecurity-secext-1.0.xsd ---- This type represents an element with arbitrary attributes. This type is used for password elements per Section 4.1. This type is used for elements containing stringified binary data. This type represents a username token per Section 4.1 A security token that is encoded in binary A security token key identifier Typedef to allow a list of usages (as URIs). This global attribute is used to indicate the usage of a referenced or indicated token within the containing context This type represents a reference to an external security token. This type represents a reference to an embedded security token. This type is used reference a security token. This complexType defines header block to use for security-relevant data directed at a specific SOAP actor. The use of "any" is to allow extensibility and different forms of security data. This complexType defines a container for elements to be specified from any namespace as properties/parameters of a DSIG transformation. The use of "any" is to allow extensibility from any namespace. This element defines the wsse:UsernameToken element per Section 4.1. This element defines the wsse:BinarySecurityToken element per Section 4.2. This element defines a security token reference This element defines a security token embedded reference This element defines a key identifier reference This element defines the wsse:SecurityTokenReference per Section 4.3. This element defines the wsse:Security SOAP header element per Section 4. This element contains properties for transformations from any namespace, including DSIG. Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/oasis-200401-wss-wssecurity-utility-1.0.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/oasis-200401-wss-wssecurity-utility-1.0.xsd ---- This type defines the fault code value for Timestamp message expiration. This global attribute supports annotating arbitrary elements with an ID. Convenience attribute group used to simplify this schema. This type is for elements whose [children] is a psuedo-dateTime and can have arbitrary attributes. This type is for elements whose [children] is an anyURI and can have arbitrary attributes. This complex type ties together the timestamp related elements into a composite type. This element allows Timestamps to be applied anywhere element wildcards are present, including as a SOAP header. This element allows an expiration time to be applied anywhere element wildcards are present. This element allows a creation time to be applied anywhere element wildcards are present. Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/soap11-envelope.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/soap11-envelope.xsd ---- Prose in the spec does not specify that attributes are allowed on the Body element 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification Fault reporting structure Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/soap12-envelope.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/soap12-envelope.xsd ---- Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace Fault reporting structure Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/xml.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/xml.xsd ----

About the XML namespace

This schema document describes the XML namespace, in a form suitable for import by other schema documents.

See http://www.w3.org/XML/1998/namespace.html and http://www.w3.org/TR/REC-xml for information about this namespace.

Note that local names in this namespace are intended to be defined only by the World Wide Web Consortium or its subgroups. The names currently defined in this namespace are listed below. They should not be used with conflicting semantics by any Working Group, specification, or document instance.

See further below in this document for more information about how to refer to this schema document from your own XSD schema documents and about the namespace-versioning policy governing this schema document.

lang (as an attribute name)

denotes an attribute whose value is a language code for the natural language of the content of any element; its value is inherited. This name is reserved by virtue of its definition in the XML specification.

Notes

Attempting to install the relevant ISO 2- and 3-letter codes as the enumerated possible values is probably never going to be a realistic possibility.

See BCP 47 at http://www.rfc-editor.org/rfc/bcp/bcp47.txt and the IANA language subtag registry at http://www.iana.org/assignments/language-subtag-registry for further information.

The union allows for the 'un-declaration' of xml:lang with the empty string.

space (as an attribute name)

denotes an attribute whose value is a keyword indicating what whitespace processing discipline is intended for the content of the element; its value is inherited. This name is reserved by virtue of its definition in the XML specification.

base (as an attribute name)

denotes an attribute whose value provides a URI to be used as the base for interpreting any relative URIs in the scope of the element on which it appears; its value is inherited. This name is reserved by virtue of its definition in the XML Base specification.

See http://www.w3.org/TR/xmlbase/ for information about this attribute.

id (as an attribute name)

denotes an attribute whose value should be interpreted as if declared to be of type ID. This name is reserved by virtue of its definition in the xml:id specification.

See http://www.w3.org/TR/xml-id/ for information about this attribute.

Father (in any context at all)

denotes Jon Bosak, the chair of the original XML Working Group. This name is reserved by the following decision of the W3C XML Plenary and XML Coordination groups:

In appreciation for his vision, leadership and dedication the W3C XML Plenary on this 10th day of February, 2000, reserves for Jon Bosak in perpetuity the XML name "xml:Father".

About this schema document

This schema defines attributes and an attribute group suitable for use by schemas wishing to allow xml:base, xml:lang, xml:space or xml:id attributes on elements they define.

To enable this, such a schema must import this schema for the XML namespace, e.g. as follows:

          <schema . . .>
           . . .
           <import namespace="http://www.w3.org/XML/1998/namespace"
                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
     

or

           <import namespace="http://www.w3.org/XML/1998/namespace"
                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
     

Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g.

          <type . . .>
           . . .
           <attributeGroup ref="xml:specialAttrs"/>
     

will define a type which will schema-validate an instance element with any of those attributes.

Versioning policy for this schema document

In keeping with the XML Schema WG's standard versioning policy, this schema document will persist at http://www.w3.org/2009/01/xml.xsd.

At the date of issue it can also be found at http://www.w3.org/2001/xml.xsd.

The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XML Schema itself, or with the XML namespace itself. In other words, if the XML Schema or XML namespaces change, the version of this document at http://www.w3.org/2001/xml.xsd will change accordingly; the version at http://www.w3.org/2009/01/xml.xsd will not change.

Previous dated (and unchanging) versions of this schema document are at:

Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/xmldsig-core-schema.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ebms/xmldsig-core-schema.xsd ---- ]> Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/CCTS_CCT_SchemaModule-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/CCTS_CCT_SchemaModule-2.1.xsd ---- UNDT000001 CCT Amount. Type 1.0 A number of monetary units specified in a currency where the unit of the currency is explicit or implied. Amount decimal UNDT000001-SC2 SC Amount Currency. Identifier The currency of the amount. Amount Currency Identification Identifier string Reference UNECE Rec 9, using 3-letter alphabetic codes. UNDT000001-SC3 SC Amount Currency. Code List Version. Identifier The VersionID of the UN/ECE Rec9 code list. Amount Currency Code List Version Identifier string UNDT000002 CCT Binary Object. Type 1.0 A set of finite-length sequences of binary octets. Binary Object binary UNDT000002-SC2 SC Binary Object. Format. Text The format of the binary content. Binary Object Format Text string UNDT000002-SC3 SC Binary Object. Mime. Code The mime type of the binary object. Binary Object Mime Code string UNDT000002-SC4 SC Binary Object. Encoding. Code Specifies the decoding algorithm of the binary object. Binary Object Encoding Code string UNDT000002-SC5 SC Binary Object. Character Set. Code The character set of the binary object if the mime type is text. Binary Object Character Set Code string UNDT000002-SC6 SC Binary Object. Uniform Resource. Identifier The Uniform Resource Identifier that identifies where the binary object is located. Binary Object Uniform Resource Identifier Identifier string UNDT000002-SC7 SC Binary Object. Filename.Text The filename of the binary object. Binary Object Filename Text string UNDT000007 CCT Code. Type 1.0 A character string (letters, figures, or symbols) that for brevity and/or languange independence may be used to represent or replace a definitive value or text of an attribute together with relevant supplementary information. Code string Should not be used if the character string identifies an instance of an object class or an object in the real world, in which case the Identifier. Type should be used. UNDT000007-SC2 SC Code List. Identifier The identification of a list of codes. Code List Identification Identifier string UNDT000007-SC3 SC Code List. Agency. Identifier An agency that maintains one or more lists of codes. Code List Agency Identifier string Defaults to the UN/EDIFACT data element 3055 code list. UNDT000007-SC4 SC Code List. Agency Name. Text The name of the agency that maintains the list of codes. Code List Agency Name Text string UNDT000007-SC5 SC Code List. Name. Text The name of a list of codes. Code List Name Text string UNDT000007-SC6 SC Code List. Version. Identifier The version of the list of codes. Code List Version Identifier string UNDT000007-SC7 SC Code. Name. Text The textual equivalent of the code content component. Code Name Text string UNDT000007-SC8 SC Language. Identifier The identifier of the language used in the code name. Language Identification Identifier string UNDT000007-SC9 SC Code List. Uniform Resource. Identifier The Uniform Resource Identifier that identifies where the code list is located. Code List Uniform Resource Identifier Identifier string UNDT000007-SC10 SC Code List Scheme. Uniform Resource. Identifier The Uniform Resource Identifier that identifies where the code list scheme is located. Code List Scheme Uniform Resource Identifier Identifier string UNDT000008 CCT Date Time. Type 1.0 A particular point in the progression of time together with the relevant supplementary information. Date Time string Can be used for a date and/or time. UNDT000008-SC1 SC Date Time. Format. Text The format of the date time content Date Time Format Text string UNDT000011 CCT Identifier. Type 1.0 A character string to identify and distinguish uniquely, one instance of an object in an identification scheme from all other objects in the same scheme together with relevant supplementary information. Identifier string UNDT000011-SC2 SC Identification Scheme. Identifier The identification of the identification scheme. Identification Scheme Identification Identifier string UNDT000011-SC3 SC Identification Scheme. Name. Text The name of the identification scheme. Identification Scheme Name Text string UNDT000011-SC4 SC Identification Scheme Agency. Identifier The identification of the agency that maintains the identification scheme. Identification Scheme Agency Identification Identifier string Defaults to the UN/EDIFACT data element 3055 code list. UNDT000011-SC5 SC Identification Scheme Agency. Name. Text The name of the agency that maintains the identification scheme. Identification Scheme Agency Agency Name Text string UNDT000011-SC6 SC Identification Scheme. Version. Identifier The version of the identification scheme. Identification Scheme Version Identifier string UNDT000011-SC7 SC Identification Scheme Data. Uniform Resource. Identifier The Uniform Resource Identifier that identifies where the identification scheme data is located. Identification Scheme Data Uniform Resource Identifier Identifier string UNDT000011-SC8 SC Identification Scheme. Uniform Resource. Identifier The Uniform Resource Identifier that identifies where the identification scheme is located. Identification Scheme Uniform Resource Identifier Identifier string UNDT000012 CCT Indicator. Type 1.0 A list of two mutually exclusive Boolean values that express the only possible states of a Property. Indicator string UNDT000012-SC2 SC Indicator. Format. Text Whether the indicator is numeric, textual or binary. Indicator Format Text string UNDT000013 CCT Measure. Type 1.0 A numeric value determined by measuring an object along with the specified unit of measure. Measure decimal UNDT000013-SC2 SC Measure Unit. Code The type of unit of measure. Measure Unit Code Code string Reference UNECE Rec. 20 and X12 355 UNDT000013-SC3 SC Measure Unit. Code List Version. Identifier The version of the measure unit code list. Measure Unit Code List Version Identifier string UNDT000014 CCT Numeric. Type 1.0 Numeric information that is assigned or is determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure. Numeric string UNDT000014-SC2 SC Numeric. Format. Text Whether the number is an integer, decimal, real number or percentage. Numeric Format Text string UNDT000018 CCT Quantity. Type 1.0 A counted number of non-monetary units possibly including fractions. Quantity decimal UNDT000018-SC2 SC Quantity. Unit. Code The unit of the quantity Quantity Unit Code Code string UNDT000018-SC3 SC Quantity Unit. Code List. Identifier The quantity unit code list. Quantity Unit Code List Identifier string UNDT000018-SC4 SC Quantity Unit. Code List Agency. Identifier The identification of the agency that maintains the quantity unit code list Quantity Unit Code List Agency Identifier string Defaults to the UN/EDIFACT data element 3055 code list. UNDT000018-SC5 SC Quantity Unit. Code List Agency Name. Text The name of the agency which maintains the quantity unit code list. Quantity Unit Code List Agency Name Text string UNDT000019 CCT Text. Type 1.0 A character string (i.e. a finite set of characters) generally in the form of words of a language. Text string UNDT000019-SC2 SC Language. Identifier The identifier of the language used in the content component. Language Identification Identifier string UNDT000019-SC3 SC Language. Locale. Identifier The identification of the locale of the language. Language Locale Identifier string Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonBasicComponents-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonBasicComponents-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonExtensionComponents-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonExtensionComponents-2.1.xsd ---- A container for all extensions present in the document. A container for all extensions present in the document. A single extension for private use. A single extension for private use. A single extension for private use. An identifier for the Extension assigned by the creator of the extension. A name for the Extension assigned by the creator of the extension. An agency that maintains one or more Extensions. The name of the agency that maintains the Extension. The version of the Extension. A URI for the Agency that maintains the Extension. A URI for the Extension. A code for reason the Extension is being included. A description of the reason for the Extension. The definition of the extension content. Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonSignatureComponents-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CommonSignatureComponents-2.1.xsd ---- ABIE UBL Document Signatures. Details This class collects all signature information for a document. UBL Document Signatures ASBIE UBL Document Signatures. Signature Information Each of these is scaffolding for a single digital signature. 1..n UBL Document Signatures Signature Information Signature Information Signature Information Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CoreComponentParameters-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-CoreComponentParameters-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-ExtensionContentDataType-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-ExtensionContentDataType-2.1.xsd ---- Any element in any namespace other than the UBL extension namespace is allowed to be the apex element of an extension. Only those elements found in the UBL schemas and in the trees of schemas imported in this module are validated. Any element for which there is no schema declaration in any of the trees of schemas passes validation and is not treated as a schema constraint violation. Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-QualifiedDataTypes-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-QualifiedDataTypes-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-SignatureAggregateComponents-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-SignatureAggregateComponents-2.1.xsd ---- ABIE Signature Information. Details This class captures a single signature and optionally associates to a signature in the document with the corresponding identifier. Signature Information BBIE Signature Information. Identifier This specifies the identifier of the signature distinguishing it from other signatures. 0..1 Signature Information Identifier Identifier Identifier. Type BBIE Signature Information. Referenced Signature Identifier. Identifier This associates this signature with the identifier of a signature business object in the document. 0..1 Signature Information Referenced Signature Identifier Identifier Identifier. Type This is a single digital signature as defined by the W3C specification. Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-SignatureBasicComponents-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-SignatureBasicComponents-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-UnqualifiedDataTypes-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-UnqualifiedDataTypes-2.1.xsd ---- UBLUDT000001 UDT Amount. Type 1.0 A number of monetary units specified using a given unit of currency. Amount UNDT000001-SC2 SC Amount. Currency. Identifier The currency of the amount. Amount Currency Identification Identifier string Reference UNECE Rec 9, using 3-letter alphabetic codes. UBLUDT000002 UDT Binary Object. Type 1.0 A set of finite-length sequences of binary octets. Binary Object binary UNDT000002-SC3 SC Binary Object. Mime. Code The mime type of the binary object. Binary Object Mime Code string UBLUDT000003 UDT Graphic. Type 1.0 A diagram, graph, mathematical curve, or similar representation. Graphic binary UNDT000003-SC3 SC Graphic. Mime. Code The mime type of the graphic object. Graphic Mime Code normalizedString UBLUDT000004 UDT Picture. Type 1.0 A diagram, graph, mathematical curve, or similar representation. Picture binary UNDT000004-SC3 SC Picture. Mime. Code The mime type of the picture object. Picture Mime Code normalizedString UBLUDT000005 UDT Sound. Type 1.0 An audio representation. Sound binary UNDT000005-SC3 SC Sound. Mime. Code The mime type of the sound object. Sound Mime Code normalizedString UBLUDT000006 UDT Video. Type 1.0 A video representation. Video binary UNDT000006-SC3 SC Video. Mime. Code The mime type of the video object. Video Mime Code normalizedString UBLUDT000007 UDT Code. Type 1.0 A character string (letters, figures, or symbols) that for brevity and/or language independence may be used to represent or replace a definitive value or text of an attribute, together with relevant supplementary information. Code string Other supplementary components in the CCT are captured as part of the token and name for the schema module containing the code list and thus, are not declared as attributes. UBLUDT000008 UDT Date Time. Type 1.0 A particular point in the progression of time, together with relevant supplementary information. Date Time string Can be used for a date and/or time. UBLUDT000009 UDT Date. Type 1.0 One calendar day according the Gregorian calendar. Date string UBLUDT0000010 UDT Time. Type 1.0 An instance of time that occurs every day. Time string UBLUDT0000011 UDT Identifier. Type 1.0 A character string to identify and uniquely distinguish one instance of an object in an identification scheme from all other objects in the same scheme, together with relevant supplementary information. Identifier string Other supplementary components in the CCT are captured as part of the token and name for the schema module containing the identifier list and thus, are not declared as attributes. UBLUDT0000012 UDT Indicator. Type 1.0 A list of two mutually exclusive Boolean values that express the only possible states of a property. Indicator string UBLUDT0000013 UDT Measure. Type 1.0 A numeric value determined by measuring an object using a specified unit of measure. Measure Type decimal UNDT000013-SC2 SC Measure. Unit. Code The type of unit of measure. Measure Unit Code Code normalizedString Reference UNECE Rec. 20 and X12 355 UBLUDT0000014 UDT Numeric. Type 1.0 Numeric information that is assigned or is determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure. Numeric string UBLUDT0000015 UDT 1.0 Value. Type Numeric information that is assigned or is determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure. Value string UBLUDT0000016 UDT 1.0 Percent. Type Numeric information that is assigned or is determined by calculation, counting, or sequencing and is expressed as a percentage. It does not require a unit of quantity or unit of measure. Percent string UBLUDT0000017 UDT 1.0 Rate. Type A numeric expression of a rate that is assigned or is determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure. Rate string UBLUDT0000018 UDT Quantity. Type 1.0 A counted number of non-monetary units, possibly including a fractional part. Quantity decimal UBLUDT0000019 UDT Text. Type 1.0 A character string (i.e. a finite set of characters), generally in the form of words of a language. Text string UBLUDT0000020 UDT Name. Type 1.0 A character string that constitutes the distinctive designation of a person, place, thing or concept. Name string Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-XAdESv132-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-XAdESv132-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-XAdESv141-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-XAdESv141-2.1.xsd ---- Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-xmldsig-core-schema-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/common/UBL-xmldsig-core-schema-2.1.xsd ---- ]> Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/maindoc/UBL-Invoice-2.1.xsd Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/maindoc/UBL-Invoice-2.1.xsd ---- This element MUST be conveyed as the root element in any instance document based on this Schema expression ABIE Invoice. Details A document used to request payment. Invoice A container for all extensions present in the document. BBIE Invoice. UBL Version Identifier. Identifier Identifies the earliest version of the UBL 2 schema for this document type that defines all of the elements that might be encountered in the current instance. 0..1 Invoice UBL Version Identifier Identifier Identifier. Type 2.0.5 BBIE Invoice. Customization Identifier. Identifier Identifies a user-defined customization of UBL for a specific use. 0..1 Invoice Customization Identifier Identifier Identifier. Type NES BBIE Invoice. Profile Identifier. Identifier Identifies a user-defined profile of the customization of UBL being used. 0..1 Invoice Profile Identifier Identifier Identifier. Type BasicProcurementProcess BBIE Invoice. Profile Execution Identifier. Identifier Identifies an instance of executing a profile, to associate all transactions in a collaboration. 0..1 Invoice Profile Execution Identifier Identifier Identifier. Type BPP-1001 BBIE Invoice. Identifier An identifier for this document, assigned by the sender. 1 Invoice Identifier Identifier Identifier. Type Invoice Number BBIE Invoice. Copy_ Indicator. Indicator Indicates whether this document is a copy (true) or not (false). 0..1 Invoice Copy Indicator Indicator Indicator. Type BBIE Invoice. UUID. Identifier A universally unique identifier for an instance of this document. 0..1 Invoice UUID Identifier Identifier. Type BBIE Invoice. Issue Date. Date The date, assigned by the sender, on which this document was issued. 1 Invoice Issue Date Date Date. Type Invoice Date BBIE Invoice. Issue Time. Time The time, assigned by the sender, at which this document was issued. 0..1 Invoice Issue Time Time Time. Type BBIE Invoice. Due Date. Date The date on which Invoice is due. 0..1 Invoice Due Date Date Date. Type BBIE Invoice. Invoice Type Code. Code A code signifying the type of the Invoice. 0..1 Invoice Invoice Type Code Code Code. Type BBIE Invoice. Note. Text Free-form text pertinent to this document, conveying information that is not contained explicitly in other structures. 0..n Invoice Note Text Text. Type BBIE Invoice. Tax Point Date. Date The date of the Invoice, used to indicate the point at which tax becomes applicable. 0..1 Invoice Tax Point Date Date Date. Type BBIE Invoice. Document_ Currency Code. Code A code signifying the default currency for this document. 0..1 Invoice Document Currency Code Code Currency Currency_ Code. Type BBIE Invoice. Tax_ Currency Code. Code A code signifying the currency used for tax amounts in the Invoice. 0..1 Invoice Tax Currency Code Code Currency Currency_ Code. Type BBIE Invoice. Pricing_ Currency Code. Code A code signifying the currency used for prices in the Invoice. 0..1 Invoice Pricing Currency Code Code Currency Currency_ Code. Type BBIE Invoice. Payment_ Currency Code. Code A code signifying the currency used for payment in the Invoice. 0..1 Invoice Payment Currency Code Code Currency Currency_ Code. Type BBIE Invoice. Payment Alternative_ Currency Code. Code A code signifying the alternative currency used for payment in the Invoice. 0..1 Invoice Payment Alternative Currency Code Code Currency Currency_ Code. Type BBIE Invoice. Accounting Cost Code. Code The buyer's accounting code, applied to the Invoice as a whole. 0..1 Invoice Accounting Cost Code Code Code. Type BBIE Invoice. Accounting Cost. Text The buyer's accounting code, applied to the Invoice as a whole, expressed as text. 0..1 Invoice Accounting Cost Text Text. Type BBIE Invoice. Line Count. Numeric The number of lines in the document. 0..1 Invoice Line Count Numeric Numeric. Type BBIE Invoice. Buyer_ Reference. Text A reference provided by the buyer used for internal routing of the document. 0..1 Invoice Buyer Reference Text Text. Type ASBIE Invoice. Invoice_ Period. Period A period to which the Invoice applies. 0..n Invoice Invoice Period Period Period ASBIE Invoice. Order Reference A reference to the Order with which this Invoice is associated. 0..1 Invoice Order Reference Order Reference Order Reference ASBIE Invoice. Billing Reference A reference to a billing document associated with this document. 0..n Invoice Billing Reference Billing Reference Billing Reference ASBIE Invoice. Despatch_ Document Reference. Document Reference A reference to a Despatch Advice associated with this document. 0..n Invoice Despatch Document Reference Document Reference Document Reference ASBIE Invoice. Receipt_ Document Reference. Document Reference A reference to a Receipt Advice associated with this document. 0..n Invoice Receipt Document Reference Document Reference Document Reference ASBIE Invoice. Statement_ Document Reference. Document Reference A reference to a Statement associated with this document. 0..n Invoice Statement Document Reference Document Reference Document Reference ASBIE Invoice. Originator_ Document Reference. Document Reference A reference to an originator document associated with this document. 0..n Invoice Originator Document Reference Document Reference Document Reference ASBIE Invoice. Contract_ Document Reference. Document Reference A reference to a contract associated with this document. 0..n Invoice Contract Document Reference Document Reference Document Reference ASBIE Invoice. Additional_ Document Reference. Document Reference A reference to an additional document associated with this document. 0..n Invoice Additional Document Reference Document Reference Document Reference ASBIE Invoice. Project Reference Information about a project. 0..n Invoice Project Reference Project Reference Project Reference ASBIE Invoice. Signature A signature applied to this document. 0..n Invoice Signature Signature Signature ASBIE Invoice. Accounting_ Supplier Party. Supplier Party The accounting supplier party. 1 Invoice Accounting Supplier Party Supplier Party Supplier Party ASBIE Invoice. Accounting_ Customer Party. Customer Party The accounting customer party. 1 Invoice Accounting Customer Party Customer Party Customer Party ASBIE Invoice. Payee_ Party. Party The payee. 0..1 Invoice Payee Party Party Party ASBIE Invoice. Buyer_ Customer Party. Customer Party The buyer. 0..1 Invoice Buyer Customer Party Customer Party Customer Party ASBIE Invoice. Seller_ Supplier Party. Supplier Party The seller. 0..1 Invoice Seller Supplier Party Supplier Party Supplier Party ASBIE Invoice. Tax Representative_ Party. Party The tax representative. 0..1 Invoice Tax Representative Party Party Party ASBIE Invoice. Delivery A delivery associated with this document. 0..n Invoice Delivery Delivery Delivery ASBIE Invoice. Delivery Terms A set of delivery terms associated with this document. 0..1 Invoice Delivery Terms Delivery Terms Delivery Terms ASBIE Invoice. Payment Means Expected means of payment. 0..n Invoice Payment Means Payment Means Payment Means ASBIE Invoice. Payment Terms A set of payment terms associated with this document. 0..n Invoice Payment Terms Payment Terms Payment Terms ASBIE Invoice. Prepaid_ Payment. Payment A prepaid payment. 0..n Invoice Prepaid Payment Payment Payment ASBIE Invoice. Allowance Charge A discount or charge that applies to a price component. 0..n Invoice Allowance Charge Allowance Charge Allowance Charge ASBIE Invoice. Tax_ Exchange Rate. Exchange Rate The exchange rate between the document currency and the tax currency. 0..1 Invoice Tax Exchange Rate Exchange Rate Exchange Rate ASBIE Invoice. Pricing_ Exchange Rate. Exchange Rate The exchange rate between the document currency and the pricing currency. 0..1 Invoice Pricing Exchange Rate Exchange Rate Exchange Rate ASBIE Invoice. Payment_ Exchange Rate. Exchange Rate The exchange rate between the document currency and the payment currency. 0..1 Invoice Payment Exchange Rate Exchange Rate Exchange Rate ASBIE Invoice. Payment Alternative_ Exchange Rate. Exchange Rate The exchange rate between the document currency and the payment alternative currency. 0..1 Invoice Payment Alternative Exchange Rate Exchange Rate Exchange Rate ASBIE Invoice. Tax Total The total amount of a specific type of tax. 0..n Invoice Tax Total Tax Total Tax Total ASBIE Invoice. Withholding_ Tax Total. Tax Total The total withholding tax. 0..n Invoice Withholding Tax Total Tax Total Tax Total ASBIE Invoice. Legal_ Monetary Total. Monetary Total The total amount payable on the Invoice, including Allowances, Charges, and Taxes. 1 Invoice Legal Monetary Total Monetary Total Monetary Total ASBIE Invoice. Invoice Line A line describing an invoice item. 1..n Invoice Invoice Line Invoice Line Invoice Line Path: redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/xml/UBL-Invoice-2.1-Example.xml Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Fixtures/xmljson/ubl/xml/UBL-Invoice-2.1-Example.xml ---- 2.1 TOSL108 2009-12-15 380 Ordered in our booth at the convention. 2009-11-30 EUR Project cost code 123 2009-11-01 2009-11-30 123 Contract321 Framework agreement Doc1 Timesheet http://www.suppliersite.eu/sheet001.html Doc2 Drawing UjBsR09EbGhjZ0dTQUxNQUFBUUNBRU1tQ1p0dU1GUXhEUzhi 1234567890123 Supp123 Salescompany ltd. 1231412341324 5467 Main street Suite 123 1 Revenue department Big city 54321 RegionA DK DK12345 VAT The Sellercompany Incorporated 5402697509 Big city RegionA DK 4621230 4621231 antonio@salescompany.dk Antonio M Salemacher Sales manager 1234567987654 345KS5324 Buyercompany ltd 1238764941386 123 Anystreet Back door 8 Accounting department Anytown 101 RegionB BE BE54321 VAT The buyercompany inc. 5645342123 Mainplace RegionB BE 5121230 5121231 john@buyercompany.eu John X Doe Purchasing manager 098740918237 Ebeneser Scrooge Inc. 6411982340 2009-12-15 6754238987648 Deliverystreet Side door 12 DeliveryCity 523427 RegionC BE 31 2009-12-31 IBAN Payref1 DK1212341234123412 DKDKABCD Penalty percentage 10% from due date true Packing cost 100 false Promotion discount 100 292.20 1460.5 292.1 S 20 VAT 1 0.1 AA 10 VAT -25 0 E 0 AAM Exempt New Means of Transport VAT 1436.5 1436.5 1729 100 100 1000 0.30 729 1 Scratch on box 1 1273 BookingCode001 1 false Damage 12 true Testing 10 254.6 Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen 1440x900 Labtop computer JB007 1234567890124 12344321 65434568 S 20 VAT Color black 1273 1 false Contract 0.15 225 1500 2 Cover is slightly damaged. -1 -3.96 5 -0.396 Returned "Advanced computing" book JB008 1234567890125 32344324 65434567 AA 10 VAT 3.96 1 3 2 4.96 3 0.496 "Computing for dummies" book JB009 1234567890126 32344324 65434566 AA 10 VAT 2.48 1 false Contract 0.1 0.275 2.75 4 -1 -25 2 0 Returned IBM 5150 desktop JB010 1234567890127 12344322 65434565 E 0 VAT 25 1 5 250 187.5 BookingCode002 4 37.5 Network cable JB011 1234567890128 12344325 65434564 S 20 VAT Type Cat5 0.75 1 Path: redb-route/tests/redb.Route.Tests.DataFormats/MimeMultipartDataFormatTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/MimeMultipartDataFormatTests.cs ---- using System.Net.Http.Headers; using System.Text; using redb.Route.Abstractions; using redb.Route.Components; using redb.Route.Core; using redb.Route.DataFormats.Mime; using redb.Route.Serialization; namespace redb.Route.Tests.DataFormats; /// /// MIME multipart: a form posted with files reads as a plus attachments, any other multipart the /// Camel way, and both write back. The bodies are the ones real senders produce: a browser (raw UTF-8 file names) and /// .NET's . /// public class MimeMultipartDataFormatTests { private static readonly byte[] Pdf = [0x25, 0x50, 0x44, 0x46, 0x00, 0xFF, 0x0D, 0x0A, 0x2D, 0x2D, 0x00, 0xFE]; private static readonly byte[] Jpeg = [0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x0D, 0x0A, 0x0D, 0x0A, 0xFF, 0xD9]; private static Exchange Received(byte[] body, string? contentType) => new(new Message(body) { ContentType = contentType }); private static async Task Unmarshal(byte[] body, string? contentType, Type? target = null, MimeMultipartDataFormatOptions? options = null) { var exchange = Received(body, contentType); await new MimeMultipartDataFormat(options).UnmarshalAsync(exchange, target ?? typeof(FormBody)); return exchange; } /// What Chrome sends for a form with two fields and two files: raw UTF-8 in the file name, binary parts. private static byte[] BrowserForm(out string contentType) { const string boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"; contentType = $"multipart/form-data; boundary={boundary}"; var body = new MemoryStream(); void Text(string s) => body.Write(Encoding.UTF8.GetBytes(s)); Text($"--{boundary}\r\nContent-Disposition: form-data; name=\"claim\"\r\n\r\n12345\r\n"); Text($"--{boundary}\r\nContent-Disposition: form-data; name=\"theme\"\r\n\r\nпретензия по качеству\r\n"); Text($"--{boundary}\r\nContent-Disposition: form-data; name=\"docs\"; filename=\"акт.pdf\"\r\nContent-Type: application/pdf\r\n\r\n"); body.Write(Pdf); Text($"\r\n--{boundary}\r\nContent-Disposition: form-data; name=\"docs\"; filename=\"C:\\Users\\anna\\photo.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n"); body.Write(Jpeg); Text($"\r\n--{boundary}--\r\n"); return body.ToArray(); } private static byte[] Bytes(Attachment attachment) => attachment.Content.ReadAllBytes(); // ── multipart/form-data ── [Fact] public async Task A_browser_form_reads_as_fields_and_file_attachments_byte_for_byte() { var exchange = await Unmarshal(BrowserForm(out var contentType), contentType); var form = exchange.In.Body.Should().BeOfType().Subject; form.Get("claim").Should().Be("12345"); form.Get("theme").Should().Be("претензия по качеству"); var files = exchange.In.Attachments; files.Select(f => f.Name).Should().Equal("акт.pdf", "photo.jpg"); files[0].ContentType.Should().Be("application/pdf"); Bytes(files[0]).Should().Equal(Pdf, "bytes with CR, LF, '--', 0x00 and 0xFF survive"); files[1].FileName.Should().Be("photo.jpg", "the directory an old client sent is dropped"); Bytes(files[1]).Should().Equal(Jpeg); files[0].Headers["Content-Disposition"].Should().Contain("name=\"docs\"", "the form field stays readable"); exchange.In.ContentType.Should().BeNull("the boundary no longer describes the body"); } [Fact] public async Task A_form_written_by_a_dotnet_client_reads_the_same() { using var content = new MultipartFormDataContent(); content.Add(new StringContent("7"), "claim"); content.Add(new StringContent("a"), "tag"); content.Add(new StringContent("b"), "tag"); var file = new ByteArrayContent(Pdf); file.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); content.Add(file, "docs", "report.pdf"); var exchange = await Unmarshal(await content.ReadAsByteArrayAsync(), content.Headers.ContentType!.ToString()); var form = (FormBody)exchange.In.Body!; form.Get("claim").Should().Be("7"); form.GetAll("tag").Should().Equal("a", "b"); Bytes(exchange.In.Attachments.Single()).Should().Equal(Pdf); exchange.In.Attachments[0].Name.Should().Be("report.pdf"); } [Fact] public async Task A_body_that_is_not_multipart_is_left_as_it_is() { var exchange = await Unmarshal("{\"a\":1}"u8.ToArray(), "application/json"); exchange.In.Body.Should().BeOfType(); exchange.In.ContentType.Should().Be("application/json"); exchange.In.Attachments.Should().BeEmpty(); } [Fact] public async Task Without_a_boundary_parameter_the_first_line_names_it() { var body = BrowserForm(out _); var exchange = await Unmarshal(body, "multipart/form-data"); ((FormBody)exchange.In.Body!).Get("claim").Should().Be("12345"); exchange.In.Attachments.Should().HaveCount(2); } [Fact] public async Task The_content_type_header_counts_when_the_message_has_none() { var exchange = Received(BrowserForm(out var contentType), null); exchange.In.Headers["Content-Type"] = contentType; await new MimeMultipartDataFormat().UnmarshalAsync(exchange, typeof(FormBody)); exchange.In.Attachments.Should().HaveCount(2); exchange.In.Headers.ContainsKey("Content-Type").Should().BeFalse(); } [Fact] public async Task A_stream_body_is_read_without_buffering_by_the_step() { var exchange = new Exchange(new Message(new MemoryStream(BrowserForm(out var contentType))) { ContentType = contentType }); await new MimeMultipartDataFormat().UnmarshalAsync(exchange, typeof(FormBody)); exchange.In.Attachments.Should().HaveCount(2); } // ── Limits ── [Fact] public async Task Limits_fail_the_step_with_the_limit_named() { var body = BrowserForm(out var contentType); var parts = () => Unmarshal(body, contentType, options: new() { MaxParts = 3 }); var part = () => Unmarshal(body, contentType, options: new() { MaxPartBytes = 8 }); var total = () => Unmarshal(body, contentType, options: new() { MaxTotalBytes = 100 }); var name = () => Unmarshal(body, contentType, options: new() { MaxFileNameLength = 5 }); await parts.Should().ThrowAsync().WithMessage("*MaxParts*"); await part.Should().ThrowAsync().WithMessage("*MaxPartBytes*"); await total.Should().ThrowAsync().WithMessage("*MaxTotalBytes*"); await name.Should().ThrowAsync().WithMessage("*MaxFileNameLength*"); } [Fact] public async Task A_field_without_a_name_is_refused() { var body = "--b\r\nContent-Disposition: form-data\r\n\r\nx\r\n--b--\r\n"u8.ToArray(); var act = () => Unmarshal(body, "multipart/form-data; boundary=b"); await act.Should().ThrowAsync().WithMessage("*has no name*"); } [Fact] public async Task Another_target_type_for_a_form_is_refused() { var act = () => Unmarshal(BrowserForm(out var contentType), contentType, typeof(int)); await act.Should().ThrowAsync().WithMessage("*FormBody*"); } // ── multipart/mixed, the Camel way ── private const string Mixed = "--m\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nпривет\r\n" + "--m\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"a.bin\"\r\nContent-Transfer-Encoding: base64\r\n\r\nAAH/\r\n" + "--m\r\nContent-Type: image/png\r\nContent-ID: \r\n\r\npng\r\n" + "--m\r\nContent-Type: text/plain\r\n\r\nno name\r\n" + "--m--\r\n"; [Fact] public async Task Mixed_puts_the_first_part_in_the_body_and_names_the_rest_as_Camel_does() { var exchange = await Unmarshal(Encoding.UTF8.GetBytes(Mixed), "multipart/mixed; boundary=m", typeof(string)); exchange.In.Body.Should().Be("привет"); exchange.In.ContentType.Should().Be("text/plain; charset=utf-8"); var attachments = exchange.In.Attachments; attachments[0].Name.Should().Be("a.bin", "the file name first"); Bytes(attachments[0]).Should().Equal([0x00, 0x01, 0xFF], "base64 is decoded"); attachments[1].Name.Should().Be("logo@example", "then the Content-ID"); attachments[1].ContentId.Should().Be("logo@example"); attachments[2].Name.Should().EndWith("@redb", "then a generated id"); } [Fact] public async Task Mixed_to_a_stream_keeps_the_first_part_re_readable() { var exchange = await Unmarshal(Encoding.UTF8.GetBytes(Mixed), "multipart/mixed; boundary=m", typeof(object)); var body = exchange.In.Body.Should().BeOfType().Subject; new StreamReader(body).ReadToEnd().Should().Be("привет"); } // ── Marshal ── [Fact] public async Task A_form_and_attachments_write_a_form_that_reads_back_the_same() { var exchange = new Exchange(new Message(new FormBody().Add("claim", "7").Add("theme", "претензия"))); exchange.In.Attachments.Add(new Attachment { Name = "акт.pdf", FileName = "акт.pdf", ContentType = "application/pdf", Content = AttachmentContent.FromBytes(Pdf) }); await new MimeMultipartDataFormat().MarshalAsync(exchange); var contentType = exchange.In.ContentType!; contentType.Should().StartWith("multipart/form-data; boundary="); exchange.In.Headers["Content-Type"].Should().Be(contentType, "http: takes the header first"); var wire = ReadAll((Stream)exchange.In.Body!); Encoding.UTF8.GetString(wire).Should().Contain("filename=\"акт.pdf\"", "a browser-style UTF-8 file name, not RFC 2231"); var back = await Unmarshal(wire, contentType); ((FormBody)back.In.Body!).Get("theme").Should().Be("претензия"); Bytes(back.In.Attachments.Single()).Should().Equal(Pdf); back.In.Attachments[0].Name.Should().Be("акт.pdf"); } [Fact] public async Task Every_marshal_gets_a_new_boundary() { async Task Once() { var exchange = new Exchange(new Message(new FormBody().Add("a", "1"))); await new MimeMultipartDataFormat().MarshalAsync(exchange); return exchange.In.ContentType!; } (await Once()).Should().NotBe(await Once()); } [Fact] public async Task A_file_read_from_a_form_goes_back_under_its_form_field() { var exchange = await Unmarshal(BrowserForm(out var contentType), contentType); await new MimeMultipartDataFormat().MarshalAsync(exchange); var wire = Encoding.UTF8.GetString(ReadAll((Stream)exchange.In.Body!)); wire.Should().Contain("name=\"docs\"; filename=\"акт.pdf\"").And.Contain("name=\"claim\""); } [Fact] public async Task Mixed_writes_the_body_first_and_skips_a_message_without_attachments() { var format = new MimeMultipartDataFormat(new() { SubType = "mixed" }); var plain = new Exchange(new Message("just text")); await format.MarshalAsync(plain); plain.In.Body.Should().Be("just text", "without attachments the body is left as it is, as Camel does"); var withFile = new Exchange(new Message("body text") { ContentType = "text/plain; charset=utf-8" }); withFile.In.Attachments.Add(new Attachment { Name = "a.bin", FileName = "a.bin", Content = AttachmentContent.FromBytes([0, 1, 255]) }); await format.MarshalAsync(withFile); var back = await Unmarshal(ReadAll((Stream)withFile.In.Body!), withFile.In.ContentType, typeof(string)); back.In.Body.Should().Be("body text"); Bytes(back.In.Attachments.Single()).Should().Equal([0, 1, 255]); } [Fact] public void The_byte_methods_say_the_format_needs_the_message() { var act = () => new MimeMultipartDataFormat().Deserialize([1]); act.Should().Throw().WithMessage("*whole message*"); } // ── In a route ── [Fact] public async Task ConvertBody_reads_a_form_through_the_registered_format() { await using var context = new RouteContext($"mime-{Guid.NewGuid():N}"); context.AddComponent(new DirectComponent()); context.AddMimeMultipartDataFormat(); IExchange? seen = null; context.AddRoutes(r => r.From("direct://mime-in") .ConvertBody() .Filter("attachments.size == 2") .Process(e => seen = e) .End()); await context.Start(); var template = new ProducerTemplate(context); template.Start(); await template.SendAsync("direct://mime-in", new Message(BrowserForm(out var contentType)) { ContentType = contentType }); seen.Should().NotBeNull(); ((FormBody)seen!.In.Body!).Get("claim").Should().Be("12345"); } private static byte[] ReadAll(Stream stream) { stream.Position = 0; using var buffer = new MemoryStream(); stream.CopyTo(buffer); stream.Position = 0; return buffer.ToArray(); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/OrderRow.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/OrderRow.cs ---- namespace redb.Route.Tests.DataFormats; /// POCO shared by the CSV / Avro / YAML round-trip tests. public sealed class OrderRow { public int Id { get; set; } public string Customer { get; set; } = ""; public decimal Amount { get; set; } public override bool Equals(object? obj) => obj is OrderRow o && o.Id == Id && o.Customer == Customer && o.Amount == Amount; public override int GetHashCode() => HashCode.Combine(Id, Customer, Amount); public override string ToString() => $"{Id}/{Customer}/{Amount}"; } Path: redb-route/tests/redb.Route.Tests.DataFormats/ProtobufDataFormatTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/ProtobufDataFormatTests.cs ---- using Google.Protobuf; using redb.Route.Core; using redb.Route.DataFormats.Protobuf; using redb.Route.TestKit; using redb.Route.Tests.DataFormats.Protos; namespace redb.Route.Tests.DataFormats; public class ProtobufDataFormatTests { private static OrderMessage Sample() => new() { Id = 7, Customer = "acme", Skus = { "a", "b" } }; [Fact] public void RoundTrip_GeneratedMessage() { var format = new ProtobufDataFormat(); var bytes = format.Serialize(Sample()); var back = format.Deserialize(bytes); bytes.Should().Equal(Sample().ToByteArray()); back.Should().Be(Sample()); } [Fact] public void ConfluentWireFormat_FramesAndUnframes() { var format = new ProtobufDataFormat(new ProtobufDataFormatOptions { ConfluentWireFormat = true, SchemaId = 0x01020304 }); var framed = format.Serialize(Sample()); framed.Take(6).Should().Equal(0, 1, 2, 3, 4, 0); framed.Skip(6).Should().Equal(Sample().ToByteArray()); format.Deserialize(framed).Should().Be(Sample()); var plain = new ProtobufDataFormat(); var act = () => format.Deserialize(plain.Serialize(Sample()) is { Length: > 0 } p && p[0] != 0 ? p : [9, 9, 9, 9, 9, 9]); act.Should().Throw().WithMessage("Protobuf data format:*wire format*"); } [Fact] public void NonMessageBody_And_NonMessageTarget_FailNamingTheFormat() { var format = new ProtobufDataFormat(); var marshal = () => format.Serialize(new OrderRow()); var unmarshal = () => format.Deserialize([1, 2, 3]); marshal.Should().Throw().WithMessage("Protobuf data format:*IMessage*"); unmarshal.Should().Throw().WithMessage("Protobuf data format:*IMessage*"); } [Fact] public void Garbage_FailsNamingTheFormat() { var act = () => new ProtobufDataFormat().Deserialize([0xFF, 0xFF, 0xFF, 0xFF, 0xFF]); act.Should().Throw().WithMessage("Protobuf data format:*"); } [Fact] public async Task Dsl_And_Registry() { await using var ctx = new RouteContext(); ctx.AddProtobufDataFormat(); ctx.AddRoutes(b => { b.From("direct://sugar").MarshalProtobuf().To("mock://wire").UnmarshalProtobuf(); b.From("direct://named").Marshal("application/x-protobuf").Unmarshal("application/protobuf"); }); await ctx.Start(); (await ctx.RequestBody("direct://sugar", Sample())).Should().Be(Sample()); (await ctx.RequestBody("direct://named", Sample())).Should().Be(Sample()); ctx.Mock("mock://wire").ReceivedExchanges[0].In.ContentType.Should().Be("application/x-protobuf"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/Protos/order.proto Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/Protos/order.proto ---- syntax = "proto3"; option csharp_namespace = "redb.Route.Tests.DataFormats.Protos"; message OrderMessage { int32 id = 1; string customer = 2; repeated string skus = 3; } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonJsonToXmlSchemaTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonJsonToXmlSchemaTests.cs ---- using System.Text; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// xmljson, JSON to XML by a schema (step S6): sequence order whatever the key order, choice branches, all, the /// schema's namespaces and prefixes, lexical forms, strict errors with the JSON path, a wrapper only where the schema /// has one. Every document written is validated against the schema. /// public sealed class XmlJsonJsonToXmlSchemaTests { private const string Orders = """ """; private static XmlSchemaSet Set(string xsd) { var set = new XmlSchemaSet(); using var reader = XmlReader.Create(new StringReader(xsd)); set.Add(null, reader); set.Compile(); return set; } private static XDocument Convert(string json, string xsd = Orders, Action? configure = null) { var set = Set(xsd); var options = new XmlJsonOptions { SchemaSet = set }; configure?.Invoke(options); return new JsonToXml(options).Convert(Encoding.UTF8.GetBytes(json)); } private static string Valid(XDocument document, string xsd = Orders) { var errors = new List(); document.Validate(Set(xsd), (_, e) => errors.Add(e.Message)); errors.Should().BeEmpty(); return document.Root!.ToString(SaveOptions.DisableFormatting); } private const string Shuffled = """ {"Order":{"Items":{"Item":[{"Qty":2,"Sku":"pen"}]},"Cash":"yes","Total":1e3,"@count":2,"Paid":true,"Id":7,"@channel":"web"}} """; [Fact] public void SequenceOrder_NamespacesAndLexicalForms_FromTheSchema() { Valid(Convert(Shuffled)).Should().Be( """7true1000yespen2"""); } [Fact] public void Prefixes_FromTheOptions_OrFromTheJson() { Valid(Convert(Shuffled, configure: o => o.Prefixes["o"] = "urn:orders")).Should().StartWith(""); } [Fact] public void Root_NamesTheGlobalElement() { Valid(Convert("""{"Id":1,"Paid":false,"Total":1,"Card":"x","Items":{"Item":[{"Sku":"a","Qty":1}]}}""", configure: o => o.Root = "Order")) .Should().StartWith("a1"); } [Fact] public void Nillable_IsXsiNil() { Valid(Convert("""{"Order":{"Id":1,"Paid":false,"Total":1,"Card":"x","Note":null,"Items":{"Item":[{"Sku":"a","Qty":1}]}}}""")) .Should().Contain("").And.Contain("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""); } [Fact] public void AStringStaysAsWritten() { Valid(Convert("""{"Order":{"Id":1,"Paid":false,"Total":"12.50","Card":"x","Code":"007","Items":{"Item":[{"Sku":"a","Qty":1}]}}}""")) .Should().Contain("12.50").And.Contain("007"); } [Theory] [InlineData("""{"Order":{"Id":1,"Card":"x","Cash":"y"}}""", "xmljson: /Order has both 'Card' and 'Cash', two branches of one choice in the schema.")] [InlineData("""{"Order":{"Id":1,"Extra":"x"}}""", "xmljson: /Order/Extra: the content of /Order in the schema has no place for 'Extra'.")] [InlineData("""{"Order":{"@size":"1"}}""", "xmljson: /Order/@size: the schema declares no attribute 'size' here.")] [InlineData("""{"Order":{"Id":[1,2]}}""", "xmljson: /Order/Id is an array of 2, and the schema allows one 'Id' here.")] [InlineData("""{"Order":{"Id":null}}""", "xmljson: /Order/Id is null, and the schema does not declare it nillable.")] [InlineData("""{"Order":{"Items":"x"}}""", "xmljson: /Order/Items holds a value, and the schema declares element content: an object is expected.")] [InlineData("""{"Other":{}}""", "xmljson: the root 'Other' is not a global element of the schema.")] public void WhatTheSchemaDoesNotAllow_IsAnError(string json, string message) { var act = () => Convert(json); act.Should().Throw().WithMessage(message); } [Fact] public void UnqualifiedLocalElements_HaveNoNamespace() { const string xsd = """ """; Valid(Convert("""{"r":{"a":5}}""", xsd), xsd).Should().Be("""5"""); } [Fact] public void UnderAWildcard_ThePlainReverseApplies() { const string xsd = """ """; Valid(Convert("""{"r":{"free":{"x":["1","2"]},"id":3}}""", xsd), xsd).Should().Be("312"); } [Fact] public void XmlToJsonToXml_RoundTripsByTheSchema() { const string xml = """7true12.50va1"""; var options = new XmlJsonOptions { SchemaSet = Set(Orders) }; var toJson = new XmlToJson(options); var json = toJson.Write(toJson.Convert(Encoding.UTF8.GetBytes(xml))); Valid(new JsonToXml(options).Convert(json)).Should().Be(xml); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonJsonToXmlTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonJsonToXmlTests.cs ---- using System.Text; using System.Xml.Linq; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// xmljson, JSON to XML without a schema (step S5): the reverse notation, root=, arrays into repeated elements, the /// plural wrapper, namespaces from @xmlns keys, and the round trip of the S2 documents. /// public sealed class XmlJsonJsonToXmlTests { private static string Xml(string json, Action? configure = null) { var options = new XmlJsonOptions(); configure?.Invoke(options); var converter = new JsonToXml(options); return converter.Convert(Encoding.UTF8.GetBytes(json)).Root!.ToString(SaveOptions.DisableFormatting); } [Theory] [InlineData("""{"a":"5"}""", "5")] [InlineData("""{"a":""}""", "")] [InlineData("""{"a":12.50}""", "12.50")] [InlineData("""{"a":true}""", "true")] [InlineData("""{"a":{"@id":"1","#text":"x"}}""", """x""")] [InlineData("""{"a":{"@id":7,"b":"2"}}""", """2""")] [InlineData("""{"a":{"@id":null,"b":"2"}}""", "2")] [InlineData("""{"o":{"i":["1","2"]}}""", "12")] [InlineData("""{"o":{"i":[]}}""", "")] [InlineData("""{"a":"Привет"}""", "Привет")] public void TheNotation(string json, string xml) { Xml(json).Should().Be(xml); } [Fact] public void Null_IsXsiNil_WithTheNamespaceDeclared() { Xml("""{"r":{"a":null}}""").Should().Be(""""""); } [Fact] public void Namespaces_FromXmlnsKeys() { Xml("""{"s:Envelope":{"@xmlns:s":"urn:s","@xmlns":"urn:d","s:Body":{"Order":{"@s:id":"7","#text":"x"}}}}""") .Should().Be("""x"""); } [Fact] public void AnUndeclaredPrefix_IsAnError() { var act = () => Xml("""{"o:Order":{"Id":"1"}}"""); act.Should().Throw() .WithMessage("xmljson: /o:Order: the prefix 'o' is not declared; declare it with an \"@xmlns:o\" key on this element or an enclosing one."); } [Fact] public void Root_WrapsTheWholeJson() { Xml("""{"Id":"1","Tag":["a","b"]}""", o => o.Root = "Order").Should().Be("1ab"); Xml("""{"Item":["a","b"]}""", o => o.Root = "List").Should().Be("ab"); var act = () => Xml("""["a","b"]""", o => o.Root = "List"); act.Should().Throw().WithMessage("xmljson: the JSON is an array, and its items have no element name*root=List."); } [Theory] [InlineData("""{"a":"1","b":"2"}""", "xmljson: the JSON is an object of 2 key(s); XML has one root element: give the JSON one top-level key, or name the root with root=.")] [InlineData("""["a"]""", "xmljson: the JSON is an array; XML has one root element: give the JSON one top-level key, or name the root with root=.")] [InlineData("""{"a":["1"]}""", "xmljson: the top-level key 'a' holds an array; XML has one root element: name the root with root=.")] [InlineData("""{"a":{"first name":"x"}}""", "xmljson: /a/first name: 'first name' is not an XML name.")] [InlineData("""{"a":{"1x":"x"}}""", "xmljson: /a/1x: '1x' is not an XML name.")] [InlineData("""{"a":{"b":[["1"]]}}""", "xmljson: /a/b is an array inside an array; XML repeats an element, it cannot nest a list in a list.")] [InlineData("""{"a":{"@id":{"x":"1"}}}""", "xmljson: /a/@id holds an object of 1 key(s), where XML has text: an attribute, a text key or a namespace.")] [InlineData("not json", "xmljson: the body is not JSON*")] public void WhatXmlCannotHold_IsAnError(string json, string message) { var act = () => Xml(json); act.Should().Throw().WithMessage(message); } [Fact] public void ThePluralRule_WrapsAnArrayInItsPlural() { Xml("""{"r":{"Incidents":["1","2"]}}""", o => o.Plural = true) .Should().Be("12"); Xml("""{"r":{"Categories":["a"],"Addresses":["b"],"Cases":["c"]}}""", o => o.Plural = true) .Should().Be("a
b
c
"); } [Fact] public void ThePluralRule_IsSilentOnOtherNames_AndOffByDefault() { Xml("""{"r":{"Data":["1"]}}""", o => o.Plural = true).Should().Be("1"); Xml("""{"r":{"Incidents":["1"]}}""").Should().Be("1"); } [Fact] public void TheKeys_AreConfigurable() { Xml("""{"a":{"-id":"1","$":"x"}}""", o => { o.TextKey = "$"; o.AttributePrefix = "-"; }).Should().Be("""
x"""); } [Theory] [InlineData("5")] [InlineData("")] [InlineData("""x""")] [InlineData("""23""")] [InlineData("""x""")] [InlineData("""x""")] [InlineData("1")] [InlineData("Привет")] public void XmlToJsonToXml_RoundTrips(string xml) { var options = new XmlJsonOptions { Arrays = { "//Item" } }; var toJson = new XmlToJson(options); var json = toJson.Write(toJson.Convert(Encoding.UTF8.GetBytes(xml))); var back = new JsonToXml(options).Convert(json); Normalize(back.Root!).Should().Be(Normalize(XElement.Parse(xml))); } [Fact] public void Write_IsUtf8WithADeclarationAndNoBom() { var converter = new JsonToXml(new XmlJsonOptions()); var bytes = converter.Write(converter.Convert(Encoding.UTF8.GetBytes("""{"a":"Ж"}"""))); bytes[0].Should().Be((byte)'<'); Encoding.UTF8.GetString(bytes).Should().Be("""Ж"""); } /// An empty element written as <a></a> or <a/> is the same element. private static string Normalize(XElement element) { var copy = new XElement(element); foreach (var e in copy.DescendantsAndSelf().Where(e => !e.HasElements && e.Value.Length == 0)) e.RemoveNodes(); return copy.ToString(SaveOptions.DisableFormatting); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonPluralTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonPluralTests.cs ---- using System.Text; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// The plural-wrapper rule of xmljson (step S4): opt-in, regular and irregular English plurals, silent on every other /// name, and a single child under a plural wrapper is an array. /// public sealed class XmlJsonPluralTests { private static string Json(string xml, bool plural = true) { var converter = new XmlToJson(new XmlJsonOptions { Plural = plural }); return Encoding.UTF8.GetString(converter.Write(converter.Convert(Encoding.UTF8.GetBytes(xml)))); } [Theory] [InlineData("Incidents", "Incident")] [InlineData("Categories", "Category")] [InlineData("Boxes", "Box")] [InlineData("Addresses", "Address")] [InlineData("Statuses", "Status")] [InlineData("Cases", "Case")] [InlineData("Movies", "Movie")] [InlineData("Children", "Child")] [InlineData("people", "person")] [InlineData("Indices", "Index")] public void ThePairs(string parent, string child) { Plural.IsPair(parent, child).Should().BeTrue(); } [Theory] [InlineData("Items", "Line")] [InlineData("Address", "Addres")] [InlineData("Status", "Code")] [InlineData("Data", "Datum")] [InlineData("incidents", "Incident")] [InlineData("Order", "Orde")] public void NotPairs(string parent, string child) { Plural.IsPair(parent, child).Should().BeFalse(); } [Fact] public void ASingleChildOfAPluralWrapper_IsAnArray() { Json("1").Should().Be("""{"r":{"Incidents":{"Incident":["1"]}}}"""); } [Fact] public void TheWrappersAttributes_DoNotMatter() { Json("""1""").Should().Be("""{"Incidents":{"@count":"1","Incident":["1"]}}"""); } [Fact] public void AWrapperWithOtherChildren_IsNotAPluralWrapper() { Json("11").Should().Be("""{"Incidents":{"Incident":"1","Total":"1"}}"""); } [Fact] public void OffByDefault() { Json("1", plural: false).Should().Be("""{"Incidents":{"Incident":"1"}}"""); new XmlJsonOptions().Plural.Should().BeFalse(); } [Fact] public void SilentOnOtherNames() { Json("1").Should().Be("""{"Order":{"Line":"1"}}"""); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonRealSchemaTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonRealSchemaTests.cs ---- using System.Runtime.CompilerServices; using System.Text; using System.Text.Json.Nodes; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// xmljson on real schemas (step S9): the schemas of this repository and public ones (OASIS ebMS 3.0 with W3C /// xmldsig and OASIS WS-Security, SOAP 1.1 and 1.2). Each sample is valid against its schema, goes XML to JSON to XML, /// and the result is valid again and equal to the sample; at a repeated place one element and several give the same /// JSON shape. The public schemas are kept under Fixtures/xmljson with their import locations made local. /// public sealed class XmlJsonRealSchemaTests { private static string Repo([CallerFilePath] string file = "") => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(file)!, "..", "..")); private static string Fixture(params string[] parts) => Path.Combine([AppContext.BaseDirectory, "Fixtures", "xmljson", .. parts]); private static XmlSchemaSet Load(string path, string? root = null) => redb.Route.Validation.SchemaResolver.Load("xmljson", path, root); private static void Valid(XmlSchemaSet set, XDocument document) { var errors = new List(); document.Validate(set, (_, e) => errors.Add(e.Message)); errors.Should().BeEmpty(); } /// The sample is valid, its JSON comes back as the same valid document; returns the JSON. private static JsonNode RoundTrip(XmlSchemaSet set, string xml, Action? configure = null) { var sample = XDocument.Parse(xml); Valid(set, sample); var options = new XmlJsonOptions { SchemaSet = set }; configure?.Invoke(options); var toJson = new XmlToJson(options); var json = toJson.Convert(Encoding.UTF8.GetBytes(xml)); var back = new JsonToXml(options).Convert(Encoding.UTF8.GetBytes(json.ToJsonString())); Valid(set, back); XNode.DeepEquals(Normalize(back.Root!), Normalize(sample.Root!)).Should().BeTrue( $"the document comes back as it was:\n{back.Root}\nversus\n{sample.Root}"); return json; } /// Namespace declarations may move to the root; prefixes and layout aside, the elements must be equal. private static XElement Normalize(XElement element) => new(element.Name, element.Attributes().Where(a => !a.IsNamespaceDeclaration).OrderBy(a => a.Name.ToString()), element.Nodes().Select(n => n switch { XElement child => (object)Normalize(child), XText text when string.IsNullOrWhiteSpace(text.Value) && element.HasElements => null!, XText text => text.Value, _ => null!, }).Where(n => n is not null)); // ── This repository ───────────────────────────────────────────────────────────────────── [Fact] public void WorkerTemplate_Order() { var set = Load(Path.Combine(Repo(), "..", "redb.Templates", "templates", "redb-worker", "RedbWorker.Module", "Xml", "Order.xsd")); RoundTrip(set, "A-1Ann12.50EUR") ["Order"]!["Amount"]!.GetValue().Should().Be(12.50m); } [Fact] public void RouteXmlTemplate_OrderWithLines() { var set = Load(Path.Combine(Repo(), "..", "redb.Templates", "templates", "route-xml", "redb-route-validator-xslt", "resources", "order.xsd")); var one = RoundTrip(set, """Ann"""); var two = RoundTrip(set, """Ann"""); one["order"]!["line"].Should().BeOfType(); two["order"]!["line"]!.AsArray().Count.Should().Be(2); one["order"]!["line"]![0]!["@qty"]!.GetValue().Should().Be(1); } [Fact] public void SerialNumbersDemo_Request() { var set = Load(Path.Combine(Repo(), "demos", "SerialNumbersDemo", "SerialNumbers.Xml", "resources", "SerialNumberRequest.xsd")); RoundTrip(set, "r1046000000000013") ["SerialNumberRequest"]!["Gtin"]!.GetValue().Should().Be("04600000000001", "a pattern-restricted string keeps its leading zero"); } [Fact] public void RouteXmlSchema_ARouteFile() { var set = Load(Path.Combine(Repo(), "demos", "XmlDemo", "schema", "redb-route-1.0.xsd")); const string one = """ """; const string two = """ """; var single = RoundTrip(set, one, o => o.Namespaces = XmlJsonNamespaces.Drop); var several = RoundTrip(set, two, o => o.Namespaces = XmlJsonNamespaces.Drop); single["routes"]!["route"].Should().BeOfType("route repeats in the schema"); single["routes"]!["route"]![0]!["to"].Should().BeOfType("the steps are a repeated choice"); several["routes"]!["route"]![0]!["to"]!.AsArray().Count.Should().Be(2); } // ── Public schemas ────────────────────────────────────────────────────────────────────── private const string Messaging = """ 2026-11-05T10:00:00Z a@example.com senderhttp://example.com/sender receiverhttp://example.com/receiver http://example.com/service Submit 1 """; [Fact] public void Ebms3_Messaging() { var set = Load(Fixture("ebms", "ebms-header-3_0-200704.xsd")); var json = RoundTrip(set, Messaging); var user = json["eb:Messaging"]!["eb:UserMessage"]!; user.Should().BeOfType("UserMessage repeats in the Messaging content"); user[0]!["eb:PartyInfo"]!["eb:From"]!["eb:PartyId"].Should().BeOfType("PartyId repeats"); user[0]!["eb:PayloadInfo"]!["eb:PartInfo"].Should().BeOfType("PartInfo repeats"); } [Fact] public void WsSecurity_SecextWithXmldsigAndUtility_Loads() { // xmldsig-core-schema.xsd starts with a DOCTYPE; a schema's own DOCTYPE is skipped. var set = Load(Fixture("ebms", "oasis-200401-wss-wssecurity-secext-1.0.xsd")); const string security = """ 2026-11-05T10:00:00Z2026-11-05T10:05:00Z """; RoundTrip(set, security)["wsse:Security"]!["wsu:Timestamp"].Should().NotBeNull(); } [Theory] [InlineData("soap11-envelope.xsd", "http://schemas.xmlsoap.org/soap/envelope/")] [InlineData("soap12-envelope.xsd", "http://www.w3.org/2003/05/soap-envelope")] public void Soap_Envelopes(string file, string ns) { var set = Load(Fixture("ebms", file)); var json = RoundTrip(set, $"""1"""); json["s:Envelope"]!["s:Body"]!["Order"]![0]!["Id"]!.GetValue().Should().Be("1", "Body is an unbounded xs:any: its content is an array and falls back below"); } [Fact] public void Ubl21_TheOfficialInvoiceExample() { var watch = System.Diagnostics.Stopwatch.StartNew(); var set = Load(Fixture("ubl", "maindoc", "UBL-Invoice-2.1.xsd"), ".."); var compile = watch.Elapsed; var json = RoundTrip(set, File.ReadAllText(Fixture("ubl", "xml", "UBL-Invoice-2.1-Example.xml")), o => o.Namespaces = XmlJsonNamespaces.Keep); var invoice = json["Invoice"]!; invoice["cac:InvoiceLine"].Should().BeOfType("InvoiceLine repeats"); invoice["cbc:Note"].Should().BeOfType("Note repeats even where the example has one"); invoice["cac:AccountingSupplierParty"].Should().BeOfType("the supplier is single"); // Reported for the release notes, not asserted: the time to compile the UBL 2.1 Invoice schema set. Console.WriteLine($"UBL 2.1 Invoice schema compile: {compile.TotalMilliseconds:F0} ms"); } // ── The schema reader and DTDs ────────────────────────────────────────────────────────── [Fact] public void ASchemaWhoseContentUsesAnEntity_FailsClearly() { var dir = Path.Combine(Path.GetTempPath(), "redb-xmljson-dtd-" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(dir); try { var path = Path.Combine(dir, "entity.xsd"); File.WriteAllText(path, """ ]> """); var act = () => Load(path); act.Should().Throw().WithMessage("*ns*"); } finally { Directory.Delete(dir, recursive: true); } } [Fact] public void AMessageWithADoctype_IsStillRefused() { var set = Load(Fixture("ebms", "soap11-envelope.xsd")); var converter = new XmlToJson(new XmlJsonOptions { SchemaSet = set }); var act = () => converter.Convert(Encoding.UTF8.GetBytes("""]>&e;""")); act.Should().Throw(); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonSchemaTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonSchemaTests.cs ---- using System.Text; using System.Xml; using System.Xml.Schema; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// xmljson with a schema (step S3): repetition from the compiled particles (element maxOccurs, a repeated sequence or /// choice, a ref whose maxOccurs sits on the particle, groups, extension, substitution, recursion, xs:any), typed /// values, element content as an object, imports and includes from the package only. /// public sealed class XmlJsonSchemaTests : IDisposable { private readonly string _dir = Path.Combine(Path.GetTempPath(), "redb-xmljson-xsd-" + Guid.NewGuid().ToString("N")); public XmlJsonSchemaTests() => Directory.CreateDirectory(_dir); public void Dispose() => Directory.Delete(_dir, recursive: true); private const string Order = """ """; private static XmlSchemaSet Set(string xsd) { var set = new XmlSchemaSet(); using var reader = XmlReader.Create(new StringReader(xsd)); set.Add(null, reader); return set; } private static string Json(string xml, XmlSchemaSet set, Action? configure = null) { var options = new XmlJsonOptions { SchemaSet = set, Namespaces = XmlJsonNamespaces.Drop }; configure?.Invoke(options); var converter = new XmlToJson(options); return Encoding.UTF8.GetString(converter.Write(converter.Convert(Encoding.UTF8.GetBytes(xml)))); } [Fact] public void TypesAndRepetition_FromTheSchema() { Json(""" 7true12.500.5007 pen """, Set(Order)) .Should().Be("""{"Order":{"Id":7,"Paid":true,"Total":12.50,"Rate":0.5,"Code":"007","Items":{"Item":[{"@qty":2,"#text":"pen"}]},"Tags":{}}}"""); } [Fact] public void OneAndMany_HaveTheSameShape() { const string one = "101aa"; const string two = "101aab"; Json(one, Set(Order)).Should().Contain("\"Item\":[\"a\"]"); Json(two, Set(Order)).Should().Contain("\"Item\":[\"a\",\"b\"]"); } [Fact] public void Nillable_IsNull() { Json("""111aa""", Set(Order)) .Should().Contain("\"Note\":null"); } [Theory] [InlineData("x11aa", "xmljson: /Order/Id holds 'x', which is not an xs:int as the schema declares.")] [InlineData("1yes1aa", "xmljson: /Order/Paid holds 'yes', which is not an xs:boolean as the schema declares.")] [InlineData("111aa", "xmljson: /Order/Items/Item/@qty holds 'many', which is not an xs:int as the schema declares.")] [InlineData("1", "xmljson: /Order holds 'Extra', which its content in the schema has no place for.")] [InlineData("", "xmljson: the root element 'Other' (no namespace) is not a global element of the schema.")] public void WhatTheSchemaDoesNotAllow_IsAnError(string xml, string message) { var act = () => Json(xml, Set(Order)); act.Should().Throw().WithMessage(message); } [Fact] public void ARepeatedChoice_MakesEachBranchAnArray() { const string xsd = """ """; Json("1", Set(xsd)).Should().Be("""{"r":{"a":["1"]}}"""); } [Fact] public void AnElementTwiceInOneSequence_IsAnArray() { const string xsd = """ """; Json("12", Set(xsd)).Should().Be("""{"r":{"a":["1"],"b":"2"}}"""); } [Fact] public void ARefWithMaxOccursOnTheParticle_Repeats() { const string xsd = """ """; Json("5", Set(xsd)).Should().Be("""{"r":{"Line":[5]}}"""); } [Fact] public void GroupsAndExtension_AreFollowed() { const string xsd = """ """; Json("12", Set(xsd)).Should().Be("""{"r":{"Id":1,"Line":[2]}}"""); } [Fact] public void ASubstitutionGroupMember_TakesTheHeadsPlace() { const string xsd = """ """; Json("ann", Set(xsd)).Should().Be("""{"r":{"Buyer":["ann"]}}"""); } [Fact] public void ARecursiveType_IsFollowedAsDeepAsTheDocument() { const string xsd = """ """; Json("123", Set(xsd)) .Should().Be("""{"node":{"v":1,"node":[{"v":2,"node":[{"v":3}]}]}}"""); } [Fact] public void UnderAWildcard_AGlobalDeclarationIsUsed_ElseTheFallback() { const string xsd = """ """; Json("4123", Set(xsd)) .Should().Be("""{"r":{"Known":[4],"Free":[{"x":["1","2"],"y":"3"}]}}"""); } [Fact] public void ArraysPaths_StillAddArraysTheSchemaDoesNotKnow() { const string xsd = """ """; Json("1", Set(xsd), o => o.Arrays.Add("/r/a")).Should().Be("""{"r":{"a":[1]}}"""); } [Fact] public void Namespaces_TheSchemaMatchesQualifiedNames() { const string xsd = """ """; Json("""1""", Set(xsd), o => o.Namespaces = XmlJsonNamespaces.Keep) .Should().Be("""{"o:Order":{"@xmlns:o":"urn:o","o:Id":[1]}}"""); } [Fact] public void ImportsAndIncludes_ResolveInsideTheRoot() { Directory.CreateDirectory(Path.Combine(_dir, "main")); Directory.CreateDirectory(Path.Combine(_dir, "common")); File.WriteAllText(Path.Combine(_dir, "common", "types.xsd"), """ """); File.WriteAllText(Path.Combine(_dir, "main", "lines.xsd"), """ """); File.WriteAllText(Path.Combine(_dir, "main", "order.xsd"), """ """); var options = new XmlJsonOptions { Schema = Path.Combine(_dir, "main", "order.xsd"), SchemaRoot = _dir, Namespaces = XmlJsonNamespaces.Drop }; var converter = new XmlToJson(options); Encoding.UTF8.GetString(converter.Write(converter.Convert(Encoding.UTF8.GetBytes("3")))) .Should().Be("""{"Order":{"Qty":[3]}}"""); } [Fact] public void AnImportOutsideTheRoot_IsRefused() { Directory.CreateDirectory(Path.Combine(_dir, "main")); File.WriteAllText(Path.Combine(_dir, "types.xsd"), """"""); File.WriteAllText(Path.Combine(_dir, "main", "order.xsd"), """ """); var act = () => new XmlToJson(new XmlJsonOptions { Schema = Path.Combine(_dir, "main", "order.xsd") }); act.Should().Throw().WithMessage("*outside*imports and includes stay inside the package*"); } [Fact] public void AnImportFromTheNetwork_IsRefused() { File.WriteAllText(Path.Combine(_dir, "order.xsd"), """ """); var act = () => new XmlToJson(new XmlJsonOptions { Schema = Path.Combine(_dir, "order.xsd") }); act.Should().Throw().WithMessage("*from the package only, not the network*"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonXmlToJsonTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/XmlJsonXmlToJsonTests.cs ---- using System.Text; using AwesomeAssertions; using redb.Route.DataFormats.XmlJson; using redb.Route.DataFormats.XmlJson.Internal; namespace redb.Route.Tests.DataFormats; /// /// xmljson, XML to JSON without a schema (step S2): the Json.NET notation, namespaces kept or dropped, the arrays /// paths, and the fallback (a repeat is an array, a single element an object). /// public sealed class XmlJsonXmlToJsonTests { private static string Json(string xml, Action? configure = null) { var options = new XmlJsonOptions(); configure?.Invoke(options); var converter = new XmlToJson(options); return Encoding.UTF8.GetString(converter.Write(converter.Convert(Encoding.UTF8.GetBytes(xml)))); } [Theory] [InlineData("5", """{"a":"5"}""")] [InlineData("", """{"a":""}""")] [InlineData("", """{"a":""}""")] [InlineData(" x ", """{"a":" x "}""")] [InlineData("xz", """{"a":"xz"}""")] [InlineData("Привет", """{"a":"Привет"}""")] public void ATextOnlyElement_IsItsText(string xml, string json) { Json(xml).Should().Be(json); } [Fact] public void Cdata_IsText() { // The writer escapes HTML-sensitive characters; the parsed value is the CDATA content. System.Text.Json.Nodes.JsonNode.Parse(Json(" & c]]>"))!["a"]!.GetValue() .Should().Be(" & c"); } [Theory] [InlineData("""""", """{"a":null}""")] [InlineData("""""", """{"r":{"a":null}}""")] public void XsiNil_IsNull(string xml, string json) { Json(xml, o => o.Namespaces = XmlJsonNamespaces.Drop).Should().Be(json); } [Fact] public void XsiNil_BesideOtherAttributes_StaysAnAttribute() { Json("""""", o => o.Namespaces = XmlJsonNamespaces.Drop) .Should().Be("""{"a":{"@id":"1","@nil":"true"}}"""); } [Theory] [InlineData("""x""", """{"a":{"@id":"1","#text":"x"}}""")] [InlineData("""""", """{"a":{"@id":"1"}}""")] [InlineData("""2""", """{"a":{"@id":"1","b":"2"}}""")] [InlineData("x2y", """{"a":{"b":"2","#text":"xy"}}""")] [InlineData("\n 2\n", """{"a":{"b":"2"}}""")] public void AttributesAndText(string xml, string json) { Json(xml).Should().Be(json); } [Fact] public void TheKeys_AreConfigurable() { Json("""x""", o => { o.TextKey = "$"; o.AttributePrefix = "-"; }) .Should().Be("""{"a":{"-id":"1","$":"x"}}"""); } [Fact] public void Namespaces_Keep_WritesPrefixesAndDeclarations() { Json("""x""") .Should().Be("""{"s:Envelope":{"@xmlns:s":"urn:s","@xmlns":"urn:d","s:Body":{"Order":{"@s:id":"7","#text":"x"}}}}"""); } [Fact] public void Namespaces_Drop_WritesLocalNames() { Json("""x""", o => o.Namespaces = XmlJsonNamespaces.Drop) .Should().Be("""{"Envelope":{"Body":{"Order":{"@id":"7","#text":"x"}}}}"""); } [Fact] public void Fallback_ARepeatIsAnArray_ASingleElementAnObject() { Json("12").Should().Be("""{"o":{"i":["1","2"]}}"""); Json("1").Should().Be("""{"o":{"i":"1"}}"""); } [Fact] public void Fallback_RepeatsGroupInFirstSeenOrder() { Json("1x2").Should().Be("""{"o":{"i":["1","2"],"n":"x"}}"""); } [Theory] [InlineData("/Order/Items/Item")] [InlineData("//Item")] [InlineData("//Items/Item")] public void ArraysPaths_MakeASingleElementAnArray(string path) { Json("1", o => o.Arrays.Add(path)) .Should().Be("""{"Order":{"Items":{"Item":["1"]}}}"""); } [Theory] [InlineData("1")] [InlineData("12")] public void WithArraysPaths_OneAndManyHaveTheSameShape(string xml) { Json(xml, o => o.Arrays.Add("//Item")).Should().StartWith("""{"Order":{"Items":{"Item":["""); } [Fact] public void ArraysPaths_FromTheRoot_MatchOnlyThatPlace() { Json("12", o => o.Arrays.Add("/r/a/i")) .Should().Be("""{"r":{"a":{"i":["1"]},"b":{"i":"2"}}}"""); } [Fact] public void ArraysPaths_APrefixedStep_ComparesTheWrittenName() { const string xml = """12"""; Json(xml, o => o.Arrays.Add("//x:i")).Should().Contain("\"x:i\":[\"1\"]"); Json(xml, o => o.Arrays.Add("//i")).Should().Contain("\"x:i\":[\"1\"]", "a step without a prefix is the local name"); Json(xml, o => o.Arrays.Add("//y:i")).Should().Contain("\"x:i\":\"1\""); } [Theory] [InlineData("Order/Item")] [InlineData("/Order//Item")] [InlineData("/")] [InlineData("// Item")] public void AMalformedArraysPath_IsAnError(string path) { var act = () => new XmlToJson(new XmlJsonOptions { Arrays = { path } }); act.Should().Throw().WithMessage($"xmljson arrays path '{path}'*"); } [Fact] public void Indent_WritesIndentedJson() { Json("1", o => o.Indent = true).Should().Contain("\n"); } [Fact] public void ADtd_IsRefused() { var act = () => Json("""]>&e;"""); act.Should().Throw(); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/YamlDataFormatTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/YamlDataFormatTests.cs ---- using redb.Route.Core; using redb.Route.DataFormats.Yaml; using redb.Route.TestKit; namespace redb.Route.Tests.DataFormats; public class YamlDataFormatTests { private static readonly OrderRow Sample = new() { Id = 7, Customer = "acme", Amount = 12.5m }; [Fact] public void RoundTrip_Poco_CamelCaseKeys() { var format = new YamlDataFormat(); var bytes = format.Serialize(Sample); var text = System.Text.Encoding.UTF8.GetString(bytes); text.Should().Contain("id: 7").And.Contain("customer: acme").And.Contain("amount: 12.5"); format.Deserialize(bytes).Should().Be(Sample); } [Fact] public void DynamicTree_HasStringKeys() { var format = new YamlDataFormat(); var tree = format.Deserialize(""" name: web replicas: 3 ports: - 80 - 443 labels: tier: front """u8.ToArray()); var map = tree.Should().BeOfType>().Subject; map["name"].Should().Be("web"); map["ports"].Should().BeOfType>().Which.Should().Equal("80", "443"); map["labels"].Should().BeOfType>().Which["tier"].Should().Be("front"); } [Fact] public void BadYaml_FailsNamingTheFormat() { var act = () => new YamlDataFormat().Deserialize("id: [unclosed"u8.ToArray()); act.Should().Throw().WithMessage("YAML data format:*"); } [Fact] public async Task Dsl_And_Registry_WithAliases() { await using var ctx = new RouteContext(); ctx.AddYamlDataFormat(); ctx.AddRoutes(b => { b.From("direct://sugar").MarshalYaml().To("mock://wire").UnmarshalYaml(); b.From("direct://alias").Unmarshal("text/yaml"); b.From("direct://by-content-type").SetHeader("Content-Type", "application/x-yaml") .Process(e => e.In.ContentType = "application/x-yaml").Unmarshal(); }); await ctx.Start(); (await ctx.RequestBody("direct://sugar", Sample)).Should().Be(Sample); (await ctx.RequestBody("direct://alias", "id: 7\ncustomer: acme\namount: 12.5\n")).Should().Be(Sample); (await ctx.RequestBody("direct://by-content-type", "id: 7\ncustomer: acme\namount: 12.5\n")).Should().Be(Sample); ctx.Mock("mock://wire").ReceivedExchanges[0].In.ContentType.Should().Be("application/yaml"); } } Path: redb-route/tests/redb.Route.Tests.DataFormats/redb.Route.Tests.DataFormats.csproj Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.DataFormats/redb.Route.Tests.DataFormats.csproj ----