diff options
author | Justin Clark-Casey (justincc) | 2011-04-18 22:24:42 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-04-18 22:24:42 +0100 |
commit | e00e518692bd3d123db69dceb98b80d3bdd59156 (patch) | |
tree | f44096fe815675a26d1ab878e18d0abddbafd5ed /OpenSim/Region/CoreModules/Avatar | |
parent | refactor: split out the code which actually copies a particular bundle to inv... (diff) | |
download | opensim-SC-e00e518692bd3d123db69dceb98b80d3bdd59156.zip opensim-SC-e00e518692bd3d123db69dceb98b80d3bdd59156.tar.gz opensim-SC-e00e518692bd3d123db69dceb98b80d3bdd59156.tar.bz2 opensim-SC-e00e518692bd3d123db69dceb98b80d3bdd59156.tar.xz |
add test to ensure that an IAR starts with the control file
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 29 |
2 files changed, 39 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f3d2f26..9acdc90 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -77,12 +77,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
77 | /// </value> | 77 | /// </value> |
78 | private Stream m_loadStream; | 78 | private Stream m_loadStream; |
79 | 79 | ||
80 | /// <summary> | 80 | public bool ControlFileLoaded { get; private set; } |
81 | /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things | 81 | |
82 | /// (I thought they weren't). We will need to bump the version number and perform this check on all | ||
83 | /// subsequent IAR versions only | ||
84 | /// </summary> | ||
85 | protected bool m_controlFileLoaded = true; | ||
86 | protected bool m_assetsLoaded; | 82 | protected bool m_assetsLoaded; |
87 | protected bool m_inventoryNodesLoaded; | 83 | protected bool m_inventoryNodesLoaded; |
88 | 84 | ||
@@ -131,6 +127,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
131 | m_userInfo = userInfo; | 127 | m_userInfo = userInfo; |
132 | m_invPath = invPath; | 128 | m_invPath = invPath; |
133 | m_loadStream = loadStream; | 129 | m_loadStream = loadStream; |
130 | |||
131 | // FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things | ||
132 | // (I thought they weren't). We will need to bump the version number and perform this check on all | ||
133 | // subsequent IAR versions only | ||
134 | ControlFileLoaded = true; | ||
134 | } | 135 | } |
135 | 136 | ||
136 | /// <summary> | 137 | /// <summary> |
@@ -522,7 +523,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
522 | /// </summary> | 523 | /// </summary> |
523 | /// <param name="path"></param> | 524 | /// <param name="path"></param> |
524 | /// <param name="data"></param> | 525 | /// <param name="data"></param> |
525 | protected void LoadControlFile(string path, byte[] data) | 526 | public void LoadControlFile(string path, byte[] data) |
526 | { | 527 | { |
527 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); | 528 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); |
528 | XElement archiveElement = doc.Element("archive"); | 529 | XElement archiveElement = doc.Element("archive"); |
@@ -538,7 +539,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
538 | majorVersion, MAX_MAJOR_VERSION)); | 539 | majorVersion, MAX_MAJOR_VERSION)); |
539 | } | 540 | } |
540 | 541 | ||
541 | m_controlFileLoaded = true; | 542 | ControlFileLoaded = true; |
542 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | 543 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); |
543 | } | 544 | } |
544 | 545 | ||
@@ -550,7 +551,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
550 | /// <param name="data"></param> | 551 | /// <param name="data"></param> |
551 | protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) | 552 | protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) |
552 | { | 553 | { |
553 | if (!m_controlFileLoaded) | 554 | if (!ControlFileLoaded) |
554 | throw new Exception( | 555 | throw new Exception( |
555 | string.Format( | 556 | string.Format( |
556 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | 557 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", |
@@ -597,7 +598,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
597 | /// <param name="data"></param> | 598 | /// <param name="data"></param> |
598 | protected void LoadAssetFile(string path, byte[] data) | 599 | protected void LoadAssetFile(string path, byte[] data) |
599 | { | 600 | { |
600 | if (!m_controlFileLoaded) | 601 | if (!ControlFileLoaded) |
601 | throw new Exception( | 602 | throw new Exception( |
602 | string.Format( | 603 | string.Format( |
603 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | 604 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d03f6da..52232a0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -94,7 +94,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
94 | 94 | ||
95 | Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); | 95 | Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); |
96 | Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); | 96 | Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); |
97 | } | 97 | } |
98 | |||
99 | /// <summary> | ||
100 | /// Test that the IAR has the required files in the right order. | ||
101 | /// </summary> | ||
102 | /// <remarks> | ||
103 | /// At the moment, the only thing that matters is that the control file is the very first one. | ||
104 | /// </remarks> | ||
105 | [Test] | ||
106 | public void TestOrder() | ||
107 | { | ||
108 | TestHelper.InMethod(); | ||
109 | // log4net.Config.XmlConfigurator.Configure(); | ||
110 | |||
111 | MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes); | ||
112 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
113 | string filePath; | ||
114 | TarArchiveReader.TarEntryType tarEntryType; | ||
115 | |||
116 | byte[] data = tar.ReadEntry(out filePath, out tarEntryType); | ||
117 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); | ||
118 | |||
119 | InventoryArchiveReadRequest iarr | ||
120 | = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false); | ||
121 | iarr.LoadControlFile(filePath, data); | ||
122 | |||
123 | Assert.That(iarr.ControlFileLoaded, Is.True); | ||
124 | } | ||
98 | 125 | ||
99 | /// <summary> | 126 | /// <summary> |
100 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive | 127 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive |