From 458c650fbbb2dee716f9d3cd8c63635f88341d83 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 14 Aug 2020 14:11:04 +0200 Subject: [PATCH] Reverted a change. --- .../Assets/AssetContentController.cs | 1 - .../Commands/CommandRequestTests.cs | 1 - .../Orleans/ExceptionWrapperFilterTests.cs | 74 ++++++++++++++++++- .../search/query-list.component.html | 2 +- 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs index f6f209ac7..ee29ad07e 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs @@ -21,7 +21,6 @@ using Squidex.Infrastructure.Assets; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Log; using Squidex.Web; -using ThirdParty.BouncyCastle.Asn1; #pragma warning disable 1573 diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs index 16a920dc9..30f8fc6ac 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.Threading.Tasks; using Orleans; using Orleans.TestingHost; -using Squidex.Infrastructure.Commands; using Xunit; #pragma warning disable SA1133 // Do not combine attributes diff --git a/backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs index ff1d44034..8a42c48bc 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs @@ -6,12 +6,21 @@ // ========================================================================== using System; +using System.Net; using System.Threading.Tasks; using FakeItEasy; +using MongoDB.Driver; +using MongoDB.Driver.Core.Clusters; +using MongoDB.Driver.Core.Connections; +using MongoDB.Driver.Core.Servers; using Orleans; +using Orleans.Hosting; +using Orleans.TestingHost; using Squidex.Infrastructure.TestHelpers; using Xunit; +#pragma warning disable SA1133 // Do not combine attributes + namespace Squidex.Infrastructure.Orleans { public class ExceptionWrapperFilterTests @@ -19,6 +28,28 @@ namespace Squidex.Infrastructure.Orleans private readonly IIncomingGrainCallContext context = A.Fake(); private readonly ExceptionWrapperFilter sut; + public interface IExceptionGrain : IGrainWithStringKey + { + Task ThrowCustomAsync(); + + Task ThrowMongoAsync(); + } + + public sealed class ExceptionGrain : Grain, IExceptionGrain + { + public Task ThrowCustomAsync() + { + throw new InvalidException("My Message"); + } + + public Task ThrowMongoAsync() + { + var connection = new ConnectionId(new ServerId(new ClusterId(), new IPEndPoint(IPAddress.Loopback, 21017)), 1); + + throw new MongoWriteException(connection, null, null, null); + } + } + private sealed class InvalidException : Exception { public InvalidException(string message) @@ -27,6 +58,14 @@ namespace Squidex.Infrastructure.Orleans } } + public sealed class Configurator : ISiloConfigurator + { + public void Configure(ISiloBuilder siloBuilder) + { + siloBuilder.AddIncomingGrainCallFilter(); + } + } + public ExceptionWrapperFilterTests() { sut = new ExceptionWrapperFilter(); @@ -68,8 +107,41 @@ namespace Squidex.Infrastructure.Orleans var result = source.SerializeAndDeserializeBinary(); Assert.Equal(result.ExceptionType, source.ExceptionType); - Assert.Equal(result.Message, source.Message); } + + [Fact, Trait("Category", "Dependencies")] + public async Task Simple_grain_tests() + { + var cluster = + new TestClusterBuilder(1) + .AddSiloBuilderConfigurator() + .Build(); + + await cluster.DeployAsync(); + + var grain = cluster.GrainFactory.GetGrain(SingleGrain.Id); + + var ex = await Assert.ThrowsAsync(() => grain.ThrowCustomAsync()); + + Assert.Equal(typeof(InvalidException), ex.ExceptionType); + } + + [Fact, Trait("Category", "Dependencies")] + public async Task Simple_grain_tests_with_mongo_exception() + { + var cluster = + new TestClusterBuilder(1) + .AddSiloBuilderConfigurator() + .Build(); + + await cluster.DeployAsync(); + + var grain = cluster.GrainFactory.GetGrain(SingleGrain.Id); + + var ex = await Assert.ThrowsAsync(() => grain.ThrowMongoAsync()); + + Assert.Equal(typeof(MongoWriteException), ex.ExceptionType); + } } } diff --git a/frontend/app/shared/components/search/query-list.component.html b/frontend/app/shared/components/search/query-list.component.html index ffb7f3d59..3040fcc08 100644 --- a/frontend/app/shared/components/search/query-list.component.html +++ b/frontend/app/shared/components/search/query-list.component.html @@ -1,4 +1,4 @@ - +