Пример #1
0
        public void ShouldCreateAndDeleteDatabase()
        {
            string  databaseName = "thisIsTestDatabaseForNetDriver";
            OServer server       = TestConnection.GetServer();

            bool exists = server.DatabaseExist(databaseName, OStorageType.PLocal);

            if (exists)
            {
                server.DropDatabase(databaseName, OStorageType.PLocal);

                exists = server.DatabaseExist(databaseName, OStorageType.PLocal);
            }

            Assert.AreEqual(exists, false);

            if (!exists)
            {
                bool isCreated = server.CreateDatabase(databaseName, ODatabaseType.Graph, OStorageType.PLocal);

                Assert.AreEqual(isCreated, true);

                if (isCreated)
                {
                    server.DropDatabase(databaseName, OStorageType.PLocal);

                    exists = server.DatabaseExist(databaseName, OStorageType.PLocal);

                    Assert.AreEqual(exists, false);
                }
            }
        }
Пример #2
0
        private static void ConnectionPoolTest()
        {
            OServer server = new OServer(Configuration["ConnectionStrings:DefaultConnection:Server"],
                                         int.Parse(Configuration["ConnectionStrings:DefaultConnection:Port"]),
                                         Configuration["ConnectionStrings:DefaultConnection:Username"],
                                         Configuration["ConnectionStrings:DefaultConnection:Password"]);

            if (server.DatabaseExist(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], OStorageType.PLocal))
            {
                server.DropDatabase(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], OStorageType.PLocal);
            }

            server.CreateDatabase(Configuration["ConnectionStrings:DefaultConnection:DefaultDB"], ODatabaseType.Graph, OStorageType.PLocal);

            using (ODatabase database = new ODatabase(Configuration["ConnectionStrings:DefaultConnection:Server"],
                                                      int.Parse(Configuration["ConnectionStrings:DefaultConnection:Port"]),
                                                      Configuration["ConnectionStrings:DefaultConnection:DefaultDB"],
                                                      ODatabaseType.Graph,
                                                      Configuration["ConnectionStrings:DefaultConnection:Username"],
                                                      Configuration["ConnectionStrings:DefaultConnection:Password"]))
            {
                database.Create.Class("Person").Run();
                database.Insert().Into("Person").Set("Name", $"John").Set("LastName", $"Doe").Set("Age", 99).Run();
                Parallel.For(0, 1000000, (i) =>
                {
                    ODocument document = database.Insert().Into("Person").Set("Name", $"John{i}").Set("LastName", $"Doe{i}").Set("Age", i).Run();
                    //System.Console.WriteLine(document.ORID);
                });
            }
        }
Пример #3
0
 public static void DropTestDatabase()
 {
     if (_server.DatabaseExist(GlobalTestDatabaseName, OStorageType.PLocal))
     {
         _server.DropDatabase(GlobalTestDatabaseName, OStorageType.PLocal);
     }
 }
Пример #4
0
 public static void DropTestDatabase()
 {
     if (_server.DatabaseExist(GlobalTestDatabaseName))
     {
         _server.DropDatabase(GlobalTestDatabaseName);
     }
 }
Пример #5
0
        public static void DropTestDatabase()
        {
            var retry = 2;

            do
            {
                try
                {
                    if (_server.DatabaseExist(GlobalTestDatabaseName, GlobalTestDatabaseStorageType))
                    {
                        _server.DropDatabase(GlobalTestDatabaseName, GlobalTestDatabaseStorageType);
                    }
                    break;
                }
                catch
                {
                    _server.Dispose();
                    _server = new OServer(_hostname, _port, _rootUserName, _rootUserParssword);
                }
                Thread.Sleep(100);
            }while (--retry > 0);

            if (_server.DatabaseExist(GlobalTestDatabaseName, GlobalTestDatabaseStorageType))
            {
                Assert.True(false, "Cannot drop test database.");
            }
        }
 public void DropTestDatabase()
 {
     if (_server.DatabaseExist(GLOBAL_TEST_DATABASE_NAME, OStorageType.Memory))
     {
         _server.DropDatabase(GLOBAL_TEST_DATABASE_NAME, OStorageType.Memory);
     }
 }
        public void DropTestDatabase()
        {
            var retry = 2;

            do
            {
                try
                {
                    if (_server.DatabaseExist(GlobalTestDatabaseName, GlobalTestDatabaseStorageType))
                    {
                        _server.DropDatabase(GlobalTestDatabaseName, GlobalTestDatabaseStorageType);
                    }
                    break;
                }
                catch
                {
                    _server.Dispose();
                    _server = new OServer(_hostname, port, _rootUserName, _rootUserParssword);
                }
            }while (--retry > 0);
        }
