public void GlobalJobListeners_with_no_registration_throws() { var c = new WindsorContainer(); var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}"); c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config); c.AddFacility("quartz", new QuartzFacility()); c.Resolve<IScheduler>(); }
public void GlobalJobListeners() { var c = new WindsorContainer(); var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}"); c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config); c.Register(Component.For<IJobListener>().ImplementedBy<SomeJobListener>().Named("jobli")); c.AddFacility("quartz", new QuartzFacility()); var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>(); foreach (IJobListener l in scheduler.GlobalJobListeners) Console.WriteLine(l.Name); Assert.AreEqual(2, scheduler.GlobalJobListeners.Count); }
public void GlobalTriggerListeners() { var c = new WindsorContainer(); var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); config.CreateChild("globalTriggerListeners").CreateChild("item", "${jobli}"); c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config); c.AddComponent("jobli", typeof (ITriggerListener), typeof (SomeTriggerListener)); c.AddFacility("quartz", new QuartzFacility()); var scheduler = c.Resolve<IScheduler>() as QuartzNetScheduler; foreach (ITriggerListener l in scheduler.GlobalTriggerListeners) Console.WriteLine(l.Name); Assert.AreEqual(1, scheduler.GlobalTriggerListeners.Count); }
public void InvalidProtocol_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName); configuration.CreateChild("solrURL", "ftp://localhost"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); new WindsorContainer(configStore); }
public void InvalidUrl_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attributes.Add("type", typeof(SolrNetFacility).FullName); configuration.CreateChild("solrURL", "123"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); new WindsorContainer(configStore); }
public void ShouldBeAbleToSupplyValueForNullableParamViaCtor_FromConfig() { var container = new WindsorContainer(); var configuration = new MutableConfiguration("parameters"); configuration.CreateChild("foo", "5"); container.Register(Component.For<ClassTakingNullableViaCtor>().Configuration(configuration)); container.Resolve<ClassTakingNullableViaCtor>(); }
private IConfiguration CreateModuleConfigurationNode() { var config = new MutableConfiguration("array"); foreach (Type type in messageModules) { config.CreateChild("item", "${" + type.FullName + "}"); } return config; }
public void Basic() { var c = new WindsorContainer(); var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config); c.AddFacility("quartz", new QuartzFacility()); c.Resolve<IJobScheduler>(); c.Resolve<IScheduler>(); }
public void ParseEndpoints_reflects_entries() { var config = new MutableConfiguration("entries"); config.CreateChild("item").Attribute("assembly", "asm1").Attribute("endpoint", "end"); var reg = new RemoteEndpointRegistry(); reg.ParseEndpoints(config); Assert.AreEqual(1, reg.EntriesCount); }
public void ShouldBeAbleToSupplyValueForNullableParam_FromConfig() { var container = new WindsorContainer(); var configuration = new MutableConfiguration("parameters"); configuration.CreateChild("SomeVal", "5"); container.Register(Component.For<ClassTakingNullable>().Configuration(configuration)); var s = container.Resolve<ClassTakingNullable>(); Assert.IsNotNull(s.SomeVal); }
public void JobListeners() { var c = new WindsorContainer(); var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); var listenerConfig = config.CreateChild("jobListeners"); listenerConfig .CreateChild("job") .Attribute("name", "someJob") .CreateChild("listener", "${jobli}"); c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config); c.AddComponent("jobli", typeof (IJobListener), typeof (SomeJobListener)); c.AddFacility("quartz", new QuartzFacility()); var scheduler = c.Resolve<IScheduler>() as QuartzNetScheduler; foreach (var l in scheduler.JobListenerNames) Console.WriteLine(l); var jobli = scheduler.GetJobListener(typeof(SomeJobListener).AssemblyQualifiedName); Assert.IsNotNull(jobli); }
public void FacilityRegistersReleasingJobListener() { using (var c = new WindsorContainer()) { var config = new MutableConfiguration("facility"); config.CreateChild("quartz"); c.AddFacility<QuartzFacility>(f => f.Configure(config)); var scheduler = c.Resolve<IScheduler>(); //Assert.IsNotNull(scheduler.GlobalJobListeners); //Assert.AreEqual(2, scheduler.GlobalJobListeners.Count); Assert.IsAssignableFrom(typeof(ReleasingJobListener), scheduler.ListenerManager.GetJobListeners()[0]); } }
public void Ping_Query() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName); configuration.CreateChild("solrURL", "http://localhost:8983/solr"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); var container = new WindsorContainer(configStore); var solr = container.Resolve<ISolrOperations<CastleFixture.Document>>(); solr.Ping(); Console.WriteLine(solr.Query(SolrQuery.All).Count); }
public void tt() { var container = new WindsorContainer(); var facilityConfig = new MutableConfiguration("facility"); var assemblies = facilityConfig.CreateChild("assemblies"); assemblies.CreateChild("item", GetType().Assembly.FullName); var nhConfig = facilityConfig.CreateChild("config"); AddConfig(nhConfig, Environment.ConnectionDriver, typeof(SQLite20Driver).FullName); AddConfig(nhConfig, Environment.Dialect, typeof(SQLiteDialect).FullName); AddConfig(nhConfig, Environment.ConnectionProvider, typeof(DriverConnectionProvider).FullName); AddConfig(nhConfig, Environment.ProxyFactoryFactoryClass, typeof(ProxyFactoryFactory).AssemblyQualifiedName); AddConfig(nhConfig, Environment.ConnectionString, "Data Source=test.db;Version=3;New=True;"); container.Kernel.ConfigurationStore.AddFacilityConfiguration("ar", facilityConfig); var arFacility = new ActiveRecordFacility(); container.AddFacility("ar", arFacility); container.AddFacility<TransactionFacility>(); ActiveRecordStarter.CreateSchema(); container.AddComponent<TransactionalService>(); container.Resolve<TransactionalService>().DoSomething(); Assert.IsFalse(ActiveRecordMediator<Person>.Exists()); }
public void Basic() { using (var c = new WindsorContainer()) { var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); c.AddFacility<QuartzFacility>(f => f.Configure(config)); var js = c.Resolve<IJobScheduler>(); var sched = c.Resolve<IScheduler>(); var factory = c.Resolve<IJobFactory>(); Assert.IsTrue(js is QuartzNetSimpleScheduler); Assert.IsTrue(sched is QuartzNetScheduler); Assert.IsTrue(factory is WindsorJobFactory); } }
public void DisposableJobIsDisposed() { using (var c = new WindsorContainer()) { c.Register(Component.For<DisposableJob>().LifeStyle.Transient); var config = new MutableConfiguration("facility"); config.CreateChild("quartz"); c.AddFacility<QuartzFacility>(f => f.Configure(config)); var scheduler = c.Resolve<IScheduler>(); var jobDetail = JobBuilder.Create<DisposableJob>().WithIdentity("somejob").Build(); var trigger = TriggerBuilder.Create().WithIdentity("sometrigger").WithSimpleSchedule(s => s.WithIntervalInSeconds(1)).Build(); scheduler.ScheduleJob(jobDetail, trigger); Assert.IsFalse(DisposableJob.Disposed); scheduler.Start(); Thread.Sleep(1000); Assert.IsTrue(DisposableJob.Disposed); } }
public static void Configure(IWindsorContainer container, IList<string> assembliesToLoad) { var facility = new MutableConfiguration("facility"); facility.Attributes.Add("id", "nhibernatefacility"); facility.Attributes.Add("isWeb", "isWeb"); facility.Attributes.Add("defaultFlushMode", "Commit"); var factory = facility.CreateChild("factory"); factory.Attributes.Add("id", "nhibernate.factory"); var settings = factory.CreateChild("settings"); CreateItem(settings, "connection.connection_string", Config.PortalConnectionString); CreateItem(settings, "connection.provider", "NHibernate.Connection.DriverConnectionProvider"); CreateItem(settings, "connection.driver_class", "NHibernate.Driver.MySqlDataDriver"); CreateItem(settings, "dialect", "NHibernate.Dialect.MySQL5Dialect"); CreateItem(settings, "proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); CreateItem(settings, "show_sql", Config.LogSqlQueries); var assemblies = factory.CreateChild("assemblies"); foreach (var assebly in assembliesToLoad) { assemblies.CreateChild("assembly", assebly); } container.Kernel.ConfigurationStore.AddFacilityConfiguration("nHibernateFacility", facility); container.AddFacility<Castle.Facilities.NHibernateIntegration.NHibernateFacility>("nHibernateFacility"); }
public void Wiring_WhenPublisherHasAProxy_ListenerShouldStillGetTheEvents() { MutableConfiguration config = new MutableConfiguration("component"); config. CreateChild("subscribers"). CreateChild("subscriber"). Attribute("id", "listener"). Attribute("event", "Event"). Attribute("handler", "OnPublish"); store.AddComponentConfiguration("publisher", config); container.AddFacility("event", new EventWiringFacility()); // Registers interceptor as component container.Register(Component.For<MyInterceptor>().Named("my.interceptor")); container.Register(Component.For<SimpleListener>().Named("listener")); // Publisher has a reference to interceptor container.Register( Component.For<SimplePublisher>(). Named("publisher"). Interceptors(new InterceptorReference("my.interceptor")).First); // Triggers events SimplePublisher publisher = container.Resolve<SimplePublisher>(); publisher.Trigger(); MyInterceptor interceptor = container.Resolve<MyInterceptor>(); Assert.AreEqual(1, interceptor.Intercepted); // Assert that event was caught SimpleListener listener = container.Resolve<SimpleListener>(); Assert.IsTrue(listener.Listened); Assert.AreSame(publisher, listener.Sender); }
private void AddDefaultFactory(MutableConfiguration config) { config.CreateChild("factory").Attribute("id", "nhibernate-factory.default"); }
public void GlobalTriggerListeners() { using (var c = new WindsorContainer()) { var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); config.CreateChild("globalTriggerListeners").CreateChild("item", "${jobli}"); c.Register(Component.For<ITriggerListener>().ImplementedBy<SomeTriggerListener>().Named("jobli")); c.AddFacility<QuartzFacility>(f => f.Configure(config)); var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>(); foreach (ITriggerListener l in scheduler.ListenerManager.GetTriggerListeners()) Console.WriteLine(l.Name); Assert.AreEqual(1, scheduler.ListenerManager.GetTriggerListeners().Count); } }
public IConfiguration ToIConfiguration() { var config = new MutableConfiguration("rhino.esb"); var busConfig = config.CreateChild("bus") .Attribute("endpoint", Endpoint) .Attribute("threadCount", ThreadCount.ToString()) .Attribute("numberOfRetries", NumberOfRetries.ToString()); if (string.IsNullOrEmpty(LoadBalancerEndpoint) == false) busConfig.Attribute("loadBalancerEndpoint", LoadBalancerEndpoint); if (string.IsNullOrEmpty(LogEndpoint) == false) busConfig.Attribute("logEndpoint", LogEndpoint); var messagesConfig = config.CreateChild("messages"); foreach (var message in Messages) { messagesConfig.CreateChild("add") .Attribute("name", message.Key) .Attribute("endpoint", message.Value); } return config; }
public void GlobalJobListeners_with_no_registration_throws() { using (var c = new WindsorContainer()) { var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}"); c.AddFacility<QuartzFacility>(f => f.Configure(config)); c.Resolve<IScheduler>(); } }
public void TriggerListeners() { using (var c = new WindsorContainer()) { var config = new MutableConfiguration("facility"); config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq"); var listenerConfig = config.CreateChild("triggerListeners"); listenerConfig .CreateChild("job") .Attribute("name", "someJob") .CreateChild("listener", "${trigli}"); c.Register(Component.For<ITriggerListener>().ImplementedBy<SomeTriggerListener>().Named("trigli")); c.AddFacility<QuartzFacility>(f => f.Configure(config)); var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>(); foreach (var l in scheduler.ListenerManager.GetTriggerListeners()) Console.WriteLine(l); var trigli = scheduler.ListenerManager.GetTriggerListener(typeof(SomeTriggerListener).AssemblyQualifiedName); Assert.IsNotNull(trigli); } }
public void Ping_Query() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.CreateChild("solrURL", "http://localhost:8983/solr"); configStore.AddFacilityConfiguration("solr", configuration); var container = new WindsorContainer(configStore); container.AddFacility<SolrNetFacility>("solr"); var solr = container.Resolve<ISolrOperations<Document>>(); solr.Ping(); Console.WriteLine(solr.Query(SolrQuery.All).Count); }
private void AddFactory(MutableConfiguration config, String alias) { config.CreateChild("factory").Attribute("id", String.Format("nhibernate-factory.{0}", alias)).Attribute("alias", alias); }
public void InvalidUrl_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.CreateChild("solrURL", "123"); configStore.AddFacilityConfiguration("solr", configuration); var container = new WindsorContainer(configStore); container.AddFacility<SolrNetFacility>("solr"); }
public void Can_satisfy_nullable_property_dependency() { var container = new WindsorContainer(); var configuration = new MutableConfiguration("parameters"); configuration.CreateChild("SomeVal", "5"); container.Register(Component.For<HasNullableIntProperty>().Configuration(configuration)); var s = container.Resolve<HasNullableIntProperty>(); Assert.IsNotNull(s.SomeVal); }
public void Can_satisfy_nullable_ctor_dependency() { var container = new WindsorContainer(); var configuration = new MutableConfiguration("parameters"); configuration.CreateChild("foo", "5"); container.Register(Component.For<HasNullableDoubleConstructor>().Configuration(configuration)); container.Resolve<HasNullableDoubleConstructor>(); }
public void DictionaryWithDifferentValueTypes() { var config = new MutableConfiguration("dictionary"); config.CreateChild("entry") .Attribute("key", "intentry") .Attribute("valueType", "System.Int32, mscorlib") .Value = "123"; config.CreateChild("entry") .Attribute("key", "values") .Attribute("valueType", "System.Int32[], mscorlib") .CreateChild("array") .Attribute("type", "System.Int32, mscorlib") .CreateChild("item", "400"); var dict = (IDictionary)converter.PerformConversion(config, typeof(IDictionary)); Assert.IsNotNull(dict); Assert.AreEqual(123, dict["intentry"]); var values = (int[])dict["values"]; Assert.IsNotNull(values); Assert.AreEqual(1, values.Length); Assert.AreEqual(400, values[0]); }
private static void CreateItem(MutableConfiguration parent, string key, string value) { var item = parent.CreateChild("item"); item.Attributes.Add("key", key); item.Value = value; }