aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-03-09 01:53:27 +0000
committerJustin Clark-Casey (justincc)2011-03-09 01:53:27 +0000
commitae507bb0600774624f876c4562391cec0111eee8 (patch)
treea44687ca003e6962dc7ab6e7d90a1c2c8689d35b /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
parentremove inventory service preserving code from SceneSetupHelpers too (diff)
downloadopensim-SC_OLD-ae507bb0600774624f876c4562391cec0111eee8.zip
opensim-SC_OLD-ae507bb0600774624f876c4562391cec0111eee8.tar.gz
opensim-SC_OLD-ae507bb0600774624f876c4562391cec0111eee8.tar.bz2
opensim-SC_OLD-ae507bb0600774624f876c4562391cec0111eee8.tar.xz
Split out path tests from InventoryArchiveTests. Factor common code into test case parent
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs124
1 files changed, 124 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
new file mode 100644
index 0000000..023c452
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -0,0 +1,124 @@
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.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48using OpenSim.Tests.Common.Setup;
49
50namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
51{
52 [TestFixture]
53 public class InventoryArchiveTestCase
54 {
55 protected ManualResetEvent mre = new ManualResetEvent(false);
56
57 /// <summary>
58 /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test.
59 /// </summary>
60 protected byte[] m_iarStreamBytes;
61
62 /// <summary>
63 /// Stream of data representing a common IAR for load tests.
64 /// </summary>
65 protected MemoryStream m_iarStream;
66
67 protected UserAccount m_ua1
68 = new UserAccount {
69 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
70 FirstName = "Mr",
71 LastName = "Tiddles" };
72 protected UserAccount m_ua2
73 = new UserAccount {
74 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
75 FirstName = "Lord",
76 LastName = "Lucan" };
77 protected string m_item1Name = "b.lsl";
78
79 [SetUp]
80 public void SetUp()
81 {
82 m_iarStream = new MemoryStream(m_iarStreamBytes);
83 }
84
85 [TestFixtureSetUp]
86 public void FixtureSetup()
87 {
88 ConstructDefaultIarBytesForTestLoad();
89 }
90
91 protected void ConstructDefaultIarBytesForTestLoad()
92 {
93// log4net.Config.XmlConfigurator.Configure();
94
95 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
96 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
97
98 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
99
100 MemoryStream archiveWriteStream = new MemoryStream();
101 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
102
103 InventoryItemBase item1 = new InventoryItemBase();
104 item1.Name = m_item1Name;
105 item1.AssetID = UUID.Random();
106 item1.GroupID = UUID.Random();
107 item1.CreatorIdAsUuid = m_ua2.PrincipalID;
108 item1.Owner = UUID.Zero;
109
110 string item1FileName
111 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
112 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
113 tar.Close();
114 m_iarStreamBytes = archiveWriteStream.ToArray();
115 }
116
117 protected void SaveCompleted(
118 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
119 Exception reportedException)
120 {
121 mre.Set();
122 }
123 }
124} \ No newline at end of file