Example #1
0
        public async Task ping_happy_path_with_http_protocol()
        {
            var sender = new BatchedSender("http://localhost:5005/messages".ToUri(),
                                           new HttpSenderProtocol(new MessagingSettings()), CancellationToken.None,
                                           TransportLogger.Empty());


            var runtime = await JasperRuntime.ForAsync <JasperRegistry>(_ =>
            {
                _.Transports.Http.EnableListening(true);
                _.Hosting.UseUrls("http://localhost:5005");
                _.Hosting.UseKestrel();

                _.Services.AddLogging();

                _.Hosting.Configure(app =>
                {
                    app.UseJasper();

                    app.Run(c => c.Response.WriteAsync("Hello"));
                });
            });

            try
            {
                await sender.Ping();
            }
            finally
            {
                await runtime.Shutdown();
            }
        }
Example #2
0
        public async Task ping_sad_path_with_tcp()
        {
            var sender = new BatchedSender("tcp://localhost:3322".ToUri(), new SocketSenderProtocol(),
                                           CancellationToken.None, TransportLogger.Empty());

            await Should.ThrowAsync <InvalidOperationException>(async() => { await sender.Ping(CancellationToken.None); });
        }
Example #3
0
        public async Task ping_sad_path_with_tcp()
        {
            var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(),
                                           CancellationToken.None, CompositeTransportLogger.Empty());

            await Jasper.Testing.Exception <InvalidOperationException> .ShouldBeThrownByAsync(async() =>
            {
                await sender.Ping();
            });
        }
Example #4
0
        public async Task ping_sad_path_with_http_protocol()
        {
            var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new BusSettings()), CancellationToken.None, CompositeTransportLogger.Empty());



            await Jasper.Testing.Exception <HttpRequestException> .ShouldBeThrownByAsync(async() =>
            {
                await sender.Ping();
            });
        }
Example #5
0
        public async Task ping_happy_path_with_tcp()
        {
            using (var runtime = JasperHost.For(_ => { _.Endpoints.ListenAtPort(2222); }))
            {
                var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(),
                                               CancellationToken.None, TransportLogger.Empty());

                sender.RegisterCallback(new StubSenderCallback());

                await sender.Ping(CancellationToken.None);
            }
        }
Example #6
0
        public async Task ping_happy_path_with_tcp()
        {
            using (var runtime = JasperRuntime.For(_ => { _.Transports.LightweightListenerAt(2222); }))
            {
                var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(),
                                               CancellationToken.None, TransportLogger.Empty());

                sender.Start(new StubSenderCallback());

                await sender.Ping();
            }
        }
Example #7
0
        public async Task ping_happy_path_with_http_protocol()
        {
            var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new BusSettings()), CancellationToken.None, CompositeTransportLogger.Empty());


            using (var runtime = JasperRuntime.For(_ =>
            {
                _.Transports.Http.EnableListening(true);
                _.Http.UseUrls("http://localhost:5005").UseKestrel();
            }))
            {
                await sender.Ping();
            }
        }