From fea93ba00dc8f68a7d8fb67bad1a38204fd2200c Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Sat, 10 Jan 2026 18:11:05 +0100 Subject: [PATCH 1/4] Added unit test to check if japanese characters will pass through the agent unchanged --- test_package/agent_test.cpp | 38 +++++++++++++++++++++- test_package/agent_test_helper.hpp | 4 +++ test_package/websockets_rest_sink_test.cpp | 5 ++- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index 5039741e..7e242c65 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -68,7 +68,8 @@ class AgentTest : public testing::Test void SetUp() override { m_agentTestHelper = make_unique(); - 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()); } @@ -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 japanses 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() == "Controller"; + }); + ASSERT_NE(controller, streams.end()); + json fault = controller->at("/Condition/Fault/0"_json_pointer); + ASSERT_TRUE(fault.is_object()); + ASSERT_EQ("ストロークエンド軸あり", fault.at("/value"_json_pointer).get()); + } +} diff --git a/test_package/agent_test_helper.hpp b/test_package/agent_test_helper.hpp index 45349324..70f34dc0 100644 --- a/test_package/agent_test_helper.hpp +++ b/test_package/agent_test_helper.hpp @@ -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; \ diff --git a/test_package/websockets_rest_sink_test.cpp b/test_package/websockets_rest_sink_test.cpp index aef828f8..a484bcf3 100644 --- a/test_package/websockets_rest_sink_test.cpp +++ b/test_package/websockets_rest_sink_test.cpp @@ -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"); } } From aa39ccab7786e914d042910b8860ac13c8a9d172 Mon Sep 17 00:00:00 2001 From: William Sobel Date: Sat, 10 Jan 2026 18:22:48 +0100 Subject: [PATCH 2/4] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- test_package/agent_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index 7e242c65..7921fb4a 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -2634,7 +2634,7 @@ TEST_F(AgentTest, should_handle_japanese_characters) m_agentTestHelper->m_adapter->processData( "2026-01-07T22:32:50.8567651Z|lp|FAULT|1111|||ストロークエンド軸あり"); - // Validate we can handle japanses characters. + // Validate we can handle Japanese characters. { PARSE_XML_RESPONSE("/current"); ASSERT_XML_PATH_EQUAL(doc, From fe047a209c737453ecf77ab4c89fededdf56c8d3 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Sat, 10 Jan 2026 18:24:25 +0100 Subject: [PATCH 3/4] Fixed assert order --- test_package/agent_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index 7921fb4a..25679675 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -2652,7 +2652,7 @@ TEST_F(AgentTest, should_handle_japanese_characters) auto controller = std::find_if(streams.begin(), streams.end(), [](const json &comp) { return comp.at("/component"_json_pointer).get() == "Controller"; }); - ASSERT_NE(controller, streams.end()); + 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()); From 11192a5b7b6c4216e335f4a6a98e5b697a0d23f6 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Sat, 10 Jan 2026 18:33:53 +0100 Subject: [PATCH 4/4] Version 2.7.0.2 RC2 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c530e9c..6af32a04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)