Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 7)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 1)
set(AGENT_VERSION_RC "RC1")
set(AGENT_VERSION_BUILD 2)
set(AGENT_VERSION_RC "RC2")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
Expand Down
38 changes: 37 additions & 1 deletion test_package/agent_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class AgentTest : public testing::Test
void SetUp() override
{
m_agentTestHelper = make_unique<AgentTestHelper>();
m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 25, true);
m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.3", 25, true, true,
{{configuration::JsonVersion, 2}});
m_agentId = to_string(getCurrentTimeInSec());
}

Expand Down Expand Up @@ -2622,3 +2623,38 @@ TEST_F(AgentTest, should_initialize_observaton_to_initial_value_when_available)
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:PartCount", "0");
}
}

TEST_F(AgentTest, should_handle_japanese_characters)
{
addAdapter({{configuration::FilterDuplicates, true}});
auto agent = m_agentTestHelper->getAgent();
auto logic = agent->getDataItemForDevice("LinuxCNC", "lp");
ASSERT_TRUE(logic);

m_agentTestHelper->m_adapter->processData(
"2026-01-07T22:32:50.8567651Z|lp|FAULT|1111|||ストロークエンド軸あり");

// Validate we can handle Japanese characters.
{
PARSE_XML_RESPONSE("/current");
ASSERT_XML_PATH_EQUAL(doc,
"//m:DeviceStream//"
"m:ComponentStream[@component='Controller']/m:Condition/"
"m:Fault[@dataItemId='lp']",
"ストロークエンド軸あり");
}

// And in JSON
{
PARSE_JSON_RESPONSE("/current");
json streams = doc.at("/MTConnectStreams/Streams/DeviceStream/0/ComponentStream"_json_pointer);
ASSERT_TRUE(streams.is_array());
auto controller = std::find_if(streams.begin(), streams.end(), [](const json &comp) {
return comp.at("/component"_json_pointer).get<string>() == "Controller";
});
ASSERT_NE(streams.end(), controller);
json fault = controller->at("/Condition/Fault/0"_json_pointer);
ASSERT_TRUE(fault.is_object());
ASSERT_EQ("ストロークエンド軸あり", fault.at("/value"_json_pointer).get<string>());
}
}
4 changes: 4 additions & 0 deletions test_package/agent_test_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ struct XmlDocFreer
nlohmann::json doc; \
m_agentTestHelper->responseHelper(__FILE__, __LINE__, {}, doc, path)

#define PARSE_JSON_RESPONSE_QUERY(path, query) \
nlohmann::json doc; \
m_agentTestHelper->responseHelper(__FILE__, __LINE__, query, doc, path)

#define PARSE_XML_WS_RESPONSE(req) \
xmlDocPtr doc = nullptr; \
std::string id; \
Expand Down
5 changes: 2 additions & 3 deletions test_package/websockets_rest_sink_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ TEST_F(WebsocketsRestSinkTest, should_return_error_for_bad_parameter_value)
PARSE_XML_WS_RESPONSE(
R"({ "id": "1", "request": "current", "format": "xml", "at": "notanumber" })");
ASSERT_XML_PATH_EQUAL(doc, "//m:InvalidParameterValue@errorCode", "INVALID_PARAMETER_VALUE");
ASSERT_XML_PATH_EQUAL(
doc, "//m:ErrorMessage",
"query parameter 'at': invalid type, expected uint64");
ASSERT_XML_PATH_EQUAL(doc, "//m:ErrorMessage",
"query parameter 'at': invalid type, expected uint64");
}
}