Пример #8
0
        static void Main(string[] args)
        {
            _server = new OServer(_hostname, _port, _rootUserName, _rootUserPassword);

            //If the DB already exists I delete it
            if (_server.DatabaseExist(_DBname, OStorageType.PLocal))
            {
                _server.DropDatabase("TestDatabaseName", OStorageType.PLocal);
                Console.WriteLine("Database " + _DBname + " deleted");
            }
            //Creating the new DB
            _server.CreateDatabase(_DBname, ODatabaseType.Graph, OStorageType.PLocal);
            Console.WriteLine("Database " + _DBname + " created");
            //Connect to the DB and populate it
            OClient.CreateDatabasePool(
                "127.0.0.1",
                2424,
                _DBname,
                ODatabaseType.Graph,
                _username,
                _password,
                10,
                "myTestDatabaseAlias"
                );
            Console.WriteLine("Connected to the DB " + _DBname);
            using (ODatabase database = new ODatabase("myTestDatabaseAlias"))
            {
                database
                .Create.Class("TestClass")
                .Extends <OVertex>()
                .Run();
                OVertex createdVertex = database
                                        .Create.Vertex("TestClass")
                                        .Set("name", "LucaS")
                                        .Run();
                Console.WriteLine("Created vertex with @rid " + createdVertex.ORID);
            }
        }
Пример #9
0
        static void CreateDatabaseTestManualy()
        {
            var serverConnInfo = Configuration.GetSection("ConnectionStrings:DefaultConnection").GetChildren().ToDictionary(x => x.Key);

            using (var server = new OServer(serverConnInfo["Server"].Value, int.Parse(serverConnInfo["Port"].Value), serverConnInfo["Username"].Value, serverConnInfo["Password"].Value))
            {
                var created = false;
                try
                {
                    var exists = server.DatabaseExist("TestManualy", OStorageType.PLocal);
                    if (exists)
                    {
                        server.DropDatabase("TestManualy", OStorageType.PLocal);
                    }

                    created = server.CreateDatabase("TestManualy", ODatabaseType.Document, OStorageType.PLocal);

                    if (!created)
                    {
                        throw new Exception("Database not created");
                    }

                    exists = server.DatabaseExist("TestManualy", OStorageType.PLocal);

                    if (!exists)
                    {
                        throw new Exception("Database not exists");
                    }

                    System.Console.WriteLine("Database created - get server configuration");

                    var config = server.ConfigList();
                    foreach (var item in config)
                    {
                        System.Console.WriteLine("{0} : {1}",
                                                 item.Key, item.Value);
                    }

                    System.Console.WriteLine("try connect to the database and query");

                    OClient.CreateDatabasePool(
                        serverConnInfo["Server"].Value,
                        int.Parse(serverConnInfo["Port"].Value),
                        "TestManualy",
                        ODatabaseType.Graph,
                        serverConnInfo["Username"].Value,
                        serverConnInfo["Password"].Value,
                        10,
                        "AppConnection"
                        );
                    using (var database = new ODatabase("AppConnection"))
                    {
                        var documents = database.Query("select from OUser");
                        foreach (var item in documents)
                        {
                            System.Console.WriteLine("Name: {0} Status: {1}",
                                                     item.GetField <string>("name"), item.GetField <string>("status"));
                        }
                    }
                    OClient.DropDatabasePool("AppConnection");
                }
                finally
                {
                    if (created)
                    {
                        server.DropDatabase("TestManualy", OStorageType.PLocal);
                    }
                }
            }
        }
Пример #10
0
        static void CreateDatabaseTestManualy()
        {
            using (var server = new OServer("127.0.0.1", 2424, "root", "root"))
            {
                var created = false;
                try
                {
                    created = server.CreateDatabase("TestManualy", ODatabaseType.Document, OStorageType.PLocal);

                    if (!created)
                    {
                        throw new Exception("Database not created");
                    }

                    var exists = server.DatabaseExist("TestManualy", OStorageType.PLocal);

                    if (!exists)
                    {
                        throw new Exception("Database not exists");
                    }

                    System.Console.WriteLine("Database created - get server configuration");

                    var config = server.ConfigList();
                    foreach (var item in config)
                    {
                        System.Console.WriteLine("{0} : {1}",
                                                 item.Key, item.Value);
                    }

                    System.Console.WriteLine("try connect to the database and query");

                    OClient.CreateDatabasePool(
                        "localhost",
                        2424,
                        "TestManualy",
                        ODatabaseType.Graph,
                        "root",
                        "root",
                        10,
                        "AppConnection"
                        );
                    using (var database = new ODatabase("AppConnection"))
                    {
                        var documents = database.Query("select from OUser");
                        foreach (var item in documents)
                        {
                            System.Console.WriteLine("Name: {0} Status: {1}",
                                                     item.GetField <string>("name"), item.GetField <string>("status"));
                        }
                    }
                    OClient.DropDatabasePool("AppConnection");
                }
                finally
                {
                    if (created)
                    {
                        server.DropDatabase("TestManualy", OStorageType.PLocal);
                    }
                }
            }
        }