public void FixtureSetUp()
        {
            //FubuTransport.AllQueuesInMemory = true;

            runtime = FubuRuntime.For <TestingJobRegistry>();

            history        = runtime.Get <JobHistory>();
            clock          = runtime.Get <ISystemTime>().As <RewindableClock>();
            theController  = runtime.Get <IScheduledJobController>();
            thePersistence = runtime.Get <ISchedulePersistence>();
            theTimer       = runtime.Get <IJobTimer>();

            theController.Deactivate();
            theTimer.ClearAll();
            history.ClearAll();

            theStartingTime = (DateTimeOffset)DateTime.Today.AddHours(8).ToUniversalTime();

            theEndingTime = theStartingTime.AddSeconds(30);

            addTimes <Job1>(3);
            addTimes <Job2>(10);
            addTimes <Job3>(15);

            clock.Reset(theStartingTime.DateTime);

            theController.Activate();

            theController.IsActive().ShouldBeTrue();

            Thread.Sleep(32.Seconds());

            theController.Deactivate();
        }
Beispiel #2
0
        public void SetUp()
        {
            TestMessageRecorder.Clear();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2040/downstream".ToUri()
            };
            var lightningUri = settings.Downstream.ToLightningUri();


            _runtime = FubuRuntime.For <ErrorRegistry>(x =>
            {
                x.Services.For <BusSettings>().Use(settings);
            });


            _runtime.Get <IPersistentQueues>().ClearAll();

            theServiceBus = _runtime.Get <IServiceBus>();

            _queueManager = _runtime.Get <IPersistentQueues>().PersistentManagerFor(lightningUri.Port, true);

            message1 = new OneMessage();

            theServiceBus.Send(message1);
        }
        public void SetUp()
        {
            runtime = FubuRuntime.BasicBus();
            runtime.Get <IContainer>().UseInMemoryDatastore();

            thePersistence = runtime.Get <RavenDbSchedulePersistence>();

            foo1 = new JobStatusDTO {
                JobKey = "1", NodeName = "foo"
            };
            foo2 = new JobStatusDTO {
                JobKey = "2", NodeName = "foo"
            };
            foo3 = new JobStatusDTO {
                JobKey = "3", NodeName = "foo"
            };
            bar1 = new JobStatusDTO {
                JobKey = "1", NodeName = "bar"
            };
            bar2 = new JobStatusDTO {
                JobKey = "2", NodeName = "bar"
            };

            thePersistence.Persist(new[] { foo1, foo2, foo3, bar1, bar2 });
        }
Beispiel #4
0
        public void the_polling_job_chains_are_tagged_for_no_tracing()
        {
            var graph  = theRuntime.Get <BehaviorGraph>();
            var chains = graph.PollingJobs;

            chains.Each(x => x.IsTagged(BehaviorChain.NoTracing).ShouldBeTrue());
        }
        public void SetUp()
        {
            runtime = FubuRuntime.BasicBus();
            runtime.Get <IContainer>().UseInMemoryDatastore();

            persistence = runtime.Get <RavenDbSubscriptionPersistence>();
        }
Beispiel #6
0
        public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null)
        {
            settings = settings ?? runtime.Get<OwinSettings>();
            var host = new FubuOwinHost(runtime.Routes);
            AppFunc inner = host.Invoke;
            AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Get<IServiceFactory>());

            var diagnostics = runtime.Get<DiagnosticsSettings>();
            return diagnostics.WrapAppFunc(runtime, appFunc);
        }
Beispiel #7
0
        public void the_scheduled_job_chains_are_present()
        {
            var graph  = theRuntime.Get <BehaviorGraph>();
            var chains = graph.Chains.Where(x => x.InputType() != null && x.InputType().Closes(typeof(ExecuteScheduledJob <>)));

            chains.ShouldHaveCount(3);
        }
Beispiel #8
0
        public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null)
        {
            settings = settings ?? runtime.Get <OwinSettings>();
            var     host    = new FubuOwinHost(runtime.Routes);
            AppFunc inner   = host.Invoke;
            AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Get <IServiceFactory>());

            var diagnostics = runtime.Get <DiagnosticsSettings>();

            return(diagnostics.WrapAppFunc(runtime, appFunc));
        }
