You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2018/11/02 09:05:22 UTC

[incubator-plc4x] branch add-simple-mock-driver updated: Cleanup.

This is an automated email from the ASF dual-hosted git repository.

jfeinauer pushed a commit to branch add-simple-mock-driver
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/add-simple-mock-driver by this push:
     new 38a4148  Cleanup.
38a4148 is described below

commit 38a41485c9cdd8dcd98abd60cb87a0e74bb65681
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Fri Nov 2 10:05:13 2018 +0100

    Cleanup.
---
 .../apache/plc4x/java/mock/PlcMockDriverTest.java  | 74 ----------------------
 .../java/mock/connection/PlcMockConnection.java    | 26 --------
 .../plc4x/java/mock/connection/PlcMockDriver.java  | 50 ---------------
 .../services/org.apache.plc4x.java.spi.PlcDriver   | 19 ------
 .../services/org.apache.plc4x.java.spi.PlcDriver   |  1 +
 5 files changed, 1 insertion(+), 169 deletions(-)

diff --git a/plc4j/core/src/test/java/org/apache/plc4x/java/mock/PlcMockDriverTest.java b/plc4j/core/src/test/java/org/apache/plc4x/java/mock/PlcMockDriverTest.java
deleted file mode 100644
index 532e20f..0000000
--- a/plc4j/core/src/test/java/org/apache/plc4x/java/mock/PlcMockDriverTest.java
+++ /dev/null
@@ -1,74 +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.
- */
-
-package org.apache.plc4x.java.mock;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.plc4x.java.PlcDriverManager;
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
-import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.base.messages.items.DefaultLongFieldItem;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import static junit.framework.TestCase.assertFalse;
-import static junit.framework.TestCase.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class PlcMockDriverTest {
-
-    private final PlcDriverManager driverManager = new PlcDriverManager();
-
-    @Test
-    public void useMockDriver_noDevice_isNotConnected() throws Exception {
-        PlcConnection connection = driverManager.getConnection("mock:dummy");
-
-        assertFalse(connection.isConnected());
-    }
-
-    @Test
-    public void useMockDriver_deviceSet_isConnected() throws Exception {
-        PlcMockConnection connection = (PlcMockConnection) driverManager.getConnection("mock:dummy");
-        MockDevice mock = Mockito.mock(MockDevice.class);
-        connection.setDevice(mock);
-
-        assertTrue(connection.isConnected());
-    }
-
-    @Test
-    public void mockDriver_assertSimpleRequest() throws PlcConnectionException {
-        PlcMockConnection connection = (PlcMockConnection) driverManager.getConnection("mock:dummy");
-        MockDevice mock = Mockito.mock(MockDevice.class);
-        when(mock.read(any())).thenReturn(Pair.of(PlcResponseCode.OK, new DefaultLongFieldItem(1L)));
-        connection.setDevice(mock);
-
-        connection.readRequestBuilder()
-            .addItem("item1", "myPlcField")
-            .build()
-            .execute();
-
-        // Verify the call
-        verify(mock, times(1)).read(eq("myPlcField"));
-    }
-}
\ No newline at end of file
diff --git a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockConnection.java b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockConnection.java
deleted file mode 100644
index dbae61f..0000000
--- a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockConnection.java
+++ /dev/null
@@ -1,26 +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.
- */
-
-package org.apache.plc4x.java.mock.connection;
-
-/**
- * Connection which is used for mocking.
- */
-public class PlcMockConnection {
-}
diff --git a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockDriver.java b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockDriver.java
deleted file mode 100644
index 5effc7e..0000000
--- a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/mock/connection/PlcMockDriver.java
+++ /dev/null
@@ -1,50 +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.
- */
-
-package org.apache.plc4x.java.mock.connection;
-
-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;
-
-/**
- * Driver which can be used for mocking.
- */
-public class PlcMockDriver implements PlcDriver {
-    @Override
-    public String getProtocolCode() {
-        return "mock";
-    }
-
-    @Override
-    public String getProtocolName() {
-        return null;
-    }
-
-    @Override
-    public PlcConnection connect(String url) {
-        return null;
-    }
-
-    @Override
-    public PlcConnection connect(String url, PlcAuthentication authentication) {
-        return null;
-    }
-}
diff --git a/plc4j/protocols/driver-bases/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver b/plc4j/protocols/driver-bases/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
deleted file mode 100644
index ebff4aa..0000000
--- a/plc4j/protocols/driver-bases/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.plc4x.java.mock.PlcMockDriver
diff --git a/plc4j/protocols/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver b/plc4j/protocols/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
index f71d436..f145b55 100644
--- a/plc4j/protocols/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
+++ b/plc4j/protocols/test/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
@@ -17,3 +17,4 @@
 # under the License.
 #
 org.apache.plc4x.java.test.TestPlcDriver
+org.apache.plc4x.java.mock.PlcMockDriver