diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs new file mode 100644 index 0000000..ecf70ac --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -0,0 +1,133 @@ | |||
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 Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Serialization; | ||
39 | using OpenSim.Framework.Serialization.External; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
42 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Tests.Common; | ||
47 | using OpenSim.Tests.Common.Mock; | ||
48 | using OpenSim.Tests.Common.Setup; | ||
49 | |||
50 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | ||
51 | { | ||
52 | [TestFixture] | ||
53 | public class InventoryAccessModuleTests | ||
54 | { | ||
55 | protected TestScene m_scene; | ||
56 | protected BasicInventoryAccessModule m_iam; | ||
57 | |||
58 | [SetUp] | ||
59 | public void SetUp() | ||
60 | { | ||
61 | m_iam = new BasicInventoryAccessModule(); | ||
62 | |||
63 | IConfigSource config = new IniConfigSource(); | ||
64 | config.AddConfig("Modules"); | ||
65 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
66 | |||
67 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
68 | SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam); | ||
69 | } | ||
70 | |||
71 | [Test] | ||
72 | public void TestRezObject() | ||
73 | { | ||
74 | TestHelper.InMethod(); | ||
75 | log4net.Config.XmlConfigurator.Configure(); | ||
76 | |||
77 | // Create user | ||
78 | string userFirstName = "Jock"; | ||
79 | string userLastName = "Stirrup"; | ||
80 | string userPassword = "troll"; | ||
81 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
82 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); | ||
83 | |||
84 | // Create asset | ||
85 | SceneObjectGroup object1; | ||
86 | SceneObjectPart part1; | ||
87 | { | ||
88 | string partName = "My Little Dog Object"; | ||
89 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
90 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
91 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
92 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
93 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
94 | |||
95 | part1 | ||
96 | = new SceneObjectPart( | ||
97 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
98 | part1.Name = partName; | ||
99 | |||
100 | object1 = new SceneObjectGroup(part1); | ||
101 | } | ||
102 | |||
103 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
104 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
105 | m_scene.AssetService.Store(asset1); | ||
106 | |||
107 | // Create item | ||
108 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
109 | string item1Name = "My Little Dog"; | ||
110 | InventoryItemBase item1 = new InventoryItemBase(); | ||
111 | item1.Name = item1Name; | ||
112 | item1.AssetID = asset1.FullID; | ||
113 | item1.ID = item1Id; | ||
114 | InventoryFolderBase objsFolder | ||
115 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; | ||
116 | item1.Folder = objsFolder.ID; | ||
117 | m_scene.AddInventoryItem(item1); | ||
118 | |||
119 | AgentCircuitData acd = new AgentCircuitData(); | ||
120 | acd.AgentID = userId; | ||
121 | TestClient tc = new TestClient(acd, m_scene); | ||
122 | |||
123 | SceneObjectGroup so | ||
124 | = m_iam.RezObject( | ||
125 | tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | ||
126 | |||
127 | Assert.That(so, Is.Not.Null); | ||
128 | |||
129 | SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID); | ||
130 | Assert.That(retrievedPart, Is.Not.Null); | ||
131 | } | ||
132 | } | ||
133 | } \ No newline at end of file | ||