public void Should_throw_ArgumentNullException_parameter_path() { Assert.ThrowsException <ArgumentNullException>(() => { var rpe = new ReplayExtension(""); }); }
public void Should_throw_ArgumentNullException_parameter_netMonFile() { Assert.ThrowsException <ArgumentNullException>(() => { var rpe = new ReplayExtension(netMonFile: null); }); }
public void Should_add_one_ReadDeviceInfoIndicationBehavior_to_BehaviorList_from_testfile() { var rpe = new ReplayExtension(@".\TestFiles\ReadDeviceInfo.cap"); Assert.IsNotNull(rpe.BehaviorList); Assert.AreEqual(rpe.BehaviorList.Count(), 1); Assert.IsInstanceOfType(rpe.BehaviorList.First(), typeof(ReadDeviceInfoIndicationBehavior)); }
static void Main(string[] args) { var longPollingTransport = new LongPollingTransport(null) { HeaderCollection = new WebHeaderCollection { new NameValueCollection { { "Content-Type", "application/json" }, { "Authorization", $"Bearer {accessToken}" } }, }, CookieCollection = new CookieCollection(), }; var client = new BayeuxClient(url, new List <ClientTransport> { longPollingTransport }); // Save the newReplayId in a reliable way. This is basically the last message processed // So when your application recovers a crash the next subscription should start from the last replay id processed var replayExtension = new ReplayExtension((changedChannel, newReplayId) => Console.WriteLine($"{changedChannel}: {newReplayId}")); replayExtension.SetReplayId(channelName, replayId); client.AddExtension(replayExtension); client.Handshake(new Dictionary <string, object> { { MessageFields.ReplayField, true } }); var result = client.WaitFor(6000, new List <BayeuxClient.State> { BayeuxClient.State.Connected }); // Subscription to channels IClientSessionChannel channel = client.GetChannel(channelName); var listener = new SimpleListener(); channel.Subscribe(listener); //channel.Unsubscribe(listener); //replayExtension.SetReplayId(channelName, 100); //channel.Subscribe(listener); Thread.Sleep(Timeout.Infinite); }
public async Task Should_add_one_ReadIndicationBehavior_to_BehaviorList_from_NetMonFile() { var capFilePath = @".\TestFiles\ReadRequestPort10k.cap"; var(ok, nmf) = await NetMonFileFactory.TryParseNetMonFileAsync(capFilePath, CancellationToken.None, null); Assert.IsTrue(ok); var rpe = new ReplayExtension(nmf); Assert.IsNotNull(rpe.BehaviorList); Assert.AreEqual(rpe.BehaviorList.Count(), 1); Assert.IsInstanceOfType(rpe.BehaviorList.First(), typeof(ReadIndicationBehavior)); }
private void InitBayeuxClient() { if (_isDisposed) { throw new ObjectDisposedException("Cannot create connection when disposed"); } _logger.LogDebug("Initializing {name} ...", nameof(BayeuxClient)); if (!_authenticationClient.IsAuthenticated) { Reauthenticate(); } _tokenInfo = _authenticationClient.AuthenticationClient.AccessInfo; // Salesforce socket timeout during connection(CometD session) = 110 seconds var options = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase) { { ClientTransport.TIMEOUT_OPTION, _options.ReadTimeOut ?? ReadTimeOut }, { ClientTransport.MAX_NETWORK_DELAY_OPTION, _options.ReadTimeOut ?? ReadTimeOut } }; var headers = new NameValueCollection { { HttpRequestHeader.Authorization.ToString(), $"OAuth {_tokenInfo.AccessToken}" } }; _clientTransport = new LongPollingTransport(options, headers); // only need the scheme and host, strip out the rest var serverUri = new Uri(_tokenInfo.InstanceUrl); var endpoint = $"{serverUri.Scheme}://{serverUri.Host}{_options.CometDUri}"; _bayeuxClient = new BayeuxClient(endpoint, _clientTransport); // adds logging and also raises an event to process reconnection to the server. _errorExtension = new ErrorExtension(); _errorExtension.ConnectionError += ErrorExtension_ConnectionError; _errorExtension.ConnectionException += ErrorExtension_ConnectionException; _errorExtension.ConnectionMessage += ErrorExtension_ConnectionMessage; _bayeuxClient.AddExtension(_errorExtension); _replayIdExtension = new ReplayExtension(); _bayeuxClient.AddExtension(_replayIdExtension); _logger.LogDebug("{name} initializing completed...", nameof(BayeuxClient)); }
public void Should_not_throw_on_invalid_file_path() { var rpe = new ReplayExtension("invalidPath.cap"); Assert.IsNull(rpe.BehaviorList); }