/// <summary>
        ///     Configures the document store internal.
        /// </summary>
        /// <param name="documentStore">The document store.</param>
        private void ConfigureDocumentStoreInternal(EmbeddableDocumentStore documentStore)
        {
            documentStore.RegisterListener(new StoreListener(this.OnPagePublish, this.OnPageSave, this.OnPageUnPublish));
            documentStore.RegisterListener(new DeleteListener(this.OnDocumentDelete));

            IndexCreation.CreateIndexes(typeof(DefaultBrickPileBootstrapper).Assembly, documentStore);
        }
Exemplo n.º 2
0
        private void ConfigureStore(EmbeddableDocumentStore store)
        {
            if (createSeededTestDatabase)
            {
                store.DefaultDatabase = "StudioHub";

                store.DataDirectory = Path.Combine(EmbeddedDatabasePath, @"Databases\System");
                store.Configuration.PluginsDirectory            = ConfigurePlugins();
                store.Configuration.CompiledIndexCacheDirectory = Path.Combine(EmbeddedDatabasePath, "CompiledIndexCache");
                store.Configuration.AccessControlAllowOrigin    = new HashSet <string>()
                {
                    "*"
                };

                store.Conventions = new DocumentConvention()
                {
                    DisableProfiling = true,
                    MaxNumberOfRequestsPerSession = 30,
                    DefaultQueryingConsistency    = ConsistencyOptions.None
                };

                store.RegisterListener(new UniqueConstraintsStoreListener());
            }
            else
            {
                store.UseEmbeddedHttpServer = true;
                store.DefaultDatabase       = "StudioHub";

                store.Configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = false;

                store.DataDirectory = Path.Combine(EmbeddedDatabasePath, @"Databases\");
                store.Configuration.PluginsDirectory            = ConfigurePlugins();
                store.Configuration.CompiledIndexCacheDirectory = Path.Combine(EmbeddedDatabasePath, "CompiledIndexCache");
                store.Configuration.AccessControlAllowOrigin    = new HashSet <string>()
                {
                    "*"
                };

                store.Conventions = new DocumentConvention()
                {
                    DisableProfiling = true,
                    MaxNumberOfRequestsPerSession = 30,
                    DefaultQueryingConsistency    = ConsistencyOptions.None
                };

                store.RegisterListener(new UniqueConstraintsStoreListener());
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Configures StructureMap to look for registries.
 /// </summary>
 /// <returns></returns>
 public static IContainer Initialize()
 {
     ObjectFactory.Initialize(x => {
         var documentStore = new EmbeddableDocumentStore {
             ConnectionStringName = "RavenDB"
         };
         documentStore.Conventions.FindTypeTagName = type => typeof(IPageModel).IsAssignableFrom(type) ? "Pages" : null;
         documentStore.RegisterListener(new StoreListener());
         documentStore.Initialize();
         IndexCreation.CreateIndexes(typeof(DocumentsByParent).Assembly, documentStore);
         x.For <IDocumentStore>().Use(documentStore);
         x.For <IDocumentSession>()
         .HybridHttpOrThreadLocalScoped()
         .Use(y =>
         {
             var store = y.GetInstance <IDocumentStore>();
             return(store.OpenSession());
         });
         x.For <IVirtualPathResolver>().Use <VirtualPathResolver>();
         x.For <IPathResolver>().Use <PathResolver>();
         x.For <IPathData>().Use <PathData>();
         x.For <IControllerMapper>().Use <ControllerMapper>();
         x.For <ISettings>().Use <Settings>();
         x.Scan(scanner =>
         {
             scanner.AssembliesFromApplicationBaseDirectory();
             scanner.Convention <PageTypeRegistrationConvetion>();
         });
         x.For <IPageModel>().UseSpecial(y => y.ConstructedBy(r => ((MvcHandler)HttpContext.Current.Handler).RequestContext.RouteData.GetCurrentPage <IPageModel>()));
         x.For <IStructureInfo>().UseSpecial(y => y.ConstructedBy(r => ((MvcHandler)HttpContext.Current.Handler).RequestContext.RouteData.GetStructureInfo()));
     });
     return(ObjectFactory.Container);
 }
Exemplo n.º 4
0
 protected override void ModifyStore(EmbeddableDocumentStore documentStore)
 {
     documentStore.RegisterListener(new UniqueConstraintsStoreListener());
     documentStore.Conventions.IdentityTypeConvertors.Add(new CustomerIdentityConverter());
     documentStore.Conventions.IdentityTypeConvertors.Add(new ProductIdentityConverter());
     base.ModifyStore(documentStore);
 }
Exemplo n.º 5
0
        public ChrisDNF()
        {
            documentStore = NewDocumentStore();
            documentStore.RegisterListener(new NoStaleQueriesAllowed());

            new ActivityIndexes.Activity_ByCategoryId().Execute(documentStore);
        }
Exemplo n.º 6
0
        public RavenDbStore(bool runInMemory = false, bool allowStaleQueries = true)
        {
            string dataDirectory = ConfigurationManager.GetAppSetting("ravendb.data.directory");
            int    port          = int.Parse(ConfigurationManager.GetAppSetting("ravendb.server.port"));

            if (runInMemory)
            {
                _embeddableDocumentStore = new EmbeddableDocumentStore
                {
                    RunInMemory           = true,
                    UseEmbeddedHttpServer = true,
                    DataDirectory         = dataDirectory,
                    Configuration         = { Port = port }
                };
                // Necessary to run tests in the FSharp project.
                _embeddableDocumentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
            }
            else
            {
                _embeddableDocumentStore = new EmbeddableDocumentStore
                {
                    RunInMemory           = false,
                    UseEmbeddedHttpServer = false,
                    DataDirectory         = dataDirectory,
                    Configuration         = { Port = port }
                };
            }

            if (!allowStaleQueries)
            {
                _embeddableDocumentStore.RegisterListener(new NoStaleQueriesAllowedListener());
            }
        }
Exemplo n.º 7
0
        private static EmbeddableDocumentStore CreateDocumentStore()
        {
            var documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                Conventions =
                {
                    DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites,
                }
            };

            documentStore.Initialize();

            // Force query's to wait for index's to catch up. Unit Testing only :P
            documentStore.RegisterListener(new NoStaleQueriesListener());

            // Wire up the index.
            new LogEntries_Search().Execute(documentStore);

            // Seed fake data.
            using (var documentSession = documentStore.OpenSession())
            {
                foreach (LogEntry logEntry in CreateFakeLogEntries())
                {
                    documentSession.Store(logEntry);
                }

                documentSession.SaveChanges();
            }

            return(documentStore);
        }
Exemplo n.º 8
0
        public void InitEmeddedDocumentStore(string dataDirectory, IDocumentQueryListener queryListener)
        {
            var mockRavenDBConfigurationInstance = MockRepository.GenerateStub <RavenDBConfiguration>();

            Func <IDocumentStore> setDocumentStore =
                () =>
            {
                var documentStore = new EmbeddableDocumentStore
                {
                    DataDirectory = dataDirectory
                };
                if (queryListener != null)
                {
                    documentStore.RegisterListener(queryListener);
                }

                return(documentStore);
            };


            mockRavenDBConfigurationInstance.Stub(x => x.GetDocumentStore()).Do(setDocumentStore);
            RavenDBConfiguration.Instance(mockRavenDBConfigurationInstance).Init();

            //RavenDBConfiguration.Instance().CreateIndex(typeof (Package_CurrentInventory).Assembly);
        }
Exemplo n.º 9
0
        public void InitaliseDocumentStore()
        {
            // Initialise the Store.
            var documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                Conventions = { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }
            };

            documentStore.Initialize();

            // Force query's to wait for index's to catch up. Unit Testing only :P
            documentStore.RegisterListener(new NoStaleQueriesListener());

            // Index initialisation.
            IndexCreation.CreateIndexes(typeof(RecentPopularTags).Assembly, documentStore);

            // Create any Facets.
            RavenFacetTags.CreateFacets(documentStore);

            // Create our Seed Data.
            CreateSeedData(documentStore);

            DocumentStore = documentStore;
        }
Exemplo n.º 10
0
 public RavenHost()
 {
     documentStore = new EmbeddableDocumentStore
     {
         DataDirectory         = "Data",
         UseEmbeddedHttpServer = true,
         DefaultDatabase       = "NServiceBus",
         Configuration         =
         {
             Port             =                        32076,
             PluginsDirectory = Environment.CurrentDirectory,
             HostName         = "localhost",
             Settings         =
             {
                 { "Raven/ActiveBundles", "Unique Constraints" }
             }
         }
     };
     documentStore.RegisterListener(new UniqueConstraintsStoreListener());
     documentStore.Initialize();
     // since hosting a fake raven server in process need to remove it from the logging pipeline
     Trace.Listeners.Clear();
     Trace.Listeners.Add(new DefaultTraceListener());
     Console.WriteLine("Raven server started on http://localhost:32076/");
 }
Exemplo n.º 11
0
        public static void Initialize(IContainer container)
        {
            if (_documentStore != null)
            {
                return;
            }

            var documentStore = new EmbeddableDocumentStore {
                //DataDirectory = "App_Data",
                RunInMemory           = true,
                UseEmbeddedHttpServer = true
            };

            documentStore.Configuration.PluginsDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, "Plugins");
            documentStore.RegisterListener(new DocumentStoreListener());
            documentStore.Initialize();

            _documentStore = documentStore;

            IndexCreation.CreateIndexes(typeof(RavenConfig).Assembly, _documentStore);

            RavenProfiler.InitializeFor(_documentStore);

            using (var session = _documentStore.OpenSession()) {
                RavenQueryStatistics stats;
                session.Query <Document>().Statistics(out stats).Take(0).ToList();
                if (stats.TotalResults == 0)
                {
                    // we need to create some documents
                    var rootDoc = new Document {
                        Slug = string.Empty, Title = "Home page", Body = "<p>Welcome to this site. Go and see <a href=\"/blog\">the blog</a>.</p><p><a href=\"/about\">here</a> is the about page.</p>"
                    };
                    session.Store(rootDoc);
                    session.Store(new Document {
                        ParentId = rootDoc.Id,
                        Slug     = "about",
                        Title    = "About",
                        Body     = "This is about this site."
                    });

                    var blogDoc = new Document {
                        ParentId = rootDoc.Id,
                        Slug     = "blog",
                        Title    = "Blog",
                        Body     = "This is my blog."
                    };
                    session.Store(blogDoc);
                    session.Store(new Document {
                        ParentId = blogDoc.Id,
                        Slug     = "First",
                        Title    = "my first blog post",
                        Body     = "Hooray"
                    });

                    session.SaveChanges();
                }
            }

            container.Configure(x => x.For <IDocumentSession>().HybridHttpOrThreadLocalScoped().Use(() => _documentStore.OpenSession()));
        }
