You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2017/11/02 03:21:26 UTC

[15/50] [abbrv] incubator-edgent git commit: change JDBC test to not be TMO dependent on success

change JDBC test to not be TMO dependent on success

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/b7897e59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/b7897e59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/b7897e59

Branch: refs/heads/develop
Commit: b7897e595072e2c4ae6a084a1a356018c2e5cb44
Parents: e231c41
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Wed Oct 25 14:50:10 2017 -0400
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Wed Oct 25 14:50:10 2017 -0400

----------------------------------------------------------------------
 .../test/connectors/jdbc/JdbcStreamsTest.java       | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/b7897e59/connectors/jdbc/src/test/java/org/apache/edgent/test/connectors/jdbc/JdbcStreamsTest.java
----------------------------------------------------------------------
diff --git a/connectors/jdbc/src/test/java/org/apache/edgent/test/connectors/jdbc/JdbcStreamsTest.java b/connectors/jdbc/src/test/java/org/apache/edgent/test/connectors/jdbc/JdbcStreamsTest.java
index 13ce2d1..a284340 100644
--- a/connectors/jdbc/src/test/java/org/apache/edgent/test/connectors/jdbc/JdbcStreamsTest.java
+++ b/connectors/jdbc/src/test/java/org/apache/edgent/test/connectors/jdbc/JdbcStreamsTest.java
@@ -20,6 +20,7 @@ package org.apache.edgent.test.connectors.jdbc;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 
 import java.lang.reflect.Method;
@@ -42,6 +43,7 @@ import org.apache.edgent.topology.TSink;
 import org.apache.edgent.topology.TStream;
 import org.apache.edgent.topology.Topology;
 import org.apache.edgent.topology.plumbing.PlumbingStreams;
+import org.apache.edgent.topology.tester.Condition;
 import org.junit.Test;
 
 /**
@@ -464,6 +466,7 @@ public class JdbcStreamsTest  extends ConnectorTestBase {
                         executionExcCnt.incrementAndGet();
                         return;
                     }
+                    // don't ever expect to get here in this case
                     resultSet.next();
                     int id = resultSet.getInt("id");
                     String firstName = resultSet.getString("firstname");
@@ -475,10 +478,21 @@ public class JdbcStreamsTest  extends ConnectorTestBase {
                 );
         TStream<String> rcvd = rcvdPerson.map(person -> person.toString());
         
+        // Await completion on having received the correct number of exception.
+        // Then also verify that no non-exceptional results were received.
+        Condition<Object> tc = new Condition<Object>() {
+            public boolean valid() {
+                return executionExcCnt.get() == expectedExcCnt;
+            }
+            public Object getResult() { return executionExcCnt.get(); }
+        };
+        Condition<List<String>> rcvdContents = t.getTester().streamContents(rcvd, expected.toArray(new String[0]));
+        
         rcvd.sink(tuple -> System.out.println(
                 String.format("%s rcvd: %s", t.getName(), tuple)));
-        completeAndValidate("", t, rcvd, SEC_TIMEOUT, expected.toArray(new String[0]));
+        complete(t, tc, SEC_TIMEOUT, TimeUnit.SECONDS);
         assertEquals("executionExcCnt", expectedExcCnt, executionExcCnt.get());
+        assertTrue("rcvd: "+rcvdContents.getResult(), rcvdContents.valid());
     }
     
     @Test