get TestSaveIarV0_1() uncommented but not running as a test yet since I didn't get the authentication server to work and my brain is about to fizzle out my ears

soprefactor
Justin Clark-Casey (justincc) 2010-05-28 23:14:24 +01:00
parent a60ca5236c
commit 191db0e6a4
4 changed files with 130 additions and 102 deletions

View File

@ -76,125 +76,118 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Commenting for now! The mock inventory service needs more beef, at least for // Commenting for now! The mock inventory service needs more beef, at least for
// GetFolderForType // GetFolderForType
// REFACTORING PROBLEM. This needs to be rewritten. // REFACTORING PROBLEM. This needs to be rewritten.
//[Test]
public void TestSaveIarV0_1()
{
TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure();
// [Test] InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
// public void TestSaveIarV0_1()
// {
// TestHelper.InMethod();
// //log4net.Config.XmlConfigurator.Configure();
// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); Scene scene = SceneSetupHelpers.SetupScene("Inventory");
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
// Scene scene = SceneSetupHelpers.SetupScene("Inventory"); // Create user
// SceneSetupHelpers.SetupSceneModules(scene, archiverModule); string userFirstName = "Jock";
// CommunicationsManager cm = scene.CommsManager; string userLastName = "Stirrup";
string userPassword = "troll";
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
// // Create user // Create asset
// string userFirstName = "Jock"; SceneObjectGroup object1;
// string userLastName = "Stirrup"; SceneObjectPart part1;
// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); {
string partName = "My Little Dog Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
// lock (this) part1
// { = new SceneObjectPart(
// UserProfileTestUtils.CreateUserWithInventory( ownerId, shape, groupPosition, rotationOffset, offsetPosition);
// cm, userFirstName, userLastName, userId, InventoryReceived); part1.Name = partName;
// Monitor.Wait(this, 60000);
// }
// // Create asset object1 = new SceneObjectGroup(part1);
// SceneObjectGroup object1; scene.AddNewSceneObject(object1, false);
// SceneObjectPart part1; }
// {
// string partName = "My Little Dog Object";
// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
// Vector3 groupPosition = new Vector3(10, 20, 30);
// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
// Vector3 offsetPosition = new Vector3(5, 10, 15);
// part1 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
// = new SceneObjectPart( AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
// ownerId, shape, groupPosition, rotationOffset, offsetPosition); scene.AssetService.Store(asset1);
// part1.Name = partName;
// object1 = new SceneObjectGroup(part1); // Create item
// scene.AddNewSceneObject(object1, false); UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
// } InventoryItemBase item1 = new InventoryItemBase();
item1.Name = "My Little Dog";
item1.AssetID = asset1.FullID;
item1.ID = item1Id;
InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
item1.Folder = objsFolder.ID;
scene.AddInventoryItem(userId, item1);
// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); MemoryStream archiveWriteStream = new MemoryStream();
// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); archiverModule.OnInventoryArchiveSaved += SaveCompleted;
// scene.AssetService.Store(asset1);
// // Create item mre.Reset();
// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); archiverModule.ArchiveInventory(
// InventoryItemBase item1 = new InventoryItemBase(); Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
// item1.Name = "My Little Dog"; mre.WaitOne(60000, false);
// item1.AssetID = asset1.FullID;
// item1.ID = item1Id;
// InventoryFolderBase objsFolder
// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
// item1.Folder = objsFolder.ID;
// scene.AddInventoryItem(userId, item1);
// MemoryStream archiveWriteStream = new MemoryStream(); byte[] archive = archiveWriteStream.ToArray();
// archiverModule.OnInventoryArchiveSaved += SaveCompleted; MemoryStream archiveReadStream = new MemoryStream(archive);
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
// mre.Reset(); //bool gotControlFile = false;
// archiverModule.ArchiveInventory( bool gotObject1File = false;
// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); //bool gotObject2File = false;
// mre.WaitOne(60000, false); string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
string expectedObject1FilePath = string.Format(
"{0}{1}{2}",
ArchiveConstants.INVENTORY_PATH,
InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
expectedObject1FileName);
// byte[] archive = archiveWriteStream.ToArray(); string filePath;
// MemoryStream archiveReadStream = new MemoryStream(archive); TarArchiveReader.TarEntryType tarEntryType;
// TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
// //bool gotControlFile = false;
// bool gotObject1File = false;
// //bool gotObject2File = false;
// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
// string expectedObject1FilePath = string.Format(
// "{0}{1}{2}",
// ArchiveConstants.INVENTORY_PATH,
// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
// expectedObject1FileName);
// string filePath;
// TarArchiveReader.TarEntryType tarEntryType;
// Console.WriteLine("Reading archive"); // Console.WriteLine("Reading archive");
// while (tar.ReadEntry(out filePath, out tarEntryType) != null) while (tar.ReadEntry(out filePath, out tarEntryType) != null)
// { {
// Console.WriteLine("Got {0}", filePath); Console.WriteLine("Got {0}", filePath);
//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) // if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
//// {
//// gotControlFile = true;
//// }
// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
// { // {
//// string fileName = filePath.Remove(0, "Objects/".Length); // gotControlFile = true;
////
//// if (fileName.StartsWith(part1.Name))
//// {
// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
// gotObject1File = true;
//// }
//// else if (fileName.StartsWith(part2.Name))
//// {
//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
//// gotObject2File = true;
//// }
// } // }
// }
//// Assert.That(gotControlFile, Is.True, "No control file in archive"); if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
// Assert.That(gotObject1File, Is.True, "No item1 file in archive"); {
//// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); // string fileName = filePath.Remove(0, "Objects/".Length);
//
// if (fileName.StartsWith(part1.Name))
// {
Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
gotObject1File = true;
// }
// else if (fileName.StartsWith(part2.Name))
// {
// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
// gotObject2File = true;
// }
}
}
// // TODO: Test presence of more files and contents of files. // Assert.That(gotControlFile, Is.True, "No control file in archive");
// } Assert.That(gotObject1File, Is.True, "No item1 file in archive");
// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
// TODO: Test presence of more files and contents of files.
}
/// <summary> /// <summary>
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where

