[ 
https://issues.apache.org/jira/browse/CAMEL-12964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16703243#comment-16703243
 ] 

ASF GitHub Bot commented on CAMEL-12964:
----------------------------------------

mswiderski commented on a change in pull request #2644: CAMEL-12964: Initial 
import of jBPM CamelWIH and Command.
URL: https://github.com/apache/camel/pull/2644#discussion_r237505308
 
 

 ##########
 File path: 
components/camel-jbpm/src/test/java/org/apache/camel/component/jbpm/workitem/CamelWorkItemHandlerIntegrationTests.java
 ##########
 @@ -0,0 +1,204 @@
+/**
+ * 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.component.jbpm.workitem;
+
+import static org.hamcrest.CoreMatchers.*;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.drools.core.process.instance.impl.WorkItemImpl;
+import org.jbpm.bpmn2.handler.WorkItemHandlerRuntimeException;
+import org.jbpm.process.workitem.core.TestWorkItemManager;
+import org.jbpm.services.api.service.ServiceRegistry;
+import org.junit.Test;
+import org.kie.api.runtime.process.WorkItemHandler;
+
+//http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html
+//http://camel.apache.org/async.html
+public class CamelWorkItemHandlerIntegrationTests extends CamelTestSupport {
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint resultEndpoint;
+
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+
+    @Test
+    public void testSyncInOnly() throws Exception {
+        // Setup
+        String routeId = "testSyncInOnlyExceptionRoute";
+        RouteBuilder builder = new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId(routeId)
+                        .setBody(simple("${body.getParameter(\"request\")}"))
+                        .to("mock:result");
+            }
+        };
+        context.addRoutes(builder);
+        try {
+            // Register the Camel Context with the jBPM ServiceRegistry.
+            ServiceRegistry.get().register("GlobalCamelService", context);
+
+            // Test
+            String expectedBody = "helloRequest";
+            resultEndpoint.expectedBodiesReceived(expectedBody);
+
+            WorkItemImpl workItem = new WorkItemImpl();
+            workItem.setParameter("camel-endpoint-id", "start");
+            workItem.setParameter("request", expectedBody);
+
+            TestWorkItemManager manager = new TestWorkItemManager();
+
+            WorkItemHandler handler = new InOnlyCamelWorkItemHandler();
+
+            handler.executeWorkItem(workItem, manager);
+
+            // Assertions
+            assertThat(manager.getResults().size(), equalTo(0));
+            resultEndpoint.assertIsSatisfied();
+        } finally {
+            // Cleanup
+            context.removeRoute(routeId);
+        }
+    }
+
+    @Test(expected = WorkItemHandlerRuntimeException.class)
+    public void testSyncInOnlyException() throws Exception {
+        // Setup
+        String routeId = "testSyncInOnlyExceptionRoute";
+        RouteBuilder builder = new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId(routeId)
+                        .setBody(simple("${body.getParameter(\"request\")}"))
+                        .throwException(new IllegalArgumentException("Illegal 
contennt!"))
+                        .to("mock:result");
+            }
+        };
+        context.addRoutes(builder);
+        try {
+            // Register the Camel Context with the jBPM ServiceRegistry.
+            ServiceRegistry.get().register("GlobalCamelService", context);
 
 Review comment:
   same here, use constant

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Create new CamelWIH to integrate with recently added Camel support in 
> jBPM/KIE-Server 
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12964
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12964
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-jbpm
>    Affects Versions: 2.23.0
>            Reporter: Duncan Doyle
>            Assignee: Maciej Swiderski
>            Priority: Major
>
> The new camel-jbpm component allows CamelContexts and Routes to be defined on 
> both a global (KIE-Server) and runtimeManager/deploymentUnit/KJAR level. A 
> new CamelWorkItemHandler that integrates with these CamelContexts and routes 
> would allow easy integration with external resources throuch Camel Components 
> from within a process/case definition.
> See: https://issues.jboss.org/browse/JBPM-7995



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to