Index: Core/Components/src/Core.Components.BruTile/Configurations/PersistentCacheConfiguration.cs
===================================================================
diff -u -rc779a09fcdb11c7263b460e664e93cc36d0daf6f -r684e249584f81413e836ca8fb3382ea56e5d7a3b
--- Core/Components/src/Core.Components.BruTile/Configurations/PersistentCacheConfiguration.cs (.../PersistentCacheConfiguration.cs) (revision c779a09fcdb11c7263b460e664e93cc36d0daf6f)
+++ Core/Components/src/Core.Components.BruTile/Configurations/PersistentCacheConfiguration.cs (.../PersistentCacheConfiguration.cs) (revision 684e249584f81413e836ca8fb3382ea56e5d7a3b)
@@ -159,28 +159,14 @@
BruTileSettings.MemoryCacheMaximum,
tileCache);
}
- catch (Exception e) when (e is NotSupportedException || e is ArgumentException)
+ catch (Exception e) when (e is NotSupportedException)
{
throw new CannotReceiveTilesException(Resources.Configuration_InitializeFromTileSource_TileSource_does_not_allow_access_to_provider, e);
}
Initialized = true;
}
///
- /// Throws an when
- /// is true.
- ///
- /// Thrown when calling this method while
- /// this instance is disposed.
- protected void ThrowExceptionIfDisposed()
- {
- if (IsDisposed)
- {
- throw new ObjectDisposedException(GetType().Name);
- }
- }
-
- ///
/// Creates the tile cache.
///
/// The file cache.
@@ -211,6 +197,20 @@
private bool IsDisposed { get; set; }
+ ///
+ /// Throws an when
+ /// is true.
+ ///
+ /// Thrown when calling this method while
+ /// this instance is disposed.
+ private void ThrowExceptionIfDisposed()
+ {
+ if (IsDisposed)
+ {
+ throw new ObjectDisposedException(GetType().Name);
+ }
+ }
+
private static bool SupportedCreateDirectoryExceptions(Exception exception)
{
return exception is IOException
Index: Core/Components/src/Core.Components.BruTile/Configurations/WmtsLayerConfiguration.cs
===================================================================
diff -u -r74efc36a4db93f588a262a08735fb1fb0f6c096b -r684e249584f81413e836ca8fb3382ea56e5d7a3b
--- Core/Components/src/Core.Components.BruTile/Configurations/WmtsLayerConfiguration.cs (.../WmtsLayerConfiguration.cs) (revision 74efc36a4db93f588a262a08735fb1fb0f6c096b)
+++ Core/Components/src/Core.Components.BruTile/Configurations/WmtsLayerConfiguration.cs (.../WmtsLayerConfiguration.cs) (revision 684e249584f81413e836ca8fb3382ea56e5d7a3b)
@@ -74,7 +74,7 @@
/// Thrown when creating the file
/// cache failed.
/// Thrown when
- /// doesn't contain a .
+ /// does not allow for tiles to be retrieved.
/// Thrown when a critical error
/// occurs when creating the tile cache.
private WmtsLayerConfiguration(string wmtsCapabilitiesUrl, ITileSource tileSource)
@@ -101,7 +101,7 @@
/// to create an based on the given information (for example:
/// unable to connect to server).
/// Thrown when the configured
- /// doesn't contain a .
+ /// does not allow for tiles to be retrieved.
/// Thrown when a critical error
/// occurs when creating the tile cache.
public static WmtsLayerConfiguration CreateInitializedConfiguration(string wmtsCapabilitiesUrl, string capabilityIdentifier, string preferredFormat)
Index: Core/Components/test/Core.Components.BruTile.Test/Configurations/WmtsLayerConfigurationTest.cs
===================================================================
diff -u -r7fc071aa21ada037052184432c734ce79adf5c8c -r684e249584f81413e836ca8fb3382ea56e5d7a3b
--- Core/Components/test/Core.Components.BruTile.Test/Configurations/WmtsLayerConfigurationTest.cs (.../WmtsLayerConfigurationTest.cs) (revision 7fc071aa21ada037052184432c734ce79adf5c8c)
+++ Core/Components/test/Core.Components.BruTile.Test/Configurations/WmtsLayerConfigurationTest.cs (.../WmtsLayerConfigurationTest.cs) (revision 684e249584f81413e836ca8fb3382ea56e5d7a3b)
@@ -21,12 +21,15 @@
using System;
using System.Linq;
+using System.Security.AccessControl;
using BruTile;
using BruTile.Web;
+using BruTile.Wmts;
using Core.Common.Gui.TestUtil.Settings;
using Core.Common.TestUtil;
using Core.Components.BruTile.Configurations;
using Core.Components.BruTile.TestUtil;
+using Core.Components.Gis.Data;
using Core.Components.Gis.Exceptions;
using Core.Components.Gis.TestUtil;
using NUnit.Framework;
@@ -112,10 +115,50 @@
}
[Test]
+ public void CreateInitializedConfiguration_CannotCreateCache_ThrowCannotCreateCacheException()
+ {
+ // Setup
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
+
+ IRequest nullRequest = null;
+ var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
+ nullRequest);
+
+ var mocks = new MockRepository();
+ var factory = mocks.Stub();
+ factory.Stub(f => f.GetWmtsTileSources(targetMapData.SourceCapabilitiesUrl)).Return(new [] { tileSource });
+ mocks.ReplayAll();
+
+ using (new UseCustomSettingsHelper(testSettingsHelper))
+ using (new UseCustomTileSourceFactoryConfig(factory))
+ {
+ directoryDisposeHelper.LockDirectory(FileSystemRights.Write);
+
+ // Call
+ TestDelegate call = () => WmtsLayerConfiguration.CreateInitializedConfiguration(targetMapData.SourceCapabilitiesUrl,
+ targetMapData.SelectedCapabilityIdentifier,
+ targetMapData.PreferredFormat);
+
+ try
+ {
+ // Assert
+ string message = Assert.Throws(call).Message;
+ string expectedMessage = "Een kritieke fout is opgetreden bij het aanmaken van de cache.";
+ Assert.AreEqual(expectedMessage, message);
+ }
+ finally
+ {
+ directoryDisposeHelper.UnlockDirectory();
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void CreateInitializedConfiguration_MatchingLayerAvailable_ReturnConfiguration()
{
// Setup
- var targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
IRequest nullRequest = null;
var tileSource1 = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(WmtsMapDataTestHelper.CreateDefaultPdokMapData()),
@@ -154,7 +197,7 @@
public void Clone_FromFullyInitializedConfiguration_CreateNewUninitializedInstance()
{
// Setup
- var targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
IRequest nullRequest = null;
var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
@@ -193,7 +236,7 @@
public void Clone_ConfigurationDisposed_ThrowObjectDisposedException()
{
// Setup
- var targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
IRequest nullRequest = null;
var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
@@ -230,7 +273,7 @@
public void GivenFullyInitializedConfiguration_WhenClonedAndInitialized_ConfigurationAreEqual()
{
// Given
- var targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
IRequest nullRequest = null;
var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),
@@ -267,7 +310,7 @@
public void Initialize_ConfigurationDisposed_ThrowsObjectDisposedException()
{
// Setup
- var targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
+ WmtsMapData targetMapData = WmtsMapDataTestHelper.CreateAlternativePdokMapData();
IRequest nullRequest = null;
var tileSource = new HttpTileSource(TileSchemaFactory.CreateWmtsTileSchema(targetMapData),