aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-09-21 04:02:50 +0100
committerMelanie2010-09-21 04:02:50 +0100
commit2b8c99c2fbbd377cb270087531385bc753932555 (patch)
treee0509ae1a72ae1155032241965e4a77c89e5c6f8 /OpenSim
parentFix a typo (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.zip
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.gz
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.bz2
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/Migration.cs6
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs4
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs4
-rw-r--r--OpenSim/Framework/MapAndArray.cs5
-rw-r--r--OpenSim/Framework/Tests/CacheTests.cs46
-rw-r--r--OpenSim/Framework/Tests/LocationTest.cs19
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs311
-rw-r--r--OpenSim/Framework/Tests/PrimeNumberHelperTests.cs (renamed from OpenSim/Framework/tests/PrimeNumberHelperTests.cs)0
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs114
-rw-r--r--OpenSim/Region/Application/OpenSim.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs35
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs11
14 files changed, 532 insertions, 37 deletions
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs
index fc9a142..2895a71 100644
--- a/OpenSim/Data/Migration.cs
+++ b/OpenSim/Data/Migration.cs
@@ -138,12 +138,12 @@ namespace OpenSim.Data
138 /// <param name="conn"></param> 138 /// <param name="conn"></param>
139 /// <param name="script">Array of strings, one-per-batch (often just one)</param> 139 /// <param name="script">Array of strings, one-per-batch (often just one)</param>
140 protected virtual void ExecuteScript(DbConnection conn, string[] script) 140 protected virtual void ExecuteScript(DbConnection conn, string[] script)
141 { 141 {
142 using (DbCommand cmd = conn.CreateCommand()) 142 using (DbCommand cmd = conn.CreateCommand())
143 { 143 {
144 cmd.CommandTimeout = 0; 144 cmd.CommandTimeout = 0;
145 foreach (string sql in script) 145 foreach (string sql in script)
146 { 146 {
147 cmd.CommandText = sql; 147 cmd.CommandText = sql;
148 try 148 try
149 { 149 {
@@ -204,7 +204,7 @@ namespace OpenSim.Data
204 catch (Exception e) 204 catch (Exception e)
205 { 205 {
206 m_log.DebugFormat("[MIGRATIONS]: Cmd was {0}", e.Message.Replace("\n", " ")); 206 m_log.DebugFormat("[MIGRATIONS]: Cmd was {0}", e.Message.Replace("\n", " "));
207 m_log.Debug("[MIGRATIONS]: An error has occurred in the migration. This may mean you could see errors trying to run OpenSim. If you see database related errors, you will need to fix the issue manually. Continuing."); 207 m_log.Debug("[MIGRATIONS]: An error has occurred in the migration. If you're running OpenSim for the first time then you can probably safely ignore this, since certain migration commands attempt to fetch data out of old tables. However, if you're using an existing database and you see database related errors while running OpenSim then you will need to fix these problems manually. Continuing.");
208 ExecuteScript("ROLLBACK;"); 208 ExecuteScript("ROLLBACK;");
209 } 209 }
210 210
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 89ee39c..0dc5dbc 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -150,10 +150,10 @@ namespace OpenSim.Framework
150 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); 150 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
151 151
152 if (args["left_axis"] != null) 152 if (args["left_axis"] != null)
153 Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); 153 Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis);
154 154
155 if (args["up_axis"] != null) 155 if (args["up_axis"] != null)
156 Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); 156 Vector3.TryParse(args["up_axis"].AsString(), out UpAxis);
157 157
158 if (args["changed_grid"] != null) 158 if (args["changed_grid"] != null)
159 ChangedGrid = args["changed_grid"].AsBoolean(); 159 ChangedGrid = args["changed_grid"].AsBoolean();
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index c038aac..7eb289b 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -288,7 +288,7 @@ namespace OpenSim.Framework.Console
288 288
289 reply["str_response_string"] = xmldoc.InnerXml; 289 reply["str_response_string"] = xmldoc.InnerXml;
290 reply["int_response_code"] = 200; 290 reply["int_response_code"] = 200;
291 reply["content_type"] = "text/plain"; 291 reply["content_type"] = "text/xml";
292 292
293 return reply; 293 return reply;
294 } 294 }
@@ -343,7 +343,7 @@ namespace OpenSim.Framework.Console
343 343
344 reply["str_response_string"] = xmldoc.InnerXml; 344 reply["str_response_string"] = xmldoc.InnerXml;
345 reply["int_response_code"] = 200; 345 reply["int_response_code"] = 200;
346 reply["content_type"] = "text/plain"; 346 reply["content_type"] = "text/xml";
347 347
348 return reply; 348 return reply;
349 } 349 }
diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs
index bbe6a9e..c98d3cc 100644
--- a/OpenSim/Framework/MapAndArray.cs
+++ b/OpenSim/Framework/MapAndArray.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 *
@@ -131,7 +131,8 @@ namespace OpenSim.Framework
131 /// <returns>True if the key was found, otherwise false</returns> 131 /// <returns>True if the key was found, otherwise false</returns>
132 public bool ContainsKey(TKey key) 132 public bool ContainsKey(TKey key)
133 { 133 {
134 return m_dict.ContainsKey(key); 134 lock (m_syncRoot)
135 return m_dict.ContainsKey(key);
135 } 136 }
136 137
137 /// <summary> 138 /// <summary>
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs
index 32c0c95..c3613e6 100644
--- a/OpenSim/Framework/Tests/CacheTests.cs
+++ b/OpenSim/Framework/Tests/CacheTests.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Framework.Tests
40 public void Build() 40 public void Build()
41 { 41 {
42 cache = new Cache(); 42 cache = new Cache();
43 cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate);
43 cacheItemUUID = UUID.Random(); 44 cacheItemUUID = UUID.Random();
44 MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); 45 MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1));
45 byte[] foo = new byte[1]; 46 byte[] foo = new byte[1];
@@ -68,36 +69,55 @@ namespace OpenSim.Framework.Tests
68 Assert.That(citem == null, "Item should not be in Cache"); 69 Assert.That(citem == null, "Item should not be in Cache");
69 } 70 }
70 71
71 //NOTE: Test Case disabled until Cache is fixed 72
72 [Test] 73 [Test]
73 public void TestTTLExpiredEntry() 74 public void ExpireItemManually()
74 { 75 {
75 UUID ImmediateExpiryUUID = UUID.Random(); 76 UUID ImmediateExpiryUUID = UUID.Random();
76 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); 77 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1));
77 byte[] foo = new byte[1]; 78 byte[] foo = new byte[1];
78 foo[0] = 1; 79 foo[0] = 1;
79 cachedItem.Store(foo); 80 cachedItem.Store(foo);
80 cache.Store(cacheItemUUID.ToString(), cachedItem); 81 cache.Store(cacheItemUUID.ToString(), cachedItem);
81 82 cache.Invalidate(cacheItemUUID.ToString());
82 cache.Get(cacheItemUUID.ToString()); 83 cache.Get(cacheItemUUID.ToString());
83 //object citem = cache.Get(cacheItemUUID.ToString()); 84 object citem = cache.Get(cacheItemUUID.ToString());
84 //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); 85 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
85 } 86 }
86 87
87 //NOTE: Test Case disabled until Cache is fixed
88 [Test] 88 [Test]
89 public void ExpireItemManually() 89 public void ClearCacheTest()
90 { 90 {
91 UUID ImmediateExpiryUUID = UUID.Random(); 91 UUID ImmediateExpiryUUID = UUID.Random();
92 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); 92 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), DateTime.Now - TimeSpan.FromDays(1));
93 byte[] foo = new byte[1]; 93 byte[] foo = new byte[1];
94 foo[0] = 1; 94 foo[0] = 1;
95 cachedItem.Store(foo); 95 cachedItem.Store(foo);
96 cache.Store(cacheItemUUID.ToString(), cachedItem); 96 cache.Store(cacheItemUUID.ToString(), cachedItem);
97 cache.Invalidate(ImmediateExpiryUUID.ToString()); 97 cache.Clear();
98 cache.Get(cacheItemUUID.ToString()); 98
99 //object citem = cache.Get(cacheItemUUID.ToString()); 99 object citem = cache.Get(cacheItemUUID.ToString());
100 //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); 100 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
101 }
102
103 [Test]
104 public void CacheItemMundane()
105 {
106 UUID Random1 = UUID.Random();
107 UUID Random2 = UUID.Random();
108 byte[] data = new byte[0];
109 CacheItemBase cb1 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1));
110 CacheItemBase cb2 = new CacheItemBase(Random2.ToString(), DateTime.Now + TimeSpan.FromDays(1));
111 CacheItemBase cb3 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1));
112
113 cb1.Store(data);
114
115 Assert.That(cb1.Equals(cb3), "cb1 should equal cb3, their uuids are the same");
116 Assert.That(!cb2.Equals(cb1), "cb2 should not equal cb1, their uuids are NOT the same");
117 Assert.That(cb1.IsLocked() == false, "CacheItemBase default is false");
118 Assert.That(cb1.Retrieve() == null, "Virtual Retrieve method should return null");
119
120
101 } 121 }
102 122
103 } 123 }
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs
index 237568f..2707afa 100644
--- a/OpenSim/Framework/Tests/LocationTest.cs
+++ b/OpenSim/Framework/Tests/LocationTest.cs
@@ -54,9 +54,28 @@ namespace OpenSim.Framework.Tests
54 Location TestLocation2 = new Location(1099511628032000); 54 Location TestLocation2 = new Location(1099511628032000);
55 Assert.That(TestLocation1 == TestLocation2); 55 Assert.That(TestLocation1 == TestLocation2);
56 56
57 Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
58
59 Assert.That(TestLocation2.RegionHandle == 1099511628032000,
60 "Location RegionHandle Property didn't match regionhandle provided in constructor");
61
62
57 TestLocation1 = new Location(256001, 256001); 63 TestLocation1 = new Location(256001, 256001);
58 TestLocation2 = new Location(1099511628032000); 64 TestLocation2 = new Location(1099511628032000);
59 Assert.That(TestLocation1 != TestLocation2); 65 Assert.That(TestLocation1 != TestLocation2);
66
67 Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
68
69 Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");
70
71 Location TestLocation3;
72 object cln = TestLocation2.Clone();
73 TestLocation3 = (Location) cln;
74 Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y,
75 "Cloned Location values do not match");
76
77 Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
78
60 } 79 }
61 80
62 } 81 }
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
new file mode 100644
index 0000000..04be083
--- /dev/null
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -0,0 +1,311 @@
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 NUnit.Framework;
29using OpenSim.Framework;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32using System;
33using System.Globalization;
34using System.Threading;
35
36namespace OpenSim.Framework.Tests
37{
38 [TestFixture]
39 public class MundaneFrameworkTests
40 {
41 private bool m_RegionSettingsOnSaveEventFired;
42 private bool m_RegionLightShareDataOnSaveEventFired;
43
44
45 [Test]
46 public void ChildAgentDataUpdate01()
47 {
48 // code coverage
49 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
50 Assert.IsFalse(cadu.alwaysrun, "Default is false");
51 }
52
53 [Test]
54 public void AgentPositionTest01()
55 {
56 UUID AgentId1 = UUID.Random();
57 UUID SessionId1 = UUID.Random();
58 uint CircuitCode1 = uint.MinValue;
59 Vector3 Size1 = Vector3.UnitZ;
60 Vector3 Position1 = Vector3.UnitX;
61 Vector3 LeftAxis1 = Vector3.UnitY;
62 Vector3 UpAxis1 = Vector3.UnitZ;
63 Vector3 AtAxis1 = Vector3.UnitX;
64
65 ulong RegionHandle1 = ulong.MinValue;
66 byte[] Throttles1 = new byte[] {0, 1, 0};
67
68 Vector3 Velocity1 = Vector3.Zero;
69 float Far1 = 256;
70
71 bool ChangedGrid1 = false;
72 Vector3 Center1 = Vector3.Zero;
73
74 AgentPosition position1 = new AgentPosition();
75 position1.AgentID = AgentId1;
76 position1.SessionID = SessionId1;
77 position1.CircuitCode = CircuitCode1;
78 position1.Size = Size1;
79 position1.Position = Position1;
80 position1.LeftAxis = LeftAxis1;
81 position1.UpAxis = UpAxis1;
82 position1.AtAxis = AtAxis1;
83 position1.RegionHandle = RegionHandle1;
84 position1.Throttles = Throttles1;
85 position1.Velocity = Velocity1;
86 position1.Far = Far1;
87 position1.ChangedGrid = ChangedGrid1;
88 position1.Center = Center1;
89
90 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
91 cadu.AgentID = AgentId1.Guid;
92 cadu.ActiveGroupID = UUID.Zero.Guid;
93 cadu.throttles = Throttles1;
94 cadu.drawdistance = Far1;
95 cadu.Position = Position1;
96 cadu.Velocity = Velocity1;
97 cadu.regionHandle = RegionHandle1;
98 cadu.cameraPosition = Center1;
99 cadu.AVHeight = Size1.Z;
100
101 AgentPosition position2 = new AgentPosition();
102 position2.CopyFrom(cadu);
103
104 Assert.IsTrue(
105 position2.AgentID == position1.AgentID
106 && position2.Size == position1.Size
107 && position2.Position == position1.Position
108 && position2.Velocity == position1.Velocity
109 && position2.Center == position1.Center
110 && position2.RegionHandle == position1.RegionHandle
111 && position2.Far == position1.Far
112
113 ,"Copy From ChildAgentDataUpdate failed");
114
115 position2 = new AgentPosition();
116
117 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
118 position2.Unpack(position1.Pack());
119
120 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
121 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
122 Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed");
123 Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed");
124 Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed");
125 Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed");
126 Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed");
127 Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed");
128 Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed");
129 Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed");
130 Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed");
131 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
132
133 }
134
135 [Test]
136 public void RegionSettingsTest01()
137 {
138 RegionSettings settings = new RegionSettings();
139 settings.OnSave += RegionSaveFired;
140 settings.Save();
141 settings.OnSave -= RegionSaveFired;
142
143 string str = settings.LoadedCreationDate;
144 int dt = settings.LoadedCreationDateTime;
145 string id = settings.LoadedCreationID;
146 string time = settings.LoadedCreationTime;
147
148 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
149
150 }
151 public void RegionSaveFired(RegionSettings settings)
152 {
153 m_RegionSettingsOnSaveEventFired = true;
154 }
155
156 [Test]
157 public void InventoryItemBaseConstructorTest01()
158 {
159 InventoryItemBase b1 = new InventoryItemBase();
160 Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero");
161 Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero");
162
163 UUID ItemID = UUID.Random();
164 UUID OwnerID = UUID.Random();
165
166 InventoryItemBase b2 = new InventoryItemBase(ItemID);
167 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
168 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
169
170 InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID);
171 Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID");
172 Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
173
174 }
175
176 [Test]
177 public void AssetMetaDataNonNullContentTypeTest01()
178 {
179 AssetMetadata assetMetadata = new AssetMetadata();
180 assetMetadata.ContentType = "image/jp2";
181 Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture");
182 Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2");
183 UUID rndID = UUID.Random();
184 assetMetadata.ID = rndID.ToString();
185 Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent");
186 DateTime fixedTime = DateTime.Now;
187 assetMetadata.CreationDate = fixedTime;
188 }
189
190 [Test]
191 public void RegionLightShareDataCloneSaveTest01()
192 {
193 RegionLightShareData rlsd = new RegionLightShareData();
194 rlsd.OnSave += RegionLightShareDataSaveFired;
195 rlsd.Save();
196 rlsd.OnSave -= RegionLightShareDataSaveFired;
197 Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired");
198
199 object o = rlsd.Clone();
200 RegionLightShareData dupe = (RegionLightShareData) o;
201 Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed");
202 }
203 public void RegionLightShareDataSaveFired(RegionLightShareData settings)
204 {
205 m_RegionLightShareDataOnSaveEventFired = true;
206 }
207
208 [Test]
209 public void EstateSettingsMundateTests()
210 {
211 EstateSettings es = new EstateSettings();
212 es.AddBan(null);
213 UUID bannedUserId = UUID.Random();
214 es.AddBan(new EstateBan()
215 { BannedHostAddress = string.Empty,
216 BannedHostIPMask = string.Empty,
217 BannedHostNameMask = string.Empty,
218 BannedUserID = bannedUserId}
219 );
220 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
221 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
222
223 es.RemoveBan(bannedUserId);
224
225 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
226
227 es.AddEstateManager(UUID.Zero);
228
229 es.AddEstateManager(bannedUserId);
230 Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't.");
231
232 es.RemoveEstateManager(bannedUserId);
233 Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be");
234
235 Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
236
237 es.AddEstateUser(bannedUserId);
238
239 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
240 es.RemoveEstateUser(bannedUserId);
241
242 es.AddEstateManager(bannedUserId);
243
244 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
245
246 Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length");
247
248 es.AddEstateGroup(bannedUserId);
249
250 Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length");
251
252 Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups");
253
254 }
255
256 [Test]
257 public void InventoryFolderBaseConstructorTest01()
258 {
259 UUID uuid1 = UUID.Random();
260 UUID uuid2 = UUID.Random();
261
262 InventoryFolderBase fld = new InventoryFolderBase(uuid1);
263 Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field.");
264
265 fld = new InventoryFolderBase(uuid1, uuid2);
266 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
267 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
268 }
269
270 [Test]
271 public void AsssetBaseConstructorTest01()
272 {
273 AssetBase abase = new AssetBase();
274 Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't.");
275 UUID itemID = UUID.Random();
276 UUID creatorID = UUID.Random();
277 abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString());
278
279 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't.");
280 Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property");
281 Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID");
282
283
284 abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString());
285 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't.");
286 Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again");
287
288 AssetMetadata metts = new AssetMetadata();
289 metts.FullID = itemID;
290 metts.ID = string.Empty;
291 metts.Name = "test item";
292 abase.Metadata = metts;
293
294 Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()");
295 Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
296 }
297
298 [Test]
299 public void CultureSetCultureTest01()
300 {
301 CultureInfo ci = new CultureInfo("en-US", false);
302 Culture.SetCurrentCulture();
303 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
304
305 }
306
307
308
309 }
310}
311
diff --git a/OpenSim/Framework/tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
index d741f91..d741f91 100644
--- a/OpenSim/Framework/tests/PrimeNumberHelperTests.cs
+++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index 45d822c..89f5c0c 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -170,5 +170,119 @@ namespace OpenSim.Framework.Tests
170 // Varying secrets should not eqal the same 170 // Varying secrets should not eqal the same
171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); 171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2"));
172 } 172 }
173
174 [Test]
175 public void SLUtilTypeConvertTests()
176 {
177 int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
178 ,23,24,25,46,47,48};
179 string[] contenttypes = new string[]
180 {
181 "application/octet-stream",
182 "image/x-j2c",
183 "audio/ogg",
184 "application/vnd.ll.callingcard",
185 "application/vnd.ll.landmark",
186 "application/vnd.ll.clothing",
187 "application/vnd.ll.primitive",
188 "application/vnd.ll.notecard",
189 "application/vnd.ll.folder",
190 "application/vnd.ll.rootfolder",
191 "application/vnd.ll.lsltext",
192 "application/vnd.ll.lslbyte",
193 "image/tga",
194 "application/vnd.ll.bodypart",
195 "application/vnd.ll.trashfolder",
196 "application/vnd.ll.snapshotfolder",
197 "application/vnd.ll.lostandfoundfolder",
198 "audio/x-wav",
199 "image/tga",
200 "image/jpeg",
201 "application/vnd.ll.animation",
202 "application/vnd.ll.gesture",
203 "application/x-metaverse-simstate",
204 "application/vnd.ll.favoritefolder",
205 "application/vnd.ll.link",
206 "application/vnd.ll.linkfolder",
207 "application/vnd.ll.currentoutfitfolder",
208 "application/vnd.ll.outfitfolder",
209 "application/vnd.ll.myoutfitsfolder"
210 };
211 for (int i=0;i<assettypes.Length;i++)
212 {
213 Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
214 }
215
216 for (int i = 0; i < contenttypes.Length; i++)
217 {
218 if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18)
219 {
220 Assert.That(contenttypes[i] == "image/tga");
221 }
222 else
223 {
224 Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i],
225 "Expecting {0} but got {1}", assettypes[i],
226 SLUtil.ContentTypeToSLAssetType(contenttypes[i]));
227 }
228 }
229
230 int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20};
231 string[] invcontenttypes = new string[]
232 {
233 "application/octet-stream",
234 "image/x-j2c",
235 "audio/ogg",
236 "application/vnd.ll.callingcard",
237 "application/vnd.ll.landmark",
238 "application/vnd.ll.primitive",
239 "application/vnd.ll.notecard",
240 "application/vnd.ll.folder",
241 "application/octet-stream",
242 "application/vnd.ll.lsltext",
243 "image/x-j2c",
244 "application/vnd.ll.primitive",
245 "application/vnd.ll.clothing",
246 "application/vnd.ll.gesture"
247 };
248
249 for (int i=0;i<inventorytypes.Length;i++)
250 {
251 Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]));
252 }
253
254 invcontenttypes = new string[]
255 {
256 "image/x-j2c","image/jp2","image/tga",
257 "image/jpeg","application/ogg","audio/ogg",
258 "audio/x-wav","application/vnd.ll.callingcard",
259 "application/x-metaverse-callingcard",
260 "application/vnd.ll.landmark",
261 "application/x-metaverse-landmark",
262 "application/vnd.ll.clothing",
263 "application/x-metaverse-clothing","application/vnd.ll.bodypart",
264 "application/x-metaverse-bodypart","application/vnd.ll.primitive",
265 "application/x-metaverse-primitive","application/vnd.ll.notecard",
266 "application/x-metaverse-notecard","application/vnd.ll.folder",
267 "application/vnd.ll.rootfolder","application/vnd.ll.lsltext",
268 "application/x-metaverse-lsl","application/vnd.ll.lslbyte",
269 "application/x-metaverse-lso","application/vnd.ll.trashfolder",
270 "application/vnd.ll.snapshotfolder",
271 "application/vnd.ll.lostandfoundfolder","application/vnd.ll.animation",
272 "application/x-metaverse-animation","application/vnd.ll.gesture",
273 "application/x-metaverse-gesture","application/x-metaverse-simstate",
274 "application/octet-stream"
275 };
276 sbyte[] invtypes = new sbyte[]
277 {
278 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 18, 18, 18, 18, 6, 6, 7, 7, 8, 9, 10, 10, 10, 10
279 , 8, 8, 8, 19, 19, 20, 20, 15, -1
280 };
281
282 for (int i = 0; i < invtypes.Length; i++)
283 {
284 Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]));
285 }
286 }
173 } 287 }
174} 288}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index c85ff82..7a0142f 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -316,7 +316,7 @@ namespace OpenSim
316 m_console.Commands.AddCommand("region", false, "create region", 316 m_console.Commands.AddCommand("region", false, "create region",
317 "create region [\"region name\"] <region_file.ini>", 317 "create region [\"region name\"] <region_file.ini>",
318 "Create a new region.", 318 "Create a new region.",
319 "The settings for \"region name\" are read from <region_file.ini> in your Regions directory." 319 "The settings for \"region name\" are read from <region_file.ini>. Paths specified with <region_file.ini> are relative to your Regions directory, unless an absolute path is given."
320 + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine 320 + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine
321 + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine 321 + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine
322 + "If <region_file.ini> does not exist, it will be created.", 322 + "If <region_file.ini> does not exist, it will be created.",
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 02f0968..ef5efdd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -237,9 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
237 237
238 public virtual void OnChatBroadcast(Object sender, OSChatMessage c) 238 public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
239 { 239 {
240 // unless the chat to be broadcast is of type Region, we 240 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
241 // drop it if its channel is neither 0 nor DEBUG_CHANNEL
242 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region) return;
243 241
244 ChatTypeEnum cType = c.Type; 242 ChatTypeEnum cType = c.Type;
245 if (c.Channel == DEBUG_CHANNEL) 243 if (c.Channel == DEBUG_CHANNEL)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 994b9e3..b655f39 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -330,8 +330,12 @@ namespace OpenSim.Region.Framework.Scenes
330 get { return m_rootPart.UUID; } 330 get { return m_rootPart.UUID; }
331 set 331 set
332 { 332 {
333 m_rootPart.UUID = value; 333 lock (m_parts.SyncRoot)
334 m_parts.AddOrReplace(value, m_rootPart); 334 {
335 m_parts.Remove(m_rootPart.UUID);
336 m_rootPart.UUID = value;
337 m_parts.Add(value, m_rootPart);
338 }
335 } 339 }
336 } 340 }
337 341
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 54b3260..e6ff0c0 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -189,5 +189,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests
189 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 189 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
190 // Assert.That(retrievedPart, Is.Null); 190 // Assert.That(retrievedPart, Is.Null);
191 //} 191 //}
192
193 /// <summary>
194 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
195 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by
196 /// OpenSim.
197 /// </summary>
198 [Test]
199 public void TestChangeSceneObjectUuid()
200 {
201 string rootPartName = "rootpart";
202 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
203 string childPartName = "childPart";
204 UUID childPartUuid = new UUID("00000000-0000-0000-0001-000000000000");
205
206 SceneObjectPart rootPart
207 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
208 { Name = rootPartName, UUID = rootPartUuid };
209 SceneObjectPart linkPart
210 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
211 { Name = childPartName, UUID = childPartUuid };
212
213 SceneObjectGroup sog = new SceneObjectGroup(rootPart);
214 sog.AddPart(linkPart);
215
216 Assert.That(sog.UUID, Is.EqualTo(rootPartUuid));
217 Assert.That(sog.RootPart.UUID, Is.EqualTo(rootPartUuid));
218 Assert.That(sog.Parts.Length, Is.EqualTo(2));
219
220 UUID newRootPartUuid = new UUID("00000000-0000-0000-0000-000000000002");
221 sog.UUID = newRootPartUuid;
222
223 Assert.That(sog.UUID, Is.EqualTo(newRootPartUuid));
224 Assert.That(sog.RootPart.UUID, Is.EqualTo(newRootPartUuid));
225 Assert.That(sog.Parts.Length, Is.EqualTo(2));
226 }
192 } 227 }
193} 228}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index a88c5e2..5fabbb0 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -957,7 +957,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
957 CacheKey = sb.ToString(); 957 CacheKey = sb.ToString();
958 m_memoryCache.TryGetValue(CacheKey, out resp); 958 m_memoryCache.TryGetValue(CacheKey, out resp);
959 } 959 }
960
961 } 960 }
962 961
963 if (resp == null) 962 if (resp == null)
@@ -965,22 +964,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
965 string UserService; 964 string UserService;
966 UUID SessionID; 965 UUID SessionID;
967 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); 966 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
968 param.Add("requestingAgentID", requestingAgentID.ToString()); 967
968 param.Add("RequestingAgentID", requestingAgentID.ToString());
969 param.Add("RequestingAgentUserService", UserService); 969 param.Add("RequestingAgentUserService", UserService);
970 param.Add("RequestingSessionID", SessionID.ToString()); 970 param.Add("RequestingSessionID", SessionID.ToString());
971
972
973 param.Add("ReadKey", m_groupReadKey); 971 param.Add("ReadKey", m_groupReadKey);
974 param.Add("WriteKey", m_groupWriteKey); 972 param.Add("WriteKey", m_groupWriteKey);
975 973
976
977 IList parameters = new ArrayList(); 974 IList parameters = new ArrayList();
978 parameters.Add(param); 975 parameters.Add(param);
979 976
980 ConfigurableKeepAliveXmlRpcRequest req; 977 ConfigurableKeepAliveXmlRpcRequest req;
981 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); 978 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
982 979
983
984 try 980 try
985 { 981 {
986 resp = req.Send(m_groupsServerURI, 10000); 982 resp = req.Send(m_groupsServerURI, 10000);
@@ -989,7 +985,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
989 { 985 {
990 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); 986 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
991 } 987 }
992
993 } 988 }
994 catch (Exception e) 989 catch (Exception e)
995 { 990 {
@@ -1058,10 +1053,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1058 { 1053 {
1059 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); 1054 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line);
1060 } 1055 }
1061
1062 } 1056 }
1063 } 1057 }
1064
1065 1058
1066 /// <summary> 1059 /// <summary>
1067 /// Group Request Tokens are an attempt to allow the groups service to authenticate 1060 /// Group Request Tokens are an attempt to allow the groups service to authenticate