Exemplo n.º 12
0
        public void WillSupportNullableDoubles2()
        {
            using (var documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                Conventions = { MaxNumberOfRequestsPerSession = int.MaxValue }
            })
            {
                documentStore.RegisterListener(new NoStaleQueriesAllowed());
                documentStore.Initialize();
                new Events_ByActiveStagingPublishOnSaleAndStartDate().Execute(documentStore);

                using (var documentSession = documentStore.OpenSession())
                {
                    new ConfigForNotificationSender(documentSession).PopulateData();

                    var results = documentSession.Query <Event, Events_ByActiveStagingPublishOnSaleAndStartDate>()
                                  .Customize(x => x.Include <Event>(e => e.PerformerIds).Include <Event>(e => e.VenueId).WaitForNonStaleResults())
                                  .Where(e => e.StartDate == DateTime.Now.Date)
                                  .ToList();

                    Assert.Empty(documentStore.DatabaseCommands.GetStatistics().Errors);
                    Assert.True(results.Count > 0);
                }
            }
        }
        public override IPersistStreams Build()
        {
            var embeddedStore = new EmbeddableDocumentStore();

            embeddedStore.Configuration.RunInMemory = true;
            embeddedStore.RegisterListener(new CheckpointNumberIncrementListener(embeddedStore));
            embeddedStore.Initialize();
            return(new RavenPersistenceEngine(embeddedStore, Serializer, Options));
        }
