コード例 #1
0
        public void Paths_Expected_JSONSources()
        {
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var servicesPath  = Path.Combine(workspacePath, "Services");
            var sourcesPath   = Path.Combine(workspacePath, "Sources");
            var pluginsPath   = Path.Combine(workspacePath, "Plugins");

            try
            {
                Directory.CreateDirectory(servicesPath);
                Directory.CreateDirectory(sourcesPath);
                Directory.CreateDirectory(pluginsPath);

                var xml = XmlResource.Fetch("Calculate_RecordSet_Subtract");
                xml.Save(Path.Combine(servicesPath, "Calculate_RecordSet_Subtract.xml"));

                xml = XmlResource.Fetch("HostSecurityProviderServerSigned");
                xml.Save(Path.Combine(sourcesPath, "HostSecurityProviderServerSigned.xml"));

                var testResources = new Dev2.Runtime.ServiceModel.Resources();
                var actual        = testResources.Paths("", workspaceID, Guid.Empty);
                Assert.AreEqual("[\"Integration Test Services\\\\Calculate_RecordSet_Subtract\"]", actual);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #2
0
ファイル: EmailSourcesTests.cs プロジェクト: ndubul/Chillas
        public void EmailSourcesGetWithValidArgsExpectedReturnsSource()
        {
            var expected = CreateYahooSource();
            var saveArgs = expected.ToString();

            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                var handler = new EmailSources();
                handler.Save(saveArgs, workspaceID, Guid.Empty);

                var actual = handler.Get(expected.ResourceID.ToString(), workspaceID, Guid.Empty);

                VerifySource(actual, expected);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #3
0
        public void SourcesWithValidArgsExpectedReturnsList()
        {
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                const int Modulo        = 2;
                const int ExpectedCount = 6;
                for (var i = 0; i < ExpectedCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID   = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}", i),
                        ResourceType = (i % Modulo == 0) ? ResourceType.DbSource : ResourceType.Unknown
                    };
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                var result    = resources.Sources("{\"resourceType\":\"" + ResourceType.DbSource + "\"}", workspaceID, Guid.Empty);

                Assert.AreEqual(ExpectedCount / Modulo, result.Count);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #4
0
        public void WebSourcesGetWithValidArgsExpectedReturnsSource()
        {
            var expected = CreateWebSource();
            var saveArgs = expected.ToString();

            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                var handler = new WebSources();
                handler.Save(saveArgs, workspaceID, Guid.Empty);

                var actual = handler.Get(expected.ResourceID.ToString(), workspaceID, Guid.Empty);

                VerifySource(actual, expected);
            }
            finally
            {
                try
                {
                    if (Directory.Exists(workspacePath))
                    {
                        DirectoryHelper.CleanUp(workspacePath);
                    }
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch (Exception)
                // ReSharper restore EmptyGeneralCatchClause
                {
                }
            }
        }
コード例 #5
0
        public void DbServices_Save_ValidArgsAndEmptyResourceID_AssignsNewResourceID()
        {
            var svc = CreateDev2TestingDbService();

            svc.ResourceID = Guid.Empty;
            var args = svc.ToString();

            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                var services = new TestDbServices();

                //------------Execute Test---------------------------
                var result = services.Save(args, workspaceID, Guid.Empty);

                //Assert Assigns New Resource ID
                var service = JsonConvert.DeserializeObject <Service>(result);
                Assert.AreNotEqual(Guid.Empty, service.ResourceID);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #6
0
        public void DbServices_Save_ValidArgs_SavesXmlToDisk()
        {
            var svc           = CreateDev2TestingDbService();
            var args          = svc.ToString();
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var path          = workspacePath;
            var fileName      = String.Format("{0}\\{1}.xml", path, svc.ResourcePath);

            try
            {
                var services = new TestDbServices();

                //------------Execute Test---------------------------
                services.Save(args, workspaceID, Guid.Empty);

                //Assert Saves Xml To Disk
                var exists = File.Exists(fileName);
                Assert.IsTrue(exists);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #7
0
 public string GetResourcePath(Guid workspaceID)
 {
     if (FilePath == null && IsReservedService)
     {
         return(ResourceName);
     }
     return(FilePath?.Replace(EnvironmentVariables.GetWorkspacePath(workspaceID) + "\\", "").Replace(".xml", "").Replace(".bite", "") ?? "");
 }
コード例 #8
0
 public IExplorerItem Load(Guid workSpaceId, bool reload = false)
 {
     if (_root == null || reload)
     {
         _root = ExplorerItemFactory.CreateRootExplorerItem(EnvironmentVariables.GetWorkspacePath(workSpaceId), workSpaceId);
     }
     return(_root);
 }
コード例 #9
0
        // ReSharper disable InconsistentNaming
        public void Resources_UnitTest_PluginPathsAndNames_AllServicePathsExeptWorkflows()
        // ReSharper restore InconsistentNaming
        {
            //Isolate PathsAndNames for workflows as a functional unit
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                const int Modulo             = 3;
                const int TotalResourceCount = 9;
                for (var i = 0; i < TotalResourceCount; i++)
                {
                    var resource = new Resource
                    {
                        ResourceID   = Guid.NewGuid(),
                        ResourceName = string.Format("My Name {0}", i),
                        ResourcePath = string.Format("My Path {0}\\{1}", i, string.Format("My Name {0}", i))
                    };

                    switch (i % Modulo)
                    {
                    case 0:
                        resource.ResourcePath = ResourceType.WorkflowService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.WorkflowService;
                        break;

                    case 1:
                        resource.ResourcePath = ResourceType.DbService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.DbService;
                        break;

                    case 2:
                        resource.ResourcePath = ResourceType.PluginService + "\\" + resource.ResourceName;
                        resource.ResourceType = ResourceType.PluginService;
                        break;
                    }
                    ResourceCatalog.Instance.SaveResource(workspaceID, resource);
                }
                var          resources    = new Dev2.Runtime.ServiceModel.Resources();
                const string ExpectedJson = "{\"Names\":[\"My Name 1\",\"My Name 4\",\"My Name 7\"],\"Paths\":[\"DbService\"]}";

                //Run PathsAndNames
                var actualJson = resources.PathsAndNames("DbService", workspaceID, Guid.Empty);

                //Assert CorrectListReturned
                Assert.AreEqual(ExpectedJson, actualJson, "Incorrect list of names and paths for workflow services");
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #10
0
        public void EnvironmentVariables_GetWorkspacePath_GuidEmpty()
        {
            //------------Setup for test--------------------------
            const string folderPart = "ProgramData\\Warewolf\\Resources";
            //------------Execute Test---------------------------
            var folderPath = EnvironmentVariables.GetWorkspacePath(Guid.Empty);

            //------------Assert Results-------------------------
            StringAssert.Contains(folderPath, folderPart);
        }
コード例 #11
0
        public void GetLatest(IWorkspace workspace, IList <string> servicesToIgnore)
        {
            lock (_readLock)
            {
                var filesToIgnore = servicesToIgnore.Select(s => s + ".bite").ToList();

                var targetPath = EnvironmentVariables.GetWorkspacePath(workspace.ID);
                _resourceCatalog.SyncTo(ServerWorkspacePath, targetPath, true, true, filesToIgnore);
            }
        }
コード例 #12
0
 /// <summary>
 /// Overwrites this workspace with the server versions except for those provided.
 /// </summary>
 /// <param name="workspace">The workspace to be queried.</param>
 /// <param name="servicesToIgnore">The services being to be ignored.</param>
 public void GetLatest(IWorkspace workspace, IList <string> servicesToIgnore)
 {
     lock (_readLock)
     {
         // ReSharper disable RedundantAssignment
         var filesToIgnore = servicesToIgnore.Select(s => s += ".xml").ToList();
         // ReSharper restore RedundantAssignment
         var targetPath = EnvironmentVariables.GetWorkspacePath(workspace.ID);
         _resourceCatalog.SyncTo(ServerWorkspacePath, targetPath, true, true, filesToIgnore);
     }
 }
コード例 #13
0
        public void EnvironmentVariables_GetWorkspacePath_Guid()
        {
            var guid = new Guid("c550ca0d-d324-45de-92bb-0c91879eb8b3");
            //------------Setup for test--------------------------
            const string folderPart = "ProgramData\\Warewolf\\Workspaces\\c550ca0d-d324-45de-92bb-0c91879eb8b3\\Resources";
            //------------Execute Test---------------------------
            var folderPath = EnvironmentVariables.GetWorkspacePath(guid);

            //------------Assert Results-------------------------
            StringAssert.Contains(folderPath, folderPart);
        }
コード例 #14
0
        public void PluginServicesMethodsWithReturnsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.MethodsWithReturns(service);

            Assert.AreEqual(7, result.Count);
        }
コード例 #15
0
        public void Iterate(string resourcePath, Guid workspaceID, Func <ResourceIteratorResult, bool> action, params ResourceDelimiter[] delimiters)
        {
            if (delimiters == null || delimiters.Length == 0 || action == null || string.IsNullOrEmpty(resourcePath))
            {
                return;
            }

            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var folders       = new List <string> {
                workspacePath
            };

            folders.AddRange(Directory.EnumerateDirectories(workspacePath, "*", SearchOption.AllDirectories));
            foreach (var path in folders.Select(folder => Path.Combine(workspacePath, folder)))
            {
                if (Directory.Exists(path))
                {
                    var files = Directory.GetFiles(path, "*.xml");
                    foreach (var file in files)
                    {
                        if (!string.IsNullOrEmpty(resourcePath))
                        {
                            if (!file.Contains(resourcePath))
                            {
                                continue;
                            }
                        }
                        // XML parsing will add overhead - so just read file and use string ops instead
                        var content        = File.ReadAllText(file);
                        var iteratorResult = new ResourceIteratorResult {
                            Content = content
                        };
                        var delimiterFound = false;
                        foreach (var delimiter in delimiters)
                        {
                            string value;
                            if (delimiter.TryGetValue(content, out value))
                            {
                                delimiterFound = true;
                                iteratorResult.Values.Add(delimiter.ID, value);
                            }
                        }
                        if (delimiterFound)
                        {
                            if (!action(iteratorResult))
                            {
                                return;
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
        public void ComPluginServicesMethodsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new ComPluginServices();
            var result   = services.Methods(service, workspaceID, Guid.Empty);

            Assert.IsTrue(result.Count > 5, "Not enough items in COM server method list.");
        }
コード例 #17
0
        public void PluginServicesConstructorsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.Constructors(service, workspaceID, Guid.Empty);

            Assert.AreEqual(2, result.Count);
        }
コード例 #18
0
        public void ComPluginServicesNamespacesWithValidArgsExpectedReturnsList()
        {
            var source      = CreatePluginSource();
            var args        = source.ToString();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new ComPluginServices();
            var result   = services.Namespaces(source, workspaceID, Guid.Empty);

            Assert.IsTrue(result.Count > 0);
        }
コード例 #19
0
        public void PluginServicesNamespacesWithValidArgsExpectedReturnsList()
        {
            var source      = CreatePluginSource();
            var args        = source.ToString();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.Namespaces(source, workspaceID, Guid.Empty);

            // DO NOT assert equality on Count as this will
            // change as new namespaces are added to this assembly!
            Assert.IsTrue(result.Count > 0);
        }
コード例 #20
0
        public string SetResourceFilePath(Guid workspaceID, IResource resource, ref string savedPath)
        {
            if (savedPath.EndsWith("\\"))
            {
                savedPath = savedPath.TrimEnd('\\');
            }
            if (savedPath.StartsWith("\\"))
            {
                savedPath = savedPath.TrimStart('\\');
            }
            var workspacePath    = EnvironmentVariables.GetWorkspacePath(workspaceID);
            var directoryName    = Path.Combine(workspacePath, savedPath);
            var resourceFilePath = Path.Combine(directoryName, resource.ResourceName + ".bite");

            resource.FilePath = resourceFilePath;
            return(directoryName);
        }
コード例 #21
0
        public void DBServices_DbMethods_ValidArgs_ReturnsList()
        {
            var source          = SqlServerTests.CreateDev2TestingDbSource();
            var args            = source.ToString();
            var workspaceID     = Guid.NewGuid();
            var resourceCatalog = new Mock <IResourceCatalog>();

            resourceCatalog.Setup(catalog => catalog.GetResource <DbSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(source);
            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new TestDbServices(resourceCatalog.Object);

            //------------Execute Test---------------------------
            var result = services.DbMethods(args, workspaceID, Guid.Empty);

            // Assert Returns Valid List
            Assert.IsTrue(result.Count >= 25, "DbMethods does not return a list");
        }
コード例 #22
0
ファイル: ResourcesTests.cs プロジェクト: ndubul/Chillas
        public void DataListInputWhereValidArgsDataListHasNoInputsExpectEmptyString()
        {
            //------------Setup for test--------------------------
            LoadActivitiesPresentationDll();
            var workspaceID = Guid.NewGuid();

            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                string completePath = Path.Combine(workspacePath, "Bugs");
                if (Directory.Exists(completePath))
                {
                    Directory.Delete(completePath);
                }
                var xml          = XmlResource.Fetch("Bug6619");
                var resourcePath = xml.Element("Category");
                Directory.CreateDirectory(completePath);
                Assert.IsNotNull(resourcePath);
                xml.Save(Path.Combine(workspacePath, resourcePath.Value + ".xml"));
                var resources = new Resources();
                //-----------------Assert Preconditions-----------------------------
                Assert.IsNotNull(resourcePath);
                var resource = ResourceCatalog.Instance.GetResource(workspaceID, resourcePath.Value);
                Assert.IsNotNull(resource);
                //------------Execute Test---------------------------
                var dataListInputVariables = resources.DataListInputVariables(resource.ResourceID.ToString(), workspaceID, Guid.Empty);
                //------------Assert Results-------------------------
                Assert.IsTrue(string.IsNullOrEmpty(dataListInputVariables));
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #23
0
        public void DBServices_Get_ValidArgs_ReturnsService()
        {
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                //------------Setup for test--------------------------
                var svc     = CreateDev2TestingDbService();
                var getArgs = string.Format("{{\"resourceID\":\"{0}\",\"resourceType\":\"{1}\"}}", svc.ResourceID, ResourceType.DbService);

                var resourceCatalog = new Mock <IResourceCatalog>();
                resourceCatalog.Setup(c => c.GetResourceContents(workspaceID, svc.ResourceID))
                .Returns((Guid wsID, Guid resourceID) => svc.ToXml().ToStringBuilder())
                .Verifiable();

                var services = new TestDbServices(resourceCatalog.Object);

                //------------Execute Test---------------------------
                var getResult = services.Get(getArgs, workspaceID, Guid.Empty);

                //------------Assert Results-------------------------
                resourceCatalog.Verify(c => c.GetResourceContents(workspaceID, svc.ResourceID));

                Assert.AreEqual(svc.ResourceID, getResult.ResourceID);
                Assert.AreEqual(svc.ResourceName, getResult.ResourceName);
                Assert.AreEqual(svc.ResourcePath, getResult.ResourcePath);
                Assert.AreEqual(svc.ResourceType, getResult.ResourceType);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #24
0
        public void DataListInputWhereValidArgsDataListHasInputsScalarsAndRecSetExpectCorrectString()
        {
            //------------Setup for test--------------------------
            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                string completePath = Path.Combine(workspacePath, "Mo");
                if (Directory.Exists(completePath))
                {
                    Directory.Delete(completePath);
                }
                var xml          = XmlResource.Fetch("TestForEachOutput");
                var resourcePath = xml.Element("Category");
                Directory.CreateDirectory(completePath);
                Assert.IsNotNull(resourcePath);
                xml.Save(Path.Combine(workspacePath, resourcePath.Value + ".xml"));
                var resources = new Dev2.Runtime.ServiceModel.Resources();
                //---------------Assert Preconditions------------------------------
                Assert.IsNotNull(resourcePath);
                var resource = ResourceCatalog.Instance.GetResource(workspaceID, resourcePath.Value);
                Assert.IsNotNull(resource);
                //------------Execute Test---------------------------
                var dataListInputVariables = resources.DataListInputVariables(resource.ResourceID.ToString(), workspaceID, Guid.Empty);
                //------------Assert Results-------------------------
                StringAssert.Contains(dataListInputVariables, "inputScalar");
                StringAssert.Contains(dataListInputVariables, "bothScalar");
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
コード例 #25
0
 public IExplorerItem Load(string type, Guid workSpaceId)
 {
     return(ExplorerItemFactory.CreateRootExplorerItem(type, EnvironmentVariables.GetWorkspacePath(workSpaceId), workSpaceId));
 }
コード例 #26
0
 public IExplorerItem Load(string type, string filter)
 {
     return(ExplorerItemFactory.CreateRootExplorerItem(type, Path.Combine(EnvironmentVariables.GetWorkspacePath(Guid.Empty), filter), Guid.Empty));
 }
コード例 #27
0
 static ServerExplorerRepository()
 {
     Instance = new ServerExplorerRepository
     {
         ResourceCatalogue   = ResourceCatalog.Instance,
         TestCatalog         = Runtime.TestCatalog.Instance,
         ExplorerItemFactory = new ExplorerItemFactory(ResourceCatalog.Instance, new DirectoryWrapper(), ServerAuthorizationService.Instance),
         Directory           = new DirectoryWrapper(),
         VersionRepository   = new ServerVersionRepository(new VersionStrategy(), ResourceCatalog.Instance, new DirectoryWrapper(), EnvironmentVariables.GetWorkspacePath(GlobalConstants.ServerWorkspaceID), new FileWrapper())
     };
 }
コード例 #28
0
        List <IResource> LoadWorkspaceImpl(Guid workspaceID)
        {
            var workspacePath = workspaceID == GlobalConstants.ServerWorkspaceID ? EnvironmentVariables.ResourcePath : EnvironmentVariables.GetWorkspacePath(workspaceID);
            IList <IResource> userServices = new List <IResource>();

            if (Directory.Exists(workspacePath))
            {
                var folders    = Directory.EnumerateDirectories(workspacePath, "*", SearchOption.AllDirectories);
                var allFolders = folders.ToList();
                allFolders.Add(workspacePath);
                userServices = LoadWorkspaceViaBuilder(workspacePath, workspaceID == GlobalConstants.ServerWorkspaceID, allFolders.ToArray());
            }
            var result    = userServices.Union(ManagementServices.Values);
            var resources = result.ToList();

            return(resources);
        }
コード例 #29
0
 public ResourceCatalog(IEnumerable <DynamicService> managementServices)
 {
     InitializeWorkspaceResources();
     _serverVersionRepository = new ServerVersionRepository(new VersionStrategy(), this, _directoryWrapper, EnvironmentVariables.GetWorkspacePath(GlobalConstants.ServerWorkspaceID), new FileWrapper(), new FilePathWrapper());
     _catalogPluginContainer  = new ResourceCatalogPluginContainer(_serverVersionRepository, WorkspaceResources, managementServices);
     _catalogPluginContainer.Build(this);
 }
コード例 #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceCatalog" /> class.
        /// <remarks>
        /// DO NOT instantiate directly - use static Instance property instead; this is for testing only!
        /// </remarks>
        /// </summary>
        /// <param name="managementServices">The management services to be loaded.</param>
        public ResourceCatalog(IEnumerable <DynamicService> managementServices = null)
        {
            InitializeWorkspaceResources();
            // MUST load management services BEFORE server workspace!!
            IServerVersionRepository versioningRepository = new ServerVersionRepository(new VersionStrategy(), this, new DirectoryWrapper(), EnvironmentVariables.GetWorkspacePath(GlobalConstants.ServerWorkspaceID), new FileWrapper());

            _catalogPluginContainer = new ResourceCatalogPluginContainer(versioningRepository, WorkspaceResources, managementServices);
            _catalogPluginContainer.Build(this);
        }