clockwerk-opensim-stable – Blame information for rev 3
?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 InventoryArchiveTestCase : OpenSimTestCase |
||
52 | { |
||
53 | protected ManualResetEvent mre = new ManualResetEvent(false); |
||
54 | |||
55 | /// <summary> |
||
56 | /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test. |
||
57 | /// </summary> |
||
58 | protected byte[] m_iarStreamBytes; |
||
59 | |||
60 | /// <summary> |
||
61 | /// Stream of data representing a common IAR for load tests. |
||
62 | /// </summary> |
||
63 | protected MemoryStream m_iarStream; |
||
64 | |||
65 | protected UserAccount m_uaMT |
||
66 | = new UserAccount { |
||
67 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), |
||
68 | FirstName = "Mr", |
||
69 | LastName = "Tiddles" }; |
||
70 | |||
71 | protected UserAccount m_uaLL1 |
||
72 | = new UserAccount { |
||
73 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), |
||
74 | FirstName = "Lord", |
||
75 | LastName = "Lucan" }; |
||
76 | |||
77 | protected UserAccount m_uaLL2 |
||
78 | = new UserAccount { |
||
79 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), |
||
80 | FirstName = "Lord", |
||
81 | LastName = "Lucan" }; |
||
82 | |||
83 | protected string m_item1Name = "Ray Gun Item"; |
||
84 | protected string m_coaItemName = "Coalesced Item"; |
||
85 | |||
86 | [TestFixtureSetUp] |
||
87 | public void FixtureSetup() |
||
88 | { |
||
89 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. |
||
90 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; |
||
91 | |||
92 | ConstructDefaultIarBytesForTestLoad(); |
||
93 | } |
||
94 | |||
95 | [TestFixtureTearDown] |
||
96 | public void TearDown() |
||
97 | { |
||
98 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple |
||
99 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression |
||
100 | // tests really shouldn't). |
||
101 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
||
102 | } |
||
103 | |||
104 | [SetUp] |
||
105 | public override void SetUp() |
||
106 | { |
||
107 | base.SetUp(); |
||
108 | m_iarStream = new MemoryStream(m_iarStreamBytes); |
||
109 | } |
||
110 | |||
111 | protected void ConstructDefaultIarBytesForTestLoad() |
||
112 | { |
||
113 | // log4net.Config.XmlConfigurator.Configure(); |
||
114 | |||
115 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
||
116 | Scene scene = new SceneHelpers().SetupScene(); |
||
117 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
||
118 | |||
119 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
||
120 | |||
121 | MemoryStream archiveWriteStream = new MemoryStream(); |
||
122 | |||
123 | // Create scene object asset |
||
124 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
||
125 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); |
||
126 | |||
127 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
||
128 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
||
129 | scene.AssetService.Store(asset1); |
||
130 | |||
131 | // Create scene object item |
||
132 | InventoryItemBase item1 = new InventoryItemBase(); |
||
133 | item1.Name = m_item1Name; |
||
134 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
||
135 | item1.AssetID = asset1.FullID; |
||
136 | item1.GroupID = UUID.Random(); |
||
137 | item1.CreatorId = m_uaLL1.PrincipalID.ToString(); |
||
138 | item1.Owner = m_uaLL1.PrincipalID; |
||
139 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; |
||
140 | scene.AddInventoryItem(item1); |
||
141 | |||
142 | // Create coalesced objects asset |
||
143 | SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); |
||
144 | cobj1.AbsolutePosition = new Vector3(15, 30, 45); |
||
145 | |||
146 | SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); |
||
147 | cobj2.AbsolutePosition = new Vector3(25, 50, 75); |
||
148 | |||
149 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); |
||
150 | |||
151 | AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa); |
||
152 | scene.AssetService.Store(coaAsset); |
||
153 | |||
154 | // Create coalesced objects inventory item |
||
155 | InventoryItemBase coaItem = new InventoryItemBase(); |
||
156 | coaItem.Name = m_coaItemName; |
||
157 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); |
||
158 | coaItem.AssetID = coaAsset.FullID; |
||
159 | coaItem.GroupID = UUID.Random(); |
||
160 | coaItem.CreatorId = m_uaLL1.PrincipalID.ToString(); |
||
161 | coaItem.Owner = m_uaLL1.PrincipalID; |
||
162 | coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; |
||
163 | scene.AddInventoryItem(coaItem); |
||
164 | |||
165 | archiverModule.ArchiveInventory( |
||
3 | vero | 166 | Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", archiveWriteStream); |
1 | vero | 167 | |
168 | m_iarStreamBytes = archiveWriteStream.ToArray(); |
||
169 | } |
||
170 | |||
171 | protected void SaveCompleted( |
||
172 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
||
173 | Exception reportedException) |
||
174 | { |
||
175 | mre.Set(); |
||
176 | } |
||
177 | } |
||
178 | } |