Exemple #1
0
 public static string GenerateToken(LoginToken loginToken, TextEncryptor signer)
 {
     AssertUtils.AssertNotNull(loginToken);
     return(signer.Encrypt(JsonConvert.SerializeObject(loginToken)));
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorMessage"/> class.
 /// </summary>
 /// <param name="bindingId">the id of the binding this error message is associated with</param>
 /// <param name="id">the message id</param>
 /// <param name="parameters">optional parameters to this message</param>
 public BindingErrorMessage(string bindingId, string id, params object[] parameters) : base(id, parameters)
 {
     AssertUtils.ArgumentNotNull(bindingId, "bindingId");
     _bindingId = bindingId;
 }
 /// <summary>
 /// Does this <see cref="Spring.Objects.Factory.Support.MethodOverride"/>
 /// match the supplied <paramref name="method"/>?
 /// </summary>
 /// <param name="method">The method to be checked.</param>
 /// <returns>
 /// <see lang="true"/> if this override matches the supplied <paramref name="method"/>.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="method"/> is <see langword="null"/>.
 /// </exception>
 public override bool Matches(MethodInfo method)
 {
     AssertUtils.ArgumentNotNull(method, "method");
     return(MethodName == method.Name || method.Name.EndsWith(MethodName));
 }
Exemple #4
0
 public void TestThatRemoveLastDeploymentAlsoRemovesVersion()
 {
     _deploymentConfig = _deploymentConfig.RemoveApplication(new AppIdentity("app1", "1.0.0"), "deploymentid1");
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "1.0.1" }, _deploymentConfig.ListVersions("app1"));
 }
Exemple #5
0
 public void TestListApplications()
 {
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "app1", "app2", "app3" },
                                                _deploymentConfig.ListApplications());
 }
 /// <summary>
 /// Creates a new cache instance and attaches it to the given <see cref="sharedStateHolder" />
 /// </summary>
 /// <param name="sharedStateHolder">the holder of the shared state dictionary to be used for caching.</param>
 public SharedStateResourceCache(ISharedStateAware sharedStateHolder)
 {
     AssertUtils.ArgumentNotNull(sharedStateHolder, "sharedStateHolder");
     this.sharedStateHolder = sharedStateHolder;
 }
Exemple #7
0
 public void TestThatRemoveLastVersionAlsoRemovesTheApp()
 {
     _deploymentConfig = _deploymentConfig.RemoveApplication(new AppIdentity("app2", "1.0.0"));
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "app1", "app3" }, _deploymentConfig.ListApplications());
 }
