Beispiel #1
0
        private void TestP2PError(MockConnectionLifecycleLocation location, bool recoverable)
        {
            using (var mdoc = new MutableDocument("livesindb")) {
                mdoc.SetString("name", "db");
                Db.Save(mdoc);
            }

            var expectedDomain = recoverable ? 0 : CouchbaseLiteErrorType.CouchbaseLite;
            var expectedCode   = recoverable ? 0 : (int)CouchbaseLiteError.WebSocketAbnormalClose;

            var config = CreateFailureP2PConfiguration(ProtocolType.ByteStream, location, recoverable);

            RunReplication(config, expectedCode, expectedDomain);
            config = CreateFailureP2PConfiguration(ProtocolType.MessageStream, location, recoverable);
            RunReplication(config, expectedCode, expectedDomain, true);
        }
Beispiel #2
0
        private ReplicatorConfiguration CreateFailureP2PConfiguration(ProtocolType protocolType, MockConnectionLifecycleLocation location, bool recoverable)
        {
            var errorLocation = TestErrorLogic.FailWhen(location);

            if (recoverable)
            {
                errorLocation.WithRecoverableException();
            }
            else
            {
                errorLocation.WithPermanentException();
            }

            var listener = new MessageEndpointListener(new MessageEndpointListenerConfiguration(_otherDB, protocolType));
            var server   = new MockServerConnection(listener, protocolType)
            {
                ErrorLogic = errorLocation
            };
            var config = new ReplicatorConfiguration(Db,
                                                     new MessageEndpoint("p2ptest1", server, protocolType, new MockConnectionFactory(errorLocation)))
            {
                ReplicatorType = ReplicatorType.Push,
                Continuous     = false
            };

            return(config);
        }
Beispiel #3
0
 public bool ShouldClose(MockConnectionLifecycleLocation location)
 {
     return(ErrorActive && location == MockConnectionLifecycleLocation.Connect);
 }
Beispiel #4
0
 public bool ShouldClose(MockConnectionLifecycleLocation location)
 {
     return(_current < _total && _locations.HasFlag(location));
 }
Beispiel #5
0
 public static TestErrorLogic FailWhen(MockConnectionLifecycleLocation locations)
 {
     return(new TestErrorLogic(locations));
 }
Beispiel #6
0
 private TestErrorLogic(MockConnectionLifecycleLocation locations)
 {
     _locations = locations;
 }