Example #1
0
        public void CanRouteLiveDataMeasurements()
        {
            var queue = BuildRemoteQueue();

            queue.EnqueueMeasurementToTarget(new Measurement {
                Timestamp         = DateTime.UtcNow,
                PlatformTimestamp = DateTime.UtcNow,
                Latitude          = 1.1234M,
                Longitude         = 1.134643M,
                SensorId          = ObjectId.GenerateNewId(),
                Data = new Dictionary <string, DataPoint>()
            }, new RoutingTarget()
            {
                Target = "Local"
            });

            queue.EnqueueMeasurementToTarget(new Measurement {
                Timestamp         = DateTime.UtcNow,
                PlatformTimestamp = DateTime.UtcNow,
                Latitude          = 1.1234M,
                Longitude         = 1.134643M,
                SensorId          = ObjectId.GenerateNewId(),
                Data = new Dictionary <string, DataPoint>()
            }, new RoutingTarget()
            {
                Target = "Local"
            });

            queue.FlushAsync();
            Assert.AreEqual(1, ClientStub.GetPublishCount("sensateiot/internal/measurements/Local/bulk"));
        }
Example #2
0
        public void CanRouteLiveDataMessages()
        {
            var queue = BuildRemoteQueue();

            queue.EnqueueMessageToTarget(new Message {
                Timestamp         = DateTime.UtcNow,
                PlatformTimestamp = DateTime.UtcNow,
                Data     = "Hello, World",
                SensorId = ObjectId.GenerateNewId()
            }, new RoutingTarget {
                Target = "Local"
            });

            queue.EnqueueMessageToTarget(new Message {
                Timestamp         = DateTime.UtcNow,
                PlatformTimestamp = DateTime.UtcNow,
                Data     = "Hello, World",
                SensorId = ObjectId.GenerateNewId()
            }, new RoutingTarget {
                Target = "Remote"
            });

            queue.FlushAsync();
            Assert.AreEqual(1, ClientStub.GetPublishCount("sensateiot/internal/messages/Local/bulk"));
            Assert.AreEqual(1, ClientStub.GetPublishCount("sensateiot/internal/messages/Remote/bulk"));
        }
Example #3
0
        public void WithDuplicateAccessTokenReturnsSameStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient(), "accessToken");

            var stub2 = stub.WithAccess("accessToken");

            stub.Should().Be(stub2);
        }
Example #4
0
        public void WithNonEmptyAccessTokenGeneratesNewStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var stub2 = stub.WithAccess("accessToken");

            stub.Should().NotBe(stub2);
        }
Example #5
0
        public void WithEmptyAccessTokenReturnsSameStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var stub2 = stub.WithAccess(null);

            Assert.AreEqual(stub, stub2);
        }
Example #6
0
        public void SimpleCallExample()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var response = stub.Dispatch(new MeaningOfLifeRequest(), (c, r, o) => c.WhatIsTheMeaningOfLife(r, o));

            response.MeaningOfLife.Should().Be(42);
        }
Example #7
0
        public void WithDuplicateAccessTokenReturnsSameStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient(), "accessToken");

            var stub2 = stub.WithAccess("accessToken");

            Assert.AreEqual(stub, stub2);
        }
Example #8
0
        public void WithNonEmptyAccessTokenGeneratesNewStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var stub2 = stub.WithAccess("accessToken");

            Assert.AreNotEqual(stub, stub2);
        }
Example #9
0
        public void SimpleCallExample()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var response = stub.Dispatch(new MeaningOfLifeRequest(), (c, r, o) => c.WhatIsTheMeaningOfLife(r, o));

            Assert.AreEqual(42, response.MeaningOfLife);
        }
Example #10
0
        public void WithEmptyAccessTokenReturnsSameStub()
        {
            var stub = new ClientStub <ServiceClient>(new ServiceClient());

            var stub2 = stub.WithAccess(null);

            stub.Should().Be(stub2);
        }
Example #11
0
            public void Throws_exception_on_no_sender()
            {
                //Arrange
                var clientConfiguration = new ClientConfiguration(Environment.DifiQa, GetPostenTestCertificate());
                var client = new ClientStub(clientConfiguration);

                //Act
                Assert.Throws <SenderNotSpecifiedException>(() => client.GetCurrentSender(null));
            }
Example #12
0
            public void Returns_job_sender_if_only_set()
            {
                //Arrange
                var expected            = new Sender(BringPublicOrganizationNumber);
                var clientConfiguration = new ClientConfiguration(Environment.DifiQa, GetBringCertificate());
                var client = new ClientStub(clientConfiguration);

                //Act
                var actual = client.GetCurrentSender(expected);

                //Assert
                Assert.Equal(expected, actual);
            }
Example #13
0
            public void Can_disable_sender_certificate_validation()
            {
                //Arrange
                var sender = new Sender(BringPublicOrganizationNumber);
                var incorrectSenderCertificate = GetPostenTestCertificate();
                var clientConfiguration        = new ClientConfiguration(Environment.DifiQa, incorrectSenderCertificate)
                {
                    CertificateValidationPreferences = { ValidateSenderCertificate = false }
                };
                var client = new ClientStub(clientConfiguration);

                //Act
                var actual = client.GetCurrentSender(sender);

                //Assert
            }
