Attempts to fix issue

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-06-30 20:11:39 +02:00
parent 984e660bec
commit 7b546e6cee
13 changed files with 38 additions and 21 deletions

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Examine
/// </summary>
public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex
{
protected ILocalizationService LanguageService { get; }
#region Constructors

View File

@@ -26,7 +26,7 @@ namespace Umbraco.Tests.Testing
// FIXME: to be completed
/// <summary>
/// Gets or sets a value indicating ...
/// Gets or sets a value indicating ...
/// </summary>
public bool PublishedRepositoryEvents { get => _publishedRepositoryEvents.ValueOrDefault(false); set => _publishedRepositoryEvents.Set(value); }
private readonly Settable<bool> _publishedRepositoryEvents = new Settable<bool>();
@@ -50,6 +50,10 @@ namespace Umbraco.Tests.Testing
/// </summary>
/// <remarks>Default is to use the global tests plugin manager.</remarks>
public UmbracoTestOptions.TypeLoader TypeLoader { get => _typeLoader.ValueOrDefault(UmbracoTestOptions.TypeLoader.Default); set => _typeLoader.Set(value); }
public bool Boot { get => _boot.ValueOrDefault(true); set => _boot.Set(value); }
private readonly Settable<bool> _boot = new Settable<bool>();
private readonly Settable<UmbracoTestOptions.TypeLoader> _typeLoader = new Settable<UmbracoTestOptions.TypeLoader>();
protected override TestOptionAttributeBase Merge(TestOptionAttributeBase other)

View File

@@ -7,7 +7,6 @@ using Umbraco.Web.BackOffice.Controllers;
namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class BackOfficeAssetsControllerTests: UmbracoTestServerTestBase
{
[Test]

View File

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Tests.Common.Builders;
@@ -16,9 +17,7 @@ using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
[Explicit("We need to fix the tests on buildserver and when running multiple tests in one run")]
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ContentControllerTests : UmbracoTestServerTestBase
{
@@ -150,7 +149,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
Assert.Multiple(() =>
{
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
Assert.AreEqual(")]}',\n{\"message\":\"No variants flagged for saving\"}", body);
Assert.AreEqual(")]}',\n{\"Message\":\"No variants flagged for saving\"}", body);
});
}

View File

@@ -14,9 +14,7 @@ using Umbraco.Web.Models.TemplateQuery;
namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
[Explicit("We need to fix the tests on buildserver and when running multiple tests in one run")]
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class TemplateQueryControllerTests : UmbracoTestServerTestBase
{
[Test]
@@ -43,7 +41,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
var alias = nameof(ContentTypeModel.Alias);
var camelCaseAlias = alias.ToCamelCase();
Assert.IsNotNull(jToken.Value<string>(camelCaseAlias), $"'{jToken}' do not contain the key '{camelCaseAlias}'");
Assert.IsNotNull(jToken.Value<string>(camelCaseAlias), $"'{jToken}' do not contain the key '{camelCaseAlias}' in the expected casing");
Assert.IsNull(jToken.Value<string>(alias), $"'{jToken}' do contain the key '{alias}', which was not expect in that casing");
}
});

View File

@@ -22,9 +22,7 @@ using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
[Explicit("We need to fix the tests on buildserver and when running multiple tests in one run")]
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class UsersControllerTests : UmbracoTestServerTestBase
{
[Test]

View File

@@ -11,6 +11,7 @@ using NUnit.Framework;
using Umbraco.Composing;
using Umbraco.Extensions;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web;
using Umbraco.Web.Common.Controllers;
using Umbraco.Web.Editors;
@@ -19,6 +20,7 @@ using Umbraco.Web.Editors;
namespace Umbraco.Tests.Integration.TestServerTest
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console, Boot = false)]
public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTest
{
[SetUp]
@@ -29,7 +31,6 @@ namespace Umbraco.Tests.Integration.TestServerTest
AllowAutoRedirect = false
});
LinkGenerator = Factory.Services.GetRequiredService<LinkGenerator>();
}
protected T GetRequiredService<T>() => Factory.Services.GetRequiredService<T>();

View File

