opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.IO; |
||
31 | using System.Reflection; |
||
32 | using System.Threading; |
||
33 | using log4net.Config; |
||
34 | using Nini.Config; |
||
35 | using NUnit.Framework; |
||
36 | using OpenMetaverse; |
||
37 | using OpenSim.Framework; |
||
38 | using OpenSim.Region.Framework.Scenes; |
||
39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; |
||
40 | using OpenSim.Tests.Common; |
||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests |
||
43 | { |
||
44 | [TestFixture] |
||
45 | public class AssetConnectorTests : OpenSimTestCase |
||
46 | { |
||
47 | [Test] |
||
48 | public void TestAddAsset() |
||
49 | { |
||
50 | TestHelpers.InMethod(); |
||
51 | // TestHelpers.EnableLogging(); |
||
52 | |||
53 | IConfigSource config = new IniConfigSource(); |
||
54 | config.AddConfig("Modules"); |
||
55 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
||
56 | config.AddConfig("AssetService"); |
||
57 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
||
58 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
||
59 | |||
60 | LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); |
||
61 | lasc.Initialise(config); |
||
62 | |||
63 | AssetBase a1 = AssetHelpers.CreateNotecardAsset(); |
||
64 | lasc.Store(a1); |
||
65 | |||
66 | AssetBase retreivedA1 = lasc.Get(a1.ID); |
||
67 | Assert.That(retreivedA1.ID, Is.EqualTo(a1.ID)); |
||
68 | Assert.That(retreivedA1.Metadata.ID, Is.EqualTo(a1.Metadata.ID)); |
||
69 | Assert.That(retreivedA1.Data.Length, Is.EqualTo(a1.Data.Length)); |
||
70 | |||
71 | AssetMetadata retrievedA1Metadata = lasc.GetMetadata(a1.ID); |
||
72 | Assert.That(retrievedA1Metadata.ID, Is.EqualTo(a1.ID)); |
||
73 | |||
74 | byte[] retrievedA1Data = lasc.GetData(a1.ID); |
||
75 | Assert.That(retrievedA1Data.Length, Is.EqualTo(a1.Data.Length)); |
||
76 | |||
77 | // TODO: Add cache and check that this does receive a copy of the asset |
||
78 | } |
||
79 | |||
80 | public void TestAddTemporaryAsset() |
||
81 | { |
||
82 | TestHelpers.InMethod(); |
||
83 | // TestHelpers.EnableLogging(); |
||
84 | |||
85 | IConfigSource config = new IniConfigSource(); |
||
86 | config.AddConfig("Modules"); |
||
87 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
||
88 | config.AddConfig("AssetService"); |
||
89 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
||
90 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
||
91 | |||
92 | LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); |
||
93 | lasc.Initialise(config); |
||
94 | |||
95 | // If it is remote, it should be stored |
||
96 | AssetBase a2 = AssetHelpers.CreateNotecardAsset(); |
||
97 | a2.Local = false; |
||
98 | a2.Temporary = true; |
||
99 | |||
100 | lasc.Store(a2); |
||
101 | |||
102 | AssetBase retreivedA2 = lasc.Get(a2.ID); |
||
103 | Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID)); |
||
104 | Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID)); |
||
105 | Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length)); |
||
106 | |||
107 | AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID); |
||
108 | Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID)); |
||
109 | |||
110 | byte[] retrievedA2Data = lasc.GetData(a2.ID); |
||
111 | Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length)); |
||
112 | |||
113 | // TODO: Add cache and check that this does receive a copy of the asset |
||
114 | } |
||
115 | |||
116 | [Test] |
||
117 | public void TestAddLocalAsset() |
||
118 | { |
||
119 | TestHelpers.InMethod(); |
||
120 | // TestHelpers.EnableLogging(); |
||
121 | |||
122 | IConfigSource config = new IniConfigSource(); |
||
123 | config.AddConfig("Modules"); |
||
124 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
||
125 | config.AddConfig("AssetService"); |
||
126 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
||
127 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
||
128 | |||
129 | LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); |
||
130 | lasc.Initialise(config); |
||
131 | |||
132 | AssetBase a1 = AssetHelpers.CreateNotecardAsset(); |
||
133 | a1.Local = true; |
||
134 | |||
135 | lasc.Store(a1); |
||
136 | |||
137 | Assert.That(lasc.Get(a1.ID), Is.Null); |
||
138 | Assert.That(lasc.GetData(a1.ID), Is.Null); |
||
139 | Assert.That(lasc.GetMetadata(a1.ID), Is.Null); |
||
140 | |||
141 | // TODO: Add cache and check that this does receive a copy of the asset |
||
142 | } |
||
143 | |||
144 | [Test] |
||
145 | public void TestAddTemporaryLocalAsset() |
||
146 | { |
||
147 | TestHelpers.InMethod(); |
||
148 | // TestHelpers.EnableLogging(); |
||
149 | |||
150 | IConfigSource config = new IniConfigSource(); |
||
151 | config.AddConfig("Modules"); |
||
152 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
||
153 | config.AddConfig("AssetService"); |
||
154 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
||
155 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
||
156 | |||
157 | LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); |
||
158 | lasc.Initialise(config); |
||
159 | |||
160 | // If it is local, it should not be stored |
||
161 | AssetBase a1 = AssetHelpers.CreateNotecardAsset(); |
||
162 | a1.Local = true; |
||
163 | a1.Temporary = true; |
||
164 | |||
165 | lasc.Store(a1); |
||
166 | |||
167 | Assert.That(lasc.Get(a1.ID), Is.Null); |
||
168 | Assert.That(lasc.GetData(a1.ID), Is.Null); |
||
169 | Assert.That(lasc.GetMetadata(a1.ID), Is.Null); |
||
170 | |||
171 | // TODO: Add cache and check that this does receive a copy of the asset |
||
172 | } |
||
173 | } |
||
174 | } |