2017-05-05 17:31:58 +00:00
|
|
|
/*
|
2018-02-12 23:31:53 +00:00
|
|
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-05-05 17:31:58 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* A copy of the License is located at
|
|
|
|
*
|
|
|
|
* http://aws.amazon.com/apache2.0/
|
|
|
|
*
|
|
|
|
* or in the "license" file accompanying this file. This file is distributed
|
|
|
|
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
|
|
* express or implied. See the License for the specific language governing
|
|
|
|
* permissions and limitations under the License.
|
|
|
|
*/
|
2018-02-12 23:31:53 +00:00
|
|
|
|
2017-05-05 17:31:58 +00:00
|
|
|
// @file ConfigurationNodeTest.cpp
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2017-06-23 23:26:34 +00:00
|
|
|
#include "AVSCommon/Utils/Configuration/ConfigurationNode.h"
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
2017-06-23 23:26:34 +00:00
|
|
|
namespace avsCommon {
|
|
|
|
namespace utils {
|
2017-05-05 17:31:58 +00:00
|
|
|
namespace configuration {
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
|
|
/// Name of non-existent object for exercising failure to find a @c ConfigurationNode.
|
|
|
|
static const std::string NON_OBJECT = "non-existent-object";
|
|
|
|
|
|
|
|
/// Name of first root level object.
|
|
|
|
static const std::string OBJECT1 = "object1";
|
|
|
|
|
|
|
|
/// Name of first bool value in first root level object.
|
|
|
|
static const std::string BOOL1_1 = "bool1.1";
|
|
|
|
|
|
|
|
/// Value of first bool value in first root level object.
|
|
|
|
static const bool BOOL_VALUE1_1 = true;
|
|
|
|
|
|
|
|
/// Name of first object inside first root level object.
|
|
|
|
static const std::string OBJECT1_1 = "object1.1";
|
|
|
|
|
|
|
|
/// Name of first string value in first object inside first root level object.
|
|
|
|
static const std::string STRING1_1_1 = "string1.1.1";
|
|
|
|
|
|
|
|
/// Value of first string value in first object inside first root level object.
|
|
|
|
static const std::string STRING_VALUE1_1_1 = "stringValue1.1.1";
|
|
|
|
|
|
|
|
/// Name of second root level object.
|
|
|
|
static const std::string OBJECT2 = "object2";
|
|
|
|
|
|
|
|
/// Name of first string in second root level object.
|
|
|
|
static const std::string STRING2_1 = "string2.1";
|
|
|
|
|
|
|
|
/// Replaced value of first string in second root level object.
|
|
|
|
static const std::string NEW_STRING_VALUE2_1 = "new-stringValue2.1";
|
|
|
|
|
|
|
|
/// Name for non-existent int value in second root level object.
|
|
|
|
static const std::string NON_EXISTENT_INT2_1 = "non-existent-int2.1";
|
|
|
|
|
|
|
|
/// Default value for non-existent int value in second root level object.
|
|
|
|
static const int NON_EXISTENT_INT_VALUE2_1 = 123;
|
|
|
|
|
|
|
|
/// Name of first int value in second root level object.
|
|
|
|
static const std::string INT2_1 = "int2.1";
|
|
|
|
|
|
|
|
/// Name of first object inside second root level object.
|
|
|
|
static const std::string OBJECT2_1 = "object2.1";
|
|
|
|
|
|
|
|
/// Name of first string inside first object inside second root level object.
|
|
|
|
static const std::string STRING2_1_1 = "string2.1.1";
|
|
|
|
|
|
|
|
/// Replaced value of first string inside first object inside second root level object.
|
|
|
|
static const std::string NEW_STRING_VALUE2_1_1 = "new-stringValue2.1.1";
|
|
|
|
|
|
|
|
/// Bad JSON string to verify handling the failure to parse JSON
|
|
|
|
static const std::string BAD_JSON = "{ bad json }";
|
|
|
|
|
|
|
|
/// First JSON string to parse, serving as default for configuration values.
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format off
|
2017-05-05 17:31:58 +00:00
|
|
|
static const std::string FIRST_JSON = R"(
|
|
|
|
{
|
|
|
|
"object1" : {
|
|
|
|
"bool1.1" : true
|
|
|
|
},
|
|
|
|
"object2" : {
|
|
|
|
"int2.1" : 21,
|
|
|
|
"string2.1" : "stringValue2.1",
|
|
|
|
"object2.1" : {
|
|
|
|
"string2.1.1" : "stringValue2.1.1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})";
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format on
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
/// Second JSON string to parse, overlaying configuration values from FIRST_JSON.
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format off
|
2017-05-05 17:31:58 +00:00
|
|
|
static const std::string SECOND_JSON = R"(
|
|
|
|
{
|
|
|
|
"object1" : {
|
|
|
|
"object1.1" : {
|
|
|
|
"string1.1.1" : "stringValue1.1.1"
|
|
|
|
},
|
|
|
|
"int1.1" : 11
|
|
|
|
}
|
|
|
|
})";
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format on
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
/// Third JSON string to parse, overlaying configuration values from FIRST_JSON and SECOND_JSON.
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format off
|
2017-05-05 17:31:58 +00:00
|
|
|
static const std::string THIRD_JSON = R"(
|
|
|
|
{
|
|
|
|
"object2" : {
|
|
|
|
"int2.1" : 21,
|
|
|
|
"string2.1" : "new-stringValue2.1",
|
|
|
|
"object2.1" : {
|
|
|
|
"string2.1.1" : "new-stringValue2.1.1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})";
|
2017-10-02 22:59:05 +00:00
|
|
|
// clang-format on
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
/**
|
2017-06-23 23:26:34 +00:00
|
|
|
* Class for testing the ConfigurationNode class
|
|
|
|
*/
|
2017-10-02 22:59:05 +00:00
|
|
|
class ConfigurationNodeTest : public ::testing::Test {};
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify initialization a configuration. Verify both the implementation of accessor methods and the results
|
|
|
|
* of merging JSON streams.
|
|
|
|
*/
|
|
|
|
TEST_F(ConfigurationNodeTest, testInitializationAndAccess) {
|
|
|
|
// Verify a null configuration results in failure
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**Known Issues**
* The `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
std::vector<std::shared_ptr<std::istream>> jsonStream;
|
|
|
|
jsonStream.push_back(nullptr);
|
|
|
|
ASSERT_FALSE(ConfigurationNode::initialize(jsonStream));
|
|
|
|
jsonStream.clear();
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
// Verify invalid JSON results in failure
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**Known Issues**
* The `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
auto badStream = std::shared_ptr<std::stringstream>(new std::stringstream());
|
|
|
|
(*badStream) << BAD_JSON;
|
|
|
|
jsonStream.push_back(badStream);
|
|
|
|
ASSERT_FALSE(ConfigurationNode::initialize(jsonStream));
|
|
|
|
jsonStream.clear();
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
// Combine valid JSON streams with overlapping values. Verify reported success.
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**Known Issues**
* The `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
auto firstStream = std::shared_ptr<std::stringstream>(new std::stringstream());
|
|
|
|
(*firstStream) << FIRST_JSON;
|
|
|
|
auto secondStream = std::shared_ptr<std::stringstream>(new std::stringstream());
|
|
|
|
(*secondStream) << SECOND_JSON;
|
|
|
|
auto thirdStream = std::shared_ptr<std::stringstream>(new std::stringstream());
|
|
|
|
(*thirdStream) << THIRD_JSON;
|
|
|
|
jsonStream.push_back(firstStream);
|
|
|
|
jsonStream.push_back(secondStream);
|
|
|
|
jsonStream.push_back(thirdStream);
|
|
|
|
ASSERT_TRUE(ConfigurationNode::initialize(jsonStream));
|
|
|
|
jsonStream.clear();
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
// Verify failure reported for subsequent initializations.
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**Known Issues**
* The `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
auto firstStream1 = std::shared_ptr<std::stringstream>(new std::stringstream());
|
|
|
|
(*firstStream1) << FIRST_JSON;
|
|
|
|
jsonStream.push_back(firstStream1);
|
|
|
|
ASSERT_FALSE(ConfigurationNode::initialize(jsonStream));
|
|
|
|
jsonStream.clear();
|
2017-05-05 17:31:58 +00:00
|
|
|
|
|
|
|
// Verify non-found name results in a ConfigurationNode that evaluates to false.
|
|
|
|
ASSERT_FALSE(ConfigurationNode::getRoot()[NON_OBJECT]);
|
|
|
|
|
|
|
|
// Verify found name results in a ConfigurationNode that evaluates to true.
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT1]);
|
|
|
|
|
|
|
|
// Verify extraction of bool value.
|
|
|
|
bool bool11 = true;
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT1].getBool(BOOL1_1, &bool11));
|
|
|
|
ASSERT_EQ(bool11, BOOL_VALUE1_1);
|
|
|
|
|
|
|
|
// Verify traversal of multiple levels of ConfigurationNode and extraction of a string value.
|
|
|
|
std::string string111;
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT1][OBJECT1_1].getString(STRING1_1_1, &string111));
|
|
|
|
ASSERT_EQ(string111, STRING_VALUE1_1_1);
|
|
|
|
|
|
|
|
// Verify retrieval of default value when name does not match any value.
|
|
|
|
int nonExistentInt21 = 0;
|
|
|
|
ASSERT_NE(nonExistentInt21, NON_EXISTENT_INT_VALUE2_1);
|
|
|
|
ASSERT_FALSE(ConfigurationNode::getRoot()[OBJECT2].getInt(
|
2017-10-02 22:59:05 +00:00
|
|
|
NON_EXISTENT_INT2_1, &nonExistentInt21, NON_EXISTENT_INT_VALUE2_1));
|
2017-05-05 17:31:58 +00:00
|
|
|
ASSERT_EQ(nonExistentInt21, NON_EXISTENT_INT_VALUE2_1);
|
|
|
|
|
|
|
|
// Verify extraction if an integer value.
|
|
|
|
int int21;
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT2].getInt(INT2_1, &int21));
|
|
|
|
ASSERT_EQ(int21, 21);
|
|
|
|
|
|
|
|
// Verify overwrite of string value by subsequent JSON.
|
|
|
|
std::string newString21;
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT2].getString(STRING2_1, &newString21));
|
|
|
|
ASSERT_EQ(newString21, NEW_STRING_VALUE2_1);
|
|
|
|
|
|
|
|
// Verify retrieval of default value when type does not match an existing value.
|
|
|
|
nonExistentInt21 = 0;
|
|
|
|
ASSERT_NE(nonExistentInt21, NON_EXISTENT_INT_VALUE2_1);
|
2017-10-02 22:59:05 +00:00
|
|
|
ASSERT_FALSE(ConfigurationNode::getRoot()[OBJECT2].getInt(STRING2_1, &nonExistentInt21, NON_EXISTENT_INT_VALUE2_1));
|
2017-05-05 17:31:58 +00:00
|
|
|
ASSERT_EQ(nonExistentInt21, NON_EXISTENT_INT_VALUE2_1);
|
|
|
|
|
|
|
|
// Verify overwrite of string value in nested Configuration node.
|
|
|
|
std::string string211;
|
|
|
|
ASSERT_TRUE(ConfigurationNode::getRoot()[OBJECT2][OBJECT2_1].getString(STRING2_1_1, &string211));
|
|
|
|
ASSERT_EQ(string211, NEW_STRING_VALUE2_1_1);
|
|
|
|
}
|
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
} // namespace test
|
|
|
|
} // namespace configuration
|
|
|
|
} // namespace utils
|
|
|
|
} // namespace avsCommon
|
|
|
|
} // namespace alexaClientSDK
|