Exemple #8
0
        public async Task Test_OTAA_Unconfirmed_Receives_Confirmed_C2D_Message(string devicePropertyName)
        {
            var device = this.TestFixtureCi.GetDeviceByPropertyName(devicePropertyName);

            this.LogTestStart(device);
            await this.ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWOTAA);

            await this.ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, device.AppEUI);

            await this.ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey);

            await this.ArduinoDevice.SetupLora(this.TestFixtureCi.Configuration.LoraRegion);

            var joinSucceeded = await this.ArduinoDevice.setOTAAJoinAsyncWithRetry(LoRaArduinoSerial._otaa_join_cmd_t.JOIN, 20000, 5);

            Assert.True(joinSucceeded, "Join failed");

            // wait 1 second after joined
            await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_JOIN);

            if (device.IsMultiGw)
            {
                await this.TestFixtureCi.WaitForTwinSyncAfterJoinAsync(this.ArduinoDevice.SerialLogs, device.DeviceID);
            }

            // Sends 2x unconfirmed messages
            for (var i = 1; i <= 2; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i}/10");

                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                this.TestFixtureCi.ClearLogs();
            }

            // sends C2D - between 10 and 99
            var c2dMessageBody = (100 + random.Next(90)).ToString();
            var msgId          = Guid.NewGuid().ToString();
            var c2dMessage     = new LoRaCloudToDeviceMessage()
            {
                Payload   = c2dMessageBody,
                Fport     = 1,
                MessageId = msgId,
                Confirmed = true,
            };

            await this.TestFixtureCi.SendCloudToDeviceMessageAsync(device.DeviceID, c2dMessage);

            this.Log($"Message {c2dMessageBody} sent to device, need to check if it receives");

            var foundC2DMessage      = false;
            var foundReceivePacket   = false;
            var expectedRxSerial     = $"+MSG: PORT: 1; RX: \"{this.ToHexString(c2dMessageBody)}\"";
            var expectedUDPMessageV1 = $"{device.DevAddr}: ConfirmedDataDown";
            var expectedUDPMessageV2 = $"{device.DeviceID}: cloud to device message: {this.ToHexString(c2dMessageBody)}, id: {msgId}, fport: 1, confirmed: True";

            this.Log($"Expected C2D received log is: {expectedRxSerial}");
            this.Log($"Expected UDP log starting with: {expectedUDPMessageV1} or {expectedUDPMessageV2}");

            // Sends 8x unconfirmed messages, stopping if C2D message is found
            for (var i = 3; i <= 10; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i}/10");
                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                // check if c2d message was found
                var searchResults = await this.TestFixtureCi.SearchNetworkServerModuleAsync(
                    (messageBody) =>
                {
                    return(messageBody.StartsWith(expectedUDPMessageV1) || messageBody.StartsWith(expectedUDPMessageV2));
                },
                    new SearchLogOptions
                {
                    Description = $"{expectedUDPMessageV1} or {expectedUDPMessageV2}",
                    MaxAttempts = 1
                });

                // We should only receive the message once
                if (searchResults.Found)
                {
                    this.Log($"{device.DeviceID}: Found C2D message in log (after sending {i}/10) ? {foundC2DMessage}");
                    Assert.False(foundC2DMessage, "Cloud to Device message should have been detected in Network Service module only once");
                    foundC2DMessage = true;
                }

                var localFoundCloudToDeviceInSerial = this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial);
                if (localFoundCloudToDeviceInSerial)
                {
                    Assert.False(foundReceivePacket, "Cloud to device message should have been received only once");
                    foundReceivePacket = true;
                }

                this.TestFixtureCi.ClearLogs();

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);
            }

            Assert.True(foundC2DMessage, $"Did not find {expectedUDPMessageV1} or {expectedUDPMessageV2} in logs");

            // checks if log arrived
            if (!foundReceivePacket)
            {
                foundReceivePacket = this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial);
            }

            Assert.True(foundReceivePacket, $"Could not find lora receiving message '{expectedRxSerial}'");
        }
