This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers in repository https://gitbox.apache.org/repos/asf/camel.git
commit f5d4f8b70541fdcf59119a2b0782f7f51aa061b2 Author: Nicolas Filotto <[email protected]> AuthorDate: Thu Mar 17 14:19:46 2022 +0100 CAMEL-17792: Add doc about the message headers of camel-coap --- .../resources/org/apache/camel/coap/coap+tcp.json | 6 ++++++ .../resources/org/apache/camel/coap/coap.json | 6 ++++++ .../resources/org/apache/camel/coap/coaps+tcp.json | 6 ++++++ .../resources/org/apache/camel/coap/coaps.json | 6 ++++++ .../camel-coap/src/main/docs/coap-component.adoc | 18 +++--------------- .../java/org/apache/camel/coap/CamelCoapResource.java | 4 ++-- .../main/java/org/apache/camel/coap/CoAPConstants.java | 13 +++++++++++++ .../main/java/org/apache/camel/coap/CoAPEndpoint.java | 2 +- .../main/java/org/apache/camel/coap/CoAPProducer.java | 4 ++-- .../apache/camel/coap/CoAPComponentTLSTestBase.java | 18 +++++++++--------- .../java/org/apache/camel/coap/CoAPComponentTest.java | 5 ++--- .../apache/camel/coap/CoAPRestComponentTestBase.java | 5 ++--- 12 files changed, 58 insertions(+), 35 deletions(-) diff --git a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap+tcp.json b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap+tcp.json index 59d4ef1..4d75e37 100644 --- a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap+tcp.json +++ b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap+tcp.json @@ -27,6 +27,12 @@ "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] }, + "headers": { + "CamelCoapMethod": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The request method that the CoAP producer should use when calling the target CoAP\nserver URI. Valid options are DELETE, GET, PING, POST & PUT." }, + "CamelCoapResponseCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The CoAP response code sent by the external server. See RFC 7252 for details\nof what each code means." }, + "CamelCoapUri": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint." }, + "Content-Type": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content type" } + }, "properties": { "uri": { "kind": "path", "displayName": "Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "description": "The URI for the CoAP endpoint" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "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 m [...] diff --git a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap.json b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap.json index ea77364..11495aa 100644 --- a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap.json +++ b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coap.json @@ -27,6 +27,12 @@ "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] }, + "headers": { + "CamelCoapMethod": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The request method that the CoAP producer should use when calling the target CoAP\nserver URI. Valid options are DELETE, GET, PING, POST & PUT." }, + "CamelCoapResponseCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The CoAP response code sent by the external server. See RFC 7252 for details\nof what each code means." }, + "CamelCoapUri": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint." }, + "Content-Type": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content type" } + }, "properties": { "uri": { "kind": "path", "displayName": "Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "description": "The URI for the CoAP endpoint" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "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 m [...] diff --git a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps+tcp.json b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps+tcp.json index 6c0da841..66aa21e 100644 --- a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps+tcp.json +++ b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps+tcp.json @@ -27,6 +27,12 @@ "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] }, + "headers": { + "CamelCoapMethod": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The request method that the CoAP producer should use when calling the target CoAP\nserver URI. Valid options are DELETE, GET, PING, POST & PUT." }, + "CamelCoapResponseCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The CoAP response code sent by the external server. See RFC 7252 for details\nof what each code means." }, + "CamelCoapUri": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint." }, + "Content-Type": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content type" } + }, "properties": { "uri": { "kind": "path", "displayName": "Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "description": "The URI for the CoAP endpoint" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "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 m [...] diff --git a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps.json b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps.json index e9a8546..e668fb9 100644 --- a/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps.json +++ b/components/camel-coap/src/generated/resources/org/apache/camel/coap/coaps.json @@ -27,6 +27,12 @@ "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] }, + "headers": { + "CamelCoapMethod": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The request method that the CoAP producer should use when calling the target CoAP\nserver URI. Valid options are DELETE, GET, PING, POST & PUT." }, + "CamelCoapResponseCode": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The CoAP response code sent by the external server. See RFC 7252 for details\nof what each code means." }, + "CamelCoapUri": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint." }, + "Content-Type": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The content type" } + }, "properties": { "uri": { "kind": "path", "displayName": "Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "description": "The URI for the CoAP endpoint" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "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 m [...] diff --git a/components/camel-coap/src/main/docs/coap-component.adoc b/components/camel-coap/src/main/docs/coap-component.adoc index 528f18a..94737c5 100644 --- a/components/camel-coap/src/main/docs/coap-component.adoc +++ b/components/camel-coap/src/main/docs/coap-component.adoc @@ -62,21 +62,9 @@ include::partial$component-endpoint-options.adoc[] // 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. - -|`CamelCoapResponseCode` |`String` |The CoAP response code sent by the external server. See RFC 7252 for details -of what each code means. - -|`CamelCoapUri` |`String` |The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint. -|======================================================================= +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END === Configuring the CoAP producer request method 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 5045117..a938396 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 @@ -111,7 +111,7 @@ final class CamelCoapResource extends CoapResource { if (options.hasContentFormat()) { String mt = MediaTypeRegistry.toString(options.getContentFormat()); - camelExchange.getIn().setHeader(org.apache.camel.Exchange.CONTENT_TYPE, mt); + camelExchange.getIn().setHeader(CoAPConstants.CONTENT_TYPE, mt); } List<String> path = exchange.getRequest().getOptions().getUriPath(); @@ -140,7 +140,7 @@ final class CamelCoapResource extends CoapResource { consumer.getProcessor().process(camelExchange); Message target = camelExchange.getMessage(); - int format = MediaTypeRegistry.parse(target.getHeader(org.apache.camel.Exchange.CONTENT_TYPE, String.class)); + int format = MediaTypeRegistry.parse(target.getHeader(CoAPConstants.CONTENT_TYPE, String.class)); cexchange.respond(ResponseCode.CONTENT, target.getBody(byte[].class), format); } catch (Exception e) { 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 index 042f1c2..211bdb7 100644 --- 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 @@ -16,6 +16,9 @@ */ package org.apache.camel.coap; +import org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; + /** * CoAP component constants */ @@ -38,7 +41,17 @@ public interface CoAPConstants { /** * CoAP exchange header names */ + @Metadata(description = "The request method that the CoAP producer should use when calling the target CoAP\n" + + "server URI. Valid options are DELETE, GET, PING, POST & PUT.", + javaType = "String") String COAP_METHOD = "CamelCoapMethod"; + @Metadata(description = "The CoAP response code sent by the external server. See RFC 7252 for details\n" + + "of what each code means.", + javaType = "String") String COAP_RESPONSE_CODE = "CamelCoapResponseCode"; + @Metadata(description = "The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint.", + javaType = "String") String COAP_URI = "CamelCoapUri"; + @Metadata(description = "The content type", javaType = "String") + String CONTENT_TYPE = Exchange.CONTENT_TYPE; } 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 82119b5..3814cb9 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 @@ -51,7 +51,7 @@ import org.eclipse.californium.scandium.dtls.rpkstore.TrustedRpkStore; * Send and receive messages to/from COAP capable devices. */ @UriEndpoint(firstVersion = "2.16.0", scheme = "coap,coaps,coap+tcp,coaps+tcp", title = "CoAP", syntax = "coap:uri", - category = { Category.IOT }) + category = { Category.IOT }, headersClass = CoAPConstants.class) public class CoAPEndpoint extends DefaultEndpoint { @UriPath private URI uri; 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 bcbd70a..fc60f19 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 @@ -49,7 +49,7 @@ public class CoAPProducer extends DefaultProducer { @Override public void process(Exchange exchange) throws Exception { CoapClient client = getClient(exchange); - String ct = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); + String ct = exchange.getIn().getHeader(CoAPConstants.CONTENT_TYPE, String.class); if (ct == null) { // ?default? ct = "application/octet-stream"; @@ -83,7 +83,7 @@ public class CoAPProducer extends DefaultProducer { if (response != null) { Message resp = exchange.getOut(); String mt = MediaTypeRegistry.toString(response.getOptions().getContentFormat()); - resp.setHeader(org.apache.camel.Exchange.CONTENT_TYPE, mt); + resp.setHeader(CoAPConstants.CONTENT_TYPE, mt); resp.setHeader(CoAPConstants.COAP_RESPONSE_CODE, response.getCode().toString()); resp.setBody(response.getPayload()); } diff --git a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTestBase.java b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTestBase.java index 27b9c71..05a165a 100644 --- a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTestBase.java +++ b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTestBase.java @@ -59,7 +59,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:start", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -87,7 +87,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:selfsigned", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -99,7 +99,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:clientauth", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -119,7 +119,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:ciphersuites", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -132,7 +132,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:rpk", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -166,7 +166,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:rpkclientauth", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -180,7 +180,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:psk", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -194,7 +194,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:pskciphersuite", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); @@ -208,7 +208,7 @@ abstract class CoAPComponentTLSTestBase extends CamelTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sendBodyAndHeader("direct:pskx509", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); 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 0c60ced..6bd9ba9 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,7 +16,6 @@ */ 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; @@ -49,7 +48,7 @@ public class CoAPComponentTest extends CoAPTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); sender.sendBody("Camel CoAP"); @@ -61,7 +60,7 @@ public class CoAPComponentTest extends CoAPTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived("Hello Camel CoAP"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, + mock.expectedHeaderReceived(CoAPConstants.CONTENT_TYPE, MediaTypeRegistry.toString(MediaTypeRegistry.APPLICATION_OCTET_STREAM)); mock.expectedHeaderReceived(CoAPConstants.COAP_RESPONSE_CODE, CoAP.ResponseCode.CONTENT.toString()); tcpSender.sendBody("Camel CoAP"); diff --git a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTestBase.java b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTestBase.java index 9e9e4f20..95c4a91 100644 --- a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTestBase.java +++ b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTestBase.java @@ -19,7 +19,6 @@ package org.apache.camel.coap; import java.io.IOException; import java.security.GeneralSecurityException; -import org.apache.camel.Exchange; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; @@ -140,9 +139,9 @@ abstract class CoAPRestComponentTestBase extends CamelTestSupport { from("direct:post1").process(exchange -> { String id = exchange.getIn().getHeader("id", String.class); - String ct = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); + String ct = exchange.getIn().getHeader(CoAPConstants.CONTENT_TYPE, String.class); exchange.getMessage().setBody("Hello " + id + ": " + exchange.getIn().getBody(String.class)); - exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, ct); + exchange.getMessage().setHeader(CoAPConstants.CONTENT_TYPE, ct); }); from("direct:start").toF(getClientURI(), coapport).to("mock:result");
