コード例 #1
0
        public override ServerControls NewServer()
        {
            try
            {
                using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
                {
                    File userLogFile     = new File(_serverFolder, "neo4j.log");
                    File internalLogFile = new File(_serverFolder, "debug.log");

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.OutputStream logOutputStream;
                    Stream logOutputStream;
                    try
                    {
                        logOutputStream = createOrOpenAsOutputStream(fileSystem, userLogFile, true);
                    }
                    catch (IOException e)
                    {
                        throw new Exception("Unable to create log file", e);
                    }

                    _config[ServerSettings.third_party_packages.name()]           = ToStringForThirdPartyPackageProperty(_extensions.toList());
                    _config[GraphDatabaseSettings.store_internal_log_path.name()] = internalLogFile.AbsolutePath;

                    LogProvider userLogProvider            = FormattedLogProvider.withZoneId(LogZoneIdFrom(_config)).toOutputStream(logOutputStream);
                    GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Iterable<org.neo4j.kernel.extension.KernelExtensionFactory<?>> kernelExtensions = append(new Neo4jHarnessExtensions(procedures), dependencies.kernelExtensions());
                    IEnumerable <KernelExtensionFactory <object> > kernelExtensions = append(new Neo4jHarnessExtensions(_procedures), dependencies.KernelExtensions());
                    dependencies = dependencies.KernelExtensions(kernelExtensions);

                    Config       dbConfig             = Config.defaults(_config);
                    GraphFactory graphFactory         = CreateGraphFactory(dbConfig);
                    bool         httpAndHttpsDisabled = dbConfig.EnabledHttpConnectors().Count == 0;

                    NeoServer server = httpAndHttpsDisabled ? new DisabledNeoServer(graphFactory, dependencies, dbConfig) : CreateNeoServer(graphFactory, dbConfig, dependencies);

                    InProcessServerControls controls = new InProcessServerControls(_serverFolder, userLogFile, internalLogFile, server, logOutputStream);
                    controls.Start();

                    try
                    {
                        _fixtures.applyTo(controls);
                    }
                    catch (Exception e)
                    {
                        controls.Close();
                        throw e;
                    }
                    return(controls);
                }
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
        }
コード例 #2
0
        public virtual void ApplyTo(InProcessServerControls controls)
        {
            GraphDatabaseService db = controls.Graph();

            foreach (string fixtureStatement in _fixtureStatements)
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.execute(fixtureStatement);
                    tx.Success();
                }
            }
            foreach (System.Func <GraphDatabaseService, Void> fixtureFunction in _fixtureFunctions)
            {
                fixtureFunction(db);
            }
        }