Exemple #9
0
        public async Task C2D_When_Device_Has_Preferred_Windows_2_Should_Receive_In_2nd_Window_With_Custom_DR()
        {
            var device = this.TestFixtureCi.Device21_ABP;

            this.LogTestStart(device);
            // Setup LoRa device properties
            await this.ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWABP);

            await this.ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, device.AppEUI);

            await this.ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey);

            // Setup protocol properties
            await this.ArduinoDevice.SetupLora(this.TestFixture.Configuration.LoraRegion);

            // Sends 2x unconfirmed messages
            for (var i = 1; i <= 2; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i}/10");

                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                this.TestFixture.ClearLogs();
            }

            // sends C2D - between 10 and 99
            var c2dMessageBody = (100 + random.Next(90)).ToString();
            var msgId          = Guid.NewGuid().ToString();
            var c2dMessage     = new LoRaCloudToDeviceMessage()
            {
                Payload   = c2dMessageBody,
                Fport     = 1,
                MessageId = msgId,
                Confirmed = true,
            };

            await this.TestFixtureCi.SendCloudToDeviceMessageAsync(device.DeviceID, c2dMessage);

            this.Log($"Message {c2dMessageBody} sent to device, need to check if it receives");

            var foundC2DMessage         = false;
            var foundReceivePacket      = false;
            var foundReceivePacketInRX2 = false;
            var expectedRxSerial1       = $"+MSG: PORT: 1; RX: \"{this.ToHexString(c2dMessageBody)}\"";
            var expectedRxSerial2       = $"+MSG: RXWIN2";
            var expectedUDPMessageV1    = $"{device.DevAddr}: ConfirmedDataDown";
            var expectedUDPMessageV2    = $"{device.DeviceID}: cloud to device message: {this.ToHexString(c2dMessageBody)}, id: {msgId}, fport: 1, confirmed: True";

            this.Log($"Expected C2D received log is: {expectedRxSerial1} and {expectedRxSerial2}");
            this.Log($"Expected UDP log starting with: {expectedUDPMessageV1} or {expectedUDPMessageV2}");

            // Sends 8x confirmed messages, stopping if C2D message is found
            for (var i = 3; i <= 10; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i}/10");
                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                // check if c2d message was found
                if (!foundC2DMessage)
                {
                    var searchResults = await this.TestFixture.SearchNetworkServerModuleAsync(
                        (messageBody) =>
                    {
                        return(messageBody.StartsWith(expectedUDPMessageV1) || messageBody.StartsWith(expectedUDPMessageV2));
                    },
                        new SearchLogOptions
                    {
                        Description = $"{expectedUDPMessageV1} or {expectedUDPMessageV2}",
                        MaxAttempts = 1,
                    });

                    // We should only receive the message once
                    if (searchResults.Found)
                    {
                        this.Log($"{device.DeviceID}: Found C2D message in log (after sending {i}/10)");
                        foundC2DMessage = true;
                    }
                }

                if (!foundReceivePacket)
                {
                    if (this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial1))
                    {
                        this.Log($"{device.DeviceID}: Found serial log message {expectedRxSerial1} in log (after sending {i}/10)");
                        foundReceivePacket = true;
                    }
                }

                if (!foundReceivePacketInRX2)
                {
                    if (this.ArduinoDevice.SerialLogs.Any(x => x.StartsWith(expectedRxSerial2)))
                    {
                        this.Log($"{device.DeviceID}: Found serial log message {expectedRxSerial2} in log (after sending {i}/10)");
                        foundReceivePacketInRX2 = true;
                    }
                }

                if (foundReceivePacket && foundReceivePacketInRX2 && foundC2DMessage)
                {
                    this.Log($"{device.DeviceID}: Found all messages in log (after sending {i}/10)");
                    break;
                }

                this.TestFixture.ClearLogs();

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);
            }

            Assert.True(foundC2DMessage, $"Did not find {expectedUDPMessageV1} or {expectedUDPMessageV2} in logs");

            // checks if serial received the message
            if (!foundReceivePacket)
            {
                foundReceivePacket = this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial1);
            }

            Assert.True(foundReceivePacket, $"Could not find lora receiving message '{expectedRxSerial1}'");

            // checks if serial received the message in RX2
            if (!foundReceivePacketInRX2)
            {
                foundReceivePacketInRX2 = this.ArduinoDevice.SerialLogs.Any(x => x.StartsWith(expectedRxSerial2));
            }

            Assert.True(foundReceivePacketInRX2, $"Could not find lora receiving message '{expectedRxSerial2}'");
        }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Aop.Framework.DynamicTargetSourceWrapper"/>
 /// class.
 /// </summary>
 /// <param name="targetSource">
 /// The target object that proxy methods will be delegated to.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="targetSource"/> is
 /// <see langword="null"/>.
 /// </exception>
 internal DynamicTargetSourceWrapper(ITargetSource targetSource)
 {
     AssertUtils.ArgumentNotNull(targetSource, "targetSource");
     this.targetSource = targetSource;
 }
