CreateValidExampleApplication() public static method

Creates a valid example application structure in a random destination directory and returns the path to the directory.
public static CreateValidExampleApplication ( ) : string
return string
コード例 #1
0
        public void BootstrapsPullUpAndExecuteJob()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp(true).ResultType);

                CreateFileJob job = new CreateFileJob()
                {
                    Path = Path.Combine(path, Path.GetRandomFileName())
                };

                Assert.IsFalse(File.Exists(job.Path));

                // The default configuration specifies a SQLite repository pointing
                // to BlueCollar.sqlite in the application's root directory.
                using (IRepository repository = new SQLiteRepository(string.Format(CultureInfo.InvariantCulture, "data source={0};journal mode=Off;synchronous=Off;version=3", Path.Combine(path, "BlueCollar.sqlite"))))
                {
                    job.Enqueue("Default", null, repository);
                }

                // Default worker heartbeat is 5 seconds.
                Thread.Sleep(6000);
                Assert.IsTrue(File.Exists(job.Path));
            }
        }
コード例 #2
0
        public void ApplicationProcessStopForce()
        {
            string           path   = ApplicationUtils.CreateValidExampleApplication();
            ManualResetEvent handle = new ManualResetEvent(false);

            try
            {
                using (ApplicationProcess process = new ApplicationProcess(Logger, path, Path.GetFullPath("Collar.exe")))
                {
                    process.Exited += (object sender, EventArgs e) =>
                    {
                        Assert.Fail();
                        handle.Set();
                    };

                    process.KillTimeout += (object sender, EventArgs e) =>
                    {
                        Assert.Fail();
                        handle.Set();
                    };

                    Assert.IsTrue(process.Start());
                    process.Stop(true);
                    WaitHandle.WaitAll(new WaitHandle[] { handle }, 11000);
                }
            }
            finally
            {
                handle.Close();
            }
        }
コード例 #3
0
        public void ApplicationCoordinatorRefreshRemove()
        {
            ApplicationElement element1 = new ApplicationElement()
            {
                ApplicationPath = ApplicationUtils.CreateValidExampleApplication(), Framework = Framework
            };
            ApplicationElement element2 = new ApplicationElement()
            {
                ApplicationPath = ApplicationUtils.CreateValidExampleApplication(), Framework = Framework
            };
            ApplicationElement element3 = new ApplicationElement()
            {
                ApplicationPath = ApplicationUtils.CreateValidExampleApplication(), Framework = Framework
            };

            using (ApplicationCoordinator coordinator = new ApplicationCoordinator(Logger, Path.GetFullPath("Collar.exe")))
            {
                coordinator.StartAndRefresh(new ApplicationElement[] { element1, element2, element3 });
                Assert.IsTrue(coordinator.IsRunning);

                var paths = coordinator.GetCoordinatedApplicationPaths();
                Assert.AreEqual(3, coordinator.Count);
                Assert.IsTrue(paths.Contains(element1.ApplicationPath));
                Assert.IsTrue(paths.Contains(element2.ApplicationPath));
                Assert.IsTrue(paths.Contains(element3.ApplicationPath));

                coordinator.StartAndRefresh(new ApplicationElement[] { element1, element3 });
                Assert.IsTrue(coordinator.IsRunning);

                paths = coordinator.GetCoordinatedApplicationPaths();
                Assert.AreEqual(2, coordinator.Count);
                Assert.IsTrue(paths.Contains(element1.ApplicationPath));
                Assert.IsTrue(paths.Contains(element3.ApplicationPath));
            }
        }
コード例 #4
0
        public void BootstrapsBasicApplicationFileChange()
        {
            string           path     = ApplicationUtils.CreateValidExampleApplication();
            string           filePath = Path.Combine(path, Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".dll");
            ManualResetEvent handle   = new ManualResetEvent(false);

            try
            {
                using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
                {
                    bootstraps.ApplicationFilesChanged += (sender, e) =>
                    {
                        Assert.AreEqual(filePath, e.FullPath);
                        handle.Set();
                    };

                    Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);

                    using (File.Create(filePath))
                    {
                    }

                    WaitHandle.WaitAll(new WaitHandle[] { handle });
                }
            }
            finally
            {
                handle.Close();
            }
        }
コード例 #5
0
        public void BootstrapsPullUpAndExcecuteJobWithHttpApplicationEntryPoint()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp(true).ResultType);

                CreateFileJob job = new CreateFileJob()
                {
                    Path = Path.Combine(path, Path.GetRandomFileName())
                };

                Assert.IsFalse(File.Exists(job.Path));

                using (IRepository repository = new SQLiteRepository(string.Format(CultureInfo.InvariantCulture, "data source={0};journal mode=Off;synchronous=Off;version=3", Path.Combine(path, "BlueCollar.sqlite"))))
                {
                    job.Enqueue("Default", null, repository);
                }

                Thread.Sleep(6000);
                Assert.IsTrue(File.Exists("HttpApplicationStart"));

                bootstraps.Pushdown(true);
                Assert.IsTrue(File.Exists("HttpApplicationEnd"));
            }
        }
コード例 #6
0
        public void ApplicationProcessStart()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (ApplicationProcess process = new ApplicationProcess(Logger, path, Path.GetFullPath("Collar.exe")))
            {
                Assert.IsTrue(process.Start());
            }
        }
コード例 #7
0
        public void BootstrapsPullUpBasicApplication()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                Assert.AreEqual(BootstrapsPullupResultType.Success, bootstraps.PullUp().ResultType);
                Assert.IsTrue(bootstraps.IsLoaded);
            }
        }
コード例 #8
0
        public void BootstrapsPullUpFail()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            File.Delete(Path.Combine(path, "BlueCollar.dll"));

            using (Bootstraps bootstraps = new Bootstraps(path, null, 500))
            {
                BootstrapsPullupResult result = bootstraps.PullUp();
                Assert.AreEqual(BootstrapsPullupResultType.Exception, result.ResultType);
                Assert.IsNotNull(result.Exception);
            }
        }
コード例 #9
0
        public void BootstrapsBasicApplicationAssembliesNotLocked()
        {
            string path = ApplicationUtils.CreateValidExampleApplication();

            AssembliesNotLocked(path, Path.Combine(path, "BlueCollar.dll"));
        }