aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs92
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2bin0 -> 24410 bytes
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs13
6 files changed, 107 insertions, 12 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
index 185a909..bbd2c43 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
82 /// <param name="packetsToSend">Maximum number of packets to send during this call</param> 82 /// <param name="packetsToSend">Maximum number of packets to send during this call</param>
83 /// <param name="packetsSent">Number of packets sent during this call</param> 83 /// <param name="packetsSent">Number of packets sent during this call</param>
84 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns> 84 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns>
85 public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) 85 public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent)
86 { 86 {
87 packetsSent = 0; 87 packetsSent = 0;
88 88
@@ -212,7 +212,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
212 } 212 }
213 } 213 }
214 214
215 private bool SendFirstPacket(LLClientView client) 215 private bool SendFirstPacket(IClientAPI client)
216 { 216 {
217 if (client == null) 217 if (client == null)
218 return false; 218 return false;
@@ -247,7 +247,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
247 return false; 247 return false;
248 } 248 }
249 249
250 private bool SendPacket(LLClientView client) 250 private bool SendPacket(IClientAPI client)
251 { 251 {
252 if (client == null) 252 if (client == null)
253 return false; 253 return false;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
index db428f1..30d3712 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
@@ -55,16 +55,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 private bool m_shuttingdown; 56 private bool m_shuttingdown;
57 private AssetBase m_missingImage; 57 private AssetBase m_missingImage;
58 private LLClientView m_client; //Client we're assigned to 58 private IClientAPI m_client; //Client we're assigned to
59 private IAssetService m_assetCache; //Asset Cache 59 private IAssetService m_assetCache; //Asset Cache
60 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module 60 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
61 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); 61 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
62 private object m_syncRoot = new object(); 62 private object m_syncRoot = new object();
63 63
64 public LLClientView Client { get { return m_client; } } 64 public IClientAPI Client { get { return m_client; } }
65 public AssetBase MissingImage { get { return m_missingImage; } } 65 public AssetBase MissingImage { get { return m_missingImage; } }
66 66
67 public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) 67 public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
68 { 68 {
69 m_client = client; 69 m_client = client;
70 m_assetCache = pAssetCache; 70 m_assetCache = pAssetCache;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
new file mode 100644
index 0000000..bdc9c7d
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
@@ -0,0 +1,92 @@
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;
29using System.IO;
30using System.Net;
31using System.Reflection;
32using log4net.Config;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Packets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.Agent.TextureSender;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Tests.Common;
41using OpenSim.Tests.Common.Mock;
42
43namespace OpenSim.Region.ClientStack.LindenUDP.Tests
44{
45 [TestFixture]
46 public class LLImageManagerTests
47 {
48 [Test]
49 public void TestRequestAndSendImage()
50 {
51 TestHelpers.InMethod();
52// XmlConfigurator.Configure();
53
54 UUID imageId = TestHelpers.ParseTail(0x1);
55 string creatorId = TestHelpers.ParseTail(0x2).ToString();
56 UUID userId = TestHelpers.ParseTail(0x3);
57
58 J2KDecoderModule j2kdm = new J2KDecoderModule();
59
60 Scene scene = SceneHelpers.SetupScene();
61 SceneHelpers.SetupSceneModules(scene, j2kdm);
62
63 TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
64 LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm);
65
66 using (
67 Stream resource
68 = GetType().Assembly.GetManifestResourceStream(
69 "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
70 {
71 using (BinaryReader br = new BinaryReader(resource))
72 {
73 AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId);
74 asset.Data = br.ReadBytes(99999999);
75 scene.AssetService.Store(asset);
76 }
77 }
78
79 TextureRequestArgs args = new TextureRequestArgs();
80 args.RequestedAssetID = TestHelpers.ParseTail(0x1);
81 args.DiscardLevel = 0;
82 args.PacketNumber = 1;
83 args.Priority = 5;
84 args.requestSequence = 1;
85
86 llim.EnqueueReq(args);
87 llim.ProcessImageQueue(20);
88
89 Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
90 }
91 }
92} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2
new file mode 100644
index 0000000..8c63104
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2
Binary files differ
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index e798e5e..eec3c1b 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -344,7 +344,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
344 { 344 {
345 using (BinaryReader br = new BinaryReader(resource)) 345 using (BinaryReader br = new BinaryReader(resource))
346 { 346 {
347 // FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion 347 // FIXME: Use the inspector instead
348 soundData = br.ReadBytes(99999999); 348 soundData = br.ReadBytes(99999999);
349 UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); 349 UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
350 string soundAssetFileName 350 string soundAssetFileName
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 37b90e1..2fc6572 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -44,9 +44,6 @@ namespace OpenSim.Tests.Common.Mock
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 // Mock testing variables
48 public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>();
49 public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>();
50 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
51 48
52 // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup 49 // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup
@@ -61,6 +58,9 @@ namespace OpenSim.Tests.Common.Mock
61 public List<UUID> ReceivedOnlineNotifications { get; private set; } 58 public List<UUID> ReceivedOnlineNotifications { get; private set; }
62 public List<UUID> ReceivedFriendshipTerminations { get; private set; } 59 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
63 60
61 public List<ImageDataPacket> SentImageDataPackets { get; private set; }
62 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
63
64// disable warning: public events, part of the public API 64// disable warning: public events, part of the public API
65#pragma warning disable 67 65#pragma warning disable 67
66 66
@@ -452,6 +452,9 @@ namespace OpenSim.Tests.Common.Mock
452 ReceivedOfflineNotifications = new List<UUID>(); 452 ReceivedOfflineNotifications = new List<UUID>();
453 ReceivedOnlineNotifications = new List<UUID>(); 453 ReceivedOnlineNotifications = new List<UUID>();
454 ReceivedFriendshipTerminations = new List<UUID>(); 454 ReceivedFriendshipTerminations = new List<UUID>();
455
456 SentImageDataPackets = new List<ImageDataPacket>();
457 SentImagePacketPackets = new List<ImagePacketPacket>();
455 } 458 }
456 459
457 /// <summary> 460 /// <summary>
@@ -804,7 +807,7 @@ namespace OpenSim.Tests.Common.Mock
804 im.ImageData.Data = ImageData; 807 im.ImageData.Data = ImageData;
805 im.ImageID.Codec = imageCodec; 808 im.ImageID.Codec = imageCodec;
806 im.Header.Zerocoded = true; 809 im.Header.Zerocoded = true;
807 sentdatapkt.Add(im); 810 SentImageDataPackets.Add(im);
808 } 811 }
809 812
810 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) 813 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
@@ -814,7 +817,7 @@ namespace OpenSim.Tests.Common.Mock
814 im.ImageID.Packet = partNumber; 817 im.ImageID.Packet = partNumber;
815 im.ImageID.ID = imageUuid; 818 im.ImageID.ID = imageUuid;
816 im.ImageData.Data = imageData; 819 im.ImageData.Data = imageData;
817 sentpktpkt.Add(im); 820 SentImagePacketPackets.Add(im);
818 } 821 }
819 822
820 public void SendImageNotFound(UUID imageid) 823 public void SendImageNotFound(UUID imageid)