Exemple #11
0
        public async Task Test_OTAA_Confirmed_Receives_C2D_Message_With_RX_Delay_2()
        {
            var device = this.TestFixtureCi.Device9_OTAA;

            this.LogTestStart(device);

            await this.ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWOTAA);

            await this.ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, device.AppEUI);

            await this.ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey);

            await this.ArduinoDevice.SetupLora(this.TestFixtureCi.Configuration.LoraRegion);

            var joinSucceeded = await this.ArduinoDevice.setOTAAJoinAsyncWithRetry(LoRaArduinoSerial._otaa_join_cmd_t.JOIN, 20000, 5);

            Assert.True(joinSucceeded, "Join failed");

            // find the gateway that accepted the join
            var joinAccept = await this.TestFixtureCi.SearchNetworkServerModuleAsync((s) => s.IndexOf("JoinAccept") != -1);

            Assert.NotNull(joinAccept);
            Assert.NotNull(joinAccept.MatchedEvent);

            var targetGw = joinAccept.MatchedEvent.SourceId;

            Assert.Equal(device.GatewayID, targetGw);

            // wait 1 second after joined
            await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_JOIN);

            // Sends 2x confirmed messages
            for (var i = 1; i <= 2; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending confirmed '{msg}' {i}/10");

                await this.ArduinoDevice.transferPacketWithConfirmedAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                // +CMSG: ACK Received
                await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", this.ArduinoDevice.SerialLogs);

                this.TestFixtureCi.ClearLogs();
            }

            // sends C2D - between 10 and 99
            var c2dMessageBody = (100 + random.Next(90)).ToString();
            var c2dMessage     = new LoRaCloudToDeviceMessage()
            {
                Payload   = c2dMessageBody,
                Fport     = 1,
                MessageId = Guid.NewGuid().ToString(),
            };

            await this.TestFixtureCi.SendCloudToDeviceMessageAsync(device.DeviceID, c2dMessage);

            this.Log($"Message {c2dMessageBody} sent to device, need to check if it receives");

            var foundC2DMessage    = false;
            var foundReceivePacket = false;
            var expectedRxSerial   = $"+CMSG: PORT: 1; RX: \"{this.ToHexString(c2dMessageBody)}\"";

            this.Log($"Expected C2D received log is: {expectedRxSerial}");

            // Sends 8x confirmed messages, stopping if C2D message is found
            for (var i = 3; i <= 10; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending confirmed '{msg}' {i}/10");
                await this.ArduinoDevice.transferPacketWithConfirmedAsync(msg, 10);

                await Task.Delay(TimeSpan.FromSeconds(5));

                // After transferPacketWithConfirmed: Expectation from serial
                // +CMSG: ACK Received
                await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", this.ArduinoDevice.SerialLogs);

                // Check that RXDelay was correctly used
                if (this.ArduinoDevice.SerialLogs.Where(x => x.StartsWith("+CMSG: RXWIN1")).Count() > 0)
                {
                    await this.TestFixtureCi.CheckAnswerTimingAsync(device.RXDelay *Constants.CONVERT_TO_PKT_FWD_TIME, false, device.GatewayID);
                }
                else if (this.ArduinoDevice.SerialLogs.Where(x => x.StartsWith("+CMSG: RXWIN2")).Count() > 0)
                {
                    await this.TestFixtureCi.CheckAnswerTimingAsync(device.RXDelay *Constants.CONVERT_TO_PKT_FWD_TIME, true, device.GatewayID);
                }
                else
                {
                    Assert.True(false, "We were not able to determine in which windows the acknowledgement was submitted");
                }

                // check if c2d message was found
                // 0000000000000009: C2D message: 58
                var c2dLogMessage = $"{device.DeviceID}: done completing cloud to device message, id: {c2dMessage.MessageId}";
                var searchResults = await this.TestFixtureCi.SearchNetworkServerModuleAsync(
                    (messageBody) =>
                {
                    return(messageBody.StartsWith(c2dLogMessage));
                },
                    new SearchLogOptions
                {
                    Description = c2dLogMessage,
                    MaxAttempts = 1
                });

                // We should only receive the message once
                if (searchResults.Found)
                {
                    this.Log($"{device.DeviceID}: Found C2D message in log (after sending {i}/10) ? {foundC2DMessage}");
                    Assert.False(foundC2DMessage, "Cloud to Device message should have been detected in Network Service module only once");
                    foundC2DMessage = true;
                }

                var localFoundCloudToDeviceInSerial = this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial);
                if (localFoundCloudToDeviceInSerial)
                {
                    Assert.False(foundReceivePacket, "Cloud to device message should have been received only once");
                    foundReceivePacket = true;
                }

                this.TestFixtureCi.ClearLogs();

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);
            }

            Assert.True(foundC2DMessage, $"Did not find '{device.DeviceID}: C2D message: {c2dMessageBody}' in logs");

            // checks if log arrived
            if (!foundReceivePacket)
            {
                foundReceivePacket = this.ArduinoDevice.SerialLogs.Contains(expectedRxSerial);
            }

            Assert.True(foundReceivePacket, $"Could not find lora receiving message '{expectedRxSerial}'");
        }
 /// <summary>Initializes a new instance of the <see cref="AbstractConnectionFactory"/> class.</summary>
 /// <param name="rabbitConnectionFactory">The rabbit connection factory.</param>
 public AbstractConnectionFactory(ConnectionFactory rabbitConnectionFactory)
 {
     AssertUtils.ArgumentNotNull(rabbitConnectionFactory, "Target ConnectionFactory must not be null");
     this.rabbitConnectionFactory = rabbitConnectionFactory;
 }
