diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 205 |
1 files changed, 99 insertions, 106 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d339543..c81f295 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -76,125 +76,118 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
76 | // Commenting for now! The mock inventory service needs more beef, at least for | 76 | // Commenting for now! The mock inventory service needs more beef, at least for |
77 | // GetFolderForType | 77 | // GetFolderForType |
78 | // REFACTORING PROBLEM. This needs to be rewritten. | 78 | // REFACTORING PROBLEM. This needs to be rewritten. |
79 | //[Test] | ||
80 | public void TestSaveIarV0_1() | ||
81 | { | ||
82 | TestHelper.InMethod(); | ||
83 | log4net.Config.XmlConfigurator.Configure(); | ||
79 | 84 | ||
80 | // [Test] | 85 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
81 | // public void TestSaveIarV0_1() | ||
82 | // { | ||
83 | // TestHelper.InMethod(); | ||
84 | // //log4net.Config.XmlConfigurator.Configure(); | ||
85 | 86 | ||
86 | // InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | 87 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); |
88 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
87 | 89 | ||
88 | // Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | 90 | // Create user |
89 | // SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 91 | string userFirstName = "Jock"; |
90 | // CommunicationsManager cm = scene.CommsManager; | 92 | string userLastName = "Stirrup"; |
91 | 93 | string userPassword = "troll"; | |
92 | // // Create user | 94 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
93 | // string userFirstName = "Jock"; | 95 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); |
94 | // string userLastName = "Stirrup"; | ||
95 | // UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
96 | |||
97 | // lock (this) | ||
98 | // { | ||
99 | // UserProfileTestUtils.CreateUserWithInventory( | ||
100 | // cm, userFirstName, userLastName, userId, InventoryReceived); | ||
101 | // Monitor.Wait(this, 60000); | ||
102 | // } | ||
103 | 96 | ||
104 | // // Create asset | 97 | // Create asset |
105 | // SceneObjectGroup object1; | 98 | SceneObjectGroup object1; |
106 | // SceneObjectPart part1; | 99 | SceneObjectPart part1; |
107 | // { | 100 | { |
108 | // string partName = "My Little Dog Object"; | 101 | string partName = "My Little Dog Object"; |
109 | // UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | 102 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
110 | // PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | 103 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); |
111 | // Vector3 groupPosition = new Vector3(10, 20, 30); | 104 | Vector3 groupPosition = new Vector3(10, 20, 30); |
112 | // Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | 105 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); |
113 | // Vector3 offsetPosition = new Vector3(5, 10, 15); | 106 | Vector3 offsetPosition = new Vector3(5, 10, 15); |
114 | 107 | ||
115 | // part1 | 108 | part1 |
116 | // = new SceneObjectPart( | 109 | = new SceneObjectPart( |
117 | // ownerId, shape, groupPosition, rotationOffset, offsetPosition); | 110 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); |
118 | // part1.Name = partName; | 111 | part1.Name = partName; |
119 | 112 | ||
120 | // object1 = new SceneObjectGroup(part1); | 113 | object1 = new SceneObjectGroup(part1); |
121 | // scene.AddNewSceneObject(object1, false); | 114 | scene.AddNewSceneObject(object1, false); |
122 | // } | 115 | } |
123 | |||
124 | // UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
125 | // AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
126 | // scene.AssetService.Store(asset1); | ||
127 | |||
128 | // // Create item | ||
129 | // UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
130 | // InventoryItemBase item1 = new InventoryItemBase(); | ||
131 | // item1.Name = "My Little Dog"; | ||
132 | // item1.AssetID = asset1.FullID; | ||
133 | // item1.ID = item1Id; | ||
134 | // InventoryFolderBase objsFolder | ||
135 | // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | ||
136 | // item1.Folder = objsFolder.ID; | ||
137 | // scene.AddInventoryItem(userId, item1); | ||
138 | |||
139 | // MemoryStream archiveWriteStream = new MemoryStream(); | ||
140 | // archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
141 | |||
142 | // mre.Reset(); | ||
143 | // archiverModule.ArchiveInventory( | ||
144 | // Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); | ||
145 | // mre.WaitOne(60000, false); | ||
146 | |||
147 | // byte[] archive = archiveWriteStream.ToArray(); | ||
148 | // MemoryStream archiveReadStream = new MemoryStream(archive); | ||
149 | // TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
150 | |||
151 | // //bool gotControlFile = false; | ||
152 | // bool gotObject1File = false; | ||
153 | // //bool gotObject2File = false; | ||
154 | // string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
155 | // string expectedObject1FilePath = string.Format( | ||
156 | // "{0}{1}{2}", | ||
157 | // ArchiveConstants.INVENTORY_PATH, | ||
158 | // InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | ||
159 | // expectedObject1FileName); | ||
160 | 116 | ||
161 | // string filePath; | 117 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
162 | // TarArchiveReader.TarEntryType tarEntryType; | 118 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
119 | scene.AssetService.Store(asset1); | ||
120 | |||
121 | // Create item | ||
122 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
123 | InventoryItemBase item1 = new InventoryItemBase(); | ||
124 | item1.Name = "My Little Dog"; | ||
125 | item1.AssetID = asset1.FullID; | ||
126 | item1.ID = item1Id; | ||
127 | InventoryFolderBase objsFolder | ||
128 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | ||
129 | item1.Folder = objsFolder.ID; | ||
130 | scene.AddInventoryItem(userId, item1); | ||
131 | |||
132 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
133 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
134 | |||
135 | mre.Reset(); | ||
136 | archiverModule.ArchiveInventory( | ||
137 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
138 | mre.WaitOne(60000, false); | ||
139 | |||
140 | byte[] archive = archiveWriteStream.ToArray(); | ||
141 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
142 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
143 | |||
144 | //bool gotControlFile = false; | ||
145 | bool gotObject1File = false; | ||
146 | //bool gotObject2File = false; | ||
147 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
148 | string expectedObject1FilePath = string.Format( | ||
149 | "{0}{1}{2}", | ||
150 | ArchiveConstants.INVENTORY_PATH, | ||
151 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | ||
152 | expectedObject1FileName); | ||
153 | |||
154 | string filePath; | ||
155 | TarArchiveReader.TarEntryType tarEntryType; | ||
163 | 156 | ||
164 | // Console.WriteLine("Reading archive"); | 157 | // Console.WriteLine("Reading archive"); |
165 | 158 | ||
166 | // while (tar.ReadEntry(out filePath, out tarEntryType) != null) | 159 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) |
167 | // { | 160 | { |
168 | // Console.WriteLine("Got {0}", filePath); | 161 | Console.WriteLine("Got {0}", filePath); |
169 | 162 | ||
170 | //// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | 163 | // if (ArchiveConstants.CONTROL_FILE_PATH == filePath) |
171 | //// { | ||
172 | //// gotControlFile = true; | ||
173 | //// } | ||
174 | |||
175 | // if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
176 | // { | 164 | // { |
177 | //// string fileName = filePath.Remove(0, "Objects/".Length); | 165 | // gotControlFile = true; |
178 | //// | ||
179 | //// if (fileName.StartsWith(part1.Name)) | ||
180 | //// { | ||
181 | // Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
182 | // gotObject1File = true; | ||
183 | //// } | ||
184 | //// else if (fileName.StartsWith(part2.Name)) | ||
185 | //// { | ||
186 | //// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
187 | //// gotObject2File = true; | ||
188 | //// } | ||
189 | // } | 166 | // } |
190 | // } | 167 | |
168 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
169 | { | ||
170 | // string fileName = filePath.Remove(0, "Objects/".Length); | ||
171 | // | ||
172 | // if (fileName.StartsWith(part1.Name)) | ||
173 | // { | ||
174 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
175 | gotObject1File = true; | ||
176 | // } | ||
177 | // else if (fileName.StartsWith(part2.Name)) | ||
178 | // { | ||
179 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
180 | // gotObject2File = true; | ||
181 | // } | ||
182 | } | ||
183 | } | ||
191 | 184 | ||
192 | //// Assert.That(gotControlFile, Is.True, "No control file in archive"); | 185 | // Assert.That(gotControlFile, Is.True, "No control file in archive"); |
193 | // Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | 186 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); |
194 | //// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | 187 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); |
195 | 188 | ||
196 | // // TODO: Test presence of more files and contents of files. | 189 | // TODO: Test presence of more files and contents of files. |
197 | // } | 190 | } |
198 | 191 | ||
199 | /// <summary> | 192 | /// <summary> |
200 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 193 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |