This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7a3099b8552990a3cdc3d51669df6ee7e9d3a7aa Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Wed May 15 13:20:42 2024 +0200 (chores) camel-test-junit5: split context creation logic --- .../apache/camel/test/junit5/CamelTestSupport.java | 12 ++------ .../test/junit5/util/CamelContextTestHelper.java | 36 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java index bd54b3196d7..7e4501bc919 100644 --- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java +++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java @@ -56,6 +56,7 @@ import org.apache.camel.spi.Registry; import org.apache.camel.support.BreakpointSupport; import org.apache.camel.support.EndpointHelper; import org.apache.camel.support.PluginHelper; +import org.apache.camel.test.junit5.util.CamelContextTestHelper; import org.apache.camel.test.junit5.util.ExtensionHelper; import org.apache.camel.test.junit5.util.RouteCoverageDumperExtension; import org.apache.camel.util.StopWatch; @@ -768,16 +769,7 @@ public abstract class CamelTestSupport } protected CamelContext createCamelContext() throws Exception { - Registry registry = createCamelRegistry(); - - CamelContext retContext; - if (registry != null) { - retContext = new DefaultCamelContext(registry); - } else { - retContext = new DefaultCamelContext(); - } - - return retContext; + return CamelContextTestHelper.createCamelContext(createCamelRegistry()); } /** diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/util/CamelContextTestHelper.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/util/CamelContextTestHelper.java new file mode 100644 index 00000000000..f9e42e6c57c --- /dev/null +++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/util/CamelContextTestHelper.java @@ -0,0 +1,36 @@ +/* + * 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.test.junit5.util; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.spi.Registry; + +public final class CamelContextTestHelper { + + public static CamelContext createCamelContext(Registry registry) throws Exception { + CamelContext retContext; + if (registry != null) { + retContext = new DefaultCamelContext(registry); + } else { + retContext = new DefaultCamelContext(); + } + + return retContext; + } +}