Exemple #13
0
 public virtual void AfterPropertiesSet()
 {
     AssertUtils.ArgumentNotNull(keys, "a non-null keys is required.");
 }
Exemple #14
0
 /// <summary>
 /// Add argument value for the given name in the constructor argument list.
 /// </summary>
 /// <param name="name">The name in the constructor argument list.</param>
 /// <param name="value">The argument value.</param>
 /// <exception cref="ArgumentException">
 /// If the supplied <paramref name="name"/> is <see langword="null"/>
 /// or is composed wholly of whitespace.
 /// </exception>
 public void AddNamedArgumentValue(string name, object value)
 {
     AssertUtils.ArgumentHasText(name, "name");
     GetAndInitializeNamedArgumentValuesIfNeeded()[GetCanonicalNamedArgument(name)] = new ValueHolder(value);
 }
 /// <summary>
 /// Initializes a new instance of <see cref="SynchronizedHashtable"/>, copying initial entries from <param name="dictionary"/>
 /// handling keys depending on <param name="ignoreCase"/>.
 /// </summary>
 public SynchronizedHashtable(IDictionary dictionary, bool ignoreCase)
 {
     AssertUtils.ArgumentNotNull(dictionary, "dictionary");
     this._table      = (ignoreCase) ? CollectionsUtil.CreateCaseInsensitiveHashtable(dictionary) : new Hashtable(dictionary);
     this._ignoreCase = ignoreCase;
 }
Exemple #16
0
        public async Task Test_OTAA_Confirmed_And_Unconfirmed_Message()
        {
            const int MESSAGES_COUNT = 10;

            var device = this.testFixture.Device4_OTAA;

            Console.WriteLine($"Starting {nameof(Test_OTAA_Confirmed_And_Unconfirmed_Message)} using device {device.DeviceID}");

            await lora.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWOTAA);

            await lora.setIdAsync(device.DevAddr, device.DeviceID, device.AppEUI);

            await lora.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey);

            await lora.SetupLora(this.testFixture.Configuration.LoraRegion);

            var joinSucceeded = await lora.setOTAAJoinAsyncWithRetry(LoRaArduinoSerial._otaa_join_cmd_t.JOIN, 20000, 5);

            if (!joinSucceeded)
            {
                Assert.True(joinSucceeded, "Join failed");
            }

            // wait 1 second after joined
            await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_JOIN);

            // Sends 10x unconfirmed messages
            for (var i = 0; i < MESSAGES_COUNT; ++i)
            {
                var msg = (100 + i).ToString();
                await lora.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET);

                // After transferPacket: Expectation from serial
                // +MSG: Done
                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.lora.SerialLogs);


                // 0000000000000005: valid frame counter, msg: 1 server: 0
                await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: valid frame counter, msg:");

                // 0000000000000005: decoding with: DecoderValueSensor port: 8
                await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: decoding with: {device.SensorDecoder} port:");

                // 0000000000000005: message '{"value": 51}' sent to hub
                await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: message '{{\"value\":{msg}}}' sent to hub");

                this.lora.ClearSerialLogs();
                testFixture.ClearNetworkServerLogEvents();

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);
            }

            // Sends 10x confirmed messages
            for (var i = 0; i < MESSAGES_COUNT; ++i)
            {
                var msg = (50 + i).ToString();
                await lora.transferPacketWithConfirmedAsync(msg, 10);

                await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET);

                // After transferPacketWithConfirmed: Expectation from serial
                // +CMSG: ACK Received
                await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", this.lora.SerialLogs);

                // 0000000000000005: valid frame counter, msg: 1 server: 0
                //await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: valid frame counter, msg:");

                // 0000000000000005: decoding with: DecoderValueSensor port: 8
                await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: decoding with: {device.SensorDecoder} port:");

                // 0000000000000005: message '{"value": 51}' sent to hub
                await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: message '{{\"value\":{msg}}}' sent to hub");

                this.lora.ClearSerialLogs();
                testFixture.ClearNetworkServerLogEvents();

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);
            }
        }
 /// <summary>
 /// Creates a <see cref="SynchronizedHashtable"/> instance that
 /// synchronizes access to the underlying <see cref="Hashtable"/>.
 /// </summary>
 /// <param name="other">the hashtable to be synchronized</param>
 protected SynchronizedHashtable(Hashtable other)
 {
     AssertUtils.ArgumentNotNull(other, "other");
     this._table = other;
 }
 /// <summary>
 /// Creates new instance of the
 /// <see cref="Spring.Core.IO.ConfigSectionResource"/> class.
 /// </summary>
 /// <param name="configSection">
 /// The actual XML configuration section.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="configSection"/> is <see langword="null"/>.
 /// </exception>
 public ConfigSectionResource(XmlElement configSection)
 {
     AssertUtils.ArgumentNotNull(configSection, "configSection");
     sectionName   = configSection.Name;
     configElement = configSection;
 }
