Beispiel #1
0
        public virtual void TestMissingClassesInServer()
        {
            IList serverMissedClasses = new ArrayList();
            IList clientMissedClasses = new ArrayList();
            var   serverConfig        = Db4oClientServer.NewServerConfiguration();

            PrepareHost(serverConfig.File, serverConfig.Common, serverMissedClasses);
            ExcludeClasses(serverConfig.Common, new[]
            {
                typeof(Pilot
                       ),
                typeof(Car)
            });
            var server = Db4oClientServer.OpenServer(serverConfig, DbUri, Port);

            server.GrantAccess(User, Password);
            try
            {
                var clientConfig = Db4oClientServer.NewClientConfiguration();
                PrepareCommon(clientConfig.Common, clientMissedClasses);
                var client = Db4oClientServer.OpenClient(clientConfig, "localhost",
                                                         Port, User, Password);
                client.Query(new AcceptAllPredicate());
                client.Close();
            }
            finally
            {
                server.Close();
            }
            AssertPilotAndCarMissing(serverMissedClasses);
            Assert.AreEqual(0, clientMissedClasses.Count);
        }
Beispiel #2
0
        private IClientConfiguration MultithreadedClientConfig()
        {
            var config = Db4oClientServer.NewClientConfiguration();

            config.Networking.SingleThreadedClient = false;
            return(config);
        }
Beispiel #3
0
        /// <summary></summary>
        public DummyLocalConnectedClient(int port)
        {
            IClientConfiguration config = Db4oClientServer.NewClientConfiguration();

            config.Common.StringEncoding = StringEncodings.Utf8();
            Client = Db4oClientServer.OpenClient(config, "127.0.0.1", port, User, Password);
        }
Beispiel #4
0
        private static IObjectContainer  ConnectClient()
        {
            IClientConfiguration config = Db4oClientServer.NewClientConfiguration();

            ConfigureCommon(config.Common);
            return(Db4oClientServer.OpenClient(config, conn.Host, conn.Port, conn.UserName, conn.PassWord));
        }
Beispiel #5
0
        private static void SimpleMessagingExample()
        {
            IObjectServer server = StartUpServer();

            // #example: configure a message receiver for a client
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.MessageRecipient = new ClientMessageReceiver();
            // #end example

            // #example: Get the message sender and use it
            IMessageSender sender = configuration.MessageSender;

            using (IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost",
                                                                            PortNumber, UserAndPassword,
                                                                            UserAndPassword))
            {
                sender.Send(new HelloMessage("Hi Server!"));
                WaitForAWhile();
            }
            // #end example


            server.Close();
        }
        public virtual void TestClientServerApi()
        {
            IServerConfiguration config = Db4oClientServer.NewServerConfiguration();
            IObjectServer        server = Db4oClientServer.OpenServer(config, TempFile(), unchecked (
                                                                          (int)(0xdb40)));

            try
            {
                server.GrantAccess("user", "password");
                IClientConfiguration clientConfig = Db4oClientServer.NewClientConfiguration();
                IObjectContainer     client1      = Db4oClientServer.OpenClient(clientConfig, "localhost",
                                                                                unchecked ((int)(0xdb40)), "user", "password");
                try
                {
                }
                finally
                {
                    Assert.IsTrue(client1.Close());
                }
            }
            finally
            {
                Assert.IsTrue(server.Close());
            }
        }
        private IObjectContainer OpenClient(int port)
        {
            var config = Db4oClientServer.NewClientConfiguration();

            config.PrefetchIDCount = PrefetchIdCount;
            return(Db4oClientServer.OpenClient(config, "localhost", port, User, Password));
        }
        public virtual void TestMissingClassesInClient()
        {
            IList serverMissedClasses         = new ArrayList();
            IList clientMissedClasses         = new ArrayList();
            IServerConfiguration serverConfig = Db4oClientServer.NewServerConfiguration();

            PrepareHost(serverConfig.File, serverConfig.Common, serverMissedClasses);
            IObjectServer server = Db4oClientServer.OpenServer(serverConfig, DbUri, Port);

            server.GrantAccess(User, Password);
            try
            {
                IClientConfiguration clientConfig = Db4oClientServer.NewClientConfiguration();
                PrepareCommon(clientConfig.Common, clientMissedClasses);
                ExcludeClasses(clientConfig.Common, new Type[] { typeof(MissingClassDiagnosticsTestCase.Pilot
                                                                        ), typeof(MissingClassDiagnosticsTestCase.Car) });
                IObjectContainer client = Db4oClientServer.OpenClient(clientConfig, "localhost",
                                                                      Port, User, Password);
                IObjectSet result = client.Query(new MissingClassDiagnosticsTestCase.AcceptAllPredicate
                                                     ());
                IterateOver(result);
                client.Close();
            }
            finally
            {
                server.Close();
            }
            Assert.AreEqual(0, serverMissedClasses.Count);
            AssertPilotAndCarMissing(clientMissedClasses);
        }
