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 2020/07/03 12:27:01 UTC

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #1452: Document how to use mock in JVM mode tests #1449

ppalaga commented on a change in pull request #1452:
URL: https://github.com/apache/camel-quarkus/pull/1452#discussion_r449554086



##########
File path: docs/modules/ROOT/pages/extensions/mock.adoc
##########
@@ -26,3 +26,37 @@ Please refer to the above link for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Usage
+
+To use camel-mock capabilities it is required to get access to MockEndpoint instances.

Review comment:
       ```suggestion
   To use camel-mock capabilities in tests it is required to get access to MockEndpoint instances.
   ```

##########
File path: docs/modules/ROOT/pages/extensions/mock.adoc
##########
@@ -26,3 +26,37 @@ Please refer to the above link for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Usage
+
+To use camel-mock capabilities it is required to get access to MockEndpoint instances.
+
+CDI injection could be used for accessing instances (see https://quarkus.io/guides/getting-started-testing#injection-into-tests[Quarkus documentation]).
+You can inject camelContext into test using `@Inject` annotation. Camel context can be then used for obtaining mock endpoints.
+See the following example:
+
+----
+@Inject

Review comment:
       ```suggestion
   
   @QuarkusTest
   class MyTest {
   
   @Inject
   ```
   
   plus I vote for naming all or at least the most important imports.

##########
File path: docs/modules/ROOT/pages/extensions/mock.adoc
##########
@@ -26,3 +26,37 @@ Please refer to the above link for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Usage
+
+To use camel-mock capabilities it is required to get access to MockEndpoint instances.
+
+CDI injection could be used for accessing instances (see https://quarkus.io/guides/getting-started-testing#injection-into-tests[Quarkus documentation]).
+You can inject camelContext into test using `@Inject` annotation. Camel context can be then used for obtaining mock endpoints.
+See the following example:
+
+----
+@Inject
+CamelContext camelContext;
+
+
+@Test
+public void test() throws InterruptedException {
+
+    //test code
+
+    MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:result", MockEndpoint.class);
+
+    mockEndpoint.expectedBodiesReceived("Hello World");

Review comment:
       There should be some route invocation at this location (through rest or directly over Java API). Otherwise the test does not make much sense. It would also be nice to have the route definition in the example.

##########
File path: docs/modules/ROOT/pages/extensions/mock.adoc
##########
@@ -26,3 +26,37 @@ Please refer to the above link for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Usage
+
+To use camel-mock capabilities it is required to get access to MockEndpoint instances.
+
+CDI injection could be used for accessing instances (see https://quarkus.io/guides/getting-started-testing#injection-into-tests[Quarkus documentation]).
+You can inject camelContext into test using `@Inject` annotation. Camel context can be then used for obtaining mock endpoints.
+See the following example:
+
+----
+@Inject
+CamelContext camelContext;
+
+
+@Test
+public void test() throws InterruptedException {
+
+    //test code
+
+    MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:result", MockEndpoint.class);
+
+    mockEndpoint.expectedBodiesReceived("Hello World");
+    mockEndpoint.assertIsSatisfied();
+}
+----
+
+
+== Camel Quarkus limitations
+
+Injection of CDI beans (described in Usage) does not work in native mode.
+
+In the native mode the test and the applications are running in two different processes and it is not possible

Review comment:
       ```suggestion
   In the native mode the test and the application under test are running in two different processes and it is not possible
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org