public void _TestSetUp()
        {
            var context = new GenericApplicationContext();

            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(context);
        }
        public void CanExportAopProxyToLibrary()
        {
            // NOTE: the method interceptor will return the number of method calls intercepted
            FileInfo assemblyFile               = new FileInfo("ServiceComponentExporterTests.TestServicedComponents.dll");
            XmlApplicationContext      appCtx   = new XmlApplicationContext("ServiceComponentExporterTests.TestServicedComponents.Services.xml");
            EnterpriseServicesExporter exporter = new EnterpriseServicesExporter();

            exporter.ActivationMode = ActivationOption.Library;
            Type serviceType = ExportObject(exporter, assemblyFile, appCtx, "objectTest");

            try
            {
                // ServiceComponent will obtain its target from root context
//                ContextRegistry.RegisterContext(appCtx);

                IComparable testObject;
                testObject = (IComparable)Activator.CreateInstance(serviceType);
                Assert.AreEqual(1, testObject.CompareTo(null));
                testObject = (IComparable)Activator.CreateInstance(serviceType);
                Assert.AreEqual(2, testObject.CompareTo(null));
            }
            finally
            {
                exporter.UnregisterServicedComponents(assemblyFile);
                ContextRegistry.Clear();
            }
        }
        public void CanCreateWithDefaults()
        {
            string SESSIONFACTORY_OBJECTNAME = ConfigSectionSessionScopeSettings.DEFAULT_SESSION_FACTORY_OBJECT_NAME;

            // setup expected values
            MockRepository  mocks = new MockRepository();
            ISessionFactory expectedSessionFactory    = mocks.StrictMock <ISessionFactory>();
            IInterceptor    expectedEntityInterceptor = null;
            bool            expectedSingleSession     = SessionScopeSettings.SINGLESESSION_DEFAULT;
            FlushMode       expectedDefaultFlushMode  = SessionScopeSettings.FLUSHMODE_DEFAULT;

            // create and register context
            StaticApplicationContext appCtx = new StaticApplicationContext();

            appCtx.Name = AbstractApplicationContext.DefaultRootContextName;
            appCtx.ObjectFactory.RegisterSingleton(SESSIONFACTORY_OBJECTNAME, expectedSessionFactory);
            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(appCtx);

            ConfigSectionSessionScopeSettings settings = new ConfigSectionSessionScopeSettings(this.GetType(), (IVariableSource)null);

            Assert.AreEqual(expectedSessionFactory, settings.SessionFactory);
            Assert.AreEqual(expectedEntityInterceptor, settings.EntityInterceptor);
            Assert.AreEqual(expectedSingleSession, settings.SingleSession);
            Assert.AreEqual(expectedDefaultFlushMode, settings.DefaultFlushMode);
        }
        private void CrashAndInitializeAgainWithSnapshot()
        {
            //crash
            InputDisruptorPublisher.Shutdown();
            OutputDisruptor.ShutDown();
            _exchange.StopTimer();
            inputEventStore.ShutDown();
            outputEventStore.ShutDown();
            inputJournaler.ShutDown();
            outputJournaler.ShutDown();
            ContextRegistry.Clear();

            //initialize
            inputEventStore     = new RavenNEventStore(Constants.INPUT_EVENT_STORE);
            outputEventStore    = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
            inputJournaler      = new Journaler(inputEventStore);
            outputJournaler     = new Journaler(outputEventStore);
            _applicationContext = ContextRegistry.GetContext();
            IList <CurrencyPair> currencyPairs = new List <CurrencyPair>();

            currencyPairs.Add(new CurrencyPair("BTCUSD", "USD", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCLTC", "LTC", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCDOGE", "DOGE", "BTC"));
            _exchange = new Exchange(currencyPairs, outputEventStore.LoadLastSnapshot());
            InputDisruptorPublisher.InitializeDisruptor(new IEventHandler <InputPayload>[] { _exchange, inputJournaler });
            OutputDisruptor.InitializeDisruptor(new IEventHandler <byte[]>[] { outputJournaler });
            _exchange.InitializeExchangeAfterSnaphot();
            LimitOrderBookReplayService service = new LimitOrderBookReplayService();

            service.ReplayOrderBooks(_exchange, outputJournaler);
            _exchange.EnableSnaphots(5000);
            ManualResetEvent resetEvent = new ManualResetEvent(false);

            resetEvent.WaitOne(20000);
        }
        public void _TestSetup()
        {
            using (new VirtualEnvironmentMock("/somedir/some.file", null, null, "/", true))
            {
                ContextRegistry.Clear();
                _context         = new MvcApplicationContext("file://objects.xml");
                _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjects.xml");

                ContextRegistry.RegisterContext(_context);
                ContextRegistry.RegisterContext(_mvcNamedContext);

                _factory = new SpringControllerFactory();

                //due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
                // see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
                _factory.InitializeWithControllerTypes(new[]
                {
                    typeof(FirstContainerRegisteredController),
                    typeof(SecondContainerRegisteredController),
                    typeof(NotInContainerController),
                    typeof(NamedContextController),
                });

                SpringControllerFactory.ApplicationContextName = string.Empty;
            }
        }
        public SpringObjectFactory()
        {
            applicationContext = new GenericApplicationContext();

            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(applicationContext);

            objectDefinitionRegistry = (IObjectDefinitionRegistry)applicationContext.ObjectFactory;
        }
 public void TearDown()
 {
     InputDisruptorPublisher.Shutdown();
     OutputDisruptor.ShutDown();
     ContextRegistry.Clear();
     _databaseUtility.Create();
     inputEventStore.RemoveAllEvents();
     outputEventStore.RemoveAllEvents();
 }
