You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by fm...@apache.org on 2023/03/09 12:11:27 UTC

[camel] branch camel-3.20.x updated: CAMEL-18508: Polish user config

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

fmariani pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.20.x by this push:
     new f4132d32b6a CAMEL-18508: Polish user config
f4132d32b6a is described below

commit f4132d32b6a700a97d5cb8072a5354eb7c737849
Author: Croway <fe...@gmail.com>
AuthorDate: Thu Mar 9 11:21:12 2023 +0100

    CAMEL-18508: Polish user config
---
 .../modules/ROOT/pages/camel-jbang.adoc            |  26 ++--
 dsl/camel-jbang/camel-jbang-core/pom.xml           |  14 --
 .../dsl/jbang/core/common/CommandLineHelper.java   |   8 +-
 .../org/apache/camel/dsl/jbang/BackgroundTest.java | 150 ---------------------
 4 files changed, 17 insertions(+), 181 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index 9ba0eeaf80e..6ee2ab0298f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -1645,32 +1645,32 @@ NOTE: These are options from the export command, so you can see mor details and
 
 == Configuration
 
-Camel JBang can be used to store and use user configuration so that cli options won't have to be specified each time, for example, in order to run a different camel version, instead of executing
+Camel JBang `config` command is used to store and use the user configuration. This eliminates the need to specify CLI options each time. For example, to run a different Camel version, instead of executing
 
 [source,bash]
 ----
 camel run * --camel-version=3.18.4
 ----
 
-the option camel-version can be added to the user configuration like
+the camel-version can be added to the user configuration such as:
 
 [source,bash]
 ----
 camel config set camel-version=3.18.4
 ----
 
-and then, the run command will pick the user configuration
+Now, the run command picks the user configuration:
 
 [source,bash]
 ----
 camel run *
 ----
 
-The user configuration file will be stored in ~/.camel-jbang-user.properties
+The user configuration file is stored in `~/.camel-jbang-user.properties`
 
 === Set and unset configuration
 
-Every Camel JBang option can be added to the user configuration, for example to export a simple project
+Every Camel JBang option is added to the user configuration. For example, to export a simple project such as
 
 [source,bash]
 ----
@@ -1683,32 +1683,32 @@ camel config set camel-spring-boot-version=3.20.1
 camel export
 ----
 
-User configurations values can be unset via:
+User configuration keys are unset using the following:
 
 [source,bash]
 ----
-camel config unset camel-spring-boot-version=3.20.1
+camel config unset camel-spring-boot-version
 ----
 
 === List and get configurations
 
-User configurations keys can be listed with:
+User configuration keys are listed using the following:
 
 [source,bash]
 ----
 camel config list
 ----
 
-Given the configuration in the previous paragraph the ouptut will be:
+Following is the output for the above mentioned configuration.
 
 [source,bash]
 ----
-gav
-runtime
-deps
+runtime = spring-boot
+deps = org.apache.camel.springboot:camel-timer-starter
+gav = com.foo:acme:1.0-SNAPSHOT
 ----
 