Beispiel #9
0
        public void StartUp()
        {
            try
            {
                _server = _registry.ToRuntime();

                GlobalMessageTracking.SendMessage(new ApplicationStarted
                {
                    ApplicationName = _registry.GetType().Name,
                    HomeAddress     = _server.BaseAddress,
                    Timestamp       = DateTime.Now,
                    Watcher         = _server.Get <AssetSettings>().CreateFileWatcherManifest(_server.Files)
                });
            }
            catch (HostingFailedException e)
            {
                GlobalMessageTracking.SendMessage(new InvalidApplication
                {
                    ExceptionText = e.Message,
                    Message       = "Access denied."
                });
            }
            catch (Exception e)
            {
                GlobalMessageTracking.SendMessage(new InvalidApplication
                {
                    ExceptionText = e.ToString(),
                    Message       = "Bootstrapping {0} Failed!".ToFormat(_registry.GetType().Name)
                });
            }
        }
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2050/downstream".ToUri()
            };


            theClock = new SettableClock();


            _runtime = FubuRuntime.For <DelayedRegistry>(_ =>
            {
                _.Services.ReplaceService(settings);
                _.Services.ReplaceService <ISystemTime>(theClock);
            });

            theServiceBus = _runtime.Get <IServiceBus>();
            //_runtime.Get<IPersistentQueues>().ClearAll();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            Debug.WriteLine("The current Utc time is " + theClock.UtcNow());

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
        public void disabled_jobs_are_not_executed_or_started()
        {
            DisabledJob.Executed.ShouldBe(0);
            theRuntime.Get<IPollingJobs>().IsActive<DisabledJob>()
                .ShouldBeFalse();

        }
Beispiel #12
0
        public void SetUp()
        {
            _runtime  = FubuRuntime.For <ApplicationRegistry>();
            behaviors = _runtime.Get <BehaviorGraph>();

            appChain = behaviors.ChainFor <ApplicationActions>(x => x.get_app_action());
            pakChain = behaviors.ChainFor <PackageActions>(x => x.get_pak_action());
        }
Beispiel #13
0
        public void got_all_the_routes_in_the_diagnostic_javascript_router()
        {
            var routes = runtime.Get <DiagnosticJavascriptRoutes>();
            var names  = routes.Routes().Select(x => x.Name).ToArray();

            names.ShouldContain("StructureMap:summary");
            names.ShouldContain("Chain:chain_details_Hash");
            names.ShouldContain("Requests:requests");
        }
Beispiel #14
0
        public void SetUp()
        {
            OneJob.Executed = TwoJob.Executed = ThreeJob.Executed = 0;

            theRuntime = FubuRuntime.For <PollingRegistry>();
            theRuntime.Behaviors.PollingJobs.Any().ShouldBeTrue();

            container = theRuntime.Get <IContainer>();

            Wait.Until(() => ThreeJob.Executed > 10, timeoutInMilliseconds: 6000);
        }
        public void AuthenticationSetup()
        {
            var registry = new FubuRegistry();

            configure(registry);

            registry.Features.Authentication.Enable(true);

            server       = registry.ToRuntime();
            theContainer = server.Get <IContainer>();

            beforeEach();
        }
Beispiel #16
0
        public void SetUp()
        {
            var container = new Container(x => {
                x.For <SubscriptionSettings>().Use(theSettings);
            });

            var registry = new SubscriptionRegistry();

            registry.StructureMap(container);

            _runtime = registry.ToRuntime();

            theCache = _runtime.Get <ISubscriptionCache>().As <SubscriptionCache>();
        }
        public void SetUp()
        {
            var registry = new RoutedRegistry();

            var container = new Container();

            settings = InMemoryTransport.ToInMemory <HarnessSettings>();
            container.Inject(settings);

            registry.StructureMap(container);

            runtime = registry.ToRuntime();

            theRouter = runtime.Get <ISubscriptionCache>();
        }
Beispiel #18
0
        private AuthorizationPreviewService withAuthorizationRules(Action <BehaviorGraph> configure)
        {
            var registry = new FubuRegistry();


            registry.Actions.IncludeType <OneController>();
            registry.Actions.IncludeType <TwoController>();

            registry.Configure(configure);


            _runtime = registry.ToRuntime();


            return(_runtime.Get <AuthorizationPreviewService>());
        }
Beispiel #19
0
        public void Startup(bool monitoringEnabled, ISubscriptionPersistence persistence)
        {
            AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            _sources.Each(x => Services.AddService <IPersistentTaskSource>(x));

            Services.ReplaceService(persistence);
            ServiceBus.HealthMonitoring
            .ScheduledExecution(monitoringEnabled
                    ? ScheduledExecution.WaitUntilInterval
                    : ScheduledExecution.Disabled)
            .IntervalSeed(3);

            _runtime = ToRuntime();
            var controller = _runtime.Get <IPersistentTaskController>();

            _initialTasks.Each(subject => controller.TakeOwnership(subject).Wait(1.Seconds()));
        }