Exemple #19
0
 public void TestRemoveApplication()
 {
     _deploymentConfig = _deploymentConfig.RemoveApplication("app1");
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "app2", "app3" }, _deploymentConfig.ListApplications());
 }
 /// <summary>
 /// Creates new instance of the
 /// <see cref="Spring.Core.IO.ConfigSectionResource"/> class.
 /// </summary>
 /// <param name="resourceName">
 /// The name of the configuration section.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="resourceName"/> is
 /// <see langword="null"/> or contains only whitespace character(s).
 /// </exception>
 public ConfigSectionResource(string resourceName) : base(resourceName)
 {
     AssertUtils.ArgumentHasText(resourceName, "resourceName");
     sectionName   = GetResourceNameWithoutProtocol(resourceName);
     configElement = (XmlElement)ConfigurationUtils.GetSection(sectionName);
 }
Exemple #21
0
 public void TestRemoveDeployment()
 {
     _deploymentConfig = _deploymentConfig.RemoveApplication(new AppIdentity("app1", "1.0.1"), "deploymentid2");
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "deploymentid1" },
                                                _deploymentConfig.ListDeploymentIds("app1"));
 }
        public async Task Test_ABP_Wrong_DevAddr_Is_Ignored(string devAddrToUse)
        {
            var device = this.TestFixtureCi.Device6_ABP;

            this.LogTestStart(device);

            Assert.NotEqual(devAddrToUse, device.DevAddr);
            await this.ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWABP);

            await this.ArduinoDevice.setIdAsync(devAddrToUse, device.DeviceID, null);

            await this.ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, null);

            await this.ArduinoDevice.SetupLora(this.TestFixtureCi.Configuration.LoraRegion);

            await this.ArduinoDevice.transferPacketAsync(PayloadGenerator.Next().ToString(), 10);

            await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET);

            // After transferPacket: Expectation from serial
            // +MSG: Done
            await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

            if (devAddrToUse.StartsWith("02"))
            {
                // 02060708: device is not our device, ignore message
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync(
                    $"{devAddrToUse}: device is not our device, ignore message",
                    $"{devAddrToUse}: device is not from our network, ignoring message");
            }
            else
            {
                // 05060708: device is using another network id, ignoring this message
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync(
                    $"{devAddrToUse}: device is using another network id, ignoring this message");
            }

            await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

            this.TestFixtureCi.ClearLogs();

            // Try with confirmed message
            await this.ArduinoDevice.transferPacketWithConfirmedAsync(PayloadGenerator.Next().ToString(), 10);

            // wait for serial logs to be ready
            await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET);

            // After transferPacketWithConfirmed: Expectation from serial
            // +CMSG: ACK Received -- should not be there!
            Assert.DoesNotContain("+CMSG: ACK Received", this.ArduinoDevice.SerialLogs);

            if (devAddrToUse.StartsWith("02"))
            {
                // 02060708: device is not our device, ignore message
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync(
                    $"{devAddrToUse}: device is not our device, ignore message",
                    $"{devAddrToUse}: device is not from our network, ignoring message");
            }
            else
            {
                // 05060708: device is using another network id, ignoring this message
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync(
                    $"{devAddrToUse}: device is using another network id, ignoring this message");
            }
        }
