clockwerk-opensim-stable – Diff between revs 1 and 3
?pathlinks?
Rev 1 | Rev 3 | |||
---|---|---|---|---|
1 | /* |
1 | /* |
|
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
|
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
|
4 | * |
4 | * |
|
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
|
6 | * modification, are permitted provided that the following conditions are met: |
6 | * modification, are permitted provided that the following conditions are met: |
|
7 | * * Redistributions of source code must retain the above copyright |
7 | * * Redistributions of source code must retain the above copyright |
|
8 | * notice, this list of conditions and the following disclaimer. |
8 | * notice, this list of conditions and the following disclaimer. |
|
9 | * * Redistributions in binary form must reproduce the above copyright |
9 | * * Redistributions in binary form must reproduce the above copyright |
|
10 | * notice, this list of conditions and the following disclaimer in the |
10 | * notice, this list of conditions and the following disclaimer in the |
|
11 | * documentation and/or other materials provided with the distribution. |
11 | * documentation and/or other materials provided with the distribution. |
|
12 | * * Neither the name of the OpenSimulator Project nor the |
12 | * * Neither the name of the OpenSimulator Project nor the |
|
13 | * names of its contributors may be used to endorse or promote products |
13 | * names of its contributors may be used to endorse or promote products |
|
14 | * derived from this software without specific prior written permission. |
14 | * derived from this software without specific prior written permission. |
|
15 | * |
15 | * |
|
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
|
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
|
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
26 | */ |
26 | */ |
|
27 | |
27 | |
|
28 | using System; |
28 | using System; |
|
29 | using System.Collections.Generic; |
29 | using System.Collections.Generic; |
|
30 | using System.IO; |
30 | using System.IO; |
|
31 | using System.Reflection; |
31 | using System.Reflection; |
|
32 | using System.Threading; |
32 | using System.Threading; |
|
33 | using NUnit.Framework; |
33 | using NUnit.Framework; |
|
34 | using OpenMetaverse; |
34 | using OpenMetaverse; |
|
35 | using OpenSim.Data; |
35 | using OpenSim.Data; |
|
36 | using OpenSim.Framework; |
36 | using OpenSim.Framework; |
|
37 | using OpenSim.Framework.Serialization; |
37 | using OpenSim.Framework.Serialization; |
|
38 | using OpenSim.Framework.Serialization.External; |
38 | using OpenSim.Framework.Serialization.External; |
|
39 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications; |
|
40 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; |
40 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; |
|
41 | using OpenSim.Region.CoreModules.World.Serialiser; |
41 | using OpenSim.Region.CoreModules.World.Serialiser; |
|
42 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes; |
|
43 | using OpenSim.Region.Framework.Scenes.Serialization; |
43 | using OpenSim.Region.Framework.Scenes.Serialization; |
|
44 | using OpenSim.Services.Interfaces; |
44 | using OpenSim.Services.Interfaces; |
|
45 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common; |
|
46 | using OpenSim.Tests.Common.Mock; |
46 | using OpenSim.Tests.Common.Mock; |
|
47 | |
47 | |
|
48 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests |
48 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests |
|
49 | { |
49 | { |
|
50 | [TestFixture] |
50 | [TestFixture] |
|
51 | public class InventoryArchiveLoadTests : InventoryArchiveTestCase |
51 | public class InventoryArchiveLoadTests : InventoryArchiveTestCase |
|
52 | { |
52 | { |
|
53 | protected TestScene m_scene; |
53 | protected TestScene m_scene; |
|
54 | protected InventoryArchiverModule m_archiverModule; |
54 | protected InventoryArchiverModule m_archiverModule; |
|
55 | |
55 | |
|
56 | [SetUp] |
56 | [SetUp] |
|
57 | public override void SetUp() |
57 | public override void SetUp() |
|
58 | { |
58 | { |
|
59 | base.SetUp(); |
59 | base.SetUp(); |
|
60 | |
60 | |
|
61 | SerialiserModule serialiserModule = new SerialiserModule(); |
61 | SerialiserModule serialiserModule = new SerialiserModule(); |
|
62 | m_archiverModule = new InventoryArchiverModule(); |
62 | m_archiverModule = new InventoryArchiverModule(); |
|
63 | |
63 | |
|
64 | m_scene = new SceneHelpers().SetupScene(); |
64 | m_scene = new SceneHelpers().SetupScene(); |
|
65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
|
66 | } |
66 | } |
|
67 | |
67 | |
|
68 | [Test] |
68 | [Test] |
|
69 | public void TestLoadCoalesecedItem() |
69 | public void TestLoadCoalesecedItem() |
|
70 | { |
70 | { |
|
71 | TestHelpers.InMethod(); |
71 | TestHelpers.InMethod(); |
|
72 | // TestHelpers.EnableLogging(); |
72 | // TestHelpers.EnableLogging(); |
|
73 | |
73 | |
|
74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); |
74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); |
|
75 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); |
75 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", m_iarStream); |
|
76 | |
76 | |
|
77 | InventoryItemBase coaItem |
77 | InventoryItemBase coaItem |
|
78 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); |
78 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); |
|
79 | |
79 | |
|
80 | Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1"); |
80 | Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1"); |
|
81 | |
81 | |
|
82 | string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID); |
82 | string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID); |
|
83 | |
83 | |
|
84 | CoalescedSceneObjects coa; |
84 | CoalescedSceneObjects coa; |
|
85 | bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa); |
85 | bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa); |
|
86 | |
86 | |
|
87 | Assert.That(readResult, Is.True); |
87 | Assert.That(readResult, Is.True); |
|
88 | Assert.That(coa.Count, Is.EqualTo(2)); |
88 | Assert.That(coa.Count, Is.EqualTo(2)); |
|
89 | |
89 | |
|
90 | List<SceneObjectGroup> coaObjects = coa.Objects; |
90 | List<SceneObjectGroup> coaObjects = coa.Objects; |
|
91 | Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120"))); |
91 | Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120"))); |
|
92 | Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45))); |
92 | Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45))); |
|
93 | |
93 | |
|
94 | Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); |
94 | Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); |
|
95 | Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); |
95 | Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); |
|
96 | } |
96 | } |
|
97 | |
97 | |
|
98 | /// <summary> |
98 | /// <summary> |
|
99 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized |
99 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized |
|
100 | /// objects. |
100 | /// objects. |
|
101 | /// </summary> |
101 | /// </summary> |
|
102 | [Test] |
102 | [Test] |
|
103 | public void TestLoadIarCreatorAccountPresent() |
103 | public void TestLoadIarCreatorAccountPresent() |
|
104 | { |
104 | { |
|
105 | TestHelpers.InMethod(); |
105 | TestHelpers.InMethod(); |
|
106 | // log4net.Config.XmlConfigurator.Configure(); |
106 | // log4net.Config.XmlConfigurator.Configure(); |
|
107 | |
107 | |
|
108 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); |
108 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); |
|
109 | |
109 | |
|
110 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); |
110 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", m_iarStream); |
|
111 | InventoryItemBase foundItem1 |
111 | InventoryItemBase foundItem1 |
|
112 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name); |
112 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name); |
|
113 | |
113 | |
|
114 | Assert.That( |
114 | Assert.That( |
|
115 | foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()), |
115 | foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()), |
|
116 | "Loaded item non-uuid creator doesn't match original"); |
116 | "Loaded item non-uuid creator doesn't match original"); |
|
117 | Assert.That( |
117 | Assert.That( |
|
118 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID), |
118 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID), |
|
119 | "Loaded item uuid creator doesn't match original"); |
119 | "Loaded item uuid creator doesn't match original"); |
|
120 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID), |
120 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID), |
|
121 | "Loaded item owner doesn't match inventory reciever"); |
121 | "Loaded item owner doesn't match inventory reciever"); |
|
122 | |
122 | |
|
123 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
123 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
|
124 | string xmlData = Utils.BytesToString(asset1.Data); |
124 | string xmlData = Utils.BytesToString(asset1.Data); |
|
125 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
125 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
|
126 | |
126 | |
|
127 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); |
127 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); |
|
128 | } |
128 | } |
|
129 | |
129 | |
|
130 | // /// <summary> |
130 | // /// <summary> |
|
131 | // /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
131 | // /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
|
132 | // /// an account exists with the same name as the creator, though not the same id. |
132 | // /// an account exists with the same name as the creator, though not the same id. |
|
133 | // /// </summary> |
133 | // /// </summary> |
|
134 | // [Test] |
134 | // [Test] |
|
135 | // public void TestLoadIarV0_1SameNameCreator() |
135 | // public void TestLoadIarV0_1SameNameCreator() |
|
136 | // { |
136 | // { |
|
137 | // TestHelpers.InMethod(); |
137 | // TestHelpers.InMethod(); |
|
138 | // TestHelpers.EnableLogging(); |
138 | // TestHelpers.EnableLogging(); |
|
139 | // |
139 | // |
|
140 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
140 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
|
141 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
141 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
|
142 | // |
142 | // |
|
143 | // m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
143 | // m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
|
144 | // InventoryItemBase foundItem1 |
144 | // InventoryItemBase foundItem1 |
|
145 | // = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
145 | // = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
|
146 | // |
146 | // |
|
147 | // Assert.That( |
147 | // Assert.That( |
|
148 | // foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
148 | // foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
|
149 | // "Loaded item non-uuid creator doesn't match original"); |
149 | // "Loaded item non-uuid creator doesn't match original"); |
|
150 | // Assert.That( |
150 | // Assert.That( |
|
151 | // foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
151 | // foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
|
152 | // "Loaded item uuid creator doesn't match original"); |
152 | // "Loaded item uuid creator doesn't match original"); |
|
153 | // Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
153 | // Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
|
154 | // "Loaded item owner doesn't match inventory reciever"); |
154 | // "Loaded item owner doesn't match inventory reciever"); |
|
155 | // |
155 | // |
|
156 | // AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
156 | // AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
|
157 | // string xmlData = Utils.BytesToString(asset1.Data); |
157 | // string xmlData = Utils.BytesToString(asset1.Data); |
|
158 | // SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
158 | // SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
|
159 | // |
159 | // |
|
160 | // Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); |
160 | // Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); |
|
161 | // } |
161 | // } |
|
162 | |
162 | |
|
163 | /// <summary> |
163 | /// <summary> |
|
164 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
164 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
|
165 | /// the creator or an account with the creator's name does not exist within the system. |
165 | /// the creator or an account with the creator's name does not exist within the system. |
|
166 | /// </summary> |
166 | /// </summary> |
|
167 | [Test] |
167 | [Test] |
|
168 | public void TestLoadIarV0_1AbsentCreator() |
168 | public void TestLoadIarV0_1AbsentCreator() |
|
169 | { |
169 | { |
|
170 | TestHelpers.InMethod(); |
170 | TestHelpers.InMethod(); |
|
171 | // log4net.Config.XmlConfigurator.Configure(); |
171 | // log4net.Config.XmlConfigurator.Configure(); |
|
172 | |
172 | |
|
173 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
173 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
|
174 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); |
174 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", m_iarStream); |
|
175 | |
175 | |
|
176 | InventoryItemBase foundItem1 |
176 | InventoryItemBase foundItem1 |
|
177 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
177 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
|
178 | |
178 | |
|
179 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); |
179 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); |
|
180 | Assert.That( |
180 | Assert.That( |
|
181 | foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()), |
181 | foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()), |
|
182 | "Loaded item non-uuid creator doesn't match that of the loading user"); |
182 | "Loaded item non-uuid creator doesn't match that of the loading user"); |
|
183 | Assert.That( |
183 | Assert.That( |
|
184 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID), |
184 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID), |
|
185 | "Loaded item uuid creator doesn't match that of the loading user"); |
185 | "Loaded item uuid creator doesn't match that of the loading user"); |
|
186 | |
186 | |
|
187 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
187 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
|
188 | string xmlData = Utils.BytesToString(asset1.Data); |
188 | string xmlData = Utils.BytesToString(asset1.Data); |
|
189 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
189 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
|
190 | |
190 | |
|
191 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); |
191 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); |
|
192 | } |
192 | } |
|
193 | } |
193 | } |
|
194 | } |
194 | } |
|
195 | |
195 | |
|
196 |
|
196 |
|
|
197 | |
197 | |
|
198 | |
198 | |
|
199 | |
199 | |