From 135e10ba09a527d14a2fea0c6398757ce450c9fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 11 Jun 2013 23:55:45 +0100 Subject: Uncomment Mic's code and split to create new regression TestAddTemporaryAsset() and TestAddTemporaryLocalAsset() --- .../Asset/Tests/AssetConnectorTests.cs | 64 ++++++++++++++-------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs index 7073433..4f75191 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs @@ -42,7 +42,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests { [TestFixture] - public class AssetConnectorsTests : OpenSimTestCase + public class AssetConnectorTests : OpenSimTestCase { [Test] public void TestAddAsset() @@ -77,7 +77,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests // TODO: Add cache and check that this does receive a copy of the asset } - [Test] public void TestAddTemporaryAsset() { TestHelpers.InMethod(); @@ -93,10 +92,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); lasc.Initialise(config); - // If it is local, it should not be stored + // If it is remote, it should be stored + AssetBase a2 = AssetHelpers.CreateNotecardAsset(); + a2.Local = false; + a2.Temporary = true; + + lasc.Store(a2); + + AssetBase retreivedA2 = lasc.Get(a2.ID); + Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID)); + Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID)); + Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length)); + + AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID); + Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID)); + + byte[] retrievedA2Data = lasc.GetData(a2.ID); + Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length)); + + // TODO: Add cache and check that this does receive a copy of the asset + } + + [Test] + public void TestAddLocalAsset() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); + config.AddConfig("AssetService"); + config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); + config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); + + LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); + lasc.Initialise(config); + AssetBase a1 = AssetHelpers.CreateNotecardAsset(); a1.Local = true; - a1.Temporary = true; lasc.Store(a1); @@ -104,29 +138,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests Assert.That(lasc.GetData(a1.ID), Is.Null); Assert.That(lasc.GetMetadata(a1.ID), Is.Null); - // If it is remote, it should be stored - // AssetBase a2 = AssetHelpers.CreateNotecardAsset(); - // a2.Local = false; - // a2.Temporary = true; - - // lasc.Store(a2); - - // AssetBase retreivedA2 = lasc.Get(a2.ID); - // Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID)); - // Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID)); - // Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length)); - - // AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID); - // Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID)); - - // byte[] retrievedA2Data = lasc.GetData(a2.ID); - // Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length)); - // TODO: Add cache and check that this does receive a copy of the asset } [Test] - public void TestAddLocalAsset() + public void TestAddTemporaryLocalAsset() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); @@ -141,8 +157,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); lasc.Initialise(config); + // If it is local, it should not be stored AssetBase a1 = AssetHelpers.CreateNotecardAsset(); a1.Local = true; + a1.Temporary = true; lasc.Store(a1); -- cgit v1.1