Skip to content

Commit

Permalink
thrift:// URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens-G committed Apr 24, 2024
1 parent ec3e7a2 commit 8f5aff0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/netstd/Tests/Thrift.Tests/UriFactory/TUriFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.VisualBasic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Thrift.Transport;

Expand Down Expand Up @@ -75,6 +77,20 @@ public void TFactory_Can_Parse_And_Construct_Socket_Transports()
);
}

[TestMethod]
public void TFactory_Can_Use_Multiplex()
{
var uri1 = new TThriftUri(BuiltinProtocols.binary, BuiltinTransports.http, "http://example.com");
var uri2 = new TThriftUri(BuiltinProtocols.binary, BuiltinTransports.http, "http://example.com");

uri1.Layers.Add(new("mplex", new() { ["one"] = string.Empty }));
uri2.Layers.Add(new("mplex", new() { ["two"] = string.Empty }));

var config = new TConfiguration();
var prot1 = TFactory.ConstructClientProtocolTransportStack(uri1, config, out var transport);
var prot2 = TFactory.ConstructClientProtocolTransportStack(uri1, config, out var transport);
}

private void InternalTestMethodImplementation(IEnumerable<BuiltinProtocols> protocols, IEnumerable<BuiltinTransports> transports, IEnumerable<BuiltinProtocolDecorators> decorators, IEnumerable<BuiltinLayeredTransports> layeredTransports)
{
// those must not be empty to have at least one test run
Expand All @@ -85,7 +101,7 @@ private void InternalTestMethodImplementation(IEnumerable<BuiltinProtocols> prot
Assert.IsTrue(decorators.FirstOrDefault() == BuiltinProtocolDecorators.none);
Assert.IsTrue(layeredTransports.FirstOrDefault() == BuiltinLayeredTransports.none);

// thrift://protocol/transport/layer/layer?data
// thrift:protocol/transport/layer/layer?data
var numTests = 0;
foreach (var proto in protocols)
{
Expand Down Expand Up @@ -226,6 +242,7 @@ private static string MakeQueryString(Dictionary<string, string> data)

private static void TestUri(string sUri)
{
Console.WriteLine($"Testing {sUri}");
var parsed = new TThriftUri(sUri);
Assert.AreEqual(sUri, parsed.ToString());

Expand Down

0 comments on commit 8f5aff0

Please sign in to comment.