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/09/14 16:16:20 UTC
[incubator-plc4x] branch feature/api-redesign-chris-c updated: -
Updated the getConnectionUnknownHost test to run even if internet providers
use a default host for unknown host-names.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/api-redesign-chris-c
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/feature/api-redesign-chris-c by this push:
new 022d7f5 - Updated the getConnectionUnknownHost test to run even if internet providers use a default host for unknown host-names.
022d7f5 is described below
commit 022d7f5ba1283034271909e891221d9ac14c342f
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri Sep 14 18:16:17 2018 +0200
- Updated the getConnectionUnknownHost test to run even if internet providers use a default host for unknown host-names.
---
.../org/apache/plc4x/java/ads/AdsPlcDriverTest.java | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
index 06e0eae..260ec11 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/AdsPlcDriverTest.java
@@ -19,6 +19,7 @@ under the License.
package org.apache.plc4x.java.ads;
+import io.netty.channel.ConnectTimeoutException;
import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.ads.connection.AdsConnectionFactory;
import org.apache.plc4x.java.ads.connection.AdsTcpPlcConnection;
@@ -30,6 +31,7 @@ import org.apache.plc4x.java.base.connection.tcp.TcpHexDumper;
import org.junit.Rule;
import org.junit.Test;
+import java.net.ConnectException;
import java.util.regex.Pattern;
import java.util.stream.Stream;
@@ -105,9 +107,19 @@ public class AdsPlcDriverTest {
new PlcUsernamePasswordAuthentication("admin", "admin"));
}
- @Test(expected = PlcConnectionException.class)
- public void getConnectionUnknownHost() throws Exception {
- new PlcDriverManager().getConnection("ads:tcp://nowhere:8080/0.0.0.0.0.0:13");
+ @Test
+ public void getConnectionUnknownHost() {
+ try {
+ new PlcDriverManager().getConnection("ads:tcp://nowhere:8080/0.0.0.0.0.0:13");
+ fail();
+ } catch (Exception e) {
+ assert((e instanceof PlcConnectionException) ||
+ // When running this test on systems with an internet provider that redirects
+ // all unknown hosts to a default host (For showing adds), one of these will
+ // be thrown instead.
+ (e instanceof ConnectTimeoutException) ||
+ (e.getCause() instanceof ConnectException));
+ }
}
@Test(expected = PlcConnectionException.class)