public void Main() { var ctx = new XmlApplicationContext("objects.xml"); var o1 = ctx.GetObject("SingletonObject"); var o2 = ctx.GetObject("ProtoTypeObject"); ctx.Dispose(); }
public void SingleConfigLocation() { XmlApplicationContext ctx = new XmlApplicationContext(false, "assembly://Spring.Core.Tests/Spring.Context.Support/simpleContext.xml"); Assert.IsTrue(ctx.ContainsObject("someMessageSource")); ctx.Dispose(); }
public void MultipleConfigLocations() { XmlApplicationContext ctx = new XmlApplicationContext(false, "assembly://Spring.Core.Tests/Spring.Context.Support/contextB.xml", "assembly://Spring.Core.Tests/Spring.Context.Support/contextC.xml", "assembly://Spring.Core.Tests/Spring.Context.Support/contextA.xml"); Assert.IsTrue(ctx.ContainsObject("service")); Assert.IsTrue(ctx.ContainsObject("logicOne")); Assert.IsTrue(ctx.ContainsObject("logicTwo")); Service service = (Service)ctx.GetObject("service"); ctx.Refresh(); Assert.IsTrue(service.ProperlyDestroyed); service = (Service)ctx.GetObject("service"); ctx.Dispose(); Assert.IsTrue(service.ProperlyDestroyed); }
public void MultipleConfigLocations() { XmlApplicationContext ctx = new XmlApplicationContext(false, "assembly://Spring.Core.Tests/Spring.Context.Support/contextB.xml", "assembly://Spring.Core.Tests/Spring.Context.Support/contextC.xml", "assembly://Spring.Core.Tests/Spring.Context.Support/contextA.xml"); Assert.IsTrue(ctx.ContainsObject("service")); Assert.IsTrue(ctx.ContainsObject("logicOne")); Assert.IsTrue(ctx.ContainsObject("logicTwo")); Service service = (Service) ctx.GetObject("service"); ctx.Refresh(); Assert.IsTrue(service.ProperlyDestroyed); service = (Service) ctx.GetObject("service"); ctx.Dispose(); Assert.IsTrue(service.ProperlyDestroyed); }
public void TestWithTwoAnonymousMethodInvokingJobDetailFactoryObjects() { XmlApplicationContext ctx = new XmlApplicationContext("multipleAnonymousMethodInvokingJobDetailFB.xml"); Thread.Sleep(3000); try { QuartzTestObject exportService = (QuartzTestObject) ctx.GetObject("exportService"); QuartzTestObject importService = (QuartzTestObject) ctx.GetObject("importService"); Assert.AreEqual(0, exportService.ImportCount, "doImport called exportService"); Assert.AreEqual(2, exportService.ExportCount, "doExport not called on exportService"); Assert.AreEqual(2, importService.ImportCount, "doImport not called on importService"); Assert.AreEqual(0, importService.ExportCount, "doExport called on importService"); } finally { ctx.Dispose(); } }
public void TestSchedulerRepositoryExposure() { XmlApplicationContext ctx = new XmlApplicationContext("schedulerRepositoryExposure.xml"); Assert.AreSame(SchedulerRepository.Instance.Lookup("myScheduler"), ctx.GetObject("scheduler")); ctx.Dispose(); }
public void TestSchedulerAccessorObject() { XmlApplicationContext ctx = new XmlApplicationContext("schedulerAccessorObject.xml"); Thread.Sleep(3000); try { QuartzTestObject exportService = (QuartzTestObject) ctx.GetObject("exportService"); QuartzTestObject importService = (QuartzTestObject) ctx.GetObject("importService"); Assert.AreEqual(0, exportService.ImportCount, "doImport called exportService"); Assert.AreEqual(2, exportService.ExportCount, "doExport not called on exportService"); Assert.AreEqual(2, importService.ImportCount, "doImport not called on importService"); Assert.AreEqual(0, importService.ExportCount, "doExport called on importService"); } finally { ctx.Dispose(); } }
public void TestMultipleSchedulers() { XmlApplicationContext ctx = new XmlApplicationContext("multipleSchedulers.xml"); try { IScheduler scheduler1 = (IScheduler) ctx.GetObject("scheduler1"); IScheduler scheduler2 = (IScheduler) ctx.GetObject("scheduler2"); Assert.AreNotSame(scheduler1, scheduler2); Assert.AreEqual("quartz1", scheduler1.SchedulerName); Assert.AreEqual("quartz2", scheduler2.SchedulerName); XmlApplicationContext ctx2 = new XmlApplicationContext("multipleSchedulers.xml"); try { IScheduler scheduler1a = (IScheduler) ctx2.GetObject("scheduler1"); IScheduler scheduler2a = (IScheduler) ctx2.GetObject("scheduler2"); Assert.AreNotSame(scheduler1a, scheduler2a); Assert.AreNotSame(scheduler1a, scheduler1); Assert.AreNotSame(scheduler2a, scheduler2); Assert.AreEqual("quartz1", scheduler1a.SchedulerName); Assert.AreEqual("quartz2", scheduler2a.SchedulerName); } finally { ctx2.Dispose(); } } finally { ctx.Dispose(); } }