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

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

oscerd closed pull request #2115: CAMEL-12030: Refactor handling of CoAP 
request method
URL: https://github.com/apache/camel/pull/2115
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/components/camel-coap/src/main/docs/coap-component.adoc 
b/components/camel-coap/src/main/docs/coap-component.adoc
index 1b1ba80acc3..e0f1481edb7 100644
--- a/components/camel-coap/src/main/docs/coap-component.adoc
+++ b/components/camel-coap/src/main/docs/coap-component.adoc
@@ -52,10 +52,31 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *coapMethod* (common) | The CoAP method this endpoint binds to. Default is 
to bind to all () but can be restricted to GET POST PUT DELETE PING | * | String
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the 
Camel routing Error Handler which mean any exceptions occurred while the 
consumer is trying to pickup incoming messages or the likes will now be 
processed as a message and handled by the routing Error Handler. By default the 
consumer will use the org.apache.camel.spi.ExceptionHandler to deal with 
exceptions that will be logged at WARN or ERROR level and ignored. | false | 
boolean
+| *coapMethodRestrict* (consumer) | Comma separated list of methods that the 
CoAP consumer will bind to. The default is to bind to all methods (DELETE GET 
POST PUT). |  | String
 | *exceptionHandler* (consumer) | To let the consumer use a custom 
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this 
options is not in use. By default the consumer will deal with exceptions that 
will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer 
creates an exchange. |  | ExchangePattern
 | *synchronous* (advanced) | Sets whether synchronous processing should be 
strictly used or Camel is allowed to use asynchronous processing (if 
supported). | false | boolean
 |===
 // endpoint options: END
+
+### Message Headers
+
+[width="100%",cols="10%,20%,70%",options="header",]
+|=======================================================================
+|Name |Type |Description
+
+|`CamelCoapMethod` |`String` |The request method that the CoAP producer should 
use when calling the target CoAP
+server URI. Valid options are DELETE, GET, PING, POST & PUT.
+
+|`CamelCoapUri` |`String` |The URI of a CoAP server to call. Will override any 
existing URI configured directly on the endpoint.
+|=======================================================================
+
+#### Configuring the CoAP producer request method
+
+The following rules determine which request method the CoAP producer will use 
to invoke the target URI:
+
+ 1. The value of the `CamelCoapMethod` header
+ 2. **GET** if a query string is provided on the target CoAP server URI.
+ 3. **POST** if the message exchange body is not null.
+ 4. **GET** otherwise.
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CamelCoapResource.java
 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CamelCoapResource.java
index 017fd4f6020..e8c08c0b0af 100644
--- 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CamelCoapResource.java
+++ 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CamelCoapResource.java
@@ -36,7 +36,7 @@
 
     CamelCoapResource(String name, CoAPConsumer consumer) {
         super(name);
-        consumers.put(consumer.getCoapEndpoint().getCoapMethod(), consumer);
+        addConsumer(consumer);
         possibles = null;
     }
 
@@ -46,7 +46,11 @@ private CamelCoapResource(String name, 
List<CamelCoapResource> possibles) {
     }
     
     void addConsumer(CoAPConsumer consumer) {
-        consumers.put(consumer.getCoapEndpoint().getCoapMethod(), consumer);
+        CoAPEndpoint coapEndpoint = consumer.getCoapEndpoint();
+        String coapMethodRestrict = 
CoAPHelper.getDefaultMethodRestrict(coapEndpoint.getCoapMethodRestrict());
+        for (String method : coapMethodRestrict.split(",")) {
+            consumers.put(method.trim(), consumer);
+        }
     }
     
     @Override
