christophd commented on code in PR #29663: URL: https://github.com/apache/camel/pull/29663#discussion_r4546988265
########## dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/common/PluginFilteringTest.java: ########## @@ -0,0 +1,435 @@ +/* + * 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.core.common; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.aesh.command.Command; +import org.aesh.command.CommandResult; +import org.aesh.command.invocation.CommandInvocation; +import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain; +import org.apache.camel.dsl.jbang.core.commands.CliExportContext; +import org.apache.camel.dsl.jbang.run.common.StringPrinter; +import org.apache.camel.dsl.jbang.run.export.ExportContext; +import org.apache.camel.util.json.JsonArray; +import org.apache.camel.util.json.JsonObject; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * Tests that plugins not relevant to the current command are skipped entirely — not downloaded, not customized. + * <p> + * Each test configures cached fake plugins (so no Maven download is needed). To detect whether a plugin was loaded or + * skipped, some tests use a "broken" plugin entry whose cache points to a non-existent jar: if the resolution code + * attempts to load the broken plugin, it will fail with a {@link CliException}. If the plugin is properly filtered out, + * the resolution succeeds. + */ +class PluginFilteringTest { + + @TempDir + Path tempDir; + + private Path previousHome; + private String camelVersion; + + @BeforeEach + void setup() { + previousHome = CommandLineHelper.getHomeDir(); + CommandLineHelper.useHomeDir(tempDir.toString()); + camelVersion = new org.apache.camel.catalog.DefaultCamelCatalog().getCatalogVersion(); Review Comment: Done in the third commit — `DefaultCamelCatalog` is now imported. _Claude Code on behalf of Christoph Deppisch_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