Example #8
0
        public void CanRevertToTypeMatchIfIdMatchUnsuccessful()
        {
            MvcApplicationContext context = new MvcApplicationContext("file://objectsMatchByType.xml");

            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(context);

            IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");

            Assert.AreEqual("Should_Be_Matched_By_Type", ((FirstContainerRegisteredController)controller).TestValue);
        }
Example #9
0
        public void _TestSetup()
        {
            ContextRegistry.Clear();
            _context         = new MvcApplicationContext("file://objectsMvc.xml");
            _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjectsMvc.xml");

            ContextRegistry.RegisterContext(_context);
            ContextRegistry.RegisterContext(_mvcNamedContext);

            _resolver = new SpringMvcDependencyResolver(_context);

            _resolver.ApplicationContextName = string.Empty;
        }
        public void ConfigureSoapHttpClientProtocolWithProxyType()
        {
            IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/configurableFactory.xml");
            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(ctx);

            object proxy = ctx.GetObject("withProxyType");
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            SoapHttpClientProtocol shcp = proxy as SoapHttpClientProtocol;
            Assert.AreEqual("http://www.springframework.org/", shcp.Url);
            Assert.AreEqual(10000, shcp.Timeout);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void CanCreateFromExplicitConfiguration()
        {
            string SESSIONFACTORY_OBJECTNAME    = "SessionFactory";
            string ENTITYINTERCEPTOR_OBJECTNAME = "EntityInterceptor";

            MockRepository  mocks = new MockRepository();
            ISessionFactory expectedSessionFactory    = mocks.StrictMock <ISessionFactory>();
            IInterceptor    expectedEntityInterceptor = mocks.StrictMock <IInterceptor>();
            bool            expectedSingleSession     = false;
            FlushMode       expectedDefaultFlushMode  = FlushMode.Auto;

            // create and register context
            StaticApplicationContext appCtx = new StaticApplicationContext();

            appCtx.Name = AbstractApplicationContext.DefaultRootContextName;
            appCtx.ObjectFactory.RegisterSingleton(SESSIONFACTORY_OBJECTNAME, expectedSessionFactory);
            appCtx.ObjectFactory.RegisterSingleton(ENTITYINTERCEPTOR_OBJECTNAME, expectedEntityInterceptor);
            ContextRegistry.Clear();
            ContextRegistry.RegisterContext(appCtx);

            // simulate config section
            string thisTypeName = this.GetType().FullName;
            DictionaryVariableSource variableSource = new DictionaryVariableSource()
                                                      .Add(thisTypeName + ".SessionFactoryObjectName", SESSIONFACTORY_OBJECTNAME)
                                                      .Add(thisTypeName + ".EntityInterceptorObjectName", ENTITYINTERCEPTOR_OBJECTNAME)
                                                      .Add(thisTypeName + ".SingleSession", expectedSingleSession.ToString().ToLower())       // case insensitive!
                                                      .Add(thisTypeName + ".DefaultFlushMode", expectedDefaultFlushMode.ToString().ToLower()) // case insensitive!
            ;


            ConfigSectionSessionScopeSettings settings = new ConfigSectionSessionScopeSettings(this.GetType(), variableSource);

            Assert.AreEqual(expectedSessionFactory, settings.SessionFactory);
            Assert.AreEqual(expectedEntityInterceptor, settings.EntityInterceptor);
            Assert.AreEqual(expectedSingleSession, settings.SingleSession);
            Assert.AreEqual(expectedDefaultFlushMode, settings.DefaultFlushMode);
        }
Example #12
0
        public void SetUp()
        {
            ContextRegistry.Clear();
            tesla            = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            tesla.Inventions = new string[]
            {
                "Telephone repeater", "Rotating magnetic field principle",
                "Polyphase alternating-current system", "Induction motor",
                "Alternating-current power transmission", "Tesla coil transformer",
                "Wireless communication", "Radio", "Fluorescent lights"
            };
            tesla.PlaceOfBirth.City = "Smiljan";

            pupin                      = new Inventor("Mihajlo Pupin", new DateTime(1854, 10, 9), "Serbian");
            pupin.Inventions           = new string[] { "Long distance telephony & telegraphy", "Secondary X-Ray radiation", "Sonar" };
            pupin.PlaceOfBirth.City    = "Idvor";
            pupin.PlaceOfBirth.Country = "Serbia";

            ieee = new Society();
            ieee.Members.Add(tesla);
            ieee.Members.Add(pupin);
            ieee.Officers["president"] = pupin;
            ieee.Officers["advisors"]  = new Inventor[] { tesla, pupin }; // not historically accurate, but I need an array in the map ;-)
        }
 public void Setup()
 {
     ContextRegistry.Clear();
     _applicationContext = new XmlApplicationContext(false, "assembly://Spring.Core.Tests/Spring.Objects.Factory.Attributes/ByValueObjects.xml");
     ContextRegistry.RegisterContext(_applicationContext);
 }
Example #14
0
 public void Dispose()
 {
     ContextRegistry.Clear();
 }
 public void TearDown()
 {
     ContextRegistry.Clear();
 }
Example #16
0
 /// <summary>
 /// Clears spring.net context
 /// </summary>
 public static void ContextClear()
 {
     ContextRegistry.Clear();
 }
 public void TearDown()
 {
     ContextRegistry.Clear();
     _databaseUtility.Create();
 }