@@ -237,7 +237,7 @@ namespace Umbraco.Tests.Integration.Testing
action();
return;
}
catch (SqlException e)
catch (Exception e)
{
Console.Error.WriteLine($"SqlException occured, but we try again {i+1}/{maxIterations}.\n{e}");

View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -18,7 +19,9 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Extensions;
using Umbraco.Tests.Integration.Implementations;
using Umbraco.Extensions;
using Umbraco.Tests.Testing;
using Umbraco.Web;
using ILogger = Umbraco.Core.Logging.ILogger;
namespace Umbraco.Tests.Integration.Testing
{
@@ -98,6 +101,8 @@ namespace Umbraco.Tests.Integration.Testing
{
var umbracoContainer = GetUmbracoContainer(out var serviceProviderFactory);
var testHelper = new TestHelper();
// get the currently set db options
var testOptions = TestOptionAttributeBase.GetTestOptions<UmbracoTestAttribute>();
var hostBuilder = new HostBuilder()
.UseUmbraco(serviceProviderFactory)
@@ -117,6 +122,9 @@ namespace Umbraco.Tests.Integration.Testing
services.AddMvc();
services.AddSingleton<ILogger>(new ConsoleLogger(new MessageTemplates()));
CustomTestSetup(services);
});
@@ -129,7 +137,10 @@ namespace Umbraco.Tests.Integration.Testing
app.UseTestLocalDb(testHelper.WorkingDirectory, this, out var connectionString);
TestDBConnectionString = connectionString;
app.UseUmbracoCore();
if (testOptions.Boot)
{
app.UseUmbracoCore();
}
}

View File

@@ -228,7 +228,7 @@ namespace Umbraco.Extensions
factory = coreRuntime.Configure(container);
return services;
}
}
private static ITypeFinder CreateTypeFinder(Core.Logging.ILogger logger, IProfiler profiler, IWebHostEnvironment webHostEnvironment, Assembly entryAssembly, ITypeFinderSettings typeFinderSettings)
{

View File

@@ -2,6 +2,9 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Umbraco.Web.Common.Formatters;
namespace Umbraco.Web.Common.Filters
@@ -18,13 +21,11 @@ namespace Umbraco.Web.Common.Filters
private class AngularJsonOnlyConfigurationFilter : IResultFilter
{
private readonly IOptions<MvcNewtonsoftJsonOptions> _mvcNewtonsoftJsonOptions;
private readonly ArrayPool<char> _arrayPool;
private readonly IOptions<MvcOptions> _options;
public AngularJsonOnlyConfigurationFilter(IOptions<MvcNewtonsoftJsonOptions> mvcNewtonsoftJsonOptions, ArrayPool<char> arrayPool, IOptions<MvcOptions> options)
public AngularJsonOnlyConfigurationFilter(ArrayPool<char> arrayPool, IOptions<MvcOptions> options)
{
_mvcNewtonsoftJsonOptions = mvcNewtonsoftJsonOptions;
_arrayPool = arrayPool;
_options = options;
}
@@ -37,8 +38,14 @@ namespace Umbraco.Web.Common.Filters
{
if (context.Result is ObjectResult objectResult)
{
var serializerSettings = new JsonSerializerSettings()
{
ContractResolver = new DefaultContractResolver(),
Converters = {new VersionConverter()}
};
objectResult.Formatters.Clear();
objectResult.Formatters.Add(new AngularJsonMediaTypeFormatter(_mvcNewtonsoftJsonOptions.Value.SerializerSettings, _arrayPool, _options.Value));
objectResult.Formatters.Add(new AngularJsonMediaTypeFormatter(serializerSettings, _arrayPool, _options.Value));
}
}
}

View File

@@ -21,8 +21,7 @@ namespace Umbraco.Web.Common.Formatters
public AngularJsonMediaTypeFormatter(JsonSerializerSettings serializerSettings, ArrayPool<char> charPool, MvcOptions mvcOptions)
: base(serializerSettings, charPool, mvcOptions)
{
serializerSettings.Converters.Add(new VersionConverter());
serializerSettings.ContractResolver = new DefaultContractResolver();
}
protected override JsonWriter CreateJsonWriter(TextWriter writer)

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Umbraco.Web.UI.NetCore</RootNamespace>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj" />