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