You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2023/01/04 11:38:32 UTC
[GitHub] [camel-quarkus] JiriOndrusek opened a new pull request, #4370: DoBeforeEach does not work with Advice #4362
JiriOndrusek opened a new pull request, #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370
fixes https://github.com/apache/camel-quarkus/issues/4362
Originally reported issue problem is not a bug -> this is intentional (forced) behaviour.
Second problem -> Advice not working in @BeforeEach method is na issue, which is fixed in this PR.
Tests covering both cases and a small change in the documentation are added.
<!-- Uncomment and fill this section if your PR is not trivial
[ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
[ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
[ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
[ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
[ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
-->
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061432130
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
The reason of the failure is the issue reported here https://github.com/apache/camel-quarkus/issues/4362
As you can see, RouteBuilder is registered with @Produces (which is not recommended). In a lot of cases with multiple test methods (e.g. his test) , test framework removes the routes after the first test but can not call RouteBuilder. Which means that the second test will fail with the reason, can not advice non existing route. You can see more detailed description in this [comment](https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1369885091).
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#issuecomment-1370821702
Replaces https://github.com/apache/camel-quarkus/pull/4365
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061413817
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderET.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import javax.enterprise.inject.Produces;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.quarkus.test.CamelQuarkusTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+public class ProducedRouteBuilderET extends CamelQuarkusTestSupport {
Review Comment:
What's the meaning of ET ? it is IT ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061443143
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderET.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import javax.enterprise.inject.Produces;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.quarkus.test.CamelQuarkusTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+public class ProducedRouteBuilderET extends CamelQuarkusTestSupport {
Review Comment:
ET means extension test. (or at least I suppose it is this abbreviation).
You can see several cases in Quarkus [codebase](https://github.com/quarkusio/quarkus/tree/main/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner)
These *ET classes are used in the test classes to create a tested application (for example this [line](https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java#L35))
The *ET java file can not be run directly, so it is not *Test or *IT. *ET seems like a nice solution, as the test executes another tests using devmode (new QuarkusDevModeTest()).
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061495417
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
Ok, I see. This works as expected and so enforced by a test.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger merged pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
aldettinger merged PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061415700
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
Review Comment:
4362 seems to be linked to "multiple test methods" bug. Is it the case here ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061448952
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
I think that it is better to cover also this negative scenario. In case that something is changed (because lifecycle of Quarkus is different then Camel's one) and this test fails -> we should carefully review whether there is no other impact.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061432130
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
The reason of the failure is the issue reported here https://github.com/apache/camel-quarkus/issues/4362
As you can see, RouteBuilder is registered with @Produces (which is not recommended). In a lot of cases with multiple test methods (e.g. test in this PR) , test framework removes the routes after each test execution but don't know about RouteBuilder.s created by `@Produces`. Which means that the second test will fail with the reason: Can not advice non-existing route. You can see more detailed description in this [comment](https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1369885091).
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061443143
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderET.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import javax.enterprise.inject.Produces;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.quarkus.test.CamelQuarkusTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+public class ProducedRouteBuilderET extends CamelQuarkusTestSupport {
Review Comment:
ET means extension test. (or at least I suppose that it is this abbreviation).
You can see several cases in Quarkus [codebase](https://github.com/quarkusio/quarkus/tree/main/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner)
These *ET classes are used in the test classes to create a tested application (for example this [line](https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java#L35))
The *ET java file can not be run directly, so it is not *Test or *IT. *ET seems like a nice solution, as the test executes another tests using devmode (new QuarkusDevModeTest()).
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061421724
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
Could you please explain why we expect 1 failing test and the other passing ? I would expect both `firstTest` and `secondTest` to pass as the instruction is just `Assertions.assertTrue(true);` for both of them.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
ppalaga commented on PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#issuecomment-1372143894
@JiriOndrusek thanks for taking care for this!
In the light of current changes, is there anything to add/improve in https://camel.apache.org/camel-quarkus/2.15.x/user-guide/testing.html#_cameltestsupport_style_of_testing ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061446692
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
Review Comment:
@aldettinger As you can see, I added a comment showing the issue, which is simulated by the test.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#issuecomment-1370980793
Good idea, I'll think about that, that could make the user experience much better.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#discussion_r1061432130
##########
test-framework/junit5-extension-tests/src/test/java/org/apache/camel/quarkus/test/extensions/producedRouteBuilder/ProducedRouteBuilderTest.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.extensions.producedRouteBuilder;
+
+import java.util.function.Supplier;
+
+import io.quarkus.test.ContinuousTestingTestUtils;
+import io.quarkus.test.QuarkusDevModeTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Test for https://github.com/apache/camel-quarkus/issues/4362
+ */
+public class ProducedRouteBuilderTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .add(new StringAsset(
+ ContinuousTestingTestUtils.appProperties("camel-quarkus.junit5.message=Sheldon")),
+ "application.properties");
+ }
+ })
+ .setTestArchiveProducer(new Supplier<>() {
+ @Override
+ public JavaArchive get() {
+ return ShrinkWrap.create(JavaArchive.class).addClasses(ProducedRouteBuilderET.class);
+ }
+ });
+
+ @Test
+ public void checkTests() {
+ ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
+ ContinuousTestingTestUtils.TestStatus ts = utils.waitForNextCompletion();
+
+ Assertions.assertEquals(1L, ts.getTestsFailed());
Review Comment:
The reason of the failure is the issue reported here https://github.com/apache/camel-quarkus/issues/4362
As you can see, RouteBuilder is registered with @Produces (which is not recommended). In a lot of cases with multiple test methods (e.g. test in this PR) , test framework removes the routes after the first test but can not call RouteBuilder. Which means that the second test will fail with the reason, can not advice non existing route. You can see more detailed description in this [comment](https://github.com/apache/camel-quarkus/issues/4362#issuecomment-1369885091).
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4370: DoBeforeEach does not work with Advice #4362
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4370:
URL: https://github.com/apache/camel-quarkus/pull/4370#issuecomment-1372240119
@ppalaga I made 2 changes into the doc
https://github.com/apache/camel-quarkus/pull/4370/files#diff-b0192eeed7b3641688fc3b73fa7c01e066a6038d0565eed34a679fa171798694L261
https://github.com/apache/camel-quarkus/pull/4370/files#diff-b0192eeed7b3641688fc3b73fa7c01e066a6038d0565eed34a679fa171798694L263
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org