You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/10/05 01:51:27 UTC

[camel] 05/09: CAMEL-18574: camel-core - Add disabled option to EIPs

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch disabled
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ab7de518a7caf76b3c03af2621876b38f67590d8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Oct 4 17:22:06 2022 -0500

    CAMEL-18574: camel-core - Add disabled option to EIPs
---
 .../camel/management/ManagedDisabledTest.java      | 75 ++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedDisabledTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedDisabledTest.java
new file mode 100644
index 00000000000..7476877ec94
--- /dev/null
+++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedDisabledTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+
+import static org.apache.camel.management.DefaultManagementObjectNameStrategy.TYPE_PROCESSOR;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@DisabledOnOs(OS.AIX)
+public class ManagedDisabledTest extends ManagementTestSupport {
+
+    @Test
+    public void testManageDisabled() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").expectedMessageCount(0);
+        getMockEndpoint("mock:baz").expectedMessageCount(0);
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
+        assertMockEndpointsSatisfied();
+
+        // get the stats for the route
+        MBeanServer mbeanServer = getMBeanServer();
+
+        ObjectName on = getCamelObjectName(TYPE_PROCESSOR, "mychoice");
+        String type = (String) mbeanServer.getAttribute(on, "NodeType");
+        assertEquals("choice", type);
+        on = getCamelObjectName(TYPE_PROCESSOR, "mybaz");
+        type = (String) mbeanServer.getAttribute(on, "NodeType");
+        assertEquals("to", type);
+        on = getCamelObjectName(TYPE_PROCESSOR, "mylog");
+        type = (String) mbeanServer.getAttribute(on, "NodeType");
+        assertEquals("log", type);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("mock:foo")
+                    .choice().disabled().id("mychoice")
+                        .when(xpath("/bar")).to("mock:bar")
+                        .when(xpath("/baz")).to("mock:baz")
+                    .end()
+                    .to("mock:baz").disabled(true).id("mybaz")
+                    .log("Hello World").disabled("true").id("mylog")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}