View File

@ -376,6 +376,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="mod"></param> /// <param name="mod"></param>
public void RegisterModuleInterface<M>(M mod) public void RegisterModuleInterface<M>(M mod)
{ {
m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M));
List<Object> l = null; List<Object> l = null;
if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) if (!ModuleInterfaces.TryGetValue(typeof(M), out l))
{ {

View File

@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.Agent.Capabilities; using OpenSim.Region.CoreModules.Agent.Capabilities;
using OpenSim.Region.CoreModules.Avatar.Gods; using OpenSim.Region.CoreModules.Avatar.Gods;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
@ -58,6 +59,7 @@ namespace OpenSim.Tests.Common.Setup
// These static variables in order to allow regions to be linked by shared modules and same // These static variables in order to allow regions to be linked by shared modules and same
// CommunicationsManager. // CommunicationsManager.
private static ISharedRegionModule m_assetService = null; private static ISharedRegionModule m_assetService = null;
// private static ISharedRegionModule m_authenticationService = null;
private static ISharedRegionModule m_inventoryService = null; private static ISharedRegionModule m_inventoryService = null;
private static ISharedRegionModule m_gridService = null; private static ISharedRegionModule m_gridService = null;
private static ISharedRegionModule m_userAccountService = null; private static ISharedRegionModule m_userAccountService = null;
@ -178,6 +180,9 @@ namespace OpenSim.Tests.Common.Setup
else else
StartAssetService(testScene, false); StartAssetService(testScene, false);
// For now, always started a 'real' authenication service
StartAuthenticationService(testScene, true);
if (realServices.Contains("inventory")) if (realServices.Contains("inventory"))
StartInventoryService(testScene, true); StartInventoryService(testScene, true);
else else
@ -243,6 +248,27 @@ namespace OpenSim.Tests.Common.Setup
m_assetService = assetService; m_assetService = assetService;
} }
private static void StartAuthenticationService(Scene testScene, bool real)
{
ISharedRegionModule service = new LocalAuthenticationServicesConnector();
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AuthenticationService");
config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
if (real)
config.Configs["AuthenticationService"].Set(
"LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
else
config.Configs["AuthenticationService"].Set(
"LocalServiceModule", "OpenSim.Tests.Common.dll:MockuthenticationService");
config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
service.Initialise(config);
service.AddRegion(testScene);
service.RegionLoaded(testScene);
testScene.AddRegionModule(service.Name, service);
//m_authenticationService = service;
}
private static void StartInventoryService(Scene testScene, bool real) private static void StartInventoryService(Scene testScene, bool real)
{ {
ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();

View File

@ -117,10 +117,17 @@ namespace OpenSim.Tests.Common.Setup
public static UserAccount CreateUserWithInventory(Scene scene) public static UserAccount CreateUserWithInventory(Scene scene)
{ {
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); return CreateUserWithInventory(
UserAccount ua = new UserAccount(userId) { FirstName = "Bill", LastName = "Bailey" }; scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll");
}
public static UserAccount CreateUserWithInventory(
Scene scene, string firstName, string lastName, UUID userId, string pw)
{
UserAccount ua = new UserAccount(userId) { FirstName = firstName, LastName = lastName };
scene.UserAccountService.StoreUserAccount(ua); scene.UserAccountService.StoreUserAccount(ua);
scene.InventoryService.CreateUserInventory(ua.PrincipalID); scene.InventoryService.CreateUserInventory(ua.PrincipalID);
scene.AuthenticationService.SetPassword(ua.PrincipalID, pw);
return ua; return ua;
} }