-In order to get a value given a key, get command can be used:
+To obtain a value for the given key, use the `get` command.
 
 [source,bash]
 ----
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml b/dsl/camel-jbang/camel-jbang-core/pom.xml
index 2910b8c93d1..a1899a42473 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -141,20 +141,6 @@
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
-
-        <!-- test -->
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-engine</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
-            <version>${assertj-version}</version>
-            <scope>test</scope>
-        </dependency>
-
     </dependencies>
 
 </project>
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
index 4bb8dc73ca8..a5b9a5f4369 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
@@ -46,14 +46,14 @@ public final class CommandLineHelper {
     }
 
     public static void createPropertyFile() throws IOException {
-        File file = new File(System.getProperty("user.home"), CommandLineHelper.USER_CONFIG);
+        File file = new File(System.getProperty("user.home"), USER_CONFIG);
         if (!file.exists()) {
             file.createNewFile();
         }
     }
 
     public static void loadProperties(Consumer<Properties> consumer) {
-        File file = new File(System.getProperty("user.home"), CommandLineHelper.USER_CONFIG);
+        File file = new File(System.getProperty("user.home"), USER_CONFIG);
         if (file.isFile() && file.exists()) {
             FileInputStream fis = null;
             try {
@@ -70,7 +70,7 @@ public final class CommandLineHelper {
     }
 
     public static void storeProperties(Properties properties) {
-        File file = new File(System.getProperty("user.home"), CommandLineHelper.USER_CONFIG);
+        File file = new File(System.getProperty("user.home"), USER_CONFIG);
         if (file.isFile() && file.exists()) {
             try (FileOutputStream fos = new FileOutputStream(file)) {
                 properties.store(fos, null);
@@ -78,7 +78,7 @@ public final class CommandLineHelper {
                 throw new RuntimeException(ex);
             }
         } else {
-            System.out.println(CommandLineHelper.USER_CONFIG + " does not exists");
+            System.out.println(USER_CONFIG + " does not exists");
         }
     }
 
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/BackgroundTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/BackgroundTest.java
deleted file mode 100644
index 40139a96ae7..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/BackgroundTest.java
+++ /dev/null
@@ -1,150 +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.camel.dsl.jbang;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.apache.camel.dsl.jbang.core.commands.Bind;
-import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
-import org.apache.camel.dsl.jbang.core.commands.CodeGenerator;
-import org.apache.camel.dsl.jbang.core.commands.CodeRestGenerator;
-import org.apache.camel.dsl.jbang.core.commands.Complete;
-import org.apache.camel.dsl.jbang.core.commands.DependencyCommand;
-import org.apache.camel.dsl.jbang.core.commands.DependencyCopy;
-import org.apache.camel.dsl.jbang.core.commands.DependencyList;
-import org.apache.camel.dsl.jbang.core.commands.Export;
-import org.apache.camel.dsl.jbang.core.commands.Init;
-import org.apache.camel.dsl.jbang.core.commands.Pipe;
-import org.apache.camel.dsl.jbang.core.commands.Run;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelGCAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelLogAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelReloadAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelResetStatsAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelRouteStartAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelRouteStopAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelSourceAction;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelSourceTop;
-import org.apache.camel.dsl.jbang.core.commands.action.CamelThreadDump;
-import org.apache.camel.dsl.jbang.core.commands.action.LoggerAction;
-import org.apache.camel.dsl.jbang.core.commands.action.RouteControllerAction;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogCommand;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogComponent;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogDataFormat;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogDoc;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogKamelet;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogLanguage;
-import org.apache.camel.dsl.jbang.core.commands.catalog.CatalogOther;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelContextStatus;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelContextTop;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelCount;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelProcessorStatus;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelProcessorTop;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelRouteStatus;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelRouteTop;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelStatus;
-import org.apache.camel.dsl.jbang.core.commands.process.CamelTop;
-import org.apache.camel.dsl.jbang.core.commands.process.Hawtio;
-import org.apache.camel.dsl.jbang.core.commands.process.Jolokia;
-import org.apache.camel.dsl.jbang.core.commands.process.ListBlocked;
-import org.apache.camel.dsl.jbang.core.commands.process.ListCircuitBreaker;
-import org.apache.camel.dsl.jbang.core.commands.process.ListEndpoint;
-import org.apache.camel.dsl.jbang.core.commands.process.ListEvent;
-import org.apache.camel.dsl.jbang.core.commands.process.ListHealth;
-import org.apache.camel.dsl.jbang.core.commands.process.ListInflight;
-import org.apache.camel.dsl.jbang.core.commands.process.ListMetric;
-import org.apache.camel.dsl.jbang.core.commands.process.ListProcess;
-import org.apache.camel.dsl.jbang.core.commands.process.ListService;
-import org.apache.camel.dsl.jbang.core.commands.process.ListVault;
-import org.apache.camel.dsl.jbang.core.commands.process.StopProcess;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import picocli.CommandLine;
-
-@Disabled
-public class BackgroundTest {
-
-    @Test
-    public void test() {
-        CamelJBangMain main = new CamelJBangMain();
-        CommandLine commandLine = new CommandLine(main)
-                .addSubcommand("init", new CommandLine(new Init(main)))
-                .addSubcommand("run", new CommandLine(new Run(main)))
-                .addSubcommand("log", new CommandLine(new CamelLogAction(main)))
-                .addSubcommand("ps", new CommandLine(new ListProcess(main)))
-                .addSubcommand("stop", new CommandLine(new StopProcess(main)))
-                .addSubcommand("get", new CommandLine(new CamelStatus(main))
-                        .addSubcommand("context", new CommandLine(new CamelContextStatus(main)))
-                        .addSubcommand("route", new CommandLine(new CamelRouteStatus(main)))
-                        .addSubcommand("processor", new CommandLine(new CamelProcessorStatus(main)))
-                        .addSubcommand("count", new CommandLine(new CamelCount(main)))
-                        .addSubcommand("health", new CommandLine(new ListHealth(main)))
-                        .addSubcommand("endpoint", new CommandLine(new ListEndpoint(main)))
-                        .addSubcommand("event", new CommandLine(new ListEvent(main)))
-                        .addSubcommand("inflight", new CommandLine(new ListInflight(main)))
-                        .addSubcommand("blocked", new CommandLine(new ListBlocked(main)))
-                        .addSubcommand("route-controller", new CommandLine(new RouteControllerAction(main)))
-                        .addSubcommand("circuit-breaker", new CommandLine(new ListCircuitBreaker(main)))
-                        .addSubcommand("metric", new CommandLine(new ListMetric(main)))
-                        .addSubcommand("service", new CommandLine(new ListService(main)))
-                        .addSubcommand("source", new CommandLine(new CamelSourceAction(main)))
-                        .addSubcommand("vault", new CommandLine(new ListVault(main))))
-                .addSubcommand("top", new CommandLine(new CamelTop(main))
-                        .addSubcommand("context", new CommandLine(new CamelContextTop(main)))
-                        .addSubcommand("route", new CommandLine(new CamelRouteTop(main)))
-                        .addSubcommand("processor", new CommandLine(new CamelProcessorTop(main)))
-                        .addSubcommand("source", new CommandLine(new CamelSourceTop(main))))
-                .addSubcommand("cmd", new CommandLine(new CamelAction(main))
-                        .addSubcommand("start-route", new CommandLine(new CamelRouteStartAction(main)))
-                        .addSubcommand("stop-route", new CommandLine(new CamelRouteStopAction(main)))
-                        .addSubcommand("reset-stats", new CommandLine(new CamelResetStatsAction(main)))
-                        .addSubcommand("reload", new CommandLine(new CamelReloadAction(main)))
-                        .addSubcommand("thread-dump", new CommandLine(new CamelThreadDump(main)))
-                        .addSubcommand("logger", new CommandLine(new LoggerAction(main)))
-                        .addSubcommand("gc", new CommandLine(new CamelGCAction(main))))
-                .addSubcommand("dependency", new CommandLine(new DependencyCommand(main))
-                        .addSubcommand("list", new CommandLine(new DependencyList(main)))
-                        .addSubcommand("copy", new CommandLine(new DependencyCopy(main))))
-                .addSubcommand("generate", new CommandLine(new CodeGenerator(main))
-                        .addSubcommand("rest", new CommandLine(new CodeRestGenerator(main))))
-                .addSubcommand("catalog", new CommandLine(new CatalogCommand(main))
-                        .addSubcommand("component", new CommandLine(new CatalogComponent(main)))
-                        .addSubcommand("dataformat", new CommandLine(new CatalogDataFormat(main)))
-                        .addSubcommand("language", new CommandLine(new CatalogLanguage(main)))
-                        .addSubcommand("other", new CommandLine(new CatalogOther(main)))
-                        .addSubcommand("kamelet", new CommandLine(new CatalogKamelet(main))))
-                .addSubcommand("doc", new CommandLine(new CatalogDoc(main)))
-                .addSubcommand("jolokia", new CommandLine(new Jolokia(main)))
-                .addSubcommand("hawtio", new CommandLine(new Hawtio(main)))
-                .addSubcommand("bind", new CommandLine(new Bind(main)))
-                .addSubcommand("pipe", new CommandLine(new Pipe(main)))
-                .addSubcommand("export", new CommandLine(new Export(main)))
-                .addSubcommand("completion", new CommandLine(new Complete(main)));
-
-        StringWriter sw = new StringWriter();
-        commandLine.setOut(new PrintWriter(sw));
-
-        int exitCode = commandLine.execute("init", "test.yaml", "--directory=target/data");
-        Assertions.assertThat(exitCode).isEqualTo(0);
-
-        exitCode = commandLine.execute("run", "target/data/test.yaml", "--background");
-        Assertions.assertThat(exitCode).isEqualTo(0);
-        Assertions.assertThat(sw.toString()).doesNotContain("No Camel integration files to run");
-    }
-}