Example #14
0
            public void Initializes_with_properties()
            {
                //Arrange
                var clientConfiguration = new ClientConfiguration(Environment.DifiQa, GetBringCertificate())
                {
                    HttpClientTimeoutInMilliseconds = 1441
                };

                //Act
                var clientStub = new ClientStub(clientConfiguration);

                //Assert
                Assert.Equal(clientConfiguration, clientStub.ClientConfiguration);
                Assert.NotNull(clientStub.RequestHelper);
                Assert.Equal(clientConfiguration.HttpClientTimeoutInMilliseconds, clientStub.HttpClient.Timeout.TotalMilliseconds);
            }
Example #15
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="clientStub"></param>
 /// <param name="serviceType"></param>
 internal TCPClient(ClientStub clientStub, Type serviceType) : base(clientStub, serviceType)
 {
     _responseWaits = new ResponseWaits(RequestTimeoutSeconds);
     _bootstrap     = new Bootstrap()
                      .Group(new MultithreadEventLoopGroup())
                      .Channel <TcpSocketChannel>()
                      .Option(ChannelOption.TcpNodelay, true)
                      .Handler(new ActionChannelInitializer <ISocketChannel>(channel =>
     {
         IChannelPipeline pipeline = channel.Pipeline;
         pipeline.AddLast("framing-enc", new LengthFieldPrepender(2));
         //数据包最大长度
         pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
         ClientHandler clientHandler = new ClientHandler(_responseWaits)
         {
             OnDeserializeMessage = DeserializeMessage
         };
         pipeline.AddLast(clientHandler);
     }));
 }
Example #16
0
 /// <summary>
 /// 获取客户端访问类
 /// </summary>
 /// <param name="serviceType">服务元数据信息</param>
 /// <param name="clientStub">存根</param>
 /// <returns>客户端访问对象</returns>
 protected override IClient InitializeClient(Type serviceType, ClientStub clientStub)
 {
     return(new TCPClient(clientStub, serviceType));
 }
 public ParticipantPruningClient(Channel channel, string accessToken)
 {
     _participantPruningClient = new ClientStub <ParticipantPruningService.ParticipantPruningServiceClient>(new ParticipantPruningService.ParticipantPruningServiceClient(channel), accessToken);
 }
Example #18
0
 public TimeClient(string ledgerId, Channel channel, string accessToken)
 {
     _ledgerId   = ledgerId;
     _timeClient = new ClientStub <TimeService.TimeServiceClient>(new TimeService.TimeServiceClient(channel), accessToken);
 }
 public LedgerConfigurationClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId = ledgerId;
     _ledgerConfigurationClient = new ClientStub <LedgerConfigurationService.LedgerConfigurationServiceClient>(new LedgerConfigurationService.LedgerConfigurationServiceClient(channel), accessToken);
 }
Example #20
0
 public PackageClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId       = ledgerId;
     _packageClient = new ClientStub <PackageService.PackageServiceClient>(new PackageService.PackageServiceClient(channel), accessToken);
 }
Example #21
0
 public PartyManagementClient(Channel channel, string accessToken)
 {
     _partyManagementClient = new ClientStub <PartyManagementService.PartyManagementServiceClient>(new PartyManagementService.PartyManagementServiceClient(channel), accessToken);
 }
Example #22
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="clientStub"></param>
 /// <param name="serviceType"></param>
 internal GrpcClient(ClientStub clientStub, Type serviceType) : base(clientStub, serviceType)
 {
 }
Example #23
0
 public CommandClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId       = ledgerId;
     _commandClient = new ClientStub <CommandService.CommandServiceClient>(new CommandService.CommandServiceClient(channel), accessToken);
 }
Example #24
0
 public ActiveContractsClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId = ledgerId;
     _activeContractsClient = new ClientStub <ActiveContractsService.ActiveContractsServiceClient>(new ActiveContractsService.ActiveContractsServiceClient(channel), accessToken);
 }
Example #25
0
 public TransactionsClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId            = ledgerId;
     _transactionsClient = new ClientStub <TransactionService.TransactionServiceClient>(new TransactionService.TransactionServiceClient(channel), accessToken);
 }
Example #26
0
 public ConfigManagementClient(Channel channel, string accessToken)
 {
     _configManagementClient = new ClientStub <ConfigManagementService.ConfigManagementServiceClient>(new Com.DigitalAsset.Ledger.Api.V1.Admin.ConfigManagementService.ConfigManagementServiceClient(channel), accessToken);
 }
Example #27
0
 public ResetClient(string ledgerId, Channel channel, string accessToken)
 {
     _ledgerId    = ledgerId;
     _resetClient = new ClientStub <ResetService.ResetServiceClient>(new ResetService.ResetServiceClient(channel), accessToken);
 }
 public void init()
 {
     thread = new Thread(Program.RunServer);
     thread.Start();
     clientStub = new ClientStub();
 }
 public LedgerIdentityClient(Channel channel, string accessToken)
 {
     _ledgerIdentityClient = new ClientStub <LedgerIdentityService.LedgerIdentityServiceClient>(new LedgerIdentityService.LedgerIdentityServiceClient(channel), accessToken);
 }
Example #30
0
 public VersionClient(string ledgerId, Channel channel, string accessToken)
 {
     LedgerId       = ledgerId;
     _versionClient = new ClientStub <VersionService.VersionServiceClient>(new VersionService.VersionServiceClient(channel), accessToken);
 }