Exemplo n.º 14
0
        private static IDocumentStore GetInMemoryDocumentStore()
        {
            var documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };

            documentStore.RegisterListener(new NoStaleQueriesAllowed());
            return(documentStore);
        }
Exemplo n.º 15
0
        protected RaccoonControllerTests()
        {
            documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };

            documentStore.RegisterListener(new NoStaleQueriesAllowed());
            documentStore.Initialize();
        }
Exemplo n.º 16
0
        public EmbeddableDocumentStore Store()
        {
            var store = new EmbeddableDocumentStore {
                DataDirectory = path
            };

            store.RegisterListener(new NonStaleQueryListener());
            store.Initialize();

            new TemplateTests_Search().Execute(store);

            return(store);
        }
Exemplo n.º 17
0
        public ChrisDNF()
        {
            documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };
            documentStore.RegisterListener(new NoStaleQueriesAllowed());
            documentStore.Initialize();

            new ActivityIndexes.Activity_ByCategoryId().Execute(documentStore);

            AfterInit();
        }
Exemplo n.º 18
0
        public ProjectionTests()
        {
            Now = DateTimeOffset.Now;

            DocumentStore = new EmbeddableDocumentStore {
                RunInMemory = true
            };
            DocumentStore.RegisterListener(new NoStaleQueriesAllowed());
            DocumentStore.Initialize();
            Session = DocumentStore.OpenSession();

            Setup();
        }
