本文整理汇总了Java中org.apache.camel.Message.getHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getHeaders方法的具体用法?Java Message.getHeaders怎么用?Java Message.getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.Message
的用法示例。
在下文中一共展示了Message.getHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCopyFromSameHeadersInstance
import org.apache.camel.Message; //导入方法依赖的package包/类
public void testCopyFromSameHeadersInstance() {
Exchange exchange = new DefaultExchange(context);
Message in = exchange.getIn();
Map<String, Object> headers = in.getHeaders();
headers.put("foo", 123);
Message out = new DefaultMessage();
out.setBody("Bye World");
out.setHeaders(headers);
out.copyFrom(in);
assertEquals(123, headers.get("foo"));
assertEquals(123, in.getHeader("foo"));
assertEquals(123, out.getHeader("foo"));
}
示例2: testEndpoint
import org.apache.camel.Message; //导入方法依赖的package包/类
@Test
public void testEndpoint() throws Exception {
mockEndpoint.reset();
mockEndpoint.expectedBodiesReceived(expectedBody);
template.sendBodyAndHeader("https://localhost:" + port + "/test", expectedBody, "Content-Type", "application/xml");
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
Assert.assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.info("Headers: " + headers);
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
}
示例3: testEndpoint
import org.apache.camel.Message; //导入方法依赖的package包/类
@Test
public void testEndpoint() throws Exception {
MockEndpoint mockEndpoint = getMockEndpoint("mock:a");
mockEndpoint.expectedBodiesReceived(expectedBody);
invokeHttpEndpoint();
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.info("Headers: " + headers);
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
}
示例4: copyFrom
import org.apache.camel.Message; //导入方法依赖的package包/类
public void copyFrom(Message that) {
if (that == this) {
// the same instance so do not need to copy
return;
}
setMessageId(that.getMessageId());
setBody(that.getBody());
setFault(that.isFault());
// the headers may be the same instance if the end user has made some mistake
// and set the OUT message with the same header instance of the IN message etc
boolean sameHeadersInstance = false;
if (hasHeaders() && that.hasHeaders() && getHeaders() == that.getHeaders()) {
sameHeadersInstance = true;
}
if (!sameHeadersInstance) {
if (hasHeaders()) {
// okay its safe to clear the headers
getHeaders().clear();
}
if (that.hasHeaders()) {
getHeaders().putAll(that.getHeaders());
}
}
copyAttachments(that);
}
示例5: clearMessageHeaders
import org.apache.camel.Message; //导入方法依赖的package包/类
protected void clearMessageHeaders(Message message) {
if (getConfiguration().getClearHeaders() != null && getConfiguration().getClearHeaders()) {
Map<String, Object> headers = message.getHeaders();
for (Field f : XmlSignatureConstants.class.getFields()) {
headers.remove(ObjectHelper.lookupConstantFieldValue(XmlSignatureConstants.class, f.getName()));
}
}
}
示例6: resolveMessageFrom
import org.apache.camel.Message; //导入方法依赖的package包/类
private Message resolveMessageFrom(final Exchange camelExchange) {
Message message = camelExchange.hasOut() ? camelExchange.getOut() : camelExchange.getIn();
// Remove the SERIALIZE_HEADER in case it was previously set
if (message.getHeaders() != null && message.getHeaders().containsKey(RabbitMQEndpoint.SERIALIZE_HEADER)) {
LOG.debug("Removing the {} header", RabbitMQEndpoint.SERIALIZE_HEADER);
message.getHeaders().remove(RabbitMQEndpoint.SERIALIZE_HEADER);
}
return message;
}
示例7: testHttpGet
import org.apache.camel.Message; //导入方法依赖的package包/类
@Test
@Ignore("ignore online tests")
public void testHttpGet() throws Exception {
MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
mockEndpoint.expectedMessageCount(1);
template.sendBody("direct:start", null);
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.debug("Headers: " + headers);
checkHeaders(headers);
String body = in.getBody(String.class);
log.debug("Body: " + body);
assertNotNull("Should have a body!", body);
assertTrue("body should contain: " + expectedText, body.contains(expectedText));
}
示例8: testEndpoint
import org.apache.camel.Message; //导入方法依赖的package包/类
@Test
public void testEndpoint() throws Exception {
// these tests does not run well on Windows
if (isPlatform("windows")) {
return;
}
MockEndpoint mockEndpointA = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
mockEndpointA.expectedBodiesReceived(expectedBody);
MockEndpoint mockEndpointB = resolveMandatoryEndpoint("mock:b", MockEndpoint.class);
mockEndpointB.expectedBodiesReceived(expectedBody);
invokeHttpEndpoint();
mockEndpointA.assertIsSatisfied();
mockEndpointB.assertIsSatisfied();
List<Exchange> list = mockEndpointA.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.info("Headers: " + headers);
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
}
示例9: verifyMockGotExpectedText
import org.apache.camel.Message; //导入方法依赖的package包/类
private void verifyMockGotExpectedText(MockEndpoint mockEndpoint, String expected) throws InterruptedException {
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
assertTrue("no headers are propagated", !headers.isEmpty());
assertEquals("body has expectedText:" + expected, expected, in.getBody());
}
示例10: testHttpClient
import org.apache.camel.Message; //导入方法依赖的package包/类
private void testHttpClient(String uri) throws Exception {
System.setProperty("HTTPClient.dontChunkRequests", "yes");
MockEndpoint mockEndpoint = getMockEndpoint("mock:a");
mockEndpoint.expectedBodiesReceived("<b>Hello World</b>");
template.requestBodyAndHeader(uri, new ByteArrayInputStream("This is a test".getBytes()), "Content-Type", "application/xml");
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.info("Headers: " + headers);
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
// should get the Content-Length
assertEquals("Should get the transfer-encoding as chunked", "chunked", headers.get("Transfer-Encoding"));
// remove the system property
System.clearProperty("HTTPClient.dontChunkRequests");
}
示例11: processSoapHeader
import org.apache.camel.Message; //导入方法依赖的package包/类
/**
* If applicable this method adds a SOAP header.
*
* @param inOrOut
* @param soapMessage
*/
protected void processSoapHeader(Message inOrOut, SoapMessage soapMessage) {
boolean isHeaderAvailable = inOrOut != null && inOrOut.getHeaders() != null && !inOrOut.getHeaders().isEmpty();
if (isHeaderAvailable) {
doProcessSoapHeader(inOrOut, soapMessage);
}
}
示例12: doProcessSoapHeader
import org.apache.camel.Message; //导入方法依赖的package包/类
/**
* The SOAP header is populated from exchange.getOut().getHeaders() if this
* class is used by the consumer or exchange.getIn().getHeaders() if this
* class is used by the producer. If .getHeaders() contains under a certain
* key a value with the QName object, it is directly added as a new header
* element. If it contains only a String value, it is transformed into a
* header attribute. Following headers are excluded:
*/
protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {
SoapHeader soapHeader = soapMessage.getSoapHeader();
Map<String, Object> headers = inOrOut.getHeaders();
HashSet<String> headerKeySet = new HashSet<String>(headers.keySet());
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION);
headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION);
headerKeySet.remove(BREADCRUMB_ID);
for (String name : headerKeySet) {
Object value = headers.get(name);
if (value instanceof QName) {
soapHeader.addHeaderElement((QName)value);
} else {
if (value instanceof String) {
soapHeader.addAttribute(new QName(name), value + "");
}
}
}
}
示例13: clearMessageHeaders
import org.apache.camel.Message; //导入方法依赖的package包/类
protected void clearMessageHeaders(Message in) {
if (config.isClearHeaders()) {
Map<String, Object> headers = in.getHeaders();
for (Field f : DigitalSignatureConstants.class.getFields()) {
headers.remove(ObjectHelper.lookupConstantFieldValue(DigitalSignatureConstants.class, f.getName()));
}
}
}
示例14: testHttpGetConnectionClose
import org.apache.camel.Message; //导入方法依赖的package包/类
@Test
@Ignore("ignore online tests")
public void testHttpGetConnectionClose() throws Exception {
MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
mockEndpoint.expectedMessageCount(1);
template.sendBody("direct:start", null);
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.debug("Headers: " + headers);
checkHeaders(headers);
String body = in.getBody(String.class);
log.debug("Body: " + body);
assertNotNull("Should have a body!", body);
assertTrue("body should contain: " + expectedText, body.contains(expectedText));
}
示例15: process
import org.apache.camel.Message; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Map<String, Object> headers = in.getHeaders();
headers.put("GitHubPullRequest", latestPullRequestNumber);
}