aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs203
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs8
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs2
5 files changed, 212 insertions, 5 deletions
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
new file mode 100644
index 0000000..2a055cc
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -0,0 +1,203 @@
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
28using System.Reflection;
29using System.Collections.Generic;
30using log4net;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Data.Null
37{
38 /// <summary>
39 /// Mock region data plugin. This obeys the api contract for persistence but stores everything in memory, so that
40 /// tests can check correct persistence.
41 /// </summary>
42 public class NullDataStore : IRegionDataStore
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 protected Dictionary<UUID, RegionSettings> m_regionSettings = new Dictionary<UUID, RegionSettings>();
47 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>();
48 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
49 = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
50 protected Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>();
51 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
52
53 public void Initialise(string dbfile)
54 {
55 return;
56 }
57
58 public void Dispose()
59 {
60 }
61
62 public void StoreRegionSettings(RegionSettings rs)
63 {
64 m_regionSettings[rs.RegionUUID] = rs;
65 }
66
67 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
68 {
69 //This connector doesn't support the windlight module yet
70 //Return default LL windlight settings
71 return new RegionLightShareData();
72 }
73
74 public void StoreRegionWindlightSettings(RegionLightShareData wl)
75 {
76 //This connector doesn't support the windlight module yet
77 }
78
79 public RegionSettings LoadRegionSettings(UUID regionUUID)
80 {
81 RegionSettings rs = null;
82 m_regionSettings.TryGetValue(regionUUID, out rs);
83 return rs;
84 }
85
86 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
87 {
88 // We can't simply store groups here because on delinking, OpenSim will not update the original group
89 // directly. Rather, the newly delinked parts will be updated to be in their own scene object group
90 // Therefore, we need to store parts rather than groups.
91 foreach (SceneObjectPart prim in obj.Children.Values)
92 {
93 m_log.DebugFormat(
94 "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}",
95 prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID);
96
97 m_sceneObjectParts[prim.UUID] = prim;
98 }
99 }
100
101 public void RemoveObject(UUID obj, UUID regionUUID)
102 {
103 // All parts belonging to the object with the uuid are removed.
104 List<SceneObjectPart> parts = new List<SceneObjectPart>(m_sceneObjectParts.Values);
105 foreach (SceneObjectPart part in parts)
106 {
107 if (part.ParentGroup.UUID == obj)
108 {
109 m_log.DebugFormat(
110 "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}",
111 part.Name, part.UUID, obj, regionUUID);
112 m_sceneObjectParts.Remove(part.UUID);
113 }
114 }
115 }
116
117 // see IRegionDatastore
118 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
119 {
120 m_primItems[primID] = items;
121 }
122
123 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
124 {
125 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
126
127 // Create all of the SOGs from the root prims first
128 foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
129 {
130 if (prim.IsRoot)
131 {
132 m_log.DebugFormat(
133 "[MOCK REGION DATA PLUGIN]: Loading root part {0} {1} in {2}", prim.Name, prim.UUID, regionUUID);
134 objects[prim.UUID] = new SceneObjectGroup(prim);
135 }
136 }
137
138 // Add all of the children objects to the SOGs
139 foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
140 {
141 SceneObjectGroup sog;
142 if (prim.UUID != prim.ParentUUID)
143 {
144 if (objects.TryGetValue(prim.ParentUUID, out sog))
145 {
146 int originalLinkNum = prim.LinkNum;
147
148 sog.AddPart(prim);
149
150 // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
151 // We override that here
152 if (originalLinkNum != 0)
153 prim.LinkNum = originalLinkNum;
154 }
155 else
156 {
157 m_log.WarnFormat(
158 "[MOCK REGION DATA PLUGIN]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.",
159 prim.Name, prim.UUID, regionUUID, prim.ParentUUID);
160 }
161 }
162 }
163
164 // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that
165 // way!
166
167 return new List<SceneObjectGroup>(objects.Values);
168 }
169
170 public void StoreTerrain(double[,] ter, UUID regionID)
171 {
172 m_terrains[regionID] = ter;
173 }
174
175 public double[,] LoadTerrain(UUID regionID)
176 {
177 if (m_terrains.ContainsKey(regionID))
178 return m_terrains[regionID];
179 else
180 return null;
181 }
182
183 public void RemoveLandObject(UUID globalID)
184 {
185 if (m_landData.ContainsKey(globalID))
186 m_landData.Remove(globalID);
187 }
188
189 public void StoreLandObject(ILandObject land)
190 {
191 m_landData[land.LandData.GlobalID] = land.LandData;
192 }
193
194 public List<LandData> LoadLandObjects(UUID regionUUID)
195 {
196 return new List<LandData>(m_landData.Values);
197 }
198
199 public void Shutdown()
200 {
201 }
202 }
203} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
index b70b47d..b47ad5d 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common.Mock
42 /// </summary> 42 /// </summary>
43 public class TestInventoryDataPlugin : IInventoryDataPlugin 43 public class TestInventoryDataPlugin : IInventoryDataPlugin
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 /// <value> 47 /// <value>
48 /// Inventory folders 48 /// Inventory folders
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 01f2c14..615e519 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -1,4 +1,4 @@
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 *
@@ -29,7 +29,6 @@ using System;
29using Nini.Config; 29using Nini.Config;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Framework.Communications; 31using OpenSim.Framework.Communications;
32
33using OpenSim.Framework.Servers; 32using OpenSim.Framework.Servers;
34using OpenSim.Region.Framework; 33using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
@@ -49,6 +48,11 @@ namespace OpenSim.Tests.Common.Mock
49 } 48 }
50 49
51 /// <summary> 50 /// <summary>
51 /// Allow retrieval for test check purposes
52 /// </summary>
53 public StorageManager StorageManager { get { return m_storageManager; } }
54
55 /// <summary>
52 /// Temporarily override session authentication for tests (namely teleport). 56 /// Temporarily override session authentication for tests (namely teleport).
53 /// </summary> 57 /// </summary>
54 /// 58 ///
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index d9ded2d..9318a27 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -157,7 +157,7 @@ namespace OpenSim.Tests.Common.Setup
157 AgentCircuitManager acm = new AgentCircuitManager(); 157 AgentCircuitManager acm = new AgentCircuitManager();
158 SceneCommunicationService scs = new SceneCommunicationService(); 158 SceneCommunicationService scs = new SceneCommunicationService();
159 159
160 StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); 160 StorageManager sm = new StorageManager("OpenSim.Tests.Common.dll", "", "");
161 IConfigSource configSource = new IniConfigSource(); 161 IConfigSource configSource = new IniConfigSource();
162 162
163 TestScene testScene = new TestScene( 163 TestScene testScene = new TestScene(
diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
index c57363a..915af7e 100644
--- a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Tests.Common
52 InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); 52 InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
53 53
54 item.Folder = objsFolder.ID; 54 item.Folder = objsFolder.ID;
55 scene.AddInventoryItem(userId, item); 55 scene.AddInventoryItem(item);
56 56
57 return item; 57 return item;
58 } 58 }