Exemple #23
0
 public void TestThatRemoveLastDeploymentAlsoRemovesApplication()
 {
     _deploymentConfig = _deploymentConfig.RemoveApplication(new AppIdentity("app3", "2.0.0"), "deploymentid3");
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "app1", "app2" }, _deploymentConfig.ListApplications());
 }
        public async Task Test_ABP_Confirmed_And_Unconfirmed_Message_With_ADR()
        {
            await this.ArduinoDevice.setDeviceDefaultAsync();

            const int MESSAGES_COUNT = 10;
            var       device         = this.TestFixtureCi.Device5_ABP;

            this.LogTestStart(device);
            await this.ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWABP);

            await this.ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, null);

            await this.ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, null);

            await this.ArduinoDevice.SetupLora(this.TestFixtureCi.Configuration.LoraRegion, LoRaArduinoSerial._data_rate_t.DR3, 4, true);

            // for a reason I need to set DR twice otherwise it reverts to DR 0
            // await this.ArduinoDevice.setDataRateAsync(LoRaArduinoSerial._data_rate_t.DR3, LoRaArduinoSerial._physical_type_t.EU868);
            // Sends 5x unconfirmed messages
            for (var i = 0; i < MESSAGES_COUNT / 2; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i + 1}/{MESSAGES_COUNT}");
                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                // After transferPacket: Expectation from serial
                // +MSG: Done
                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                // 0000000000000005: valid frame counter, msg: 1 server: 0
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: valid frame counter, msg:");

                // 0000000000000005: decoding with: DecoderValueSensor port: 8
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: decoding with: {device.SensorDecoder} port:");

                // 0000000000000005: message '{"value": 51}' sent to hub
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: message '{{\"value\":{msg}}}' sent to hub");

                this.TestFixtureCi.ClearLogs();
            }

            // Sends 5x confirmed messages
            for (var i = 0; i < MESSAGES_COUNT / 2; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending confirmed '{msg}' {i + 1}/{MESSAGES_COUNT / 2}");
                await this.ArduinoDevice.transferPacketWithConfirmedAsync(msg, 10);

                await Task.Delay(2 *Constants.DELAY_BETWEEN_MESSAGES);

                // After transferPacketWithConfirmed: Expectation from serial
                // +CMSG: ACK Received
                await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", this.ArduinoDevice.SerialLogs);

                // 0000000000000005: valid frame counter, msg: 1 server: 0
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: valid frame counter, msg:");

                // 0000000000000005: decoding with: DecoderValueSensor port: 8
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: decoding with: {device.SensorDecoder} port:");

                // 0000000000000005: message '{"value": 51}' sent to hub
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: message '{{\"value\":{msg}}}' sent to hub");

                this.TestFixtureCi.ClearLogs();
            }

            // Sends 10x unconfirmed messages
            for (var i = 0; i < MESSAGES_COUNT; ++i)
            {
                var msg = PayloadGenerator.Next().ToString();
                this.Log($"{device.DeviceID}: Sending unconfirmed '{msg}' {i + 1}/{MESSAGES_COUNT / 2}");
                await this.ArduinoDevice.transferPacketAsync(msg, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                // After transferPacket: Expectation from serial
                // +MSG: Done
                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                // 0000000000000005: valid frame counter, msg: 1 server: 0
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: valid frame counter, msg:");

                // 0000000000000005: decoding with: DecoderValueSensor port: 8
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: decoding with: {device.SensorDecoder} port:");

                // 0000000000000005: message '{"value": 51}' sent to hub
                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: message '{{\"value\":{msg}}}' sent to hub");

                this.TestFixtureCi.ClearLogs();
            }

            // Starting ADR test protocol
            this.Log($"{device.DeviceID}: Starting ADR protocol");

            for (var i = 0; i < 56; ++i)
            {
                var message = PayloadGenerator.Next().ToString();
                await this.ArduinoDevice.transferPacketAsync(message, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);
            }

            await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

            await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: ADR ack request received");

            await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DeviceID}: performing a rate adaptation: DR");

            // Check the messages are now sent on DR5
            for (var i = 0; i < 2; ++i)
            {
                var message = PayloadGenerator.Next().ToString();
                await this.ArduinoDevice.transferPacketAsync(message, 10);

                await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

                await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.ArduinoDevice.SerialLogs);

                await this.TestFixtureCi.AssertNetworkServerModuleLogStartsWithAsync($"{device.DevAddr}: LinkADRCmd mac command detected in upstream payload: Type: LinkADRCmd Answer, power: changed, data rate: changed,", $"{device.DevAddr}: LinkADRCmd mac command detected in upstream payload: Type: LinkADRCmd Answer, power: not changed, data rate: changed,");
            }
        }
