29 using System.Threading;
32 using NUnit.Framework;
34 using OpenSim.Framework;
35 using OpenSim.Region.CoreModules.Framework.InventoryAccess;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Region.ScriptEngine.XEngine;
38 using OpenSim.Services.Interfaces;
39 using OpenSim.Tests.Common;
49 TestHelpers.InMethod();
53 xengine.DebugLevel = 1;
55 IniConfigSource configSource =
new IniConfigSource();
57 IConfig startupConfig = configSource.AddConfig(
"Startup");
58 startupConfig.Set(
"DefaultScriptEngine",
"XEngine");
60 IConfig xEngineConfig = configSource.AddConfig(
"XEngine");
61 xEngineConfig.Set(
"Enabled",
"true");
62 xEngineConfig.Set(
"StartDelay",
"0");
63 xEngineConfig.Set(
"AppDomainLoading",
"false");
65 string homeUrl =
"http://hg.HomeTestPostAssetRewriteGrid.com";
66 string foreignUrl =
"http://hg.ForeignTestPostAssetRewriteGrid.com";
68 UUID assetId = TestHelpers.ParseTail(0x10);
69 UUID userId = TestHelpers.ParseTail(0x100);
70 UUID sceneId = TestHelpers.ParseTail(0x1000);
71 string userFirstName =
"TestPostAsset";
72 string userLastName =
"Rewrite";
75 Scene scene =
new SceneHelpers().SetupScene(
"TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource);
76 SceneHelpers.SetupSceneModules(scene, configSource, xengine);
81 = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId,
"password");
83 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID,
"part", soIdTail);
85 scene, so.UUID,
"default { state_entry() { llSay(0, \"Hello World\"); } }",
"item1", ua.
PrincipalID);
87 AssetBase asset = AssetHelpers.CreateAsset(assetId, so);
88 asset.CreatorID = foreignUrl;
89 hgam.PostAsset(foreignUrl, asset);
92 AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString());
93 Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID);
94 string xmlData = Utils.BytesToString(ncAssetGet.Data);
95 XmlDocument ncAssetGetXmlDoc =
new XmlDocument();
96 ncAssetGetXmlDoc.LoadXml(xmlData);
100 XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName(
"CreatorData");
102 Assert.AreEqual(soPartsCount, creatorDataNodes.Count);
105 foreach (XmlNode creatorDataNode
in creatorDataNodes)
108 string.Format(
"{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText);
112 XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName(
"SavedScriptState");
114 Assert.AreEqual(1, savedScriptStateNodes.Count);
115 Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count);
116 XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem(
"UUID");
117 Assert.NotNull(uuidAttribute);
122 private void RezScript(
Scene scene, UUID soId,
string script,
string itemName, UUID userId)
126 itemTemplate.Name = itemName;
127 itemTemplate.Folder = soId;
128 itemTemplate.InvType = (int)InventoryType.LSL;
132 AutoResetEvent chatEvent =
new AutoResetEvent(
false);
134 scene.EventManager.OnChatFromWorld += (s, c) =>
140 scene.RezNewScript(userId, itemTemplate, script);
143 Assert.IsTrue(chatEvent.WaitOne(60000),
"Chat event in HGAssetMapperTests.RezScript not received");
delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, UUID transactionID, uint localID)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void TestPostAssetRewrite()
Asset class. All Assets are reference by this class or a class derived from this class ...
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.
Interactive OpenSim region server