This is an automated email from the ASF dual-hosted git repository. lgallinat pushed a commit to branch feature/GEODE-4020 in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-4020 by this push: new 3ff6336 GEODE-4020 Fill in dunit tests for list connection command and send gfsh command to only one member 3ff6336 is described below commit 3ff633690af22280680e184cfb938584c59b9797 Author: Lynn Gallinat <lgalli...@pivotal.io> AuthorDate: Tue Dec 5 15:40:03 2017 -0800 GEODE-4020 Fill in dunit tests for list connection command and send gfsh command to only one member --- .../jdbc/internal/cli/ListConnectionCommand.java | 6 ++-- .../cli/ListConnectionCommandDUnitTest.java | 41 +++++++++++++++------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommand.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommand.java index d38ee30..f78191a 100644 --- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommand.java +++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommand.java @@ -55,7 +55,7 @@ public class ListConnectionCommand implements GfshCommand { // action ResultCollector<ConnectionConfiguration, List<ConnectionConfiguration[]>> resultCollector = - execute(new ListConnectionFunction(), targetMembers); + execute(new ListConnectionFunction(), targetMembers.iterator().next()); // output TabularResultData tabularResultData = ResultBuilder.createTabularResultData(); @@ -64,9 +64,9 @@ public class ListConnectionCommand implements GfshCommand { } ResultCollector<ConnectionConfiguration, List<ConnectionConfiguration[]>> execute( - ListConnectionFunction function, Set<DistributedMember> targetMembers) { + ListConnectionFunction function, DistributedMember targetMember) { return (ResultCollector<ConnectionConfiguration, List<ConnectionConfiguration[]>>) executeFunction( - function, null, targetMembers); + function, null, targetMember); } private Result createResult(TabularResultData tabularResultData, boolean connectionsExist) { diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommandDUnitTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommandDUnitTest.java index 8b0a372..fb06c1a 100644 --- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommandDUnitTest.java +++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/ListConnectionCommandDUnitTest.java @@ -14,8 +14,6 @@ */ package org.apache.geode.connectors.jdbc.internal.cli; -import static org.apache.geode.connectors.jdbc.internal.cli.DestroyConnectionCommand.DESTROY_CONNECTION; -import static org.apache.geode.connectors.jdbc.internal.cli.DestroyConnectionCommand.DESTROY_CONNECTION__NAME; import static org.apache.geode.connectors.jdbc.internal.cli.ListConnectionCommand.LIST_JDBC_CONNECTION; import static org.apache.geode.connectors.jdbc.internal.cli.ListConnectionCommand.LIST_OF_CONNECTIONS; import static org.assertj.core.api.Assertions.assertThat; @@ -29,9 +27,7 @@ import org.junit.experimental.categories.Category; import org.apache.geode.connectors.jdbc.internal.ConnectionConfigBuilder; import org.apache.geode.connectors.jdbc.internal.ConnectionConfigExistsException; -import org.apache.geode.connectors.jdbc.internal.ConnectionConfiguration; import org.apache.geode.connectors.jdbc.internal.InternalJdbcConnectorService; -import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.test.dunit.rules.LocatorServerStartupRule; @@ -71,28 +67,37 @@ public class ListConnectionCommandDUnitTest implements Serializable { @Test public void listsOneConnection() throws Exception { server.invoke(() -> createOneConnection()); - CommandStringBuilder csb = new CommandStringBuilder(LIST_JDBC_CONNECTION); CommandResultAssert commandResultAssert = gfsh.executeAndAssertThat(csb.toString()); commandResultAssert.statusIsSuccess(); - commandResultAssert.tableHasRowCount(LIST_OF_CONNECTIONS, 1); - - // TODO: assert that the table contains LIST_OF_CONNECTIONS - // TODO: assert that the table contains name of connection + commandResultAssert.tableHasColumnOnlyWithValues(LIST_OF_CONNECTIONS, connectionName); } @Test public void listsMultipleConnections() throws Exception { - // TODO: assert that the table contains LIST_OF_CONNECTIONS - // TODO: assert that the table contains names of several connections + server.invoke(() -> createNConnections(3)); + CommandStringBuilder csb = new CommandStringBuilder(LIST_JDBC_CONNECTION); + + CommandResultAssert commandResultAssert = gfsh.executeAndAssertThat(csb.toString()); + + commandResultAssert.statusIsSuccess(); + commandResultAssert.tableHasRowCount(LIST_OF_CONNECTIONS, 3); + commandResultAssert.tableHasColumnOnlyWithValues(LIST_OF_CONNECTIONS, + connectionName + "-1", connectionName + "-2", + connectionName + "-3"); } @Test public void reportsNoConnectionsFound() throws Exception { - // TODO: assert that the results show ListConnectionCommand.NO_CONNECTIONS_FOUND + CommandStringBuilder csb = new CommandStringBuilder(LIST_JDBC_CONNECTION); + + CommandResultAssert commandResultAssert = gfsh.executeAndAssertThat(csb.toString()); + + commandResultAssert.statusIsSuccess(); + commandResultAssert.containsOutput("No connections found"); } private void createOneConnection() throws ConnectionConfigExistsException { @@ -103,4 +108,16 @@ public class ListConnectionCommandDUnitTest implements Serializable { assertThat(service.getConnectionConfig(connectionName)).isNotNull(); } + + private void createNConnections(int N) throws ConnectionConfigExistsException { + InternalCache cache = LocatorServerStartupRule.getCache(); + InternalJdbcConnectorService service = cache.getService(InternalJdbcConnectorService.class); + for (int i = 1; i <= N; i++) { + String name = connectionName + "-" + i; + service.createConnectionConfig( + new ConnectionConfigBuilder().withName(name).build()); + assertThat(service.getConnectionConfig(name)).isNotNull(); + } + } + } -- To stop receiving notification emails like this one, please contact ['"commits@geode.apache.org" <commits@geode.apache.org>'].