Beispiel #20
0
        public void FixtureSetUp()
        {
            fileSystem.DeleteDirectory(Folder);
            fileSystem.CreateDirectory(Folder);

            fileSystem.CreateDirectory(Folder.AppendPath(Application));

            _streams.Each(x => x.DumpContents());

            Thread.Sleep(100); // let the file system cool off a bit first


            var registry = determineRegistry();

            registry.RootPath = _applicationDirectory;

            _host = registry.ToRuntime();

            _views = new Lazy <ViewBag>(() => { return(_host.Get <ConnegSettings>().Views); });
        }
Beispiel #21
0
        public void SetUp()
        {
            theTransportRegistry = new FubuRegistry();
            theTransportRegistry.ServiceBus.Enable(true);

            theTransportRegistry.Handlers.DisableDefaultHandlerSource();
            theTransportRegistry.ServiceBus.EnableInMemoryTransport();

            TestMessageRecorder.Clear();

            _invoker = new Lazy <IChainInvoker>(() =>
            {
                theRuntime = theTransportRegistry.ToRuntime();

                return(theRuntime.Get <IChainInvoker>());
            });

            theCallback = MockRepository.GenerateMock <IMessageCallback>();

            theContextIs();
        }
        public void SetUp()
        {
            container = new Container();
            container.Inject(new TransportSettings
            {
                DelayMessagePolling    = Int32.MaxValue,
                ListenerCleanupPolling = Int32.MaxValue
            });
            theServiceBus = MockRepository.GenerateMock <IServiceBus>();

            var registry = new FubuRegistry();

            registry.ServiceBus.Enable(true);
            registry.Actions.IncludeType <MessageOnePublisher>();
            registry.StructureMap(container);
            registry.AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            theRuntime = registry.ToRuntime();
            theGraph   = theRuntime.Get <BehaviorGraph>();
            chain      = theGraph.ChainFor <MessageOnePublisher>(x => x.post_message1(null));

            container.Inject(theServiceBus);
        }
Beispiel #23
0
        public void SetUp()
        {
            runtime = FubuRuntime.Basic(_ => _.Mode = "development");

            runtime.Get <FubuDiagnosticsEndpoint>().get__fubu();
        }
Beispiel #24
0
 public void the_application_service_registrations_win()
 {
     _runtime.Get <IAppService>().ShouldBeOfType <AppService>();
 }
Beispiel #25
0
 public IAssetTagBuilder TagBuilder()
 {
     return(_host.Get <IAssetTagBuilder>());
 }
Beispiel #26
0
        public static void Bootstrap(FubuRegistry registry)
        {
            Runtime = registry.ToRuntime();

            var settings = Runtime.Get <DiagnosticsSettings>();

            if (settings.TraceLevel == TraceLevel.None)
            {
                return;
            }

            var executionLogger = Runtime.Get <IExecutionLogger>();
            var logger          = Runtime.Get <ILogger>();

            _startRequest = () =>
            {
                try
                {
                    if (!HttpContext.Current.Items.Contains("owin.Environment"))
                    {
                        HttpContext.Current.Items.Add("owin.Environment", new Dictionary <string, object>());
                    }

                    var log = new ChainExecutionLog();
                    HttpContext.Current.Response.AppendHeader(HttpRequestExtensions.REQUEST_ID, log.Id.ToString());
                    HttpContext.Current.Items.Add(AspNetServiceArguments.CHAIN_EXECUTION_LOG, log);
                }
                catch (Exception e)
                {
                    try
                    {
                        logger.Error("Error in request logging", e);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                        Console.WriteLine(e);
                    }
                }
            };

            _endRequest = () =>
            {
                try
                {
                    if (!HttpContext.Current.Items.Contains(AspNetServiceArguments.CHAIN_EXECUTION_LOG))
                    {
                        return;
                    }

                    var log = HttpContext.Current.Items[AspNetServiceArguments.CHAIN_EXECUTION_LOG].As <ChainExecutionLog>();
                    log.MarkFinished();

                    executionLogger.Record(log, new AspNetDictionary());
                }
                catch (Exception e)
                {
                    try
                    {
                        logger.Error("Error in request logging", e);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                        Console.WriteLine(e);
                    }
                }
            };
        }
Beispiel #27
0
 public IEnumerable <Subscription> LoadedSubscriptions()
 {
     return(_runtime.Get <ISubscriptionCache>()
            .ActiveSubscriptions);
 }
Beispiel #28
0
 public Task ActivateTask(Uri subject)
 {
     return(_runtime.Get <IPersistentTaskController>().TakeOwnership(subject));
 }