@@ -81,10 +85,6 @@ public void handleRequest(Exchange exchange) {
         CoapExchange cexchange = new CoapExchange(exchange, this);
         try {
             consumer = consumers.get(exchange.getRequest().getCode().name());
-            if (consumer == null) {
-                consumer = consumers.get("*");
-            }
-
             if (consumer == null) {
                 cexchange.respond(ResponseCode.METHOD_NOT_ALLOWED);
                 return;
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java
index f24aa84b9a6..6ca54d9414e 100644
--- 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java
+++ 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java
@@ -107,7 +107,7 @@ public Consumer createConsumer(CamelContext camelContext,
             }
         }
 
-        Map<String, Object> map = new HashMap<String, Object>();
+        Map<String, Object> map = new HashMap<>();
         // setup endpoint options
         if (config.getEndpointProperties() != null && 
!config.getEndpointProperties().isEmpty()) {
             map.putAll(config.getEndpointProperties());
@@ -122,7 +122,7 @@ public Consumer createConsumer(CamelContext camelContext,
         if (uriTemplate == null) {
             uriTemplate = "";
         }
-        url += basePath + uriTemplate + "?coapMethod=" + 
verb.toUpperCase(Locale.US);
+        url += basePath + uriTemplate + "?coapMethodRestrict=" + 
verb.toUpperCase(Locale.US);
         if (!query.isEmpty()) {
             url += "&" + query;
         }
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPConstants.java 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPConstants.java
new file mode 100644
index 00000000000..bf44a2071ae
--- /dev/null
+++ 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPConstants.java
@@ -0,0 +1,43 @@
+/**
+ * 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.coap;
+
+/**
+ * CoAP component constants
+ */
+public interface CoAPConstants {
+
+    /**
+     * Supported request methods
+     */
+    String METHOD_DELETE = "DELETE";
+    String METHOD_GET = "GET";
+    String METHOD_PING = "PING";
+    String METHOD_POST = "POST";
+    String METHOD_PUT = "PUT";
+
+    /**
+     * Supported CoAP server methods
+     */
+    String METHOD_RESTRICT_ALL = String.format("%s,%s,%s,%s", METHOD_DELETE, 
METHOD_GET, METHOD_POST, METHOD_PUT);
+
+    /**
+     * CoAP exchange header names
+     */
+    String COAP_METHOD = "CamelCoapMethod";
+    String COAP_URI = "CamelCoapUri";
+}
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java
index 7375068f62e..bc0e2f1c2c1 100644
--- 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java
+++ 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java
@@ -34,8 +34,8 @@
 public class CoAPEndpoint extends DefaultEndpoint {
     @UriPath
     private URI uri;
-    @UriParam(defaultValue = "*")
-    private String coapMethod = "*";
+    @UriParam(label = "consumer")
+    private String coapMethodRestrict;
         
     private CoAPComponent component;
     
@@ -49,17 +49,17 @@ public CoAPEndpoint(String uri, CoAPComponent component) {
         this.component = component;
     }
 
-    public void setCoapMethod(String m) {
-        coapMethod = m;
+    public void setCoapMethodRestrict(String coapMethodRestrict) {
+        this.coapMethodRestrict = coapMethodRestrict;
     }
+
     /**
-     * The CoAP method this endpoint binds to. Default is to bind to all ("*") 
but can
-     * be restricted to GET, POST, PUT, DELETE, PING 
-     * @return
+     * Comma separated list of methods that the CoAP consumer will bind to. 
The default is to bind to all methods (DELETE, GET, POST, PUT).
      */
-    public String getCoapMethod() {
-        return coapMethod;
+    public String getCoapMethodRestrict() {
+        return this.coapMethodRestrict;
     }
+
     public Producer createProducer() throws Exception {
         return new CoAPProducer(this);
     }
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPHelper.java 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPHelper.java
new file mode 100644
index 00000000000..9519c1491a3
--- /dev/null
+++ b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPHelper.java
@@ -0,0 +1,64 @@
+/**
+ * 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.coap;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.californium.core.CoapClient;
+
+/**
+ * Various helper methods for CoAP
+ */
+public final class CoAPHelper {
+
+    private CoAPHelper() {
+    }
+
+    /**
+     * Determines which CoAP request method to use based on the content of the 
target
+     * request URI, the message body or value from the CamelCoapMethod header.
+     *
+     * @param exchange the exchange
+     * @param client the CoAP client
+     * @return the CoAP request method
+     */
+    public static String getDefaultMethod(Exchange exchange, CoapClient 
client) {
+        String method = exchange.getIn().getHeader(CoAPConstants.COAP_METHOD, 
String.class);
+        if (method == null) {
+            Object body = exchange.getIn().getBody();
+            if (body == null || client.getURI().contains("?")) {
+                method = CoAPConstants.METHOD_GET;
+            } else {
+                method = CoAPConstants.METHOD_POST;
+            }
+        }
+        return method;
+    }
+
+    /**
+     * Determines which method verbs the CoAP server should be restricted to 
handling.
+     *
+     * @param methodRestrict
+     * @return
+     */
+    public static String getDefaultMethodRestrict(String methodRestrict) {
+        if (ObjectHelper.isNotEmpty(methodRestrict)) {
+            return methodRestrict;
+        }
+        return CoAPConstants.METHOD_RESTRICT_ALL;
+    }
+}
diff --git 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java
index a4a17e1e673..99e46d5268f 100644
--- 
a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java
+++ 
b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java
@@ -44,37 +44,26 @@ public void process(Exchange exchange) throws Exception {
             //?default?
             ct = "application/octet-stream";
         }
-        String method = exchange.getIn().getHeader(Exchange.HTTP_METHOD, 
String.class);
-        if (method == null) {
-            method = endpoint.getCoapMethod();
-        }
-        if (method == null) {
-            Object body = exchange.getIn().getBody();
-            if (body == null) {
-                method = "GET";
-            } else {
-                method = "POST";
-            }
-        }
+        String method = CoAPHelper.getDefaultMethod(exchange, client);
         int mediaType = MediaTypeRegistry.parse(ct);
         CoapResponse response = null;
         boolean pingResponse = false;
         switch (method) {
-        case "GET":
+        case CoAPConstants.METHOD_GET:
             response = client.get();
             break;
-        case "DELETE":
+        case CoAPConstants.METHOD_DELETE:
             response = client.delete();
             break;
-        case "POST":
+        case CoAPConstants.METHOD_POST:
             byte[] bodyPost = exchange.getIn().getBody(byte[].class);
             response = client.post(bodyPost, mediaType);
             break;
-        case "PUT":
+        case CoAPConstants.METHOD_PUT:
             byte[] bodyPut = exchange.getIn().getBody(byte[].class);
             response = client.put(bodyPut, mediaType);
             break;
-        case "PING":
+        case CoAPConstants.METHOD_PING:
             pingResponse = client.ping();
             break;
         default:
@@ -87,8 +76,8 @@ public void process(Exchange exchange) throws Exception {
             resp.setHeader(org.apache.camel.Exchange.CONTENT_TYPE, mt);
             resp.setBody(response.getPayload());
         }
-        
-        if (method.equalsIgnoreCase("PING")) {
+
+        if (method.equalsIgnoreCase(CoAPConstants.METHOD_PING)) {
             Message resp = exchange.getOut();
             resp.setBody(pingResponse);
         }
@@ -96,7 +85,7 @@ public void process(Exchange exchange) throws Exception {
 
     private synchronized CoapClient getClient(Exchange exchange) {
         if (client == null) {
-            URI uri = exchange.getIn().getHeader("coapUri", URI.class);
+            URI uri = exchange.getIn().getHeader(CoAPConstants.COAP_URI, 
URI.class);
             if (uri == null) {
                 uri = endpoint.getUri();
             }
diff --git 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTest.java
 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTest.java
index 71c538d9246..7e448849322 100644
--- 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTest.java
+++ 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.coap;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
@@ -24,6 +25,7 @@
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.eclipse.californium.core.CoapClient;
 import org.eclipse.californium.core.CoapResponse;
+import org.eclipse.californium.core.coap.MediaTypeRegistry;
 import org.eclipse.californium.core.network.config.NetworkConfig;
 import org.junit.Test;
 
@@ -42,8 +44,9 @@ public void testCoAP() throws Exception {
         
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(1);
-        mock.expectedBodiesReceived("Hello");
-        sender.sendBody("Hello");
+        mock.expectedBodiesReceived("Hello Camel CoAP");
+        mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, 
MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM));
+        sender.sendBody("Camel CoAP");
         assertMockEndpointsSatisfied();
     }
 
diff --git 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodRestrictTest.java
 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodRestrictTest.java
new file mode 100644
index 00000000000..c65d3bf9819
--- /dev/null
+++ 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodRestrictTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.coap;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.californium.core.network.config.NetworkConfig;
+import org.junit.Test;
+
+public class CoAPMethodRestrictTest extends CamelTestSupport {
+
+    private static final int PORT = AvailablePortFinder.getNextAvailable();
+
+    @Test
+    public void testDefaultCoAPMethodRestrict() {
+        NetworkConfig.createStandardWithoutFile();
+
+        // All request methods should be valid on this endpoint
+        assertCoAPMethodRestrictResponse("/test", 
CoAPConstants.METHOD_RESTRICT_ALL, "GET: /test");
+    }
+
+    @Test
+    public void testSpecifiedCoAPMethodRestrict() {
+        NetworkConfig.createStandardWithoutFile();
+
+        // Only GET is valid for /test/a
+        assertCoAPMethodRestrictResponse("/test/a", "GET", "GET: /test/a");
+
+        // Only DELETE is valid for /test/a/b
+        assertCoAPMethodRestrictResponse("/test/a/b", "DELETE", "DELETE: 
/test/a/b");
+
+        // Only DELETE & GET are valid for /test/a/b/c
+        assertCoAPMethodRestrictResponse("/test/a/b/c", "DELETE,GET", "DELETE 
& GET: /test/a/b/c");
+
+        // Only GET is valid for /test/b
+        assertCoAPMethodRestrictResponse("/test/b", "GET", "GET: /test/b");
+    }
+
+    private void assertCoAPMethodRestrictResponse(String path, String 
methodRestrict, String expectedResponse) {
+        for (String method : CoAPConstants.METHOD_RESTRICT_ALL.split(",")) {
+            String result = template.requestBodyAndHeader("coap://localhost:" 
+ PORT + path, null, CoAPConstants.COAP_METHOD, method, String.class);
+            if (methodRestrict.contains(method)) {
+                assertEquals(expectedResponse, result);
+            } else {
+                assertEquals("", result);
+            }
+        }
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                fromF("coap://localhost:%d/test", PORT)
+                        .setBody(constant("GET: /test"));
+
+                fromF("coap://localhost:%d/test/a?coapMethodRestrict=GET", 
PORT)
+                        .setBody(constant("GET: /test/a"));
+
+                
fromF("coap://localhost:%d/test/a/b?coapMethodRestrict=DELETE", PORT)
+                        .setBody(constant("DELETE: /test/a/b"));
+
+                
fromF("coap://localhost:%d/test/a/b/c?coapMethodRestrict=DELETE,GET", PORT)
+                        .setBody(constant("DELETE & GET: /test/a/b/c"));
+
+                fromF("coap://localhost:%d/test/b?coapMethodRestrict=GET", 
PORT)
+                        .setBody(constant("GET: /test/b"));
+            }
+        };
+    }
+}
diff --git 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodTest.java 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodTest.java
new file mode 100644
index 00000000000..142e8a71d32
--- /dev/null
+++ 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPMethodTest.java
@@ -0,0 +1,70 @@
+/**
+ * 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.coap;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.californium.core.network.config.NetworkConfig;
+import org.junit.Test;
+
+public class CoAPMethodTest extends CamelTestSupport {
+
+    private static final int PORT = AvailablePortFinder.getNextAvailable();
+
+    @Test
+    public void testCoAPMethodDefaultGet() {
+        NetworkConfig.createStandardWithoutFile();
+
+        // No body means GET
+        String result = template.requestBody("coap://localhost:" + PORT + 
"/test/a", null, String.class);
+        assertEquals("GET: /test/a", result);
+    }
+
+    @Test
+    public void testCoAPMethodDefaultPost() {
+        NetworkConfig.createStandardWithoutFile();
+
+        // Providing a body means POST
+        String result = template.requestBody("coap://localhost:" + PORT + 
"/test/b", "Camel", String.class);
+        assertEquals("Hello Camel", result);
+    }
+
+    @Test
+    public void testCoAPMethodHeader() {
+        String result = template.requestBodyAndHeader("coap://localhost:" + 
PORT + "/test/c", null, CoAPConstants.COAP_METHOD, "DELETE", String.class);
+        assertEquals("DELETE: /test/c", result);
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                fromF("coap://localhost:%d/test/a?coapMethodRestrict=GET", 
PORT)
+                        .setBody(constant("GET: /test/a"));
+
+                fromF("coap://localhost:%d/test/b?coapMethodRestrict=POST", 
PORT)
+                        .setBody(simple("Hello ${body}"));
+
+                fromF("coap://localhost:%d/test/c?coapMethodRestrict=DELETE", 
PORT)
+                        .setBody(constant("DELETE: /test/c"));
+            }
+        };
+    }
+}
diff --git 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPPingTest.java 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPPingTest.java
index 3939c8b8b1b..c488d50f1db 100644
--- 
a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPPingTest.java
+++ 
b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPPingTest.java
@@ -37,7 +37,7 @@ public void testCoAP() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(1);
         mock.expectedBodiesReceived(true);
-        sender.sendBody("Hello");
+        sender.sendBodyAndHeader("Hello", CoAPConstants.COAP_METHOD, 
CoAPConstants.METHOD_PING);
         assertMockEndpointsSatisfied();
     }
 
@@ -46,12 +46,12 @@ protected RouteBuilder createRouteBuilder() throws 
Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception { 
-                from("coap://localhost:" + PORT + 
"/TestResource?coapMethod=PING")
+                from("coap://localhost:" + PORT + "/TestResource")
                     .to("log:exch")
                     .transform(body().convertTo(Boolean.class))
                     .to("log:exch");
                 
-                from("direct:start").to("coap://localhost:" + PORT + 
"/TestResource?coapMethod=PING").to("mock:result");
+                from("direct:start").to("coap://localhost:" + PORT + 
"/TestResource").to("mock:result");
             }
         };
     }


 

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


> Enhance CoAP producer to set a response code header
> ---------------------------------------------------
>
>                 Key: CAMEL-12030
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12030
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-coap
>            Reporter: James Netherton
>            Assignee: James Netherton
>            Priority: Minor
>             Fix For: 2.21.0
>
>
> Currently the CoAP producer only sets a CONTENT_TYPE header. It'd be useful 
> to also have the status code set on the exchange.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to