aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-05-21 19:36:39 +0100
committerJustin Clark-Casey (justincc)2010-05-21 19:36:39 +0100
commit74ef1ed36f234d93aa3d58b1602344bcb3e00d6e (patch)
tree4d2cea7595c5ae54fc8eff50f541b4716660c256
parentOnly send dialogs and notices to root agents, not child agents (diff)
downloadopensim-SC-74ef1ed36f234d93aa3d58b1602344bcb3e00d6e.zip
opensim-SC-74ef1ed36f234d93aa3d58b1602344bcb3e00d6e.tar.gz
opensim-SC-74ef1ed36f234d93aa3d58b1602344bcb3e00d6e.tar.bz2
opensim-SC-74ef1ed36f234d93aa3d58b1602344bcb3e00d6e.tar.xz
add prim item and test asset save in save oar unit test
-rw-r--r--OpenSim/Framework/Serialization/TarArchiveWriter.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs8
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs14
6 files changed, 55 insertions, 11 deletions
diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
index 0bd639f..fca909f 100644
--- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs
+++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
@@ -28,7 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection;
31using System.Text; 32using System.Text;
33using log4net;
32 34
33namespace OpenSim.Framework.Serialization 35namespace OpenSim.Framework.Serialization
34{ 36{
@@ -37,7 +39,7 @@ namespace OpenSim.Framework.Serialization
37 /// </summary> 39 /// </summary>
38 public class TarArchiveWriter 40 public class TarArchiveWriter
39 { 41 {
40 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 43
42 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 44 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
43 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 45 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
@@ -148,6 +150,9 @@ namespace OpenSim.Framework.Serialization
148 /// <param name="fileType"></param> 150 /// <param name="fileType"></param>
149 protected void WriteEntry(string filePath, byte[] data, char fileType) 151 protected void WriteEntry(string filePath, byte[] data, char fileType)
150 { 152 {
153// m_log.DebugFormat(
154// "[TAR ARCHIVE WRITER]: Data for {0} is {1} bytes", filePath, (null == data ? "null" : data.Length.ToString()));
155
151 byte[] header = new byte[512]; 156 byte[] header = new byte[512];
152 157
153 // file path field (100) 158 // file path field (100)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 4215f97..a1451ce 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
239 239
240 if (asset != null) 240 if (asset != null)
241 { 241 {
242// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as found", id); 242// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
243 m_foundAssetUuids.Add(asset.FullID); 243 m_foundAssetUuids.Add(asset.FullID);
244 m_assetsArchiver.WriteAsset(asset); 244 m_assetsArchiver.WriteAsset(asset);
245 } 245 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 624dc22..f3e5458 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -33,8 +33,8 @@ using log4net.Config;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers; 34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.Assets;
36using OpenSim.Framework; 37using OpenSim.Framework;
37
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Region.CoreModules.World.Serialiser; 40using OpenSim.Region.CoreModules.World.Serialiser;
@@ -44,6 +44,9 @@ using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Tests.Common; 44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock; 45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup; 46using OpenSim.Tests.Common.Setup;
47using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants;
48using TarArchiveReader = OpenSim.Framework.Serialization.TarArchiveReader;
49using TarArchiveWriter = OpenSim.Framework.Serialization.TarArchiveWriter;
47 50
48namespace OpenSim.Region.CoreModules.World.Archiver.Tests 51namespace OpenSim.Region.CoreModules.World.Archiver.Tests
49{ 52{
@@ -55,6 +58,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
55 58
56 protected TestScene m_scene; 59 protected TestScene m_scene;
57 protected ArchiverModule m_archiverModule; 60 protected ArchiverModule m_archiverModule;
61
62 protected TaskInventoryItem m_soundItem;
58 63
59 [SetUp] 64 [SetUp]
60 public void SetUp() 65 public void SetUp()
@@ -127,7 +132,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
127 m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); 132 m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false);
128 133
129 SceneObjectPart part2 = CreateSceneObjectPart2(); 134 SceneObjectPart part2 = CreateSceneObjectPart2();
130 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); 135
136 AssetNotecard nc = new AssetNotecard("Hello World!");
137 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
138 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
139 AssetBase ncAsset
140 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
141 m_scene.AssetService.Store(ncAsset);
142 SceneObjectGroup sog2 = new SceneObjectGroup(part2);
143 TaskInventoryItem ncItem
144 = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
145 part2.Inventory.AddInventoryItem(ncItem, true);
146
147 m_scene.AddNewSceneObject(sog2, false);
131 148
132 MemoryStream archiveWriteStream = new MemoryStream(); 149 MemoryStream archiveWriteStream = new MemoryStream();
133 m_scene.EventManager.OnOarFileSaved += SaveCompleted; 150 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
@@ -151,8 +168,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
151 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 168 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
152 169
153 bool gotControlFile = false; 170 bool gotControlFile = false;
171 bool gotNcAssetFile = false;
154 bool gotObject1File = false; 172 bool gotObject1File = false;
155 bool gotObject2File = false; 173 bool gotObject2File = false;
174
175 string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt");
156 string expectedObject1FileName = string.Format( 176 string expectedObject1FileName = string.Format(
157 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", 177 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
158 part1.Name, 178 part1.Name,
@@ -173,6 +193,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
173 { 193 {
174 gotControlFile = true; 194 gotControlFile = true;
175 } 195 }
196 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
197 {
198 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
199
200 Assert.That(fileName, Is.EqualTo(expectedNcAssetFileName));
201 gotNcAssetFile = true;
202 }
176 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 203 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
177 { 204 {
178 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); 205 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length);
@@ -191,6 +218,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
191 } 218 }
192 219
193 Assert.That(gotControlFile, Is.True, "No control file in archive"); 220 Assert.That(gotControlFile, Is.True, "No control file in archive");
221 Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive");
194 Assert.That(gotObject1File, Is.True, "No object1 file in archive"); 222 Assert.That(gotObject1File, Is.True, "No object1 file in archive");
195 Assert.That(gotObject2File, Is.True, "No object2 file in archive"); 223 Assert.That(gotObject2File, Is.True, "No object2 file in archive");
196 224
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 8b80ebe..5e6124b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -58,7 +58,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 TestHelper.InMethod(); 58 TestHelper.InMethod();
59 59
60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero); 61 AssetBase corruptAsset
62 = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 63 m_assetService.Store(corruptAsset);
63 64
64 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); 65 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 0ec3cc3..e3965ce 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -123,8 +123,8 @@ namespace OpenSim.Region.Framework.Scenes
123 123
124 foreach (SceneObjectPart part in sceneObject.GetParts()) 124 foreach (SceneObjectPart part in sceneObject.GetParts())
125 { 125 {
126 //m_log.DebugFormat( 126// m_log.DebugFormat(
127 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); 127// "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
128 128
129 try 129 try
130 { 130 {
@@ -155,7 +155,9 @@ namespace OpenSim.Region.Framework.Scenes
155 // Now analyze this prim's inventory items to preserve all the uuids that they reference 155 // Now analyze this prim's inventory items to preserve all the uuids that they reference
156 foreach (TaskInventoryItem tii in taskDictionary.Values) 156 foreach (TaskInventoryItem tii in taskDictionary.Values)
157 { 157 {
158 //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type); 158// m_log.DebugFormat(
159// "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
160// tii.Name, tii.Type, part.Name, part.UUID);
159 161
160 if (!assetUuids.ContainsKey(tii.AssetID)) 162 if (!assetUuids.ContainsKey(tii.AssetID))
161 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); 163 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 1fc3cb5..1beafcf 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -38,12 +38,20 @@ namespace OpenSim.Tests.Common
38 /// <summary> 38 /// <summary>
39 /// Create an asset from the given data 39 /// Create an asset from the given data
40 /// </summary> 40 /// </summary>
41 public static AssetBase CreateAsset(UUID assetUuid, string data, UUID creatorID) 41 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
42 { 42 {
43 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object, creatorID.ToString()); 43 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
44 asset.Data = Encoding.ASCII.GetBytes(data); 44 asset.Data = data;
45 return asset; 45 return asset;
46 } 46 }
47
48 /// <summary>
49 /// Create an asset from the given data
50 /// </summary>
51 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
52 {
53 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
54 }
47 55
48 /// <summary> 56 /// <summary>
49 /// Create an asset from the given scene object 57 /// Create an asset from the given scene object