コード例 #1
0
        public void TestServerErrors()
        {
            // tests the behaviour of the client when the server sends an error
            IReplicator replicator = new HttpReplicator(host, port, ReplicationService.REPLICATION_CONTEXT + "/s1", server.CreateHandler());

            using ReplicationClient client = new ReplicationClient(replicator, new IndexReplicationHandler(handlerIndexDir, null),
                                                                   new PerSessionDirectoryFactory(clientWorkDir.FullName));

            try
            {
                PublishRevision(5);

                try
                {
                    mockErrorConfig.RespondWithError = true;
                    client.UpdateNow();
                    fail("expected exception");
                }
                catch (Exception t) when(t.IsThrowable())
                {
                    // expected
                }

                mockErrorConfig.RespondWithError = false;
                client.UpdateNow(); // now it should work
                ReopenReader();
                assertEquals(5, J2N.Numerics.Int32.Parse(reader.IndexCommit.UserData["ID"], 16));

                client.Dispose();
            }
            finally
            {
                mockErrorConfig.RespondWithError = false;
            }
        }
コード例 #2
0
        public void TestBasic()
        {
            IReplicator       replicator = new HttpReplicator(host, port, ReplicationService.REPLICATION_CONTEXT + "/s1", server.CreateHandler());
            ReplicationClient client     = new ReplicationClient(replicator, new IndexReplicationHandler(handlerIndexDir, null),
                                                                 new PerSessionDirectoryFactory(clientWorkDir.FullName));

            PublishRevision(1);
            client.UpdateNow();
            ReopenReader();
            assertEquals(1, int.Parse(reader.IndexCommit.UserData["ID"], NumberStyles.HexNumber));

            PublishRevision(2);
            client.UpdateNow();
            ReopenReader();
            assertEquals(2, int.Parse(reader.IndexCommit.UserData["ID"], NumberStyles.HexNumber));
        }