aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-09-06 23:00:24 +0100
committerJustin Clark-Casey (justincc)2010-09-06 23:00:24 +0100
commit953b7f491798e97b7b36808e716975b22d80114b (patch)
treeca42d90b890b05457b6a9fd736929382911c85cd /OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
parentReflect the ParcelPropertiesUpdateRequest into Scene.EventManager, because (diff)
downloadopensim-SC-953b7f491798e97b7b36808e716975b22d80114b.zip
opensim-SC-953b7f491798e97b7b36808e716975b22d80114b.tar.gz
opensim-SC-953b7f491798e97b7b36808e716975b22d80114b.tar.bz2
opensim-SC-953b7f491798e97b7b36808e716975b22d80114b.tar.xz
Add test to check persistence of newly added pre-linked objects
Added a MockRegionDataPlugin to do in-memory persistence for tests since adding this to OpenSim.Data.Null.NullDataStore doesn't seem appropriate NullDataStore can do nothing because OpenSim only ever retrieve region objects from the database on startup. Adding an in-memory store here would be unecessary overhead.
Diffstat (limited to 'OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs')
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs149
1 files changed, 149 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
new file mode 100644
index 0000000..1c139c5
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -0,0 +1,149 @@
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, SceneObjectGroup> m_sceneObjects = new Dictionary<UUID, SceneObjectGroup>();
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 m_log.DebugFormat(
89 "[MOCK REGION DATA PLUGIN]: Storing object {0} {1} in {2}", obj.Name, obj.UUID, regionUUID);
90 m_sceneObjects[obj.UUID] = obj;
91 }
92
93 public void RemoveObject(UUID obj, UUID regionUUID)
94 {
95 m_log.DebugFormat(
96 "[MOCK REGION DATA PLUGIN]: Removing object {0} from {1}", obj, regionUUID);
97
98 if (m_sceneObjects.ContainsKey(obj))
99 m_sceneObjects.Remove(obj);
100 }
101
102 // see IRegionDatastore
103 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
104 {
105 m_primItems[primID] = items;
106 }
107
108 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
109 {
110 m_log.DebugFormat(
111 "[MOCK REGION DATA PLUGIN]: Loading objects from {0}", regionUUID);
112
113 return new List<SceneObjectGroup>(m_sceneObjects.Values);
114 }
115
116 public void StoreTerrain(double[,] ter, UUID regionID)
117 {
118 m_terrains[regionID] = ter;
119 }
120
121 public double[,] LoadTerrain(UUID regionID)
122 {
123 if (m_terrains.ContainsKey(regionID))
124 return m_terrains[regionID];
125 else
126 return null;
127 }
128
129 public void RemoveLandObject(UUID globalID)
130 {
131 if (m_landData.ContainsKey(globalID))
132 m_landData.Remove(globalID);
133 }
134
135 public void StoreLandObject(ILandObject land)
136 {
137 m_landData[land.LandData.GlobalID] = land.LandData;
138 }
139
140 public List<LandData> LoadLandObjects(UUID regionUUID)
141 {
142 return new List<LandData>(m_landData.Values);
143 }
144
145 public void Shutdown()
146 {
147 }
148 }
149} \ No newline at end of file