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 3a4f4fb4da fix: Added tests covering TransportInstance.getDriverConfig
to fix the JaCoCo coverage check in plc4j-transports-api.
3a4f4fb4da is described below
commit 3a4f4fb4da9011729d97d2172bc360fb6007809d
Author: Sebastian Rühl <[email protected]>
AuthorDate: Mon Jul 13 08:47:17 2026 +0200
fix: Added tests covering TransportInstance.getDriverConfig to fix the
JaCoCo coverage check in plc4j-transports-api.
The default method added to the TransportInstance interface made JaCoCo
count the interface as a class without any coverage, violating the
CLASS MISSEDCOUNT rule. Also covers the new driverConfig getter/setter
in BaseTransportInstance.
---
.../transports/api/BaseTransportInstanceTest.java | 42 +++++++++++++
.../spi/transports/api/TransportInstanceTest.java | 72 ++++++++++++++++++++++
2 files changed, 114 insertions(+)
diff --git
a/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/BaseTransportInstanceTest.java
b/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/BaseTransportInstanceTest.java
index e7d33ef1b8..c90ae1b88e 100644
---
a/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/BaseTransportInstanceTest.java
+++
b/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/BaseTransportInstanceTest.java
@@ -121,6 +121,48 @@ class BaseTransportInstanceTest {
assertThrows(NullPointerException.class, () -> new
TestBaseTransport(config, null));
}
+ @Test
+ void testGetDriverConfig_shouldDefaultToEmptyString() {
+ // Arrange
+ TransportConfiguration config = mock(TransportConfiguration.class);
+ AuditLog auditLog = mock(AuditLog.class);
+
+ TestBaseTransport transport = new TestBaseTransport(config, auditLog);
+
+ // Act & Assert
+ assertEquals("", transport.getDriverConfig());
+ }
+
+ @Test
+ void testSetDriverConfig_shouldReturnSetValue() {
+ // Arrange
+ TransportConfiguration config = mock(TransportConfiguration.class);
+ AuditLog auditLog = mock(AuditLog.class);
+
+ TestBaseTransport transport = new TestBaseTransport(config, auditLog);
+
+ // Act
+ transport.setDriverConfig("/milo");
+
+ // Assert
+ assertEquals("/milo", transport.getDriverConfig());
+ }
+
+ @Test
+ void testSetDriverConfig_withNull_shouldReturnEmptyString() {
+ // Arrange
+ TransportConfiguration config = mock(TransportConfiguration.class);
+ AuditLog auditLog = mock(AuditLog.class);
+
+ TestBaseTransport transport = new TestBaseTransport(config, auditLog);
+
+ // Act
+ transport.setDriverConfig(null);
+
+ // Assert
+ assertEquals("", transport.getDriverConfig());
+ }
+
/**
* Concrete test implementation of BaseTransport for testing purposes
*/
diff --git
a/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/TransportInstanceTest.java
b/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/TransportInstanceTest.java
new file mode 100644
index 0000000000..39f60b7b7e
--- /dev/null
+++
b/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/TransportInstanceTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License 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.
+ */
+
+package org.apache.plc4x.java.spi.transports.api;
+
+import org.apache.plc4x.java.spi.transports.api.config.TransportConfiguration;
+import org.apache.plc4x.java.spi.transports.api.exceptions.TransportException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TransportInstanceTest {
+
+ @Test
+ void testDefaultGetDriverConfig() {
+ // Create a minimal implementation to test the default method
+ TransportInstance<TransportConfiguration> transportInstance = new
TransportInstance<TransportConfiguration>() {
+ @Override
+ public TransportConfiguration getConfiguration() {
+ return null;
+ }
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public int getNumBytesAvailable() throws TransportException {
+ return 0;
+ }
+
+ @Override
+ public byte[] peekReadableBytes(int numBytes) throws
TransportException {
+ return new byte[0];
+ }
+
+ @Override
+ public byte[] read(int numBytes) throws TransportException {
+ return new byte[0];
+ }
+
+ @Override
+ public void write(byte[] bytes) throws TransportException {
+ }
+
+ @Override
+ public void close() throws TransportException {
+ }
+ };
+
+ // The default implementation returns an empty string
+ assertEquals("", transportInstance.getDriverConfig());
+ }
+
+}