diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs new file mode 100644 index 0000000..e5127a0 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -0,0 +1,155 @@ | |||
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 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | ||
50 | { | ||
51 | [TestFixture] | ||
52 | public class InventoryArchiveTestCase | ||
53 | { | ||
54 | protected ManualResetEvent mre = new ManualResetEvent(false); | ||
55 | |||
56 | /// <summary> | ||
57 | /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test. | ||
58 | /// </summary> | ||
59 | protected byte[] m_iarStreamBytes; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Stream of data representing a common IAR for load tests. | ||
63 | /// </summary> | ||
64 | protected MemoryStream m_iarStream; | ||
65 | |||
66 | protected UserAccount m_uaMT | ||
67 | = new UserAccount { | ||
68 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), | ||
69 | FirstName = "Mr", | ||
70 | LastName = "Tiddles" }; | ||
71 | protected UserAccount m_uaLL1 | ||
72 | = new UserAccount { | ||
73 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), | ||
74 | FirstName = "Lord", | ||
75 | LastName = "Lucan" }; | ||
76 | protected UserAccount m_uaLL2 | ||
77 | = new UserAccount { | ||
78 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), | ||
79 | FirstName = "Lord", | ||
80 | LastName = "Lucan" }; | ||
81 | protected string m_item1Name = "Ray Gun Item"; | ||
82 | |||
83 | [SetUp] | ||
84 | public virtual void SetUp() | ||
85 | { | ||
86 | m_iarStream = new MemoryStream(m_iarStreamBytes); | ||
87 | } | ||
88 | |||
89 | [TestFixtureSetUp] | ||
90 | public void FixtureSetup() | ||
91 | { | ||
92 | ConstructDefaultIarBytesForTestLoad(); | ||
93 | } | ||
94 | |||
95 | protected void ConstructDefaultIarBytesForTestLoad() | ||
96 | { | ||
97 | // log4net.Config.XmlConfigurator.Configure(); | ||
98 | |||
99 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
100 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
101 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
102 | |||
103 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | ||
104 | |||
105 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
106 | |||
107 | // Create asset | ||
108 | SceneObjectGroup object1; | ||
109 | SceneObjectPart part1; | ||
110 | { | ||
111 | string partName = "Ray Gun Object"; | ||
112 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
113 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
114 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
115 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
116 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
117 | |||
118 | part1 | ||
119 | = new SceneObjectPart( | ||
120 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
121 | part1.Name = partName; | ||
122 | |||
123 | object1 = new SceneObjectGroup(part1); | ||
124 | scene.AddNewSceneObject(object1, false); | ||
125 | } | ||
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 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.CreatorIdAsUuid = m_uaLL1.PrincipalID; | ||
138 | item1.Owner = m_uaLL1.PrincipalID; | ||
139 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | ||
140 | scene.AddInventoryItem(item1); | ||
141 | |||
142 | archiverModule.ArchiveInventory( | ||
143 | Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream); | ||
144 | |||
145 | m_iarStreamBytes = archiveWriteStream.ToArray(); | ||
146 | } | ||
147 | |||
148 | protected void SaveCompleted( | ||
149 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | ||
150 | Exception reportedException) | ||
151 | { | ||
152 | mre.Set(); | ||
153 | } | ||
154 | } | ||
155 | } \ No newline at end of file | ||