diff options
author | Michael Heilmann | 2015-05-19 15:18:45 -0400 |
---|---|---|
committer | Michael Heilmann | 2015-05-19 15:18:45 -0400 |
commit | 140ea04b9d692344d803fc87364fb252561725c3 (patch) | |
tree | d503b7ae17baca374d704b548fc7da512f512388 /OpenSim/Tests/Robust/Clients | |
parent | Merge pull request #7 from gamucf/moses.metricsPhase2 (diff) | |
parent | resolve possible nullref when sending appearance packet. Thanks to zadark for... (diff) | |
download | opensim-SC-140ea04b9d692344d803fc87364fb252561725c3.zip opensim-SC-140ea04b9d692344d803fc87364fb252561725c3.tar.gz opensim-SC-140ea04b9d692344d803fc87364fb252561725c3.tar.bz2 opensim-SC-140ea04b9d692344d803fc87364fb252561725c3.tar.xz |
Merging Opensim upstream before generating patch
Diffstat (limited to 'OpenSim/Tests/Robust/Clients')
6 files changed, 521 insertions, 0 deletions
diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs new file mode 100644 index 0000000..671aca7 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs | |||
@@ -0,0 +1,133 @@ | |||
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.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Services.Connectors; | ||
40 | |||
41 | namespace Robust.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class GridClient | ||
45 | { | ||
46 | // private static readonly ILog m_log = | ||
47 | // LogManager.GetLogger( | ||
48 | // MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | [Test] | ||
51 | public void Grid_001() | ||
52 | { | ||
53 | GridServicesConnector m_Connector = new GridServicesConnector(DemonServer.Address); | ||
54 | |||
55 | GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); | ||
56 | GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); | ||
57 | GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); | ||
58 | |||
59 | string msg = m_Connector.RegisterRegion(UUID.Zero, r1); | ||
60 | Assert.AreEqual(msg, string.Empty, "Region 1 failed to register"); | ||
61 | |||
62 | msg = m_Connector.RegisterRegion(UUID.Zero, r2); | ||
63 | Assert.AreEqual(msg, string.Empty, "Region 2 failed to register"); | ||
64 | |||
65 | msg = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
66 | Assert.AreEqual(msg, string.Empty, "Region 3 failed to register"); | ||
67 | |||
68 | bool success; | ||
69 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
70 | Assert.AreEqual(success, true, "Region 3 failed to deregister"); | ||
71 | |||
72 | msg = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
73 | Assert.AreEqual(msg, string.Empty, "Region 3 failed to re-register"); | ||
74 | |||
75 | List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); | ||
76 | Assert.AreNotEqual(regions, null, "GetNeighbours of region 1 failed"); | ||
77 | Assert.AreEqual(regions.Count, 1, "Region 1 should have 1 neighbor"); | ||
78 | Assert.AreEqual(regions[0].RegionName, "Test Region 2", "Region 1 has the wrong neighbor"); | ||
79 | |||
80 | GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); | ||
81 | Assert.AreNotEqual(region, null, "GetRegionByUUID for region 2 failed"); | ||
82 | Assert.AreEqual(region.RegionName, "Test Region 2", "GetRegionByUUID of region 2 returned wrong region"); | ||
83 | |||
84 | region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); | ||
85 | Assert.AreEqual(region, null, "Region with randon id should not exist"); | ||
86 | |||
87 | region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); | ||
88 | Assert.AreNotEqual(region, null, "GetRegionByUUID for region 3 failed"); | ||
89 | Assert.AreEqual(region.RegionName, "Test Region 3", "GetRegionByUUID of region 3 returned wrong region"); | ||
90 | |||
91 | region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); | ||
92 | Assert.AreEqual(region, null, "Region Foo should not exist"); | ||
93 | |||
94 | regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
95 | Assert.AreNotEqual(regions, null, "GetRegionsByName failed"); | ||
96 | Assert.AreEqual(regions.Count, 3, "GetRegionsByName should return 3"); | ||
97 | |||
98 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
99 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), | ||
100 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); | ||
101 | Assert.AreNotEqual(regions, null, "GetRegionRange failed"); | ||
102 | Assert.AreEqual(regions.Count, 2, "GetRegionRange should return 2"); | ||
103 | |||
104 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
105 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), | ||
106 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); | ||
107 | Assert.AreNotEqual(regions, null, "GetRegionRange (bis) failed"); | ||
108 | Assert.AreEqual(regions.Count, 0, "GetRegionRange (bis) should return 0"); | ||
109 | |||
110 | // Deregister them all | ||
111 | success = m_Connector.DeregisterRegion(r1.RegionID); | ||
112 | Assert.AreEqual(success, true, "Region 1 failed to deregister"); | ||
113 | |||
114 | success = m_Connector.DeregisterRegion(r2.RegionID); | ||
115 | Assert.AreEqual(success, true, "Region 2 failed to deregister"); | ||
116 | |||
117 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
118 | Assert.AreEqual(success, true, "Region 3 failed to deregister"); | ||
119 | } | ||
120 | |||
121 | private static GridRegion CreateRegion(string name, uint xcell, uint ycell) | ||
122 | { | ||
123 | GridRegion region = new GridRegion(xcell, ycell); | ||
124 | region.RegionName = name; | ||
125 | region.RegionID = UUID.Random(); | ||
126 | region.ExternalHostName = "127.0.0.1"; | ||
127 | region.HttpPort = 9000; | ||
128 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); | ||
129 | |||
130 | return region; | ||
131 | } | ||
132 | } | ||
133 | } | ||
diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridForm.html b/OpenSim/Tests/Robust/Clients/Grid/GridForm.html new file mode 100644 index 0000000..252920f --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Grid/GridForm.html | |||
@@ -0,0 +1,11 @@ | |||
1 | <html> | ||
2 | |||
3 | <form name="input" action="http://127.0.0.1:8002/grid" method="post"> | ||
4 | xmin:<input type="text" name="XMIN" value="0"> | ||
5 | xmax:<input type="text" name="XMAX" value="0"> | ||
6 | ymin:<input type="text" name="YMIN" value="0"> | ||
7 | ymax:<input type="text" name="YMAX" value="0"> | ||
8 | <input type="hidden" name="METHOD" value="get_region_range"> | ||
9 | <input type="submit" value="Submit" /> | ||
10 | </form> | ||
11 | </html> | ||
diff --git a/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs b/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs new file mode 100644 index 0000000..8f312eb --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs | |||
@@ -0,0 +1,58 @@ | |||
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.Text; | ||
31 | |||
32 | using OpenMetaverse; | ||
33 | using NUnit.Framework; | ||
34 | |||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Services.Connectors.InstantMessage; | ||
38 | |||
39 | namespace Robust.Tests | ||
40 | { | ||
41 | [TestFixture] | ||
42 | public class IMClient | ||
43 | { | ||
44 | [Test] | ||
45 | public void HGIM_001() | ||
46 | { | ||
47 | GridInstantMessage im = new GridInstantMessage(); | ||
48 | im.fromAgentID = new Guid(); | ||
49 | im.toAgentID = new Guid(); | ||
50 | im.message = "Hello"; | ||
51 | im.imSessionID = new Guid(); | ||
52 | |||
53 | bool success = InstantMessageServiceConnector.SendInstantMessage(DemonServer.Address, im); | ||
54 | Assert.IsFalse(success, "Sending of IM succeeded, but it should have failed"); | ||
55 | } | ||
56 | |||
57 | } | ||
58 | } | ||
diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs new file mode 100644 index 0000000..9d3f400 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs | |||
@@ -0,0 +1,153 @@ | |||
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.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors; | ||
39 | |||
40 | namespace Robust.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class InventoryClient | ||
44 | { | ||
45 | // private static readonly ILog m_log = | ||
46 | // LogManager.GetLogger( | ||
47 | // MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333"); | ||
50 | private UUID m_rootFolderID; | ||
51 | private UUID m_notecardsFolder; | ||
52 | private UUID m_objectsFolder; | ||
53 | |||
54 | [Test] | ||
55 | public void Inventory_001_CreateInventory() | ||
56 | { | ||
57 | XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); | ||
58 | |||
59 | // Create an inventory that looks like this: | ||
60 | // | ||
61 | // /My Inventory | ||
62 | // <other system folders> | ||
63 | // /Objects | ||
64 | // Some Object | ||
65 | // /Notecards | ||
66 | // Notecard 1 | ||
67 | // Notecard 2 | ||
68 | // /Test Folder | ||
69 | // Link to notecard -> /Notecards/Notecard 2 | ||
70 | // Link to Objects folder -> /Objects | ||
71 | |||
72 | Console.WriteLine("Starting inventory test"); | ||
73 | bool success = m_Connector.CreateUserInventory(m_userID); | ||
74 | Assert.IsTrue(success, "Failed to create user inventory"); | ||
75 | |||
76 | m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID; | ||
77 | Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero"); | ||
78 | |||
79 | InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, AssetType.Object); | ||
80 | Assert.IsNotNull(of, "Failed to retrieve Objects folder"); | ||
81 | m_objectsFolder = of.ID; | ||
82 | Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero"); | ||
83 | |||
84 | // Add an object | ||
85 | InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID); | ||
86 | item.AssetID = UUID.Random(); | ||
87 | item.AssetType = (int)AssetType.Object; | ||
88 | item.Folder = m_objectsFolder; | ||
89 | item.Name = "Some Object"; | ||
90 | item.Description = string.Empty; | ||
91 | success = m_Connector.AddItem(item); | ||
92 | Assert.IsTrue(success, "Failed to add object to inventory"); | ||
93 | |||
94 | InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, AssetType.Notecard); | ||
95 | Assert.IsNotNull(of, "Failed to retrieve Notecards folder"); | ||
96 | m_notecardsFolder = ncf.ID; | ||
97 | Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero"); | ||
98 | m_notecardsFolder = ncf.ID; | ||
99 | |||
100 | // Add a notecard | ||
101 | item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); | ||
102 | item.AssetID = UUID.Random(); | ||
103 | item.AssetType = (int)AssetType.Notecard; | ||
104 | item.Folder = m_notecardsFolder; | ||
105 | item.Name = "Test Notecard 1"; | ||
106 | item.Description = string.Empty; | ||
107 | success = m_Connector.AddItem(item); | ||
108 | Assert.IsTrue(success, "Failed to add Notecard 1 to inventory"); | ||
109 | // Add another notecard | ||
110 | item.ID = new UUID("20000000-0000-0000-0000-000000000002"); | ||
111 | item.AssetID = new UUID("a0000000-0000-0000-0000-00000000000a"); | ||
112 | item.Name = "Test Notecard 2"; | ||
113 | item.Description = string.Empty; | ||
114 | success = m_Connector.AddItem(item); | ||
115 | Assert.IsTrue(success, "Failed to add Notecard 2 to inventory"); | ||
116 | |||
117 | // Add a folder | ||
118 | InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID); | ||
119 | folder.Type = (int)AssetType.Folder; | ||
120 | success = m_Connector.AddFolder(folder); | ||
121 | Assert.IsTrue(success, "Failed to add Test Folder to inventory"); | ||
122 | |||
123 | // Add a link to notecard 2 in Test Folder | ||
124 | item.AssetID = item.ID; // use item ID of notecard 2 | ||
125 | item.ID = new UUID("40000000-0000-0000-0000-000000000004"); | ||
126 | item.AssetType = (int)AssetType.Link; | ||
127 | item.Folder = folder.ID; | ||
128 | item.Name = "Link to notecard"; | ||
129 | item.Description = string.Empty; | ||
130 | success = m_Connector.AddItem(item); | ||
131 | Assert.IsTrue(success, "Failed to add link to notecard to inventory"); | ||
132 | |||
133 | // Add a link to the Objects folder in Test Folder | ||
134 | item.AssetID = m_Connector.GetFolderForType(m_userID, AssetType.Object).ID; // use item ID of Objects folder | ||
135 | item.ID = new UUID("50000000-0000-0000-0000-000000000005"); | ||
136 | item.AssetType = (int)AssetType.LinkFolder; | ||
137 | item.Folder = folder.ID; | ||
138 | item.Name = "Link to Objects folder"; | ||
139 | item.Description = string.Empty; | ||
140 | success = m_Connector.AddItem(item); | ||
141 | Assert.IsTrue(success, "Failed to add link to objects folder to inventory"); | ||
142 | |||
143 | InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID); | ||
144 | Assert.IsNotNull(coll, "Failed to retrieve contents of root folder"); | ||
145 | Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders"); | ||
146 | |||
147 | coll = m_Connector.GetFolderContent(m_userID, folder.ID); | ||
148 | Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder"); | ||
149 | Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); | ||
150 | |||
151 | } | ||
152 | } | ||
153 | } | ||
diff --git a/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs new file mode 100644 index 0000000..31c8ee9 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs | |||
@@ -0,0 +1,81 @@ | |||
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.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors; | ||
39 | |||
40 | namespace Robust.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class PresenceClient | ||
44 | { | ||
45 | [Test] | ||
46 | public void Presence_001() | ||
47 | { | ||
48 | PresenceServicesConnector m_Connector = new PresenceServicesConnector(DemonServer.Address); | ||
49 | |||
50 | UUID user1 = UUID.Random(); | ||
51 | UUID session1 = UUID.Random(); | ||
52 | UUID region1 = UUID.Random(); | ||
53 | |||
54 | bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero); | ||
55 | Assert.AreEqual(success, true, "Failed to add user session"); | ||
56 | |||
57 | PresenceInfo pinfo = m_Connector.GetAgent(session1); | ||
58 | Assert.AreNotEqual(pinfo, null, "Unable to retrieve session"); | ||
59 | Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); | ||
60 | Assert.AreNotEqual(pinfo.RegionID, region1, "Retrieved session is unexpectedly in region"); | ||
61 | |||
62 | success = m_Connector.ReportAgent(session1, region1); | ||
63 | Assert.AreEqual(success, true, "Failed to report session in region 1"); | ||
64 | |||
65 | pinfo = m_Connector.GetAgent(session1); | ||
66 | Assert.AreNotEqual(pinfo, null, "Unable to session presence"); | ||
67 | Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); | ||
68 | Assert.AreEqual(pinfo.RegionID, region1, "Retrieved session is not in expected region"); | ||
69 | |||
70 | success = m_Connector.LogoutAgent(session1); | ||
71 | Assert.AreEqual(success, true, "Failed to remove session"); | ||
72 | |||
73 | pinfo = m_Connector.GetAgent(session1); | ||
74 | Assert.AreEqual(pinfo, null, "Session is still there, even though it shouldn't"); | ||
75 | |||
76 | success = m_Connector.ReportAgent(session1, UUID.Random()); | ||
77 | Assert.AreEqual(success, false, "Remove non-existing session should fail"); | ||
78 | } | ||
79 | |||
80 | } | ||
81 | } | ||
diff --git a/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs new file mode 100644 index 0000000..2c327e8 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs | |||
@@ -0,0 +1,85 @@ | |||
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.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors; | ||
39 | |||
40 | namespace Robust.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class UserAccountsClient | ||
44 | { | ||
45 | [Test] | ||
46 | public void UserAccounts_001() | ||
47 | { | ||
48 | UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(DemonServer.Address); | ||
49 | |||
50 | string first = "Completely"; | ||
51 | string last = "Clueless"; | ||
52 | string email = "foo@bar.com"; | ||
53 | |||
54 | UserAccount account = m_Connector.CreateUser(first, last, "123", email, UUID.Zero); | ||
55 | Assert.IsNotNull(account, "Failed to create account " + first + " " + last); | ||
56 | UUID user1 = account.PrincipalID; | ||
57 | |||
58 | account = m_Connector.GetUserAccount(UUID.Zero, user1); | ||
59 | Assert.NotNull(account, "Failed to retrieve account for user id " + user1); | ||
60 | Assert.AreEqual(account.FirstName, first, "First name does not match"); | ||
61 | Assert.AreEqual(account.LastName, last, "Last name does not match"); | ||
62 | |||
63 | account = m_Connector.GetUserAccount(UUID.Zero, first, last); | ||
64 | Assert.IsNotNull(account, "Failed to retrieve account for user " + first + " " + last); | ||
65 | Assert.AreEqual(account.FirstName, first, "First name does not match (bis)"); | ||
66 | Assert.AreEqual(account.LastName, last, "Last name does not match (bis)"); | ||
67 | |||
68 | account.Email = "user@example.com"; | ||
69 | bool success = m_Connector.StoreUserAccount(account); | ||
70 | Assert.IsTrue(success, "Failed to store existing account"); | ||
71 | |||
72 | account = m_Connector.GetUserAccount(UUID.Zero, user1); | ||
73 | Assert.NotNull(account, "Failed to retrieve account for user id " + user1); | ||
74 | Assert.AreEqual(account.Email, "user@example.com", "Incorrect email"); | ||
75 | |||
76 | account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist"); | ||
77 | Assert.IsNull(account, "Account DoesNot Exit must not be there"); | ||
78 | |||
79 | account = new UserAccount(UUID.Zero, "DoesNot", "Exist", "xxx@xxx.com"); | ||
80 | success = m_Connector.StoreUserAccount(account); | ||
81 | Assert.IsFalse(success, "Storing a non-existing account must fail"); | ||
82 | } | ||
83 | |||
84 | } | ||
85 | } | ||