Beispiel #9
0
        /// <summary>
        /// stops a db4o Server started with StartServer.
        /// </summary>
        /// <exception cref="Exception" />
        public static void Main(string[] args)
        {
            IObjectContainer IObjectContainer = null;

            try
            {
                // connect to the server
                IObjectContainer = Db4oClientServer.OpenClient(Db4oClientServer.NewClientConfiguration(),
                                                               HOST, PORT, USER, PASS);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            if (IObjectContainer != null)
            {
                // get the messageSender for the IObjectContainer
                IMessageSender messageSender = IObjectContainer.Ext()
                                               .Configure().ClientServer().GetMessageSender();

                // send an instance of a StopServer object
                messageSender.Send(new StopServer());

                // close the IObjectContainer
                IObjectContainer.Close();
            }
        }
Beispiel #10
0
        //Container/Client Staff

        private IObjectContainer GetContainerFromConfig(DB4ODatabaseElement dataBaseData, HttpContext context)
        {
            Debug.WriteLine(String.Format("GetContainerFromConfig (database: {0})", dataBaseData.Alias));

            IObjectContainer container;

            switch (dataBaseData.ServerType)
            {
            case Db4oServerType.NetworkingServer:

                var clientConfig = Db4oClientServer.NewClientConfiguration();

                if (dataBaseData.ExistAnyCustomConfiguration())
                {
                    clientConfig = dataBaseData.GetServerConfig <IClientConfiguration>();
                }

                container = Db4oClientServer.OpenClient(clientConfig, dataBaseData.RemoteHost, dataBaseData.RemotePort,
                                                        dataBaseData.RemoteUser, dataBaseData.RemotePassWord);

                break;

            case Db4oServerType.EmbeddedServer:
            default:

                var server = GetEmbeddedServer(dataBaseData, 0, context);
                container = server.OpenClient();

                break;
            }

            BindContainerEvents(container, dataBaseData);

            return(container);
        }
 public virtual void TestConfigurationHierarchy()
 {
     Assert.IsInstanceOf(typeof(INetworkingConfigurationProvider), Db4oClientServer.NewClientConfiguration
                             ());
     Assert.IsInstanceOf(typeof(INetworkingConfigurationProvider), Db4oClientServer.NewServerConfiguration
                             ());
 }
Beispiel #12
0
        private ClientObjectContainer OpenClient(int port)
        {
            ClientObjectContainer client = (ClientObjectContainer)Db4oClientServer.OpenClient
                                               (Db4oClientServer.NewClientConfiguration(), "localhost", port, Username, Password
                                               );

            return(client);
        }
Beispiel #13
0
        private static void PluggableSocket()
        {
            // #example: Exchange the socket-factory
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.SocketFactory = new StandardSocket4Factory();
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "sa", "sa");
        }
Beispiel #14
0
        private static void SingleThreadedClient()
        {
            // #example: single threaded client
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.SingleThreadedClient = true;
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "sa", "sa");
        }
Beispiel #15
0
        private static void MaxBatchQueueSize()
        {
            // #example: change the maximum batch queue size
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.MaxBatchQueueSize = 1024;
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "sa", "sa");
        }
Beispiel #16
0
        private static void ReplaceClientServerFactory()
        {
            // #example: exchange the way a client or server is created
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.ClientServerFactory = new StandardClientServerFactory();
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "sa", "sa");
        }
Beispiel #17
0
        private static void EnableBatchMode()
        {
            // #example: enable or disable batch mode
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Networking.BatchMessages = true;
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "sa", "sa");
        }
Beispiel #18
0
        private static void ClientConfiguration()
        {
            // #example: Configure a client object container
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();
            // change the configuration...
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "pwd");

            // #end example
            container.Close();
        }
Beispiel #19
0
        public static void PrefetchIDCount()
        {
            // #example: Configure the prefetch id count
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.PrefetchSlotCacheSize = 128;
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "password");

            container.Close();
        }
