diff --git a/src/main/java/com/github/cameltooling/dap/internal/BacklogDebuggerConnectionManager.java b/src/main/java/com/github/cameltooling/dap/internal/BacklogDebuggerConnectionManager.java index fe4ca24..0461e35 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/BacklogDebuggerConnectionManager.java +++ b/src/main/java/com/github/cameltooling/dap/internal/BacklogDebuggerConnectionManager.java @@ -119,6 +119,12 @@ public boolean attach(Map args, IDebugProtocolClient client) { ObjectName debuggerMBeanObjectName = names.iterator().next(); backlogDebugger = JMX.newMBeanProxy(mbeanConnection, debuggerMBeanObjectName, ManagedBacklogDebuggerMBean.class); + try { + backlogDebugger.setIncludeExchangeProperties(true); + } catch(Exception ex) { + // Ignore, we might be connected to pre 4.2 Camel version + System.out.println(ex); + } backlogDebugger.enableDebugger(); routesDOMDocument = retrieveRoutesWithSourceLineNumber(jmxAddress); @@ -194,7 +200,7 @@ private void handleSuspendedBreakpoint(String nodeId) { if (!isStepping && !notifiedSuspendedBreakpointIds.contains(nodeId)) { StoppedEventArguments stoppedEventArgs = new StoppedEventArguments(); stoppedEventArgs.setReason(StoppedEventArgumentsReason.BREAKPOINT); - String xml = backlogDebugger.dumpTracedMessagesAsXml(nodeId, true); + String xml = backlogDebugger.dumpTracedMessagesAsXml(nodeId); EventMessage eventMessage = new UnmarshallerEventMessage().getUnmarshalledEventMessage(xml); Optional thread = camelThreads.stream().filter(camelThread -> camelThread.getExchangeId().equals(eventMessage.getExchangeId())).findAny(); if(thread.isEmpty()) { diff --git a/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelExchangeScope.java b/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelExchangeScope.java index 7b24a69..31f4f29 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelExchangeScope.java +++ b/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelExchangeScope.java @@ -27,14 +27,12 @@ import com.github.cameltooling.dap.internal.IdUtils; import com.github.cameltooling.dap.internal.model.CamelScope; import com.github.cameltooling.dap.internal.model.CamelStackFrame; -import com.github.cameltooling.dap.internal.model.variables.exchange.ExchangePropertiesVariable; import com.github.cameltooling.dap.internal.types.EventMessage; import com.github.cameltooling.dap.internal.types.UnmarshallerEventMessage; public class CamelExchangeScope extends CamelScope { public static final String NAME = "Exchange"; - private ExchangePropertiesVariable exchangeVariable; public CamelExchangeScope(CamelStackFrame stackframe) { super(NAME, stackframe.getName(), IdUtils.getPositiveIntFromHashCode((stackframe.getId()+"@Exchange@" + stackframe.getName()).hashCode())); @@ -44,18 +42,12 @@ public CamelExchangeScope(CamelStackFrame stackframe) { public Set createVariables(int variablesReference, ManagedBacklogDebuggerMBean debugger) { Set variables = new HashSet<>(); if (variablesReference == getVariablesReference()) { - String xml = debugger.dumpTracedMessagesAsXml(getBreakpointId(), true); + String xml = debugger.dumpTracedMessagesAsXml(getBreakpointId()); EventMessage eventMessage = new UnmarshallerEventMessage().getUnmarshalledEventMessage(xml); if (eventMessage != null) { variables.add(createVariable("ID", eventMessage.getExchangeId())); variables.add(createVariable("To node", eventMessage.getToNode())); variables.add(createVariable("Route ID", eventMessage.getRouteId())); - exchangeVariable = new ExchangePropertiesVariable(variablesReference, eventMessage.getExchangeProperties(), getBreakpointId()); - variables.add(exchangeVariable); - } - } else { - if (exchangeVariable != null && variablesReference == exchangeVariable.getVariablesReference()) { - variables.addAll(exchangeVariable.createVariables()); } } return variables; @@ -63,16 +55,6 @@ public Set createVariables(int variablesReference, ManagedBacklogDebug @Override public SetVariableResponse setVariableIfInScope(SetVariableArguments args, ManagedBacklogDebuggerMBean backlogDebugger) { - if (getVariablesReference() == args.getVariablesReference()) { - throw new UnsupportedOperationException("Not supported"); - } else if (exchangeVariable == null) { - return null; - } - return exchangeVariable.setVariableIfInScope(args, backlogDebugger); + return null; } - - public ExchangePropertiesVariable getExchangePropertiesVariable() { - return exchangeVariable; - } - } diff --git a/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelMessageScope.java b/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelMessageScope.java index d09629f..a79dcde 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelMessageScope.java +++ b/src/main/java/com/github/cameltooling/dap/internal/model/scopes/CamelMessageScope.java @@ -28,6 +28,7 @@ import com.github.cameltooling.dap.internal.model.CamelScope; import com.github.cameltooling.dap.internal.model.CamelStackFrame; import com.github.cameltooling.dap.internal.model.variables.message.MessageBodyCamelVariable; +import com.github.cameltooling.dap.internal.model.variables.message.MessageExchangePropertiesVariable; import com.github.cameltooling.dap.internal.model.variables.message.MessageHeadersVariable; import com.github.cameltooling.dap.internal.types.EventMessage; import com.github.cameltooling.dap.internal.types.UnmarshallerEventMessage; @@ -37,6 +38,7 @@ public class CamelMessageScope extends CamelScope { public static final String NAME = "Message"; private MessageBodyCamelVariable messageBody; private MessageHeadersVariable headersVariable; + private MessageExchangePropertiesVariable exchangePropertiesVariable; public CamelMessageScope(CamelStackFrame stackframe) { super(NAME, stackframe.getName(), IdUtils.getPositiveIntFromHashCode((stackframe.getId()+"@Message@" + stackframe.getName()).hashCode())); @@ -46,7 +48,7 @@ public CamelMessageScope(CamelStackFrame stackframe) { public Set createVariables(int variablesReference, ManagedBacklogDebuggerMBean debugger) { Set variables = new HashSet<>(); if (variablesReference == getVariablesReference()) { - String xml = debugger.dumpTracedMessagesAsXml(getBreakpointId(), true); + String xml = debugger.dumpTracedMessagesAsXml(getBreakpointId()); EventMessage eventMessage = new UnmarshallerEventMessage().getUnmarshalledEventMessage(xml); if(eventMessage != null) { variables.add(createVariable("Exchange ID", eventMessage.getExchangeId())); @@ -54,11 +56,16 @@ public Set createVariables(int variablesReference, ManagedBacklogDebug variables.add(messageBody); headersVariable = new MessageHeadersVariable(variablesReference, eventMessage.getMessage().getHeaders(), getBreakpointId()); variables.add(headersVariable); + exchangePropertiesVariable = new MessageExchangePropertiesVariable(variablesReference, eventMessage.getMessage().getExchangeProperties(), getBreakpointId()); + variables.add(getExchangePropertiesVariable()); } } else { if (headersVariable != null && variablesReference == headersVariable.getVariablesReference()) { variables.addAll(headersVariable.createVariables()); } + if (getExchangePropertiesVariable() != null && variablesReference == getExchangePropertiesVariable().getVariablesReference()) { + variables.addAll(getExchangePropertiesVariable().createVariables()); + } } return variables; } @@ -74,14 +81,25 @@ public SetVariableResponse setVariableIfInScope(SetVariableArguments args, Manag } else { throw new UnsupportedOperationException("Not supported"); } - } else if (headersVariable == null) { - return null; } - return headersVariable.setVariableIfInScope(args, debugger); + if (headersVariable != null) { + SetVariableResponse response = headersVariable.setVariableIfInScope(args, debugger); + if (response != null) { + return response; + } + } + if (getExchangePropertiesVariable() != null) { + return getExchangePropertiesVariable().setVariableIfInScope(args, debugger); + } + return null; } public MessageHeadersVariable getHeadersVariable() { return headersVariable; } + public MessageExchangePropertiesVariable getExchangePropertiesVariable() { + return exchangePropertiesVariable; + } + } diff --git a/src/main/java/com/github/cameltooling/dap/internal/model/variables/exchange/ExchangePropertiesVariable.java b/src/main/java/com/github/cameltooling/dap/internal/model/variables/message/MessageExchangePropertiesVariable.java similarity index 84% rename from src/main/java/com/github/cameltooling/dap/internal/model/variables/exchange/ExchangePropertiesVariable.java rename to src/main/java/com/github/cameltooling/dap/internal/model/variables/message/MessageExchangePropertiesVariable.java index 9998d54..bc18c72 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/model/variables/exchange/ExchangePropertiesVariable.java +++ b/src/main/java/com/github/cameltooling/dap/internal/model/variables/message/MessageExchangePropertiesVariable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.github.cameltooling.dap.internal.model.variables.exchange; +package com.github.cameltooling.dap.internal.model.variables.message; import java.util.ArrayList; import java.util.Collection; @@ -28,12 +28,15 @@ import com.github.cameltooling.dap.internal.IdUtils; import com.github.cameltooling.dap.internal.types.ExchangeProperty; -public class ExchangePropertiesVariable extends Variable { +/** + * This is used pre-Camel 4.2 only (not included) + */ +public class MessageExchangePropertiesVariable extends Variable { private final List exchangeProperties; private final String breakpointId; - public ExchangePropertiesVariable(int parentVariablesReference, List exchangeProperties, String breakpointId) { + public MessageExchangePropertiesVariable(int parentVariablesReference, List exchangeProperties, String breakpointId) { this.exchangeProperties = exchangeProperties; this.breakpointId = breakpointId; setName("Properties"); @@ -46,7 +49,7 @@ public Collection createVariables() { Collection variables = new ArrayList<>(); if (exchangeProperties != null) { for (ExchangeProperty exchangeProperty : exchangeProperties) { - variables.add(createVariable(exchangeProperty.getName(), exchangeProperty.getContent())); + variables.add(createVariable(exchangeProperty.getKey(), exchangeProperty.getContent())); } } return variables; @@ -64,7 +67,7 @@ public SetVariableResponse setVariableIfInScope(SetVariableArguments args, Manag debugger.setExchangePropertyOnBreakpoint(breakpointId, args.getName(), args.getValue()); if (exchangeProperties != null) { for (ExchangeProperty exchangeProperty : exchangeProperties) { - if (exchangeProperty.getName().equals(args.getName())) { + if (exchangeProperty.getKey().equals(args.getName())) { exchangeProperty.setContent(args.getValue()); } } diff --git a/src/main/java/com/github/cameltooling/dap/internal/types/EventMessage.java b/src/main/java/com/github/cameltooling/dap/internal/types/EventMessage.java index 3003730..49557b3 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/types/EventMessage.java +++ b/src/main/java/com/github/cameltooling/dap/internal/types/EventMessage.java @@ -16,11 +16,9 @@ */ package com.github.cameltooling.dap.internal.types; -import java.util.List; import java.util.Map; import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlRootElement; import org.apache.camel.spi.BacklogTracerEventMessage; @@ -39,7 +37,6 @@ public class EventMessage implements BacklogTracerEventMessage { private String toNode; private String exchangeId; private Message message; - private List exchangeProperties; @XmlElement(name = "uid") public long getUid() { @@ -89,15 +86,6 @@ public void setMessage(Message message) { this.message = message; } - @XmlElementWrapper(name = "exchangeProperties") - @XmlElement(name = "exchangeProperty") - public List getExchangeProperties() { - return exchangeProperties; - } - public void setExchangeProperties(List exchangeProperties) { - this.exchangeProperties = exchangeProperties; - } - @Override public String getMessageAsXml() { throw new UnsupportedOperationException("This class is used only to read message sent from Camel server through JMX"); diff --git a/src/main/java/com/github/cameltooling/dap/internal/types/ExchangeProperty.java b/src/main/java/com/github/cameltooling/dap/internal/types/ExchangeProperty.java index ffa4839..a4df9ff 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/types/ExchangeProperty.java +++ b/src/main/java/com/github/cameltooling/dap/internal/types/ExchangeProperty.java @@ -27,17 +27,17 @@ public class ExchangeProperty implements Serializable { private static final long serialVersionUID = 7994857995065989510L; - private String name; + private String key; private String type; private String content; - @XmlAttribute(name = "name") - public String getName() { - return name; + @XmlAttribute(name = "key") + public String getKey() { + return key; } - public void setName(String name) { - this.name = name; + public void setKey(String key) { + this.key = key; } @XmlAttribute(name = "type") diff --git a/src/main/java/com/github/cameltooling/dap/internal/types/Message.java b/src/main/java/com/github/cameltooling/dap/internal/types/Message.java index 63e3542..3b69c68 100644 --- a/src/main/java/com/github/cameltooling/dap/internal/types/Message.java +++ b/src/main/java/com/github/cameltooling/dap/internal/types/Message.java @@ -32,6 +32,7 @@ public class Message implements Serializable { private String exchangeId; private List
headers; private String body; + private List exchangeProperties; @XmlAttribute(name = "exchangeId") public String getExchangeId() { @@ -60,4 +61,13 @@ public String getBody() { public void setBody(String body) { this.body = body; } + + @XmlElementWrapper(name = "exchangeProperties") + @XmlElement(name = "exchangeProperty") + public List getExchangeProperties() { + return exchangeProperties; + } + public void setExchangeProperties(List exchangeProperties) { + this.exchangeProperties = exchangeProperties; + } } diff --git a/src/test/java/com/github/cameltooling/dap/internal/BaseTest.java b/src/test/java/com/github/cameltooling/dap/internal/BaseTest.java index 17cf8ea..2279ffc 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/BaseTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/BaseTest.java @@ -42,9 +42,10 @@ import com.github.cameltooling.dap.internal.telemetry.TelemetryEvent; +//@SetSystemProperty(key = "camel.debug.enabled", value = "true") public abstract class BaseTest { - protected static final int DEFAULT_VARIABLES_NUMBER = 18; + protected static final int DEFAULT_VARIABLES_NUMBER = 16; protected CamelDebugAdapterServer server; protected DummyCamelDebugClient clientProxy; protected CamelContext context; diff --git a/src/test/java/com/github/cameltooling/dap/internal/BasicDebugFlowTest.java b/src/test/java/com/github/cameltooling/dap/internal/BasicDebugFlowTest.java index 3543484..89a79f8 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/BasicDebugFlowTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/BasicDebugFlowTest.java @@ -58,6 +58,7 @@ abstract class BasicDebugFlowTest extends BaseTest { @Test void testBasicFlow() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String logEndpointId = "testBasicFlow-log-id"; registerRouteToTest(context, routeId, logEndpointId); @@ -97,7 +98,7 @@ void testBasicFlow() throws Exception { await().untilAsserted(() -> assertThat(stackAndData.getScopes()).hasSize(5)); await("handling of stop event response is finished") .atMost(Duration.ofSeconds(60)) - .untilAsserted(() -> assertThat(stackAndData.getVariables()).hasSize(22)); + .untilAsserted(() -> assertThat(stackAndData.getVariables()).hasSize(21)); ManagedBacklogDebuggerMBean debugger = server.getConnectionManager().getBacklogDebugger(); List variables = stackAndData.getVariables(); assertThat(variables) diff --git a/src/test/java/com/github/cameltooling/dap/internal/CamelDebugAdapterServerTest.java b/src/test/java/com/github/cameltooling/dap/internal/CamelDebugAdapterServerTest.java index 7b36c15..e46bc06 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/CamelDebugAdapterServerTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/CamelDebugAdapterServerTest.java @@ -36,6 +36,7 @@ void testInitialize() throws Exception { @Test void testAttachToCamelWithPid() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); startBasicRoute(context); attachWithPid(server); checkConnectionEstablished(); @@ -44,6 +45,7 @@ void testAttachToCamelWithPid() throws Exception { @Test void testAttachToCamelWithDefaultJMX() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); startBasicRoute(context); attach(server); checkConnectionEstablished(); @@ -52,6 +54,7 @@ void testAttachToCamelWithDefaultJMX() throws Exception { @Test void testAttachToCamelWithProvidedJMXURL() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); startBasicRoute(context); attachWithJMXURL(server, BacklogDebuggerConnectionManager.DEFAULT_JMX_URI); checkConnectionEstablished(); @@ -60,6 +63,7 @@ void testAttachToCamelWithProvidedJMXURL() throws Exception { @Test void testFailToAttach() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); startBasicRoute(context); server.attach(Collections.singletonMap(BacklogDebuggerConnectionManager.ATTACH_PARAM_JMX_URL, "invalidUrl")).get(); assertThat(clientProxy.getOutputEventArguments().get(0).getOutput()).contains("Please check that the Camel application under debug has the following requirements:"); diff --git a/src/test/java/com/github/cameltooling/dap/internal/ConditionalBreakpointTest.java b/src/test/java/com/github/cameltooling/dap/internal/ConditionalBreakpointTest.java index 49bd8d9..0548ec1 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/ConditionalBreakpointTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/ConditionalBreakpointTest.java @@ -39,6 +39,7 @@ class ConditionalBreakpointTest extends BaseTest { @Test void testCondition() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testConditionalBreakpoint"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/MultipleThreadsTest.java b/src/test/java/com/github/cameltooling/dap/internal/MultipleThreadsTest.java index 23a46a7..6d4a8a8 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/MultipleThreadsTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/MultipleThreadsTest.java @@ -35,6 +35,7 @@ class MultipleThreadsTest extends BaseTest { @Test void test2SuspendedBreakpointsCreates2Threads() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String startEndpointUri1 = "direct:testThreads1"; String startEndpointUri2 = "direct:testThreads2"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/NextStepTest.java b/src/test/java/com/github/cameltooling/dap/internal/NextStepTest.java index 47ff978..c4d4c14 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/NextStepTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/NextStepTest.java @@ -35,6 +35,7 @@ class NextStepTest extends BaseTest { @Test void testSteppingInsideRoute() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { @@ -88,6 +89,7 @@ public void configure() throws Exception { @Test void testSteppingAtEndOfRoute() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { @@ -133,6 +135,7 @@ public void configure() throws Exception { @Test void testSteppingWithExistingBreakpoint() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/RemoveBreakpointTest.java b/src/test/java/com/github/cameltooling/dap/internal/RemoveBreakpointTest.java index 594521b..f1ce3bf 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/RemoveBreakpointTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/RemoveBreakpointTest.java @@ -34,6 +34,7 @@ class RemoveBreakpointTest extends BaseTest { @Test void testRemoveOneBreakpoint() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String fromUri = "direct:testRemoveBreakpoint"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/ResumeAllTest.java b/src/test/java/com/github/cameltooling/dap/internal/ResumeAllTest.java index 7c52287..aa5254f 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/ResumeAllTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/ResumeAllTest.java @@ -36,6 +36,7 @@ class ResumeAllTest extends BaseTest { @Test void testResumeAndSecondBreakpointHitOfAnotherRouteInstance() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { @@ -93,6 +94,7 @@ private Optional findBodyVariableAtIndex(int index) { @Test void testResumeAndSecondBreakpointHitOnSameRouteInstance() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/ResumeSingleThreadTest.java b/src/test/java/com/github/cameltooling/dap/internal/ResumeSingleThreadTest.java index b6c5069..e1a0040 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/ResumeSingleThreadTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/ResumeSingleThreadTest.java @@ -34,6 +34,7 @@ class ResumeSingleThreadTest extends BaseTest { @Test void testResume() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId1 = "a-route-id-1"; String startEndpointUri1 = "direct:testResume1"; String routeId2 = "a-route-id-2"; diff --git a/src/test/java/com/github/cameltooling/dap/internal/StepInTest.java b/src/test/java/com/github/cameltooling/dap/internal/StepInTest.java index 480fe30..c73d401 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/StepInTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/StepInTest.java @@ -35,6 +35,7 @@ class StepInTest extends BaseTest { @Test void testStepInRouteRedirectToNext() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/StepOutTest.java b/src/test/java/com/github/cameltooling/dap/internal/StepOutTest.java index d28db6a..d0df278 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/StepOutTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/StepOutTest.java @@ -35,6 +35,7 @@ class StepOutTest extends BaseTest { @Test void testStepOutRouteRedirectToNext() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/SuspendTest.java b/src/test/java/com/github/cameltooling/dap/internal/SuspendTest.java index 94c6c87..0f508f3 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/SuspendTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/SuspendTest.java @@ -36,6 +36,7 @@ class SuspendTest extends BaseTest { @SetSystemProperty(key = BacklogDebugger.SUSPEND_MODE_SYSTEM_PROP_NAME, value = "true") void testOnSuspendModeEnabled() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { @@ -68,6 +69,7 @@ public void configure() throws Exception { @SetSystemProperty(key = BacklogDebugger.SUSPEND_MODE_SYSTEM_PROP_NAME, value = "false") void testOnSuspendModeDisabled() throws Exception { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); String routeId = "a-route-id"; String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { diff --git a/src/test/java/com/github/cameltooling/dap/internal/UnverifiedBreakpointTest.java b/src/test/java/com/github/cameltooling/dap/internal/UnverifiedBreakpointTest.java index 17fa491..6e41371 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/UnverifiedBreakpointTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/UnverifiedBreakpointTest.java @@ -97,6 +97,7 @@ void testExceptionWhenSettingBreakpoint() throws Exception { private SetBreakpointsArguments startWithBreakpoint(String breakpoint) throws Exception, FileNotFoundException { context = new DefaultCamelContext(); + context.setSourceLocationEnabled(true); registerRouteToTest(context); context.start(); assertThat(context.isStarted()).isTrue(); diff --git a/src/test/java/com/github/cameltooling/dap/internal/UpdateDebuggerVariableValueTest.java b/src/test/java/com/github/cameltooling/dap/internal/UpdateDebuggerVariableValueTest.java index efc643e..fedb721 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/UpdateDebuggerVariableValueTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/UpdateDebuggerVariableValueTest.java @@ -19,6 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -40,7 +41,6 @@ import org.junit.jupiter.api.Test; import com.github.cameltooling.dap.internal.model.scopes.CamelDebuggerScope; -import com.github.cameltooling.dap.internal.model.scopes.CamelExchangeScope; import com.github.cameltooling.dap.internal.model.scopes.CamelMessageScope; import com.github.cameltooling.dap.internal.model.variables.debugger.BodyIncludeFilesCamelVariable; import com.github.cameltooling.dap.internal.model.variables.debugger.BodyIncludeStreamsCamelVariable; @@ -50,6 +50,7 @@ import com.github.cameltooling.dap.internal.model.variables.debugger.MaxCharsForBodyCamelVariable; import com.github.cameltooling.dap.internal.model.variables.message.MessageBodyCamelVariable; import com.github.cameltooling.dap.internal.types.EventMessage; +import com.github.cameltooling.dap.internal.types.ExchangeProperty; import com.github.cameltooling.dap.internal.types.UnmarshallerEventMessage; class UpdateDebuggerVariableValueTest extends BaseTest { @@ -58,13 +59,14 @@ class UpdateDebuggerVariableValueTest extends BaseTest { protected static final String SECOND_LOG_ID = "second-log-id"; private static final int NUMBER_OF_HEADER = 1; private static final int NUMBER_OF_EXCHANGE_PROPERTY = 1; + private static final int NUMBER_OF_EXCHANGE_PROPERTY_PARENT = 1; private Scope debuggerScope; private CompletableFuture asyncSendBody; @BeforeEach void beforeEach() throws Exception { context = new DefaultCamelContext(); - + context.setSourceLocationEnabled(true); String startEndpointUri = "direct:testResume"; context.addRoutes(new RouteBuilder() { @@ -95,11 +97,11 @@ public void configure() throws Exception { assertThat(stoppedEventArgument.getThreadId()).isEqualTo(1); assertThat(stoppedEventArgument.getReason()).isEqualTo(StoppedEventArgumentsReason.BREAKPOINT); assertThat(asyncSendBody.isDone()).isFalse(); - awaitAllVariablesFilled(0, DEFAULT_VARIABLES_NUMBER + NUMBER_OF_HEADER + NUMBER_OF_EXCHANGE_PROPERTY); + awaitAllVariablesFilled(0, DEFAULT_VARIABLES_NUMBER + NUMBER_OF_HEADER + NUMBER_OF_EXCHANGE_PROPERTY + NUMBER_OF_EXCHANGE_PROPERTY_PARENT); debuggerScope = clientProxy.getAllStacksAndVars().get(0).getScopes().stream().filter(scope -> CamelDebuggerScope.NAME.equals(scope.getName())).findAny().get(); } - + @AfterEach void afterEach() { server.continue_(new ContinueArguments()); @@ -221,16 +223,18 @@ void updateExchangeProperty() throws Exception { SetVariableArguments args = new SetVariableArguments(); args.setName("property1"); args.setValue("an updated exchange property"); - CamelExchangeScope exchangeScope = (CamelExchangeScope) clientProxy.getAllStacksAndVars().get(0).getScopes().stream().filter(scope -> CamelExchangeScope.NAME.equals(scope.getName())).findAny().get(); - args.setVariablesReference(exchangeScope.getExchangePropertiesVariable().getVariablesReference()); + CamelMessageScope messageScope = (CamelMessageScope) clientProxy.getAllStacksAndVars().get(0).getScopes().stream().filter(scope -> CamelMessageScope.NAME.equals(scope.getName())).findAny().get(); + args.setVariablesReference(messageScope.getExchangePropertiesVariable().getVariablesReference()); - SetVariableResponse response = server.setVariable(args).get(); assertThat(response.getValue()).isEqualTo("an updated exchange property"); EventMessage eventMessage = getMessageStateOnNextStep(); - assertThat(response.getValue()).isEqualTo(eventMessage.getExchangeProperties().get(0).getContent()); + Optional property1 = eventMessage.getMessage().getExchangeProperties().stream() + .filter(exchangeProperty -> "property1".equals(exchangeProperty.getKey())) + .findAny(); + assertThat(response.getValue()).isEqualTo(property1.get().getContent()); } @Test @@ -256,9 +260,9 @@ private EventMessage getMessageStateOnNextStep() { server.next(nextArgs); waitBreakpointNotification(2); - awaitAllVariablesFilled(1, DEFAULT_VARIABLES_NUMBER + NUMBER_OF_HEADER + NUMBER_OF_EXCHANGE_PROPERTY); + awaitAllVariablesFilled(1, DEFAULT_VARIABLES_NUMBER + NUMBER_OF_HEADER + NUMBER_OF_EXCHANGE_PROPERTY + NUMBER_OF_EXCHANGE_PROPERTY_PARENT); - String messagesAsXml = server.getConnectionManager().getBacklogDebugger().dumpTracedMessagesAsXml(SECOND_LOG_ID, true); + String messagesAsXml = server.getConnectionManager().getBacklogDebugger().dumpTracedMessagesAsXml(SECOND_LOG_ID); EventMessage eventMessage = new UnmarshallerEventMessage().getUnmarshalledEventMessage(messagesAsXml); return eventMessage; } diff --git a/src/test/java/com/github/cameltooling/dap/internal/types/UnmarshallerEventMessageTest.java b/src/test/java/com/github/cameltooling/dap/internal/types/UnmarshallerEventMessageTest.java index 5994725..7090a62 100644 --- a/src/test/java/com/github/cameltooling/dap/internal/types/UnmarshallerEventMessageTest.java +++ b/src/test/java/com/github/cameltooling/dap/internal/types/UnmarshallerEventMessageTest.java @@ -25,13 +25,42 @@ class UnmarshallerEventMessageTest { @Test void testGetUnmarshalledEventMessage() { // it is the event message when calling ManagedBacklogDebuggerMBean.dumpTracedMessagesAsXml - String eventMessageGeneratedWithCamel3_15 = "\\n 1\\n 2022-01-17T14:33:04.001+0100\\n foo\\n bean1\\n 8740E46AD27758F-000000000000000C\\n \\n \\n
1642426384000
\\n
\\n
Mon Jan 17 14:33:04 CET 2022
\\n
JobDetail 'Camel_MyCoolCamel.foo': jobClass: 'org.apache.camel.component.quartz.CamelJob concurrentExectionDisallowed: false persistJobDataAfterExecution: false isDurable: false requestsRecovers: false
\\n
org.apache.camel.component.quartz.CamelJob@7e21921c
\\n
-1
\\n
org.quartz.JobDataMap@e5e7e077
\\n
Mon Jan 17 14:33:06 CET 2022
\\n
Mon Jan 17 14:33:02 CET 2022
\\n
0
\\n
\\n
Mon Jan 17 14:33:04 CET 2022
\\n
org.quartz.impl.StdScheduler@2b09f4a4
\\n
Trigger 'Camel_MyCoolCamel.foo': triggerClass: 'org.quartz.impl.triggers.CronTriggerImpl calendar: 'null' misfireInstruction: 1 nextFireTime: Mon Jan 17 14:33:06 CET 2022
\\n
Camel_MyCoolCamel
\\n
foo
\\n
\\n [Body is null]\\n
\\n \\n [DefaultMessageHistory[routeId=foo, node=bean1]]\\n \\n
"; - EventMessage message = new UnmarshallerEventMessage().getUnmarshalledEventMessage(eventMessageGeneratedWithCamel3_15); + String eventMessageGeneratedWithCamel4_2 = """ + + 1 + false + false + false + + 2023-11-20T14:20:26.971+0100 + 1077 + Camel (camel-1) thread #2 - ProducerTemplate + false + false + basic.yaml:23 + a-route-id + testBasicFlow-log-id + 7F4C7BF7F3898E7-0000000000000000 + + + direct://testSetBreakpoint + value of property 1 + value of property 2 + + +
value of header 1
+
value of header 2
+
+ a body for test +
+
+"""; + EventMessage message = new UnmarshallerEventMessage().getUnmarshalledEventMessage(eventMessageGeneratedWithCamel4_2); assertThat(message).isNotNull(); assertThat(message.getUid()).isEqualTo(1); - assertThat(message.getMessage().getHeaders()).hasSize(16); - assertThat(message.getExchangeProperties()).hasSize(1); - assertThat(message.getMessage().getBody()).isEqualTo("[Body is null]"); + assertThat(message.getMessage().getHeaders()).hasSize(2); + assertThat(message.getMessage().getExchangeProperties()).hasSize(3); + assertThat(message.getMessage().getBody()).isEqualTo("a body for test"); } }