JiriOndrusek commented on code in PR #3847: URL: https://github.com/apache/camel-quarkus/pull/3847#discussion_r940949748
########## test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java: ########## @@ -0,0 +1,177 @@ +/* + * 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.quarkus.test; + +import java.util.List; + +import javax.inject.Inject; + +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.callback.QuarkusTestContext; +import io.quarkus.test.junit.callback.QuarkusTestMethodContext; +import org.apache.camel.CamelContext; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.Service; +import org.apache.camel.model.ModelCamelContext; +import org.apache.camel.model.RouteDefinition; +import org.apache.camel.quarkus.core.FastCamelContext; +import org.apache.camel.spi.Registry; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class CamelQuarkusTestSupport extends CamelTestSupport + implements QuarkusTestProfile { + + private boolean initialized; + + //Flag, whether routes was created by test's route builder and therefore should be stopped smd removed based on lifecycle + private boolean wasUsedRouteBuilder; + + @Inject + protected CamelContext context; + + //------------------------ quarkus callbacks --------------- + protected void doAfterAll(QuarkusTestContext context) throws Exception { + } + + protected void doAfterEach(QuarkusTestMethodContext context) throws Exception { + } + + protected void doAfterConstruct() throws Exception { + } + + protected void doBeforeEach(QuarkusTestMethodContext context) throws Exception { + } + + @Override + protected CamelContext createCamelContext() throws Exception { + return this.context; + } + + @Override + protected Registry createCamelRegistry() { + throw new UnsupportedOperationException("won't be executed."); + } + + @Override + public final void beforeAll(ExtensionContext context) { + //replaced by quarkus callback (beforeEach) + } + + @Override + public final void beforeEach(ExtensionContext context) throws Exception { + //replaced by quarkus callback (beforeEach) + } + + @Override + public final void afterAll(ExtensionContext context) { + //in camel-quarkus, junit5 uses different classloader, necessary code was moved into quarkus's callback + try { + doPostTearDown(); + cleanupResources(); + } catch (Exception e) { + // ignore + } + } + + @Override + public final void afterEach(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessary code was moved into quarkus's callback + } + + @Override + public final void afterTestExecution(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessary code was moved into quarkus's callback + } + + @Override + protected void stopCamelContext() throws Exception { + //context is started and stopped via quarkus lifecycle + } + + @Override + protected void doQuarkusCheck() { + //can run on Quarkus Review Comment: done -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org