Exemplo n.º 19
0
 public IntegrationTest()
 {
     DocumentStore = new EmbeddableDocumentStore()
     {
         RunInMemory = true
     };
     DocumentStore.RegisterListener(new NoStaleQueries());
     DocumentStore.Initialize();
     Session            = DocumentStore.OpenSession();
     UserStore          = new FlexMembershipUserStore <User, Role>(Session);
     Environment        = new FakeApplicationEnvironment();
     RoleProvider       = new FlexRoleProvider(UserStore);
     MembershipProvider = new FlexMembershipProvider(UserStore, Environment);
 }
Exemplo n.º 20
0
        public static DocumentStore Store()
        {
            var store = new EmbeddableDocumentStore
            {
                RunInMemory           = true,
                UseEmbeddedHttpServer = false,
                Conventions           = { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }
            };

            store.Initialize();
            store.RegisterListener(new NonStaleQueryListener());


            new TransactionBalances_ByYear().Execute(store);
            return(store);
        }
Exemplo n.º 21
0
        public void ScriptedPatchShouldNotResultInConcurrencyExceptionForNewlyInsertedDocument()
        {
            using (EmbeddableDocumentStore store = NewDocumentStore())
            {
                new UserProfileIndex().Execute(store);
                store.RegisterListener(new Holt.NonStaleQueryListener());

                OrganizationProfile[] organizations =
                {
                    new OrganizationProfile {
                        Id = "organizations/1", Name = "University of California"
                    },
                    new OrganizationProfile {
                        Id = "organizations/2", Name = "University of Stanford"
                    }
                };

                var orgAdmin1 = new UserProfile {
                    Id = "users/1"
                };
                var orgAdmin2 = new UserProfile {
                    Id = "users/2"
                };

                var orgAdmins = new[]
                {
                    new { User = orgAdmin1, Org = organizations[0] },
                    new { User = orgAdmin2, Org = organizations[1] }
                };

                Store(store, organizations);
                Store(store, new[] { orgAdmin1, orgAdmin2 });

                WaitForIndexing(store);

                IEnumerable <ScriptedPatchCommandData> patches = orgAdmins.SelectMany(orgAdmin =>
                                                                                      Establish(orgAdmin.User, new ManagerOf(orgAdmin.Org),
                                                                                                orgAdmin.Org, new HasManager(orgAdmin.User)));

                BatchResult[] results = ((IDocumentStore)store).DatabaseCommands.Batch(patches.ToArray());
                if (results.Any(r => r.PatchResult.Value != PatchResult.Patched))
                {
                    throw new InvalidOperationException("Some patches failed");
                }
            }
        }
Exemplo n.º 22
0
        internal protected IDocumentStore CreateEmbeddableStore()
        {
            EmbeddableDocumentStore store = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory                                              = true,
                }
            };

            store.Initialize();
            store.RegisterListener(new NoStaleQueriesListener());
            // IndexCreation.CreateIndexes(typeof(RavenUser_Roles).Assembly, store);

            return(store);
        }