Exemple #25
0
 public void TestListVersions()
 {
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "1.0.0", "1.0.1" }, _deploymentConfig.ListVersions("app1"));
     AssertUtils.ContainsSameElementsInAnyOrder(new[] { "2.0.0" }, _deploymentConfig.ListVersions("app3"));
 }
 /// <summary>
 /// Add argument value for the given name in the constructor argument list.
 /// </summary>
 /// <param name="name">The name in the constructor argument list.</param>
 /// <param name="value">The argument value.</param>
 /// <exception cref="ArgumentException">
 /// If the supplied <paramref name="name"/> is <see langword="null"/>
 /// or is composed wholly of whitespace.
 /// </exception>
 public virtual void AddNamedArgumentValue(string name, object value)
 {
     AssertUtils.ArgumentHasText(name, "name");
     NamedArgumentValues[GetCanonicalNamedArgument(name)] = new ValueHolder(value);
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.LookupMethodOverride"/> class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Methods eligible for lookup override must not have arguments.
 /// </p>
 /// </remarks>
 /// <param name="methodName">
 /// The name of the method that is to be overridden.
 /// </param>
 /// <param name="objectName">
 /// The name of the object in the current IoC context that the
 /// dependency injected method must return.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If either of the supplied arguments is <see langword="null"/> or
 /// contains only whitespace character(s).
 /// </exception>
 public LookupMethodOverride(string methodName, string objectName)
     : base(methodName)
 {
     AssertUtils.ArgumentHasText(objectName, "objectName");
     this.objectName = objectName;
 }
Exemple #28
0
        /// <summary>
        /// Creates dynamic constructor instance for the specified <see cref="ConstructorInfo"/>.
        /// </summary>
        /// <param name="constructorInfo">Constructor info to create dynamic constructor for.</param>
        /// <returns>Dynamic constructor for the specified <see cref="ConstructorInfo"/>.</returns>
        public static IDynamicConstructor Create(ConstructorInfo constructorInfo)
        {
            AssertUtils.ArgumentNotNull(constructorInfo, "You cannot create a dynamic constructor for a null value.");

            return(new SafeConstructor(constructorInfo));
        }
        /// <summary>
        /// Creates a new instance of the <see cref="ConfigurationClassEnhancer"/> class.
        /// </summary>
        /// <param name="objectFactory">
        /// The supplied ObjectFactory to check for the existence of object definitions.
        /// </param>
        public ConfigurationClassEnhancer(IConfigurableListableObjectFactory objectFactory)
        {
            AssertUtils.ArgumentNotNull(objectFactory, "objectFactory");

            this.interceptor = new ConfigurationClassInterceptor(objectFactory);
        }
Exemple #30
0
 public static LoginToken ParseToken(string loginToken, TextEncryptor signer)
 {
     AssertUtils.AssertNotNull(loginToken);
     return(JsonConvert.DeserializeObject <LoginToken>(signer.Decrypt(loginToken)));
 }