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