Exemplo n.º 23
0
        public RavenDbDataStore()
        {
            _ravenDbCachePath = Path.Combine(
                _tempRavenDbPath,
                Path.Combine(
                    "CompiledIndexCache",
                    Guid.NewGuid().ToString())
                );

            _embeddableDocumentStore = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    CacheDocumentsInMemory                                   = true,
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory                                              = true,
                    CompiledIndexCacheDirectory                              = _ravenDbCachePath,
                    TempPath = _tempRavenDbPath,
                    Settings =
                    {
                        { "Raven/FileSystem/DisableRDC", "true"               },
                        { "Raven/ActiveBundles",         "Unique Constraints" }
                    },
                    Storage                                                  =
                    {
                        PreventSchemaUpdate  = true,
                        SkipConsistencyCheck = true
                    }
                },
                Conventions =
                {
                    DisableProfiling              = true,
                    MaxNumberOfRequestsPerSession = 1000
                }
            };

            _ = _embeddableDocumentStore.RegisterListener(new UniqueConstraintsStoreListener());
            _embeddableDocumentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
            _embeddableDocumentStore.Configuration.Storage.Voron.TempPath      = _tempRavenDbPath;

            _ = _embeddableDocumentStore.Initialize();

            _embeddableDocumentStore.AttachIndexesBeforeUse();
            _embeddableDocumentStore.AttachTransformersBeforeUse();
        }
Exemplo n.º 24
0
        private EmbeddableDocumentStore InitializeDocumentStore(UniqueConstraintsStoreListener listener, int port = 8079)
        {
            EmbeddableDocumentStore documentStore = new EmbeddableDocumentStore
            {
                RunInMemory           = true,
                UseEmbeddedHttpServer = true,
                Configuration         =
                {
                    Port = port
                }
            };

            documentStore.Configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof(UniqueConstraintsPutTrigger).Assembly));
            documentStore.RegisterListener(listener);

            documentStore.Initialize();

            return(documentStore);
        }
Exemplo n.º 25
0
    static void Main()
    {
        using (var documentStore = new EmbeddableDocumentStore
        {
            DataDirectory = "Data",
            Configuration =
            {
                PluginsDirectory = Environment.CurrentDirectory,
            }
        })
        {
            #region RavenDBSetup

            documentStore
            .RegisterListener(new UniqueConstraintsStoreListener())
            .Initialize();

            #endregion

            BusConfiguration busConfiguration = new BusConfiguration();
            busConfiguration.EndpointName("Samples.RavenDBCustomSagaFinder");
            busConfiguration.UseSerialization <JsonSerializer>();
            busConfiguration.EnableInstallers();

            busConfiguration.UsePersistence <RavenDBPersistence>()
            .DoNotSetupDatabasePermissions()     //Only required to simplify the sample setup
            .SetDefaultDocumentStore(documentStore);


            using (IBus bus = Bus.Create(busConfiguration).Start())
            {
                bus.SendLocal(new StartOrder
                {
                    OrderId = "123"
                });

                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }
    }
Exemplo n.º 26
0
        protected RavenControllerTest()
        {
            //NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081);
            documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                //UseEmbeddedHttpServer = true,
            };

            documentStore.RegisterListener(new NoStaleQueriesAllowed());
            documentStore.Initialize();
            IndexCreation.CreateIndexes(typeof(BusStop_Spatial).Assembly, documentStore);

            Controller = new TController {
                RavenSession = documentStore.OpenSession()
            };

            var httpContext = Substitute.For <HttpConfiguration>();
            var httpRoute   = Substitute.For <HttpRouteData>(Substitute.For <IHttpRoute>());

            Controller.ControllerContext = new HttpControllerContext(httpContext, httpRoute, new HttpRequestMessage());
        }
Exemplo n.º 27
0
        private void ConfigureStore(EmbeddableDocumentStore store)
        {
            store.UseEmbeddedHttpServer = true;

            store.Configuration.PluginsDirectory = @"~\Plugins";
            store.Configuration.CreatePluginsDirectoryIfNotExisting  = true;
            store.Configuration.AllowLocalAccessWithoutAuthorization = true;
            store.Configuration.AnonymousUserAccessMode  = AnonymousUserAccessMode.Admin;
            store.Configuration.AccessControlAllowOrigin = new HashSet <string>()
            {
                "*"
            };
            store.Configuration.NewIndexInMemoryMaxBytes = 1073741824;

            store.Conventions = new DocumentConvention()
            {
                DisableProfiling = true,
                MaxNumberOfRequestsPerSession = 30,
                DefaultQueryingConsistency    = ConsistencyOptions.None
            };

            store.RegisterListener(new UniqueConstraintsStoreListener());
        }