This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 067ae0e9e7 test(plc4j/cbus): added bridge tests
067ae0e9e7 is described below
commit 067ae0e9e7022b80b4109979ef3c9dc0e85d6aca
Author: Sebastian Rühl <[email protected]>
AuthorDate: Fri Mar 24 16:07:58 2023 +0100
test(plc4j/cbus): added bridge tests
---
.../apache/plc4x/java/cbus/RandomPackagesTest.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git
a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
index 55533ab1af..a50c1059f8 100644
---
a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
+++
b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
@@ -20,12 +20,14 @@ package org.apache.plc4x.java.cbus;
import org.apache.plc4x.java.cbus.readwrite.*;
import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
+import org.apache.plc4x.java.spi.generation.WriteBufferByteBased;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import static org.apache.plc4x.java.cbus.Util.assertMessageMatches;
import static org.assertj.core.api.Assertions.assertThat;
@@ -453,5 +455,34 @@ public class RandomPackagesTest {
}
}
+ @Nested
+ class BridgeTest {
+ @Test
+ void BridgedIdentify() throws Exception {
+ cBusOptions = C_BUS_OPTIONS_WITH_SRCHK;
+ CALDataIdentify calDataIdentify = new
CALDataIdentify(CALCommandTypeContainer.CALCommandIdentify, null,
Attribute.Type, requestContext);
+ NetworkRoute networkRoute = new NetworkRoute(new
NetworkProtocolControlInformation((byte) 1, (byte) 1), new ArrayList<>());
+ CBusPointToPointCommandIndirect cBusPointToPointCommandIndirect =
new CBusPointToPointCommandIndirect(1, calDataIdentify, new
BridgeAddress((byte) 253), networkRoute, new UnitAddress((byte) 10),
cBusOptions);
+ CBusCommandPointToPoint cbusCommand = new
CBusCommandPointToPoint(new CBusHeader(PriorityClass.Class4, false, (byte) 0,
DestinationAddressType.PointToPoint), cBusPointToPointCommandIndirect,
cBusOptions);
+ RequestCommand request = new
RequestCommand(RequestType.REQUEST_COMMAND, null, null, null, new
RequestTermination(), cbusCommand, null, null, cBusOptions);
+ CBusMessageToServer cBusMessageToServer = new
CBusMessageToServer(request, requestContext, cBusOptions);
+
+ WriteBufferByteBased writeBuffer = new
WriteBufferByteBased(cBusMessageToServer.getLengthInBytes());
+ cBusMessageToServer.serialize(writeBuffer);
+ System.out.println(new String(writeBuffer.getBytes()));
+ }
+
+ @Test
+ void BridgedIdentifyResponse() throws Exception {
+ byte[] bytes =
("86FD020107890144494D444E344620E3\r\n").getBytes(StandardCharsets.UTF_8);
+ ReadBufferByteBased readBufferByteBased = new
ReadBufferByteBased(bytes);
+ cBusOptions = C_BUS_OPTIONS_WITH_SRCHK;
+ requestContext = new RequestContext(true);
+ CBusMessage msg = CBusMessage.staticParse(readBufferByteBased,
true, requestContext, cBusOptions);
+ assertThat(msg).isNotNull();
+ System.out.println(msg);
+ assertMessageMatches(bytes, msg);
+ }
+ }
}