Create some initial framework for client level peer tests
diff --git a/test/Proton.Client.Tests/Client/Implementation/ClientBaseTestFixture.cs b/test/Proton.Client.Tests/Client/Implementation/ClientBaseTestFixture.cs
new file mode 100644
index 0000000..5f5fc00
--- /dev/null
+++ b/test/Proton.Client.Tests/Client/Implementation/ClientBaseTestFixture.cs
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Microsoft.Extensions.Logging;
+using NUnit.Framework;
+using NLog.Extensions.Logging;
+
+namespace Apache.Qpid.Proton.Client.Implementation
+{
+ [TestFixture, Timeout(20000)]
+ public abstract class ClientBaseTestFixture
+ {
+ protected ILoggerFactory loggerFactory;
+ protected ILogger logger;
+ protected string testName;
+
+ [OneTimeSetUp]
+ public void OneTimeSetup()
+ {
+ var config = new NLog.Config.LoggingConfiguration();
+
+ // Targets where to log to: File and Console
+ NLog.Targets.FileTarget logfile = new NLog.Targets.FileTarget("logfile")
+ {
+ FileName = "./target/" + GetType().Name + ".txt",
+ DeleteOldFileOnStartup = true
+ };
+ NLog.Targets.Target logconsole = new NLog.Targets.ConsoleTarget("logconsole");
+
+ // Rules for mapping loggers to targets
+ config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logconsole);
+ config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, logfile);
+
+ loggerFactory = LoggerFactory.Create(builder =>
+ builder.ClearProviders().SetMinimumLevel(LogLevel.Trace).AddNLog(config)
+ );
+
+ logger = loggerFactory.CreateLogger(GetType().Name);
+ }
+
+ [SetUp]
+ public void SetUp()
+ {
+ testName = TestContext.CurrentContext.Test.Name;
+ logger.LogInformation("--------- Begin test {0} ---------------------------------", testName);
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ logger.LogInformation("--------- End test {0} ---------------------------------", testName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs b/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs
new file mode 100644
index 0000000..93428b9
--- /dev/null
+++ b/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+using NUnit.Framework;
+using Apache.Qpid.Proton.Test.Driver;
+using Apache.Qpid.Proton.Client.Exceptions;
+using Microsoft.Extensions.Logging;
+
+namespace Apache.Qpid.Proton.Client.Implementation
+{
+ [TestFixture, Timeout(20000)]
+ public class ClientConnectionTest : ClientBaseTestFixture
+ {
+ [Ignore("Not yet ready for these to work.")]
+ [Test]
+ public void TestConnectFailsDueToServerStopped()
+ {
+ using (ProtonTestServer peer = new ProtonTestServer(loggerFactory))
+ {
+ peer.Start();
+
+ string remoteAddress = peer.ServerAddress;
+ int remotePort = peer.ServerPort;
+
+ logger.LogInformation("Test started, peer listening on: {0}:{1}", remoteAddress, remotePort);
+
+ peer.Close();
+
+ IClient container = IClient.Create();
+
+ try
+ {
+ IConnection connection = container.Connect(remoteAddress, remotePort, new ConnectionOptions());
+ _ = connection.OpenTask.Result;
+ Assert.Fail("Should fail to connect");
+ }
+ catch (Exception ex)
+ {
+ logger.LogInformation("Connection create failed due to: ", ex);
+ Assert.IsTrue(ex.InnerException is ClientException);
+ }
+
+ peer.WaitForScriptToComplete();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Proton.Client.Tests/Proton.Client.Tests.csproj b/test/Proton.Client.Tests/Proton.Client.Tests.csproj
index e96143b..2a35b19 100644
--- a/test/Proton.Client.Tests/Proton.Client.Tests.csproj
+++ b/test/Proton.Client.Tests/Proton.Client.Tests.csproj
@@ -23,10 +23,14 @@
</PropertyGroup>
<ItemGroup>
+ <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
+ <PackageReference Include="NLog" Version="4.7.12" />
+ <PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
</ItemGroup>
<ItemGroup>