Skip to content

Commit

Permalink
Merge branches 'feature/27616-mappings-extraction' and 'feature/27616…
Browse files Browse the repository at this point in the history
…-mappings-extraction' of github.com:hivemq/hivemq-edge into feature/27616-mappings-extraction
  • Loading branch information
codepitbull committed Nov 26, 2024
2 parents af0b9ff + b124d5d commit 53ef2db
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,11 @@ protected ConfigFileReaderWriter createFileReaderWriter(final @NotNull File file
}

protected File loadTestConfigFile() throws IOException {
try (final InputStream is =
AbstractConfigWriterTest.class.getResourceAsStream("/" + getTestConfigName())){
try (final InputStream is = AbstractConfigWriterTest.class.getResourceAsStream("/test-config.xml")) {
final File tempFile = new File(System.getProperty("java.io.tmpdir"), "original-config.xml");
tempFile.deleteOnExit();
FileUtils.copyInputStreamToFile(is, tempFile);
return tempFile;
}
}

protected String getTestConfigName(){
return "test-config.xml";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void rewriteUnchangedConfigurationYieldsSameXML() throws IOException, SAX
Diff diff = XMLUnit.compareXML(originalXml, copiedFileContent);
if(!diff.identical()){
System.err.println("xml diff found " + diff);
// System.err.println(originalXml);
// System.err.println(copiedFileContent);
System.err.println(originalXml);
System.err.println(copiedFileContent);
}
Assert.assertTrue("XML Content Should Match", diff.similar());

Expand Down
104 changes: 69 additions & 35 deletions hivemq-edge/src/test/resources/test-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,85 +213,88 @@
<adapterId>simulation-server-2</adapterId>
<protocolId>opcua</protocolId>
<config>
<uri>opc.tcp://CSM1.local:53530/OPCUA/SimulationServer</uri>
<auth>
<basic>
<password>password</password>
<username>edge</username>
</basic>
</auth>
<uri>opc.tcp://CSM1.local:53530/OPCUA/SimulationServer</uri>
</config>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test/blubb/#</topic>
<tagName>tag1</tagName>
</fromEdgeMapping>
</fromEdgeMappings>
<tags>
<tag>
<name>tag1</name>
<description></description>
<definition>
<node>ns=1;i=1004</node>
</definition>
</tag>
</tags>
<toEdgeMappings/>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test/blubb/#</topic>
<tagName>tag1</tagName>
<maxQos>1</maxQos>
<messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
<includeTagNames>false</includeTagNames>
<includeTimestamp>true</includeTimestamp>
<mqttUserProperties/>
</fromEdgeMapping>
</fromEdgeMappings>
<tagMappings/>
</protocol-adapter>
<protocol-adapter>
<adapterId>modbus-1</adapterId>
<protocolId>modbus</protocolId>
<config>
<hostName>127.0.0.1</hostName>
<port>5021</port>
<modbusToMqtt>
<publishChangedDataOnly>true</publishChangedDataOnly>
<pollingIntervalMillis>1000</pollingIntervalMillis>
<maxPollingErrorsBeforeRemoval>5</maxPollingErrorsBeforeRemoval>
<publishChangedDataOnly>true</publishChangedDataOnly>
</modbusToMqtt>
<hostName>127.0.0.1</hostName>
<port>5021</port>
</config>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag1</tagName>
</fromEdgeMapping>
</fromEdgeMappings>
<tags>
<tag>
<name>tag1</name>
<description></description>
<definition>
<node>ns=1;i=1004</node>
</definition>
</tag>
</tags>
<toEdgeMappings/>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag1</tagName>
<maxQos>1</maxQos>
<messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
<includeTagNames>false</includeTagNames>
<includeTimestamp>true</includeTimestamp>
<mqttUserProperties/>
</fromEdgeMapping>
</fromEdgeMappings>
<tagMappings/>
</protocol-adapter>
<protocol-adapter>
<adapterId>modbus-2</adapterId>
<protocolId>modbus</protocolId>
<config>
<hostName>127.0.0.1</hostName>
<port>5021</port>
<modbusToMqtt>
<publishChangedDataOnly>true</publishChangedDataOnly>
<pollingIntervalMillis>1000</pollingIntervalMillis>
<maxPollingErrorsBeforeRemoval>5</maxPollingErrorsBeforeRemoval>
<publishChangedDataOnly>true</publishChangedDataOnly>
</modbusToMqtt>
<hostName>127.0.0.1</hostName>
<port>5021</port>
</config>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
</fromEdgeMapping>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
</fromEdgeMapping>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
</fromEdgeMapping>
</fromEdgeMappings>
<tags>
<tag>
<name>tag-modbus-2</name>
<description></description>
<definition>
<coils>
<endIdx>10000000</endIdx>
Expand All @@ -304,8 +307,39 @@
</definition>
</tag>
</tags>
<toEdgeMappings/>
<fromEdgeMappings>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
<maxQos>1</maxQos>
<messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
<includeTagNames>false</includeTagNames>
<includeTimestamp>true</includeTimestamp>
<mqttUserProperties/>
</fromEdgeMapping>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
<maxQos>1</maxQos>
<messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
<includeTagNames>false</includeTagNames>
<includeTimestamp>true</includeTimestamp>
<mqttUserProperties/>
</fromEdgeMapping>
<fromEdgeMapping>
<topic>test</topic>
<tagName>tag-modbus-2</tagName>
<maxQos>1</maxQos>
<messageHandlingOptions>MQTTMessagePerTag</messageHandlingOptions>
<includeTagNames>false</includeTagNames>
<includeTimestamp>true</includeTimestamp>
<mqttUserProperties/>
</fromEdgeMapping>
</fromEdgeMappings>
<tagMappings/>
</protocol-adapter>
</protocol-adapters>
<internal></internal>
<modules></modules>
<modules/>
<internal/>
</hivemq>

0 comments on commit 53ef2db

Please sign in to comment.