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 2022/06/21 12:35:47 UTC

[GitHub] [camel-website] essobedo commented on a diff in pull request #860: Blogpost: How to use Camel textual Route Debugger with Unit Test

essobedo commented on code in PR #860:
URL: https://github.com/apache/camel-website/pull/860#discussion_r902552513


##########
content/blog/2022/06/HowToUseCamelRouteTextualDebuggerWithUnitTest/index.md:
##########
@@ -0,0 +1,158 @@
+---
+title: "How to use Camel textual Route Debugger with Unit test in VS Code"
+date: 2022-06-21
+authors: [apupier]
+categories: ["Tooling"]
+preview: "How to use Camel textual Route Debugger with Unit test in VS Code"
+---
+
+Textual debug for Camel routes allows to set breakpoints at Route definition. It is convenient to leverage this feature with a Unit test.
+
+This article will explain how it is possible to configure the project and the VS Code IDE for that. Similar functionality should be possible with other IDEs but not covered in this article.
+
+# Requirements
+
+In this article, we will focus on using VS Code IDE. It implies the following requirements:
+
+- [VS Code client for Debug Adapter for Camel](https://github.com/camel-tooling/camel-dap-client-vscode/issues) installed in your VS Code instance
+- Maven available on system path
+- Java 11+ installed
+- Camel 3.17+
+
+# Project configuration
+
+## Pom file configuration
+
+`camel-debug` must be on the classpath. One way to achieve that is to provide the dependency in a profile which needs to be activated when the tests are launched.
+
+```xml
+<profiles>
+        <profile>
+            <id>camel.debug</id>
+            <activation>
+                <property>
+                    <name>camel.debug</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.camel</groupId>
+                    <artifactId>camel-debug</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+<repositories>

Review Comment:
   this line can be removed



##########
content/blog/2022/06/HowToUseCamelRouteTextualDebuggerWithUnitTest/index.md:
##########
@@ -0,0 +1,158 @@
+---
+title: "How to use Camel textual Route Debugger with Unit test in VS Code"
+date: 2022-06-21
+authors: [apupier]
+categories: ["Tooling"]
+preview: "How to use Camel textual Route Debugger with Unit test in VS Code"
+---
+
+Textual debug for Camel routes allows to set breakpoints at Route definition. It is convenient to leverage this feature with a Unit test.
+
+This article will explain how it is possible to configure the project and the VS Code IDE for that. Similar functionality should be possible with other IDEs but not covered in this article.
+
+# Requirements
+
+In this article, we will focus on using VS Code IDE. It implies the following requirements:
+
+- [VS Code client for Debug Adapter for Camel](https://github.com/camel-tooling/camel-dap-client-vscode/issues) installed in your VS Code instance
+- Maven available on system path
+- Java 11+ installed
+- Camel 3.17+
+
+# Project configuration
+
+## Pom file configuration
+
+`camel-debug` must be on the classpath. One way to achieve that is to provide the dependency in a profile which needs to be activated when the tests are launched.
+
+```xml
+<profiles>
+        <profile>
+            <id>camel.debug</id>
+            <activation>
+                <property>
+                    <name>camel.debug</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.camel</groupId>
+                    <artifactId>camel-debug</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>

Review Comment:
   ```suggestion
       <profile>
           <id>camel.debug</id>
           <activation>
               <property>
                   <name>camel.debug</name>
                   <value>true</value>
               </property>
           </activation>
           <dependencies>
               <dependency>
                   <groupId>org.apache.camel</groupId>
                   <artifactId>camel-debug</artifactId>
               </dependency>
           </dependencies>
       </profile>
   </profiles>
   ```



##########
content/blog/2022/06/HowToUseCamelRouteTextualDebuggerWithUnitTest/index.md:
##########
@@ -0,0 +1,158 @@
+---
+title: "How to use Camel textual Route Debugger with Unit test in VS Code"
+date: 2022-06-21
+authors: [apupier]
+categories: ["Tooling"]
+preview: "How to use Camel textual Route Debugger with Unit test in VS Code"
+---
+
+Textual debug for Camel routes allows to set breakpoints at Route definition. It is convenient to leverage this feature with a Unit test.
+
+This article will explain how it is possible to configure the project and the VS Code IDE for that. Similar functionality should be possible with other IDEs but not covered in this article.
+
+# Requirements
+
+In this article, we will focus on using VS Code IDE. It implies the following requirements:
+
+- [VS Code client for Debug Adapter for Camel](https://github.com/camel-tooling/camel-dap-client-vscode/issues) installed in your VS Code instance
+- Maven available on system path
+- Java 11+ installed
+- Camel 3.17+
+
+# Project configuration
+
+## Pom file configuration
+
+`camel-debug` must be on the classpath. One way to achieve that is to provide the dependency in a profile which needs to be activated when the tests are launched.
+
+```xml
+<profiles>
+        <profile>
+            <id>camel.debug</id>
+            <activation>
+                <property>
+                    <name>camel.debug</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.camel</groupId>
+                    <artifactId>camel-debug</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+<repositories>
+```
+
+## Test class configuration
+
+Two methods must have a specific value:
+
+- `isUseDebugger` method must return false. This is the default implementation, just ensure that it is not overridden.
+- `useJMX` method must return true. This needs to be overridden.
+
+
+We also need to ensure that the test is starting after Debugger is attached and breakpoint set. For now, the only solution that I can propose is to insert a (ugly) `Thread.sleep` at the beginning of the test. It will work only if the test is triggering the route execution. If your route is automatically triggered like for a `timer`, some route executions might happen before the debugger is attached and breakpoints enabled.
+
+You should end up with something like that:
+
+```java
+class MainTest extends CamelMainTestSupport {
+	@Test
+	void myTest() throws Exception {
+		Thread.sleep(2000); // to let time to Debugger to attach and install breakpoints

Review Comment:
   Why not asking to launch the IDE in debug mode and to add breakpoint instead?



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