This is an automated email from the ASF dual-hosted git repository.
sk0x50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 49d453c15d IGNITE-17170 Dropped deprecated package. Fixes #1328
49d453c15d is described below
commit 49d453c15d79a61188501c737b4e767498f55973
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Thu Nov 17 18:51:03 2022 +0200
IGNITE-17170 Dropped deprecated package. Fixes #1328
Signed-off-by: Slava Koptilin <[email protected]>
---
.../ignite/internal/cli/IntegrationTestBase.java | 9 +-
.../call/CallInitializedIntegrationTestBase.java | 3 +-
.../CliCommandTestInitializedIntegrationBase.java | 3 +-
...liCommandTestNotInitializedIntegrationBase.java | 3 +-
.../ItClusterCommandTest.java | 18 +-
.../ItConfigCommandTest.java | 32 +---
.../apache/ignite/internal/cli/CliVersionInfo.java | 2 +-
.../internal/cli/commands/node/NodeUrlMixin.java | 2 +-
.../internal/cli/commands/sql/SqlCommand.java | 2 +-
.../internal/cli/commands/sql/SqlReplCommand.java | 2 +-
.../exception}/IgniteCliException.java | 2 +-
.../handler/IgniteCliExceptionHandler.java | 2 +-
.../internal/cli/deprecated/CommandFactory.java | 46 -----
.../ignite/internal/cli/deprecated/Table.java | 206 ---------------------
.../internal/cli/deprecated/package-info.java | 22 ---
.../cli/deprecated/spec/NodeEndpointOptions.java | 80 --------
.../internal/cli/deprecated/spec/package-info.java | 22 ---
.../internal/cli/deprecated/ui/ProgressBar.java | 141 --------------
.../ignite/internal/cli/deprecated/ui/Spinner.java | 74 --------
.../ignite/internal/cli/AbstractCliTest.java} | 45 ++++-
.../{deprecated => }/IgniteCliInterfaceTest.java | 56 +-----
.../internal/cli/deprecated/AbstractCliTest.java | 33 ----
.../internal/cli/deprecated/package-info.java | 22 ---
.../cli/deprecated/ui/ProgressBarTest.java | 80 --------
.../internal/cli/deprecated/ui/SpinnerTest.java | 78 --------
.../internal/cli/deprecated/ui/package-info.java | 22 ---
26 files changed, 68 insertions(+), 939 deletions(-)
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/IntegrationTestBase.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/IntegrationTestBase.java
index 4f618d1578..c050e29ca1 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/IntegrationTestBase.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/IntegrationTestBase.java
@@ -31,7 +31,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.IntStream;
@@ -69,7 +68,7 @@ public class IntegrationTestBase extends
BaseIgniteAbstractTest {
/** Timeout should be big enough to prevent premature session expiration.
*/
private static final long SESSION_IDLE_TIMEOUT =
TimeUnit.SECONDS.toMillis(60);
- public static final int DEFAULT_NODES_COUNT = 3;
+ private static final int DEFAULT_NODES_COUNT = 3;
/** Correct ignite cluster url. */
protected static final String NODE_URL = "http://localhost:10300";
@@ -77,7 +76,7 @@ public class IntegrationTestBase extends
BaseIgniteAbstractTest {
/** Cluster nodes. */
protected static final List<Ignite> CLUSTER_NODES = new ArrayList<>();
- /** Futures that is going to be completed when all nodes are started and
the cluster is inintialized. */
+ /** Futures that are going to be completed when all nodes are started and
the cluster is initialized. */
private static List<CompletableFuture<Ignite>> futures = new ArrayList<>();
private static final IgniteLogger LOG =
Loggers.forClass(IntegrationTestBase.class);
@@ -162,9 +161,9 @@ public class IntegrationTestBase extends
BaseIgniteAbstractTest {
/**
* Before all.
*
- * @param testInfo Test information oject.
+ * @param testInfo Test information object.
*/
- protected void startNodes(TestInfo testInfo) throws ExecutionException,
InterruptedException {
+ protected void startNodes(TestInfo testInfo) {
String connectNodeAddr = "\"localhost:" + BASE_PORT + '\"';
futures = IntStream.range(0, nodes())
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/CallInitializedIntegrationTestBase.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/CallInitializedIntegrationTestBase.java
index e1877d31fc..d3396dcfe2 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/CallInitializedIntegrationTestBase.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/CallInitializedIntegrationTestBase.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.cli.call;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
-import java.util.concurrent.ExecutionException;
import org.apache.ignite.internal.cli.IntegrationTestBase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -30,7 +29,7 @@ import org.junit.jupiter.api.TestInfo;
*/
public class CallInitializedIntegrationTestBase extends IntegrationTestBase {
@BeforeAll
- void beforeAll(TestInfo testInfo) throws ExecutionException,
InterruptedException {
+ void beforeAll(TestInfo testInfo) {
startNodes(testInfo);
String metaStorageNodeName = testNodeName(testInfo, 0);
initializeCluster(metaStorageNodeName);
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestInitializedIntegrationBase.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestInitializedIntegrationBase.java
index 55da842a08..8baceea2ec 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestInitializedIntegrationBase.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestInitializedIntegrationBase.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.cli.commands;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
-import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInfo;
@@ -30,7 +29,7 @@ public class CliCommandTestInitializedIntegrationBase extends
CliCommandTestNotI
@BeforeAll
@Override
- void beforeAll(TestInfo testInfo) throws ExecutionException,
InterruptedException {
+ void beforeAll(TestInfo testInfo) {
startNodes(testInfo);
super.initializeCluster(metaStorageNodeName(testInfo));
}
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestNotInitializedIntegrationBase.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestNotInitializedIntegrationBase.java
index 7a4820a91f..ba3ce092a4 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestNotInitializedIntegrationBase.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/CliCommandTestNotInitializedIntegrationBase.java
@@ -24,7 +24,6 @@ import io.micronaut.context.ApplicationContext;
import jakarta.inject.Inject;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.concurrent.ExecutionException;
import org.apache.ignite.internal.cli.IntegrationTestBase;
import org.apache.ignite.internal.cli.NodeNameRegistry;
import
org.apache.ignite.internal.cli.commands.cliconfig.TestConfigManagerHelper;
@@ -90,7 +89,7 @@ public class CliCommandTestNotInitializedIntegrationBase
extends IntegrationTest
}
@BeforeAll
- void beforeAll(TestInfo testInfo) throws ExecutionException,
InterruptedException {
+ void beforeAll(TestInfo testInfo) {
startNodes(testInfo);
}
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItClusterCommandTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItClusterCommandTest.java
similarity index 94%
rename from
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItClusterCommandTest.java
rename to
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItClusterCommandTest.java
index 4462157619..5511b340a3 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItClusterCommandTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItClusterCommandTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.cli.deprecated;
+package org.apache.ignite.internal.cli.commands;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -25,8 +25,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import io.micronaut.context.ApplicationContext;
-import io.micronaut.context.env.Environment;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -36,6 +34,7 @@ import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.cli.AbstractCliTest;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.apache.ignite.internal.testframework.jul.NoOpHandler;
@@ -49,7 +48,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
* Integration test for {@code ignite cluster} commands.
*/
@ExtendWith(WorkDirectoryExtension.class)
-class ItClusterCommandTest extends AbstractCliIntegrationTest {
+class ItClusterCommandTest extends AbstractCliTest {
private static final String TOPOLOGY_SNAPSHOT_LOG_RECORD_PREFIX =
"Topology snapshot [nodes=";
private static final Node FIRST_NODE = new Node(0, 10100, 10300);
@@ -66,9 +65,6 @@ class ItClusterCommandTest extends AbstractCliIntegrationTest
{
private static final Logger topologyLogger =
Logger.getLogger("org.apache.ignite.network.scalecube.ScaleCubeTopologyService");
- /** DI context. */
- private ApplicationContext ctx;
-
@BeforeEach
void setup(@WorkDirectory Path workDir, TestInfo testInfo) throws
Exception {
CountDownLatch allNodesAreInPhysicalTopology = new CountDownLatch(1);
@@ -83,8 +79,6 @@ class ItClusterCommandTest extends AbstractCliIntegrationTest
{
} finally {
topologyLogger.removeHandler(physicalTopologyWaiter);
}
-
- ctx = ApplicationContext.run(Environment.TEST);
}
private Handler physicalTopologyWaiter(CountDownLatch
physicalTopologyIsFull) {
@@ -154,10 +148,6 @@ class ItClusterCommandTest extends
AbstractCliIntegrationTest {
for (int i = 0; i < NODES.size(); i++) {
IgnitionManager.stop(testNodeName(testInfo, i));
}
-
- if (ctx != null) {
- ctx.stop();
- }
}
/**
@@ -169,7 +159,7 @@ class ItClusterCommandTest extends
AbstractCliIntegrationTest {
*/
@Test
void initClusterWithNodesOfDifferentRoles(TestInfo testInfo) {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", FIRST_NODE.restHostPort(),
"--meta-storage-node", SECOND_NODE.nodeName(testInfo),
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItConfigCommandTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItConfigCommandTest.java
similarity index 88%
rename from
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItConfigCommandTest.java
rename to
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItConfigCommandTest.java
index 76f35969f9..024b027c4b 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/ItConfigCommandTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/ItConfigCommandTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.cli.deprecated;
+package org.apache.ignite.internal.cli.commands;
import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
@@ -25,14 +25,13 @@ import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import io.micronaut.context.ApplicationContext;
-import io.micronaut.context.env.Environment;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgnitionManager;
import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.cli.AbstractCliTest;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.junit.jupiter.api.AfterEach;
@@ -45,10 +44,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
* Integration test for {@code ignite node/cluster config} commands.
*/
@ExtendWith(WorkDirectoryExtension.class)
-public class ItConfigCommandTest extends AbstractCliIntegrationTest {
- /** DI context. */
- private ApplicationContext ctx;
-
+public class ItConfigCommandTest extends AbstractCliTest {
/** Node. */
private IgniteImpl node;
@@ -63,20 +59,16 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
assertThat(future, willCompleteSuccessfully());
node = (IgniteImpl) future.join();
-
- ctx = ApplicationContext.run(Environment.TEST);
}
@AfterEach
void tearDown(TestInfo testInfo) {
IgnitionManager.stop(testNodeName(testInfo, 0));
-
- ctx.stop();
}
@Test
public void setAndGetWithManualHost() {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"node",
"config",
"update",
@@ -94,7 +86,7 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
resetStreams();
- exitCode = cmd(ctx).execute(
+ exitCode = execute(
"node",
"config",
"show",
@@ -112,7 +104,7 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
@Test
public void setWithWrongData() {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"node",
"config",
"update",
@@ -129,7 +121,7 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
resetStreams();
- exitCode = cmd(ctx).execute(
+ exitCode = execute(
"node",
"config",
"update",
@@ -147,7 +139,7 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
@Test
public void partialGet() {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"node",
"config",
"show",
@@ -166,14 +158,6 @@ public class ItConfigCommandTest extends
AbstractCliIntegrationTest {
assertFalse(out.toString(UTF_8).contains("\"node\""));
}
- /**
- * Reset stderr and stdout streams.
- */
- private void resetStreams() {
- err.reset();
- out.reset();
- }
-
/**
* Unescapes quotes in the input string.
*
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/CliVersionInfo.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/CliVersionInfo.java
index 8dbb5b9fbe..c58f8710dd 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/CliVersionInfo.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/CliVersionInfo.java
@@ -21,7 +21,7 @@ import jakarta.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliException;
/**
* Provider of current Ignite CLI version info from the builtin properties
file.
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeUrlMixin.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeUrlMixin.java
index 06341f1e2c..8106ef0698 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeUrlMixin.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeUrlMixin.java
@@ -28,7 +28,7 @@ import jakarta.inject.Inject;
import java.net.URL;
import org.apache.ignite.internal.cli.NodeNameRegistry;
import org.apache.ignite.internal.cli.core.converters.UrlConverter;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliException;
import org.jetbrains.annotations.Nullable;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Option;
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
index f853c2b714..7635404003 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
@@ -28,11 +28,11 @@ import org.apache.ignite.internal.cli.commands.BaseCommand;
import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
import org.apache.ignite.internal.cli.core.call.StringCallInput;
import org.apache.ignite.internal.cli.core.exception.ExceptionWriter;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliException;
import
org.apache.ignite.internal.cli.core.exception.handler.SqlExceptionHandler;
import org.apache.ignite.internal.cli.decorators.PlainTableDecorator;
import org.apache.ignite.internal.cli.decorators.SqlQueryResultDecorator;
import org.apache.ignite.internal.cli.decorators.TableDecorator;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
import org.apache.ignite.internal.cli.sql.SqlManager;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlReplCommand.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlReplCommand.java
index b020803dae..05ea375939 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlReplCommand.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlReplCommand.java
@@ -30,6 +30,7 @@ import
org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
import org.apache.ignite.internal.cli.core.call.StringCallInput;
import org.apache.ignite.internal.cli.core.exception.ExceptionHandlers;
import org.apache.ignite.internal.cli.core.exception.ExceptionWriter;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliException;
import
org.apache.ignite.internal.cli.core.exception.handler.SqlExceptionHandler;
import org.apache.ignite.internal.cli.core.repl.Repl;
import
org.apache.ignite.internal.cli.core.repl.executor.RegistryCommandExecutor;
@@ -37,7 +38,6 @@ import
org.apache.ignite.internal.cli.core.repl.executor.ReplExecutorProvider;
import org.apache.ignite.internal.cli.decorators.PlainTableDecorator;
import org.apache.ignite.internal.cli.decorators.SqlQueryResultDecorator;
import org.apache.ignite.internal.cli.decorators.TableDecorator;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
import org.apache.ignite.internal.cli.sql.SqlManager;
import org.apache.ignite.internal.cli.sql.SqlSchemaProvider;
import picocli.CommandLine.ArgGroup;
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgniteCliException.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/IgniteCliException.java
similarity index 96%
rename from
modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgniteCliException.java
rename to
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/IgniteCliException.java
index 26c682e931..7251e59786 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgniteCliException.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/IgniteCliException.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.cli.deprecated;
+package org.apache.ignite.internal.cli.core.exception;
/**
* Top level runtime exception for throwing the error message to user.
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IgniteCliExceptionHandler.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IgniteCliExceptionHandler.java
index 6d6c6497e0..bd73cd5960 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IgniteCliExceptionHandler.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IgniteCliExceptionHandler.java
@@ -19,8 +19,8 @@ package org.apache.ignite.internal.cli.core.exception.handler;
import org.apache.ignite.internal.cli.core.exception.ExceptionHandler;
import org.apache.ignite.internal.cli.core.exception.ExceptionWriter;
+import org.apache.ignite.internal.cli.core.exception.IgniteCliException;
import org.apache.ignite.internal.cli.core.style.component.ErrorUiComponent;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
/**
* Exception handler for {@link IgniteCliException}.
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CommandFactory.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CommandFactory.java
deleted file mode 100644
index 67d61b72b0..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CommandFactory.java
+++ /dev/null
@@ -1,46 +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.ignite.internal.cli.deprecated;
-
-import io.micronaut.context.ApplicationContext;
-import java.util.Optional;
-import picocli.CommandLine;
-
-/**
- * Picocli command factory for initialize commands and DI dependencies.
- */
-public class CommandFactory implements CommandLine.IFactory {
- /** DI application context. */
- private final ApplicationContext applicationCtx;
-
- /**
- * Creates new command factory.
- *
- * @param applicationCtx DI application context.
- */
- public CommandFactory(ApplicationContext applicationCtx) {
- this.applicationCtx = applicationCtx;
- }
-
- /** {@inheritDoc} */
- @Override
- public <K> K create(Class<K> cls) throws Exception {
- Optional<K> bean = applicationCtx.findOrInstantiateBean(cls);
- return bean.isPresent() ? bean.get() :
CommandLine.defaultFactory().create(cls);
- }
-}
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/Table.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/Table.java
deleted file mode 100644
index d8af5badc4..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/Table.java
+++ /dev/null
@@ -1,206 +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.ignite.internal.cli.deprecated;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import picocli.CommandLine.Help.Ansi.Text;
-import picocli.CommandLine.Help.ColorScheme;
-
-/**
- * Basic implementation of an ascii table. Supports styling via {@link
ColorScheme}.
- */
-public class Table {
- /** Indent size. */
- private final int indent;
-
- /** Color scheme for table output. */
- private final ColorScheme cs;
-
- /** Table data. */
- private final Collection<Row> data = new ArrayList<>();
-
- /** Columns lengths. */
- private int[] lengths;
-
- /**
- * Creates a new table.
- *
- * @param indent Left-side indentation (i.e. the provided number of spaces
will be added to every line in the output).
- * @param cs Color scheme.
- */
- public Table(int indent, ColorScheme cs) {
- if (indent < 0) {
- throw new IllegalArgumentException("Indent can't be negative.");
- }
-
- this.indent = indent;
- this.cs = cs;
- }
-
- /**
- * Adds a row.
- *
- * @param items List of items in the row. Every item is converted to a
string and styled based on the provided {@link ColorScheme}. If
- * an instance of {@link Text} is provided, it is added as-is.
- */
- public void addRow(Object... items) {
- if (lengths == null) {
- lengths = new int[items.length];
- } else if (items.length != lengths.length) {
- throw new IllegalArgumentException("Wrong number of items.");
- }
-
- Text[] row = new Text[items.length];
-
- for (int i = 0; i < items.length; i++) {
- Object item = items[i];
-
- Text text = item instanceof Text ? (Text) item :
cs.text(item.toString());
-
- row[i] = text;
-
- lengths[i] = Math.max(lengths[i], text.getCJKAdjustedLength());
- }
-
- data.add(new DataRow(row));
- }
-
- /**
- * Adds a section. Title spans all columns in the table.
- *
- * @param title Section title.
- */
- public void addSection(Object title) {
- Text text = title instanceof Text ? (Text) title :
cs.text(title.toString());
-
- data.add(new SectionTitle(text));
- }
-
- /**
- * Converts the table to a string.
- *
- * @return String representation of this table.
- */
- @Override
- public String toString() {
- if (data.isEmpty()) {
- return "";
- }
-
- StringBuilder sb = new StringBuilder();
-
- for (Row row : data) {
- appendLine(sb);
- appendRow(sb, row);
- }
-
- appendLine(sb);
-
- return sb.toString().stripTrailing();
- }
-
- private void appendLine(StringBuilder sb) {
- sb.append(" ".repeat(indent));
-
- for (int length : lengths) {
- sb.append('+').append("-".repeat(length + 2));
- }
-
- sb.append("+\n");
- }
-
- /**
- * Appends the given {@code row} to the specified string builder {@code
sb}.
- *
- * @param sb String builder that accumulates a result.
- * @param row Row to be appended to the string builder.
- */
- private void appendRow(StringBuilder sb, Row row) {
- sb.append(" ".repeat(indent))
- .append(row.render())
- .append('\n');
- }
-
- /** Interface for any renderable row. */
- private interface Row {
- /** Render row to string. */
- String render();
- }
-
- /**
- * Row with actual data.
- */
- private class DataRow implements Row {
- /** Text. */
- private final Text[] row;
-
- /**
- * Creates a new {@code DataRow} with the specified data.
- *
- * @param row Text to be rendered.
- */
- DataRow(Text[] row) {
- this.row = row;
- }
-
- /** {@inheritDoc} */
- @Override
- public String render() {
- assert row.length == lengths.length;
-
- StringBuilder sb = new StringBuilder();
-
- for (int i = 0; i < row.length; i++) {
- Text item = row[i];
-
- sb.append("| ")
- .append(item.toString())
- .append(" ".repeat(lengths[i] + 1 -
item.getCJKAdjustedLength()));
- }
-
- sb.append("|");
-
- return sb.toString();
- }
- }
-
- /**
- * Row with table title.
- */
- private class SectionTitle implements Row {
- /** Title. */
- private final Text title;
-
- /**
- * Creates a new {@code SectionTitle} with the given {@code title}.
- */
- SectionTitle(Text title) {
- this.title = title;
- }
-
- /** {@inheritDoc} */
- @Override
- public String render() {
- int totalLen = Arrays.stream(lengths).sum() + 3 * (lengths.length
- 1);
-
- return "| " + title.toString() + " ".repeat(totalLen -
title.getCJKAdjustedLength()) + " |";
- }
- }
-}
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/package-info.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/package-info.java
deleted file mode 100644
index 0c8868c6ea..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/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 classes and packages for Ignite CLI tool.
- */
-
-package org.apache.ignite.internal.cli.deprecated;
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeEndpointOptions.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeEndpointOptions.java
deleted file mode 100644
index 5051f4f4b9..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeEndpointOptions.java
+++ /dev/null
@@ -1,80 +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.ignite.internal.cli.deprecated.spec;
-
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import picocli.CommandLine;
-
-/**
- * Prepared picocli mixin for generic node hostname option.
- */
-class NodeEndpointOptions {
- /**
- * Custom node REST endpoint address.
- */
- @CommandLine.Option(
- names = "--node-endpoint",
- description = "Ignite server node's REST API address and port
number",
- paramLabel = "host:port"
- )
- private String endpoint;
-
- /**
- * Returns REST endpoint port.
- *
- * @return REST endpoint port.
- */
- int port() {
- if (endpoint == null) {
- return 10300;
- }
-
- var hostPort = parse();
-
- try {
- return Integer.parseInt(hostPort[1]);
- } catch (NumberFormatException ex) {
- throw new IgniteCliException("Can't parse port from " +
hostPort[1] + " value");
- }
- }
-
- /**
- * Returns REST endpoint host.
- *
- * @return REST endpoint host.
- */
- String host() {
- return endpoint != null ? parse()[0] : "localhost";
- }
-
- /**
- * Parses REST endpoint host and port from string.
- *
- * @return 2-elements array [host, port].
- */
- private String[] parse() {
- var hostPort = endpoint.split(":");
-
- if (hostPort.length != 2) {
- throw new IgniteCliException("Incorrect host:port pair provided:
'" + endpoint + "' "
- + "(example of valid value 'localhost:10300')");
- }
-
- return hostPort;
- }
-}
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/package-info.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/package-info.java
deleted file mode 100644
index 098a0e04b1..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/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 classes with specification of CLI commands and parameters.
- */
-
-package org.apache.ignite.internal.cli.deprecated.spec;
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBar.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBar.java
deleted file mode 100644
index dbe46c1b6f..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBar.java
+++ /dev/null
@@ -1,141 +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.ignite.internal.cli.deprecated.ui;
-
-import java.io.PrintWriter;
-import java.time.Duration;
-import java.util.concurrent.locks.LockSupport;
-import org.apache.ignite.internal.logger.IgniteLogger;
-import org.apache.ignite.internal.logger.Loggers;
-import picocli.CommandLine.Help.Ansi;
-
-/**
- * Basic implementation of a progress bar.
- */
-public class ProgressBar implements AutoCloseable {
- /** Logger. **/
- private final IgniteLogger log = Loggers.forClass(getClass());
-
- /** Out to output the progress bar UI.. */
- private final PrintWriter out;
-
- /** Current progress. */
- private int curr;
-
- /** Maximum progress bar value. */
- private int max;
-
- /** Target width of bar in symbols. */
- private final int targetBarWidth;
-
- /**
- * Creates a new progress bar.
- *
- * @param out Output which terminal render will use
- * @param initMax Initial maximum number of steps.
- * @param terminalWidth Width of user terminal for scale progress bar
length
- */
- public ProgressBar(PrintWriter out, int initMax, int terminalWidth) {
- this.out = out;
-
- assert initMax > 0;
-
- max = initMax;
-
- // A huge progress bar for big terminals looks ugly.
- // It's better to have just enough wide progress bar.
- targetBarWidth = Math.min(100, terminalWidth);
- }
-
- /**
- * Updates maximum number of steps.
- *
- * @param newMax New maximum.
- */
- public void setMax(int newMax) {
- assert newMax > 0;
-
- max = newMax;
- }
-
- /**
- * Performs a single step.
- */
- public void step() {
- if (curr < max) {
- curr++;
- }
-
- out.print('\r' + render());
- out.flush();
- }
-
- /** {@inheritDoc} */
- @Override
- public void close() {
- while (curr < max) {
- LockSupport.parkNanos(Duration.ofMillis(10).toNanos());
-
- step();
- }
-
- out.println();
- }
-
- /**
- * Renders current progress bar state to Ansi string.
- *
- * @return Ansi string with progress bar.
- */
- private String render() {
- assert curr <= max;
-
- var completedPart = ((double) curr / (double) max);
-
- // Space reserved for '||Done'
- var reservedSpace = 7;
-
- if (targetBarWidth < reservedSpace) {
- log.warn("Terminal width is too small to show the progress bar");
-
- return "";
- }
-
- var numOfCompletedSymbols = (int) (completedPart * (targetBarWidth -
reservedSpace));
-
- StringBuilder sb = new StringBuilder("|");
-
- sb.append("=".repeat(numOfCompletedSymbols));
-
- String percentage;
- int percentageLen;
-
- if (completedPart < 1) {
- sb.append('>').append(" ".repeat(targetBarWidth - reservedSpace -
numOfCompletedSymbols));
-
- percentage = (int) (completedPart * 100) + "%";
- percentageLen = percentage.length();
-
- sb.append("|").append(" ".repeat(4 -
percentageLen)).append(percentage);
- } else {
- sb.append("=|@|green,bold Done|@");
- }
-
- return Ansi.AUTO.string(sb.toString());
- }
-}
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/Spinner.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/Spinner.java
deleted file mode 100644
index 1bd7763ff1..0000000000
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/ui/Spinner.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.ignite.internal.cli.deprecated.ui;
-
-import java.io.PrintWriter;
-
-/**
- * Simple ASCII spinner. It should be used for processes with unknown duration
instead of {@link ProgressBar}
- */
-public class Spinner implements AutoCloseable {
- /** Writer for display spinner. */
- private final PrintWriter out;
-
- /** Text prefix for spinner. */
- private final String spinnerPrefixText;
-
- /** Spinner cycle counter. */
- private int spinnerCnt;
-
- /**
- * Creates a new {@code Spinner}.
- *
- * @param out Writer to display spinner.
- */
- public Spinner(PrintWriter out) {
- this(out, "");
- }
-
- /**
- * Creates a new {@code Spinner}.
- *
- * @param out Writer to display spinner.
- * @param spinnerPrefixText Spinner prefix text.
- */
- public Spinner(PrintWriter out, String spinnerPrefixText) {
- this.out = out;
- this.spinnerPrefixText = spinnerPrefixText;
- }
-
- /**
- * Spin one more time.
- */
- public void spin() {
- out.print("\r" + spinnerPrefixText + ".".repeat(1 + spinnerCnt % 3) +
" ".repeat(2 - spinnerCnt % 3));
- out.flush();
-
- // Reset counter to protect it from overflow.
- spinnerCnt = 1 + spinnerCnt % 3;
- }
-
- /** {@inheritDoc} */
- @Override
- public void close() {
- out.print("\r" + spinnerPrefixText + "...");
- out.println();
-
- out.flush();
- }
-}
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/AbstractCliIntegrationTest.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/AbstractCliTest.java
similarity index 54%
rename from
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/AbstractCliIntegrationTest.java
rename to
modules/cli/src/test/java/org/apache/ignite/internal/cli/AbstractCliTest.java
index f56ac8a9fb..983a241acb 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/deprecated/AbstractCliIntegrationTest.java
+++
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/AbstractCliTest.java
@@ -15,35 +15,60 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.cli.deprecated;
+package org.apache.ignite.internal.cli;
+import io.micronaut.configuration.picocli.MicronautFactory;
import io.micronaut.context.ApplicationContext;
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import jakarta.inject.Inject;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import org.apache.ignite.internal.cli.commands.TopLevelCliCommand;
+import org.junit.jupiter.api.BeforeAll;
import picocli.CommandLine;
/**
- * Base class for CLI-related integration tests.
+ * Base class for any CLI tests.
*/
-public abstract class AbstractCliIntegrationTest extends AbstractCliTest {
+@MicronautTest(rebuildContext = true)
+public abstract class AbstractCliTest {
+ @Inject
+ private ApplicationContext ctx;
+
/** stderr. */
- protected final ByteArrayOutputStream err = new ByteArrayOutputStream();
+ protected ByteArrayOutputStream err = new ByteArrayOutputStream();
/** stdout. */
- protected final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ protected ByteArrayOutputStream out = new ByteArrayOutputStream();
/**
* Creates a new command line interpreter.
*
- * @param applicationCtx DI context.
* @return New command line instance.
*/
- protected final CommandLine cmd(ApplicationContext applicationCtx) {
- CommandLine.IFactory factory = new CommandFactory(applicationCtx);
-
- return new CommandLine(TopLevelCliCommand.class, factory)
+ private CommandLine cmd() {
+ return new CommandLine(TopLevelCliCommand.class, new
MicronautFactory(ctx))
.setErr(new PrintWriter(err, true))
.setOut(new PrintWriter(out, true));
}
+
+ protected final int execute(String... args) {
+ return cmd().execute(args);
+ }
+
+ /**
+ * Sets up a dumb terminal before tests.
+ */
+ @BeforeAll
+ static void beforeAll() {
+ System.setProperty("org.jline.terminal.dumb", "true");
+ }
+
+ /**
+ * Reset stderr and stdout streams.
+ */
+ protected void resetStreams() {
+ err.reset();
+ out.reset();
+ }
}
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/IgniteCliInterfaceTest.java
similarity index 91%
rename from
modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
rename to
modules/cli/src/test/java/org/apache/ignite/internal/cli/IgniteCliInterfaceTest.java
index c2b8512fbe..64e56f900f 100644
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
+++
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/IgniteCliInterfaceTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.cli.deprecated;
+package org.apache.ignite.internal.cli;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
@@ -30,12 +30,6 @@ import static
org.mockserver.model.HttpStatusCode.INTERNAL_SERVER_ERROR_500;
import static org.mockserver.model.HttpStatusCode.OK_200;
import static org.mockserver.model.JsonBody.json;
-import io.micronaut.context.ApplicationContext;
-import io.micronaut.context.env.Environment;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import org.apache.ignite.internal.cli.commands.TopLevelCliCommand;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
@@ -45,7 +39,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.junit.jupiter.MockServerExtension;
import org.mockserver.model.MediaType;
-import picocli.CommandLine;
/**
* Smoke test for Ignite CLI features and its UI. Structure of tests should be
self-documented and repeat the structure of Ignite CLI
@@ -55,15 +48,6 @@ import picocli.CommandLine;
@ExtendWith(MockitoExtension.class)
@ExtendWith(MockServerExtension.class)
public class IgniteCliInterfaceTest extends AbstractCliTest {
- /** DI application context. */
- ApplicationContext ctx;
-
- /** stderr. */
- ByteArrayOutputStream err;
-
- /** stdout. */
- ByteArrayOutputStream out;
-
private final ClientAndServer clientAndServer;
private final String mockUrl;
@@ -78,37 +62,13 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
*/
@BeforeEach
void setup() {
- ctx = ApplicationContext.run(Environment.TEST);
-
- err = new ByteArrayOutputStream();
- out = new ByteArrayOutputStream();
+ resetStreams();
clientAndServer.reset();
}
- /**
- * Stops application context after a test.
- */
- @AfterEach
- void tearDown() {
- ctx.stop();
- }
-
- /**
- * Creates a new command line interpreter with the given application
context.
- *
- * @return New {@code CommandLine} interpreter.
- */
- CommandLine cmd(ApplicationContext applicationCtx) {
- CommandLine.IFactory factory = new CommandFactory(applicationCtx);
-
- return new CommandLine(TopLevelCliCommand.class, factory)
- .setErr(new PrintWriter(err, true))
- .setOut(new PrintWriter(out, true));
- }
-
private int execute(String cmdLine) {
- return cmd(ctx).execute(cmdLine.split(" "));
+ return execute(cmdLine.split(" "));
}
/**
@@ -276,7 +236,7 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
.respond(response(null));
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", mockUrl,
"--meta-storage-node", "node1ConsistentId",
@@ -304,7 +264,7 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
.withBody("{\"status\":500, \"detail\":\"Oops\"}")
);
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", mockUrl,
"--meta-storage-node", "node1ConsistentId",
@@ -323,7 +283,7 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
@Test
@DisplayName("init --cluster-endpoint-url http://localhost:10300
--cmg-node node2ConsistentId --cmg-node node3ConsistentId")
void metastorageNodesAreMandatoryForInit() {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", mockUrl,
"--cmg-node", "node2ConsistentId",
@@ -347,7 +307,7 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
)
.respond(response().withStatusCode(OK_200.code()));
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", mockUrl,
"--meta-storage-node", "node1ConsistentId",
@@ -364,7 +324,7 @@ public class IgniteCliInterfaceTest extends AbstractCliTest
{
@Test
@DisplayName("init --cluster-endpoint-url http://localhost:10300
--meta-storage-node node1ConsistentId --cmg-node node2ConsistentId")
void clusterNameIsMandatoryForInit() {
- int exitCode = cmd(ctx).execute(
+ int exitCode = execute(
"cluster", "init",
"--cluster-endpoint-url", mockUrl,
"--meta-storage-node", "node1ConsistentId",
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/AbstractCliTest.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/AbstractCliTest.java
deleted file mode 100644
index 05172aa7d2..0000000000
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/AbstractCliTest.java
+++ /dev/null
@@ -1,33 +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.ignite.internal.cli.deprecated;
-
-import org.junit.jupiter.api.BeforeAll;
-
-/**
- * Base class for any CLI tests.
- */
-public abstract class AbstractCliTest {
- /**
- * Sets up a dumb terminal before tests.
- */
- @BeforeAll
- static void beforeAll() {
- System.setProperty("org.jline.terminal.dumb", "true");
- }
-}
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/package-info.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/package-info.java
deleted file mode 100644
index 15cfbe8304..0000000000
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/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 tests for Ignite CLI.
- */
-
-package org.apache.ignite.internal.cli.deprecated;
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBarTest.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBarTest.java
deleted file mode 100644
index c775b10158..0000000000
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/ProgressBarTest.java
+++ /dev/null
@@ -1,80 +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.ignite.internal.cli.deprecated.ui;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static picocli.CommandLine.Help.Ansi.AUTO;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import org.apache.ignite.internal.cli.deprecated.AbstractCliTest;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests progress bar.
- */
-public class ProgressBarTest extends AbstractCliTest {
- /** Writer that is used in order to prints formatted representation to the
underlying output stream. */
- private PrintWriter out;
-
- /** CLI output stream. */
- private ByteArrayOutputStream outputStream;
-
- @BeforeEach
- void setUp() {
- outputStream = new ByteArrayOutputStream();
- out = new PrintWriter(outputStream, true);
- }
-
- @AfterEach
- void tearDown() throws IOException {
- out.close();
- outputStream.close();
- }
-
- @Test
- public void testScaledToTerminalWidth() throws IOException {
- var progressBar = new ProgressBar(out, 3, 80);
- progressBar.step();
- assertEquals(80, outputStream.toString(UTF_8).replace("\r",
"").length());
- assertEquals(
- "\r|========================>
| 33%",
- outputStream.toString(UTF_8)
- );
- }
-
- @Test
- public void testRedundantStepsProgressBar() {
- var progressBar = new ProgressBar(out, 3, 80);
- progressBar.step();
- progressBar.step();
- progressBar.step();
- progressBar.step();
- assertEquals(AUTO.string(
- "\r|========================>
| 33%"
- +
"\r|================================================> |
66%"
- +
"\r|==========================================================================|@|green,bold
Done|@"
- +
"\r|==========================================================================|@|green,bold
Done|@"),
- outputStream.toString(UTF_8)
- );
- }
-}
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/SpinnerTest.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/SpinnerTest.java
deleted file mode 100644
index 7d102423d5..0000000000
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/SpinnerTest.java
+++ /dev/null
@@ -1,78 +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.ignite.internal.cli.deprecated.ui;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests spinner.
- */
-public class SpinnerTest {
- /** Writer that is used in order to prints formatted representation to the
underlying output stream. */
- private PrintWriter out;
-
- /** CLI output stream. */
- private ByteArrayOutputStream outputStream;
-
- @BeforeEach
- public void setUp() {
- outputStream = new ByteArrayOutputStream();
- out = new PrintWriter(outputStream);
- }
-
- @AfterEach
- public void tearDown() throws IOException {
- out.close();
- outputStream.close();
- }
-
- @Test
- public void testSpinner() {
- var spinner = new Spinner(out, "Waiting");
-
- spinner.spin();
- assertEquals("\rWaiting. ", outputStream.toString(UTF_8));
-
- spinner.spin();
- assertEquals("\rWaiting. \rWaiting.. ", outputStream.toString(UTF_8));
-
- spinner.spin();
- assertEquals("\rWaiting. \rWaiting.. \rWaiting...",
outputStream.toString(UTF_8));
-
- spinner.spin();
- assertEquals("\rWaiting. \rWaiting.. \rWaiting...\rWaiting. ",
outputStream.toString(UTF_8));
- }
-
- @Test
- public void testSpinnerClose() {
- var spinner = new Spinner(out, "Waiting");
-
- spinner.spin();
- spinner.close();
-
- assertEquals("\rWaiting. \rWaiting..." + System.lineSeparator(),
outputStream.toString(UTF_8));
- }
-}
diff --git
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/package-info.java
b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/package-info.java
deleted file mode 100644
index 7b8c9d946b..0000000000
---
a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/ui/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 tests for Ignite CLI UI elements.
- */
-
-package org.apache.ignite.internal.cli.deprecated.ui;