You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/11/23 23:02:31 UTC
[incubator-plc4x] branch develop updated: - Split up the ADS Driver
the same way the others are split up
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new a1f50a3 - Split up the ADS Driver the same way the others are split up
a1f50a3 is described below
commit a1f50a3b0b4ea3ebf7c03bd426883b192290031b
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Nov 24 00:02:27 2018 +0100
- Split up the ADS Driver the same way the others are split up
---
plc4j/drivers/ads/pom.xml | 65 ++++++++++++++++++++++
.../org/apache/plc4x/java/ads/AdsPlcDriver.java | 4 +-
.../ads/connection/AdsAbstractPlcConnection.java | 2 +-
.../java/ads/connection/AdsConnectionFactory.java | 0
.../ads/connection/AdsSerialPlcConnection.java | 0
.../java/ads/connection/AdsTcpPlcConnection.java | 39 +++++++------
.../services/org.apache.plc4x.java.spi.PlcDriver | 0
.../apache/plc4x/java/ads/AdsPlcDriverTest.java | 0
.../ads/adslib/ADSClientNotificationExample.java | 0
.../org/apache/plc4x/java/ads/adslib/AdsLib.java | 0
.../apache/plc4x/java/ads/adslib/AmsRequest.java | 2 +-
.../apache/plc4x/java/ads/adslib/AmsRouter.java | 0
.../org/apache/plc4x/java/ads/adslib/Output.java | 0
.../apache/plc4x/java/ads/adslib/package-info.java | 0
.../connection/AdsAbstractPlcConnectionTest.java | 11 ++--
.../ads/connection/AdsConnectionFactoryTest.java | 7 ++-
.../ads/connection/AdsSerialPlcConnectionTest.java | 9 ++-
.../ads/connection/AdsTcpPlcConnectionTests.java | 45 +++++++--------
plc4j/protocols/ads/pom.xml | 16 ------
.../plc4x/java/ads/connection/package-info.java | 22 --------
.../org/apache/plc4x/java/ads/package-info.java | 22 --------
21 files changed, 125 insertions(+), 119 deletions(-)
diff --git a/plc4j/drivers/ads/pom.xml b/plc4j/drivers/ads/pom.xml
index a6f7076..0d7257d 100644
--- a/plc4j/drivers/ads/pom.xml
+++ b/plc4j/drivers/ads/pom.xml
@@ -32,6 +32,71 @@
<description>Implementation of a PLC4X driver able to speak with Beckhoff devices using the ADS protocol.</description>
<dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-api</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-protocol-ads</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-protocol-driver-base</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-protocol-driver-base-tcp</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-protocol-driver-base-serial</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-configuration2</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-protocol-driver-base-test</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>se.koc</groupId>
+ <artifactId>netty-transport-jserialcomm</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
similarity index 100%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
rename to plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
index 1ce7666..464ee36 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
@@ -22,10 +22,10 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.plc4x.java.ads.api.generic.types.AmsNetId;
import org.apache.plc4x.java.ads.api.generic.types.AmsPort;
import org.apache.plc4x.java.ads.connection.AdsConnectionFactory;
-import org.apache.plc4x.java.spi.PlcDriver;
-import org.apache.plc4x.java.api.authentication.PlcAuthentication;
import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.java.api.authentication.PlcAuthentication;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+import org.apache.plc4x.java.spi.PlcDriver;
import java.net.InetAddress;
import java.net.UnknownHostException;
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java
similarity index 100%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java
rename to plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java
index 858a18f..c7a2b32 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnection.java
@@ -34,8 +34,8 @@ import org.apache.plc4x.java.ads.model.SymbolicAdsField;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.messages.*;
-import org.apache.plc4x.java.base.connection.NettyPlcConnection;
import org.apache.plc4x.java.base.connection.ChannelFactory;
+import org.apache.plc4x.java.base.connection.NettyPlcConnection;
import org.apache.plc4x.java.base.messages.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactory.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactory.java
similarity index 100%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactory.java
rename to plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactory.java
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
similarity index 100%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
rename to plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
similarity index 95%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
rename to plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
index 8f5f89c..a7af2b3 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
@@ -1,21 +1,21 @@
/*
-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.
-*/
+ 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.ads.connection;
import io.netty.channel.Channel;
@@ -32,6 +32,7 @@ import org.apache.plc4x.java.ads.model.*;
import org.apache.plc4x.java.ads.protocol.Ads2PayloadProtocol;
import org.apache.plc4x.java.ads.protocol.Payload2TcpProtocol;
import org.apache.plc4x.java.ads.protocol.Plc4x2AdsProtocol;
+import org.apache.plc4x.java.ads.protocol.util.LittleEndianDecoder;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.messages.*;
@@ -65,8 +66,6 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
-import static org.apache.plc4x.java.ads.protocol.util.LittleEndianDecoder.decodeData;
-
public class AdsTcpPlcConnection extends AdsAbstractPlcConnection implements PlcSubscriber {
private static final Logger LOGGER = LoggerFactory.getLogger(AdsTcpPlcConnection.class);
@@ -302,7 +301,7 @@ public class AdsTcpPlcConnection extends AdsAbstractPlcConnection implements Plc
String plcFieldName = adsSubscriptionHandle.getPlcFieldName();
AdsDataType adsDataType = adsSubscriptionHandle.getAdsDataType();
try {
- BaseDefaultFieldItem baseDefaultFieldItem = decodeData(adsDataType, data.getBytes());
+ BaseDefaultFieldItem baseDefaultFieldItem = LittleEndianDecoder.decodeData(adsDataType, data.getBytes());
fields.put(plcFieldName, Pair.of(PlcResponseCode.OK, baseDefaultFieldItem));
} catch (RuntimeException e) {
LOGGER.error("Can't decode {}", data, e);
diff --git a/plc4j/protocols/ads/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver b/plc4j/drivers/ads/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
similarity index 100%
rename from plc4j/protocols/ads/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
rename to plc4j/drivers/ads/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java
index a75e033..62f89ca 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRequest.java
@@ -19,8 +19,8 @@
package org.apache.plc4x.java.ads.adslib;
import org.apache.plc4x.java.ads.api.generic.AmsPacket;
-import org.apache.plc4x.java.base.messages.PlcProprietaryRequest;
import org.apache.plc4x.java.base.messages.DefaultPlcProprietaryRequest;
+import org.apache.plc4x.java.base.messages.PlcProprietaryRequest;
import java.util.concurrent.CompletableFuture;
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/Output.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/Output.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/Output.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/Output.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/package-info.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/package-info.java
similarity index 100%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/package-info.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/adslib/package-info.java
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java
similarity index 96%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java
index d20df92..1634faa 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsAbstractPlcConnectionTest.java
@@ -7,7 +7,7 @@
"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
+ 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
@@ -44,6 +44,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -178,8 +179,8 @@ class AdsAbstractPlcConnectionTest implements WithAssertions {
void mapSingleField() {
when(channel.writeAndFlush(any(PlcRequestContainer.class))).then(invocation -> {
PlcRequestContainer plcRequestContainer = invocation.getArgument(0);
- PlcProprietaryResponse plcProprietaryResponse = mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
- AdsReadWriteResponse adsReadWriteResponse = mock(AdsReadWriteResponse.class, RETURNS_DEEP_STUBS);
+ PlcProprietaryResponse plcProprietaryResponse = Mockito.mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
+ AdsReadWriteResponse adsReadWriteResponse = Mockito.mock(AdsReadWriteResponse.class, RETURNS_DEEP_STUBS);
when(adsReadWriteResponse.getResult()).thenReturn(Result.of(0));
when(adsReadWriteResponse.getData()).thenReturn(Data.of(new byte[]{1, 2, 3, 4}));
when(plcProprietaryResponse.getResponse()).thenReturn(adsReadWriteResponse);
@@ -198,8 +199,8 @@ class AdsAbstractPlcConnectionTest implements WithAssertions {
void mapSingleFieldNegative() {
when(channel.writeAndFlush(any(PlcRequestContainer.class))).then(invocation -> {
PlcRequestContainer plcRequestContainer = invocation.getArgument(0);
- PlcProprietaryResponse plcProprietaryResponse = mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
- AdsReadWriteResponse adsReadWriteResponse = mock(AdsReadWriteResponse.class, RETURNS_DEEP_STUBS);
+ PlcProprietaryResponse plcProprietaryResponse = Mockito.mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
+ AdsReadWriteResponse adsReadWriteResponse = Mockito.mock(AdsReadWriteResponse.class, RETURNS_DEEP_STUBS);
when(adsReadWriteResponse.getResult()).thenReturn(Result.of(1));
when(plcProprietaryResponse.getResponse()).thenReturn(adsReadWriteResponse);
plcRequestContainer.getResponseFuture().complete(plcProprietaryResponse);
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java
similarity index 97%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java
index 0fdd0c0..e9cff09 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsConnectionFactoryTest.java
@@ -7,7 +7,7 @@
"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
+ 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
@@ -24,6 +24,7 @@ import org.apache.plc4x.java.ads.api.generic.types.AmsPort;
import org.apache.plc4x.java.base.connection.NettyPlcConnection;
import org.apache.plc4x.java.base.connection.SerialChannelFactory;
import org.apache.plc4x.java.base.connection.TcpSocketChannelFactory;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -119,7 +120,7 @@ public class AdsConnectionFactoryTest {
TcpSocketChannelFactory channelFactory = (TcpSocketChannelFactory) FieldUtils
.getDeclaredField(NettyPlcConnection.class, "channelFactory", true)
.get(adsTcpPlcConnection);
- assertEquals(port, channelFactory.getPort());
+ Assert.assertEquals(port, channelFactory.getPort());
}
@Test
@@ -159,6 +160,6 @@ public class AdsConnectionFactoryTest {
SerialChannelFactory channelFactory = (SerialChannelFactory) FieldUtils
.getDeclaredField(NettyPlcConnection.class, "channelFactory", true)
.get(adsSerialPlcConnection);
- assertEquals(serialPort, channelFactory.getSerialPort());
+ Assert.assertEquals(serialPort, channelFactory.getSerialPort());
}
}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java
similarity index 97%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java
index 8a24c99..b4e8a01 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnectionTest.java
@@ -7,7 +7,7 @@
"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
+ 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
@@ -35,6 +35,7 @@ import org.apache.plc4x.java.base.connection.SerialChannelFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,8 +48,6 @@ import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
public class AdsSerialPlcConnectionTest {
@@ -85,10 +84,10 @@ public class AdsSerialPlcConnectionTest {
private void prepareSerialSimulator() throws Exception {
Field channelFactoryField = FieldUtils.getField(NettyPlcConnection.class, "channelFactory", true);
SerialChannelFactory serialChannelFactory = (SerialChannelFactory) channelFactoryField.get(SUT);
- SerialChannelFactory serialChannelFactorySpied = spy(serialChannelFactory);
+ SerialChannelFactory serialChannelFactorySpied = Mockito.spy(serialChannelFactory);
EmbeddedChannel embeddedChannel = new EmbeddedChannel(SUT.getChannelHandler(null));
embeddedChannel.connect(new JSerialCommDeviceAddress("/dev/tty0"));
- doReturn(embeddedChannel).when(serialChannelFactorySpied).createChannel(any());
+ Mockito.doReturn(embeddedChannel).when(serialChannelFactorySpied).createChannel(any());
channelFactoryField.set(SUT, serialChannelFactorySpied);
SUT.connect();
new SerialSimulator(embeddedChannel).start();
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java
similarity index 84%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java
rename to plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java
index 98e81d6..37397b5 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnectionTests.java
@@ -1,21 +1,21 @@
/*
-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.
-*/
+ 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.ads.connection;
@@ -47,6 +47,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import java.net.InetAddress;
@@ -81,7 +82,7 @@ class AdsTcpPlcConnectionTests implements WithAssertions {
void setUp() throws Exception {
SUT = AdsTcpPlcConnection.of(InetAddress.getByName("localhost"), AmsNetId.of("0.0.0.0.0.0"), AmsPort.of(13));
// TODO: Refactor this to use the TestChannelFactory instead.
- channelMock = mock(Channel.class, RETURNS_DEEP_STUBS);
+ channelMock = Mockito.mock(Channel.class, RETURNS_DEEP_STUBS);
FieldUtils.writeField(SUT, "channel", channelMock, true);
executorService = Executors.newFixedThreadPool(10);
}
@@ -107,8 +108,8 @@ class AdsTcpPlcConnectionTests implements WithAssertions {
void subscribe() {
when(channelMock.writeAndFlush(any(PlcRequestContainer.class))).then(invocation -> {
PlcRequestContainer plcRequestContainer = invocation.getArgument(0);
- PlcProprietaryResponse plcProprietaryResponse = mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
- AdsAddDeviceNotificationResponse adsAddDeviceNotificationResponse = mock(AdsAddDeviceNotificationResponse.class, RETURNS_DEEP_STUBS);
+ PlcProprietaryResponse plcProprietaryResponse = Mockito.mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
+ AdsAddDeviceNotificationResponse adsAddDeviceNotificationResponse = Mockito.mock(AdsAddDeviceNotificationResponse.class, RETURNS_DEEP_STUBS);
when(adsAddDeviceNotificationResponse.getResult()).thenReturn(Result.of(0));
when(adsAddDeviceNotificationResponse.getNotificationHandle()).thenReturn(NotificationHandle.of(1));
when(plcProprietaryResponse.getResponse()).thenReturn(adsAddDeviceNotificationResponse);
@@ -129,8 +130,8 @@ class AdsTcpPlcConnectionTests implements WithAssertions {
void unsubscribe() {
when(channelMock.writeAndFlush(any(PlcRequestContainer.class))).then(invocation -> {
PlcRequestContainer plcRequestContainer = invocation.getArgument(0);
- PlcProprietaryResponse plcProprietaryResponse = mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
- AdsDeleteDeviceNotificationResponse adsDeleteDeviceNotificationResponse = mock(AdsDeleteDeviceNotificationResponse.class, RETURNS_DEEP_STUBS);
+ PlcProprietaryResponse plcProprietaryResponse = Mockito.mock(InternalPlcProprietaryResponse.class, RETURNS_DEEP_STUBS);
+ AdsDeleteDeviceNotificationResponse adsDeleteDeviceNotificationResponse = Mockito.mock(AdsDeleteDeviceNotificationResponse.class, RETURNS_DEEP_STUBS);
when(adsDeleteDeviceNotificationResponse.getResult()).thenReturn(Result.of(0));
when(plcProprietaryResponse.getResponse()).thenReturn(adsDeleteDeviceNotificationResponse);
plcRequestContainer.getResponseFuture().complete(plcProprietaryResponse);
diff --git a/plc4j/protocols/ads/pom.xml b/plc4j/protocols/ads/pom.xml
index cc64139..e77c6b5 100644
--- a/plc4j/protocols/ads/pom.xml
+++ b/plc4j/protocols/ads/pom.xml
@@ -43,16 +43,6 @@
<artifactId>plc4j-protocol-driver-base</artifactId>
<version>0.3.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-protocol-driver-base-tcp</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-protocol-driver-base-serial</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>io.netty</groupId>
@@ -102,12 +92,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>se.koc</groupId>
- <artifactId>netty-transport-jserialcomm</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-protocol-driver-base-test</artifactId>
<version>0.3.0-SNAPSHOT</version>
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/package-info.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/package-info.java
deleted file mode 100644
index 043a1df..0000000
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- 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.
- */
-/**
- * Contains connection classes for TCP and Serial connections as well as a factory.
- */
-package org.apache.plc4x.java.ads.connection;
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/package-info.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/package-info.java
deleted file mode 100644
index 53d1485..0000000
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- 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.
- */
-/**
- * This package contains the ads plc implementation.
- */
-package org.apache.plc4x.java.ads;
\ No newline at end of file