diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/Tests')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 91 |
1 files changed, 89 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 2eb2861..34e2e23 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -212,6 +212,89 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
212 | } | 212 | } |
213 | 213 | ||
214 | /// <summary> | 214 | /// <summary> |
215 | /// Test saving an OpenSim Region Archive with the no assets option | ||
216 | /// </summary> | ||
217 | [Test] | ||
218 | public void TestSaveOarNoAssets() | ||
219 | { | ||
220 | TestHelper.InMethod(); | ||
221 | // log4net.Config.XmlConfigurator.Configure(); | ||
222 | |||
223 | SceneObjectPart part1 = CreateSceneObjectPart1(); | ||
224 | SceneObjectGroup sog1 = new SceneObjectGroup(part1); | ||
225 | m_scene.AddNewSceneObject(sog1, false); | ||
226 | |||
227 | SceneObjectPart part2 = CreateSceneObjectPart2(); | ||
228 | |||
229 | AssetNotecard nc = new AssetNotecard(); | ||
230 | nc.BodyText = "Hello World!"; | ||
231 | nc.Encode(); | ||
232 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
233 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
234 | AssetBase ncAsset | ||
235 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
236 | m_scene.AssetService.Store(ncAsset); | ||
237 | SceneObjectGroup sog2 = new SceneObjectGroup(part2); | ||
238 | TaskInventoryItem ncItem | ||
239 | = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; | ||
240 | part2.Inventory.AddInventoryItem(ncItem, true); | ||
241 | |||
242 | m_scene.AddNewSceneObject(sog2, false); | ||
243 | |||
244 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
245 | |||
246 | Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); | ||
247 | |||
248 | Dictionary<string, Object> options = new Dictionary<string, Object>(); | ||
249 | options.Add("noassets", true); | ||
250 | m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); | ||
251 | //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; | ||
252 | //while (assetServer.HasWaitingRequests()) | ||
253 | // assetServer.ProcessNextRequest(); | ||
254 | |||
255 | // Don't wait for completion - with --noassets save oar happens synchronously | ||
256 | // Monitor.Wait(this, 60000); | ||
257 | |||
258 | Assert.That(m_lastRequestId, Is.EqualTo(requestId)); | ||
259 | |||
260 | byte[] archive = archiveWriteStream.ToArray(); | ||
261 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
262 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
263 | |||
264 | List<string> foundPaths = new List<string>(); | ||
265 | List<string> expectedPaths = new List<string>(); | ||
266 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1)); | ||
267 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); | ||
268 | |||
269 | string filePath; | ||
270 | TarArchiveReader.TarEntryType tarEntryType; | ||
271 | |||
272 | byte[] data = tar.ReadEntry(out filePath, out tarEntryType); | ||
273 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); | ||
274 | |||
275 | ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); | ||
276 | arr.LoadControlFile(filePath, data); | ||
277 | |||
278 | Assert.That(arr.ControlFileLoaded, Is.True); | ||
279 | |||
280 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
281 | { | ||
282 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
283 | { | ||
284 | Assert.Fail("Asset was found in saved oar of TestSaveOarNoAssets()"); | ||
285 | } | ||
286 | else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) | ||
287 | { | ||
288 | foundPaths.Add(filePath); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); | ||
293 | |||
294 | // TODO: Test presence of more files and contents of files. | ||
295 | } | ||
296 | |||
297 | /// <summary> | ||
215 | /// Test loading an OpenSim Region Archive. | 298 | /// Test loading an OpenSim Region Archive. |
216 | /// </summary> | 299 | /// </summary> |
217 | [Test] | 300 | [Test] |
@@ -230,7 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
230 | // upset load | 313 | // upset load |
231 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 314 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
232 | 315 | ||
233 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>())); | 316 | tar.WriteFile( |
317 | ArchiveConstants.CONTROL_FILE_PATH, | ||
318 | new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary<string, Object>())); | ||
234 | 319 | ||
235 | SceneObjectPart part1 = CreateSceneObjectPart1(); | 320 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
236 | SceneObjectGroup object1 = new SceneObjectGroup(part1); | 321 | SceneObjectGroup object1 = new SceneObjectGroup(part1); |
@@ -331,7 +416,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
331 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | 416 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
332 | 417 | ||
333 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 418 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
334 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>())); | 419 | tar.WriteFile( |
420 | ArchiveConstants.CONTROL_FILE_PATH, | ||
421 | new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary<string, Object>())); | ||
335 | 422 | ||
336 | RegionSettings rs = new RegionSettings(); | 423 | RegionSettings rs = new RegionSettings(); |
337 | rs.AgentLimit = 17; | 424 | rs.AgentLimit = 17; |