diff options
author | Justin Clarke Casey | 2009-02-16 18:33:05 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-16 18:33:05 +0000 |
commit | ec07e1aad6fb3d28fcf4a3eca0becf4e0e209965 (patch) | |
tree | 91b100f31d4b980be18d8b362ef79a3d1d55f27a | |
parent | * remove duplicate OpenSim.Region.CoreModules assembly entry (diff) | |
download | opensim-SC_OLD-ec07e1aad6fb3d28fcf4a3eca0becf4e0e209965.zip opensim-SC_OLD-ec07e1aad6fb3d28fcf4a3eca0becf4e0e209965.tar.gz opensim-SC_OLD-ec07e1aad6fb3d28fcf4a3eca0becf4e0e209965.tar.bz2 opensim-SC_OLD-ec07e1aad6fb3d28fcf4a3eca0becf4e0e209965.tar.xz |
* Iniital inventory archive test code. Doesn't actually do any testing yet
Diffstat (limited to '')
4 files changed, 165 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs new file mode 100644 index 0000000..bc5e564 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -0,0 +1,159 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.Text; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class InventoryArchiverTests | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). | ||
47 | /// </summary> | ||
48 | [Test] | ||
49 | public void TestSaveIarV0p1() | ||
50 | { | ||
51 | //log4net.Config.XmlConfigurator.Configure(); | ||
52 | |||
53 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
54 | |||
55 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
56 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
57 | CommunicationsManager cm = scene.CommsManager; | ||
58 | |||
59 | // Create user | ||
60 | string userFirstName = "Jock"; | ||
61 | string userLastName = "Stirrup"; | ||
62 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
63 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); | ||
64 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); | ||
65 | userInfo.FetchInventory(); | ||
66 | |||
67 | // Create asset | ||
68 | SceneObjectGroup object1; | ||
69 | SceneObjectPart part1; | ||
70 | { | ||
71 | string partName = "My Little Dog Object"; | ||
72 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
73 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
74 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
75 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
76 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
77 | |||
78 | part1 | ||
79 | = new SceneObjectPart( | ||
80 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
81 | part1.Name = partName; | ||
82 | |||
83 | object1 = new SceneObjectGroup(part1); | ||
84 | } | ||
85 | |||
86 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
87 | AssetBase asset1 = new AssetBase(); | ||
88 | asset1.FullID = asset1Id; | ||
89 | asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2()); | ||
90 | cm.AssetCache.AddAsset(asset1); | ||
91 | |||
92 | // Create item | ||
93 | InventoryItemBase item1 = new InventoryItemBase(); | ||
94 | item1.Name = "My Little Dog"; | ||
95 | item1.AssetID = asset1.FullID; | ||
96 | item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID; | ||
97 | scene.AddInventoryItem(userId, item1); | ||
98 | |||
99 | /* | ||
100 | |||
101 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
102 | |||
103 | scene.EventManager.OnOarFileSaved += SaveCompleted; | ||
104 | archiverModule.ArchiveRegion(archiveWriteStream); | ||
105 | m_waitHandle.WaitOne(60000, true); | ||
106 | |||
107 | byte[] archive = archiveWriteStream.ToArray(); | ||
108 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
109 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
110 | |||
111 | bool gotControlFile = false; | ||
112 | bool gotObject1File = false; | ||
113 | bool gotObject2File = false; | ||
114 | string expectedObject1FileName = string.Format( | ||
115 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | ||
116 | part1.Name, | ||
117 | Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), | ||
118 | part1.UUID); | ||
119 | string expectedObject2FileName = string.Format( | ||
120 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | ||
121 | part2.Name, | ||
122 | Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), | ||
123 | part2.UUID); | ||
124 | |||
125 | string filePath; | ||
126 | TarArchiveReader.TarEntryType tarEntryType; | ||
127 | |||
128 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
129 | { | ||
130 | if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | ||
131 | { | ||
132 | gotControlFile = true; | ||
133 | } | ||
134 | else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) | ||
135 | { | ||
136 | string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); | ||
137 | |||
138 | if (fileName.StartsWith(part1.Name)) | ||
139 | { | ||
140 | Assert.That(fileName, Is.EqualTo(expectedObject1FileName)); | ||
141 | gotObject1File = true; | ||
142 | } | ||
143 | else if (fileName.StartsWith(part2.Name)) | ||
144 | { | ||
145 | Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
146 | gotObject2File = true; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
152 | Assert.That(gotObject1File, Is.True, "No object1 file in archive"); | ||
153 | Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
154 | |||
155 | // TODO: Test presence of more files and contents of files. | ||
156 | */ | ||
157 | } | ||
158 | } | ||
159 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 566d8d2..9b92421 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs | |||
@@ -59,6 +59,10 @@ namespace OpenSim.Tests.Common.Mock | |||
59 | m_userDataPlugin = new TestUserDataPlugin(); | 59 | m_userDataPlugin = new TestUserDataPlugin(); |
60 | m_inventoryDataPlugin = new TestInventoryDataPlugin(); | 60 | m_inventoryDataPlugin = new TestInventoryDataPlugin(); |
61 | 61 | ||
62 | SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); | ||
63 | IAssetCache ac = new AssetCache(assetService); | ||
64 | m_assetCache = ac; | ||
65 | |||
62 | LocalInventoryService lis = new LocalInventoryService(); | 66 | LocalInventoryService lis = new LocalInventoryService(); |
63 | lis.AddPlugin(m_inventoryDataPlugin); | 67 | lis.AddPlugin(m_inventoryDataPlugin); |
64 | m_interServiceInventoryService = lis; | 68 | m_interServiceInventoryService = lis; |
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 81fccbb..813c8b2 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -73,14 +73,11 @@ namespace OpenSim.Tests.Common.Setup | |||
73 | AgentCircuitManager acm = new AgentCircuitManager(); | 73 | AgentCircuitManager acm = new AgentCircuitManager(); |
74 | SceneCommunicationService scs = new SceneCommunicationService(cm); | 74 | SceneCommunicationService scs = new SceneCommunicationService(cm); |
75 | 75 | ||
76 | SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); | ||
77 | IAssetCache ac = (IAssetCache) new AssetCache(assetService); | ||
78 | |||
79 | StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); | 76 | StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); |
80 | IConfigSource configSource = new IniConfigSource(); | 77 | IConfigSource configSource = new IniConfigSource(); |
81 | 78 | ||
82 | TestScene testScene = new TestScene( | 79 | TestScene testScene = new TestScene( |
83 | regInfo, acm, cm, scs, ac, sm, null, false, false, false, configSource, null); | 80 | regInfo, acm, cm, scs, cm.AssetCache, sm, null, false, false, false, configSource, null); |
84 | 81 | ||
85 | IRegionModule capsModule = new CapabilitiesModule(); | 82 | IRegionModule capsModule = new CapabilitiesModule(); |
86 | capsModule.Initialise(testScene, new IniConfigSource()); | 83 | capsModule.Initialise(testScene, new IniConfigSource()); |
diff --git a/prebuild.xml b/prebuild.xml index 48d3697..193d58a 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2727,6 +2727,7 @@ | |||
2727 | <Files> | 2727 | <Files> |
2728 | <!-- SADLY the way this works means you need to keep adding these paths --> | 2728 | <!-- SADLY the way this works means you need to keep adding these paths --> |
2729 | <Match path="Agent/TextureSender/Tests" pattern="*.cs" recurse="true" /> | 2729 | <Match path="Agent/TextureSender/Tests" pattern="*.cs" recurse="true" /> |
2730 | <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true" /> | ||
2730 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> | 2731 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> |
2731 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true" /> | 2732 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true" /> |
2732 | </Files> | 2733 | </Files> |