aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Setup/AssetHelpers.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-05-21 00:51:34 +0100
committerJustin Clark-Casey (justincc)2011-05-21 00:51:34 +0100
commit4073f1013346e206131f2f7d40508fd2bf0505d4 (patch)
treee788de7181beeaddfb74858f40e515c1e37f7da4 /OpenSim/Tests/Common/Setup/AssetHelpers.cs
parentrename UserInventoryTestsUtils -> UserInventoryHelpers for consistency (diff)
downloadopensim-SC_OLD-4073f1013346e206131f2f7d40508fd2bf0505d4.zip
opensim-SC_OLD-4073f1013346e206131f2f7d40508fd2bf0505d4.tar.gz
opensim-SC_OLD-4073f1013346e206131f2f7d40508fd2bf0505d4.tar.bz2
opensim-SC_OLD-4073f1013346e206131f2f7d40508fd2bf0505d4.tar.xz
rename test helpers enclosing package from Setup to Helpers
Diffstat (limited to 'OpenSim/Tests/Common/Setup/AssetHelpers.cs')
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs143
1 files changed, 0 insertions, 143 deletions
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
deleted file mode 100644
index aa55bcd..0000000
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ /dev/null
@@ -1,143 +0,0 @@
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.Text;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Scenes.Serialization;
33using OpenSim.Services.Interfaces;
34
35namespace OpenSim.Tests.Common
36{
37 public class AssetHelpers
38 {
39 /// <summary>
40 /// Create a notecard asset with a random uuid and dummy text.
41 /// </summary>
42 /// <param name="creatorId">/param>
43 /// <returns></returns>
44 public static AssetBase CreateAsset(UUID creatorId)
45 {
46 return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
47 }
48
49 /// <summary>
50 /// Create and store a notecard asset with a random uuid and dummy text.
51 /// </summary>
52 /// <param name="creatorId">/param>
53 /// <returns></returns>
54 public static AssetBase CreateAsset(Scene scene, UUID creatorId)
55 {
56 AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
57 scene.AssetService.Store(asset);
58 return asset;
59 }
60
61 /// <summary>
62 /// Create an asset from the given object.
63 /// </summary>
64 /// <param name="assetUuidTail">
65 /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
66 /// will be used.
67 /// </param>
68 /// <param name="sog"></param>
69 /// <returns></returns>
70 public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog)
71 {
72 return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog);
73 }
74
75 /// <summary>
76 /// Create an asset from the given object.
77 /// </summary>
78 /// <param name="assetUuid"></param>
79 /// <param name="sog"></param>
80 /// <returns></returns>
81 public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog)
82 {
83 return CreateAsset(
84 assetUuid,
85 AssetType.Object,
86 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
87 sog.OwnerID);
88 }
89
90 /// <summary>
91 /// Create an asset from the given scene object.
92 /// </summary>
93 /// <param name="assetUuidTail">
94 /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
95 /// will be used.
96 /// </param>
97 /// <param name="coa"></param>
98 /// <returns></returns>
99 public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa)
100 {
101 return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa);
102 }
103
104 /// <summary>
105 /// Create an asset from the given scene object.
106 /// </summary>
107 /// <param name="assetUuid"></param>
108 /// <param name="coa"></param>
109 /// <returns></returns>
110 public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa)
111 {
112 return CreateAsset(
113 assetUuid,
114 AssetType.Object,
115 Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)),
116 coa.CreatorId);
117 }
118
119 /// <summary>
120 /// Create an asset from the given data.
121 /// </summary>
122 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
123 {
124 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
125 }
126
127 /// <summary>
128 /// Create an asset from the given data.
129 /// </summary>
130 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
131 {
132 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
133 asset.Data = data;
134 return asset;
135 }
136
137 public static string ReadAssetAsString(IAssetService assetService, UUID uuid)
138 {
139 byte[] assetData = assetService.GetData(uuid.ToString());
140 return Encoding.ASCII.GetString(assetData);
141 }
142 }
143}