Beispiel #20
0
        private static void RunClient()
        {
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.Common.Add(new NetworkingMonitoringSupport());
            using (IObjectContainer client = Db4oClientServer.OpenClient(configuration,
                                                                         "localhost", PortNumber, User, Password))
            {
                DoOperationsOnClient(client);
            }
        }
Beispiel #21
0
        public static void PrefetchDepth()
        {
            // #example: Configure the prefetch depth
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.PrefetchDepth = 5;
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "password");

            container.Close();
        }
Beispiel #22
0
        public static void ConnectionTimeOut()
        {
            // #example: Configure the timeout
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.TimeoutClientSocket = (1 * 60 * 1000);
            // #end example
            IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "password");

            container.Close();
        }
Beispiel #23
0
        private static void SSLClient()
        {
            // #example: Add SSL-support to the client
            IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration();

            configuration.AddConfigurationItem(new ClientSslSupport(CheckCertificate));
            // #end example
            using (IObjectContainer container = OpenClient(configuration))
            {
                container.Store(new Person());
                Console.Out.WriteLine("Stored person");
            }
        }
 public override IFixtureProvider[] FixtureProviders()
 {
     return(new[]
     {
         Subjects(new object[]
         {
             Db4oEmbedded.NewConfiguration
                 (),
             Db4oClientServer.NewClientConfiguration(), Db4oClientServer.NewServerConfiguration
                 ()
         })
     });
 }
Beispiel #25
0
        /// <summary>
        /// Open connection to the entity service.
        /// </summary>
        /// <exception cref="System.Exception">Throws when the singleton
        /// is already initialized.</exception>
        public void Open()
        {
            if (_container != null)
            {
                throw new Exception("Context is open");
            }
            var userInfo = _connectionString.UserInfo.Split(new char[] { ':' });

            _container = Db4oClientServer.OpenClient(
                Db4oClientServer.NewClientConfiguration(),
                _connectionString.Host,
                _connectionString.Port,
                userInfo[0],
                userInfo[1]);
        }
Beispiel #26
0
        private static IObjectContainer  ConnectClient()
        {
            IClientConfiguration config = null;

            if (CustomConfig)
            {
                config = ManageCustomConfig.ConfigureClientCustomConfig();
            }
            if (config == null)
            {
                config = Db4oClientServer.NewClientConfiguration();
            }
            ConfigureCommon(config.Common);
            return(Db4oClientServer.OpenClient(config, CurrentConnParams.Host, CurrentConnParams.Port, CurrentConnParams.UserName, CurrentConnParams.PassWord));
        }
        private IObjectContainer OpenContainer()
        {
            string user     = "******";
            string password = "******";

            _server = Db4oClientServer.OpenServer(((IServerConfiguration)Configure(Db4oClientServer
                                                                                   .NewServerConfiguration(), "db4o server(" + DatabaseFileName + ")")), DatabaseFileName
                                                  , Db4oClientServer.ArbitraryPort);
            _server.GrantAccess(user, password);
            return(Db4oClientServer.OpenClient(((IClientConfiguration)Configure(Db4oClientServer
                                                                                .NewClientConfiguration(), "db4o client(localhost:" + _server.Ext().Port() + ")"
                                                                                )), "localhost", _server.Ext().Port(), user, password));

            return(Db4oEmbedded.OpenFile(((IEmbeddedConfiguration)Configure(Db4oEmbedded.NewConfiguration
                                                                                (), "db4o(" + DatabaseFileName + ")")), DatabaseFileName));
        }
        public virtual void Test()
        {
            IServerConfiguration serverConfig = Db4oClientServer.NewServerConfiguration();

            serverConfig.File.Storage = new MemoryStorage();
            IObjectServer server = Db4oClientServer.OpenServer(serverConfig, string.Empty, Db4oClientServer
                                                               .ArbitraryPort);

            server.GrantAccess(User, Password);
            IClientConfiguration clientConfig = Db4oClientServer.NewClientConfiguration();

            ClientConfigurationItemIntegrationTestCase.DummyConfigurationItem item = new ClientConfigurationItemIntegrationTestCase.DummyConfigurationItem
                                                                                         (this);
            clientConfig.AddConfigurationItem(item);
            IExtClient client = (IExtClient)Db4oClientServer.OpenClient(clientConfig, "localhost"
                                                                        , server.Ext().Port(), User, Password);

            item.Verify(clientConfig, client);
            client.Close();
            server.Close();
        }
 /// <exception cref="System.Exception"></exception>
 public virtual void SetUp()
 {
     _applied = new ArrayList();
     _config  = (ClientConfigurationImpl)Db4oClientServer.NewClientConfiguration();
 }