本文整理汇总了Java中org.apache.camel.ExchangePattern.InOut方法的典型用法代码示例。如果您正苦于以下问题:Java ExchangePattern.InOut方法的具体用法?Java ExchangePattern.InOut怎么用?Java ExchangePattern.InOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.ExchangePattern
的用法示例。
在下文中一共展示了ExchangePattern.InOut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void execute() throws Exception {
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "ReplaceSm");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, new Date(2222222));
exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
exchange.getIn().setBody("new short message body");
session.replaceShortMessage(eq("1"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"), eq("-300101001831100+"), eq("-300101003702200+"),
eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq((byte) 0), aryEq("new short message body".getBytes()));
replay(session);
command.execute(exchange);
verify(session);
assertEquals("1", exchange.getOut().getHeader(SmppConstants.ID));
}
示例2: prepareExchange
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
private org.apache.camel.Exchange prepareExchange(Exchange cxfExchange, Method method,
Object[] paramArray, Object response) {
ExchangePattern ep = ExchangePattern.InOut;
if (method.getReturnType() == Void.class) {
ep = ExchangePattern.InOnly;
}
final org.apache.camel.Exchange camelExchange = endpoint.createExchange(ep);
if (response != null) {
camelExchange.getOut().setBody(response);
}
CxfRsBinding binding = endpoint.getBinding();
binding.populateExchangeFromCxfRsRequest(cxfExchange, camelExchange, method, paramArray);
// REVISIT: It can be done inside a binding but a propagateContext would need to be passed along as
// the CXF in message property. Question: where should this property name be set up ?
if (endpoint.isPropagateContexts()) {
camelExchange.setProperty(UriInfo.class.getName(), new UriInfoImpl(cxfExchange.getInMessage()));
camelExchange.setProperty(Request.class.getName(), new RequestImpl(cxfExchange.getInMessage()));
camelExchange.setProperty(HttpHeaders.class.getName(), new HttpHeadersImpl(cxfExchange.getInMessage()));
camelExchange.setProperty(SecurityContext.class.getName(), new SecurityContextImpl(cxfExchange.getInMessage()));
}
return camelExchange;
}
示例3: execute
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void execute() throws Exception {
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "CancelSm");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setHeader(SmppConstants.SERVICE_TYPE, "XXX");
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR, "1919");
session.cancelShortMessage("XXX", "1", TypeOfNumber.NATIONAL, NumberingPlanIndicator.NATIONAL, "1818", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.INTERNET, "1919");
replay(session);
command.execute(exchange);
verify(session);
assertEquals("1", exchange.getOut().getHeader(SmppConstants.ID));
}
示例4: testInvokingSimpleServerWithParams
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void testInvokingSimpleServerWithParams() throws Exception {
// START SNIPPET: sending
Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
final List<String> params = new ArrayList<String>();
// Prepare the request message for the camel-cxf procedure
params.add(TEST_MESSAGE);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);
Exchange exchange = template.send("direct:EndpointA", senderExchange);
org.apache.camel.Message out = exchange.getOut();
// The response message's body is an MessageContentsList which first element is the return value of the operation,
// If there are some holder parameters, the holder parameter will be filled in the reset of List.
// The result will be extract from the MessageContentsList with the String class type
MessageContentsList result = (MessageContentsList)out.getBody();
LOG.info("Received output text: " + result.get(0));
Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
assertEquals("We should get the response context here", "UTF-8", responseContext.get(org.apache.cxf.message.Message.ENCODING));
assertEquals("Reply body on Camel is wrong", "echo " + TEST_MESSAGE, result.get(0));
// END SNIPPET: sending
}
示例5: bodyWithSmscDefaultDataCodingNarrowedToCharset
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void bodyWithSmscDefaultDataCodingNarrowedToCharset() throws Exception {
final byte dataCoding = (byte)0x00; /* SMSC-default */
byte[] body = {(byte)0xFF, 'A', 'B', (byte)0x00, (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF};
byte[] bodyNarrowed = {'?', 'A', 'B', '\0', '?', (byte)0x7F, 'C', '?'};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
exchange.getIn().setHeader(SmppConstants.DATA_CODING, dataCoding);
exchange.getIn().setBody(body);
Address[] destAddrs = new Address[] {
new Address(TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
"1717")
};
expect(session.submitMultiple(eq("CMT"),
eq(TypeOfNumber.UNKNOWN),
eq(NumberingPlanIndicator.UNKNOWN),
eq("1616"),
aryEq(destAddrs),
eq(new ESMClass()),
eq((byte) 0),
eq((byte) 1),
(String) isNull(),
(String) isNull(),
eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)),
eq(ReplaceIfPresentFlag.DEFAULT),
eq(DataCodings.newInstance(dataCoding)),
eq((byte) 0),
aryEq(bodyNarrowed)))
.andReturn(new SubmitMultiResult("1"));
replay(session);
command.execute(exchange);
verify(session);
}
示例6: runTest
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Exchange runTest(String uri) throws Exception {
MockEndpoint mr = getMockEndpoint("mock:run");
MockEndpoint ma = getMockEndpoint("mock:a");
MockEndpoint mb = getMockEndpoint("mock:b");
mr.expectedMessageCount(0);
ma.expectedMessageCount(0);
mb.expectedMessageCount(1);
Exchange request = new DefaultExchange(context, ExchangePattern.InOut);
request.getIn().setBody("Hello World");
Exchange result = template.send(uri, request);
assertMockEndpointsSatisfied();
return result;
}
示例7: bodyWithSMPP8bitDataCodingNotModified
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void bodyWithSMPP8bitDataCodingNotModified() throws Exception {
final byte dataCoding = (byte)0x04; /* SMPP 8-bit */
byte[] body = {(byte)0xFF, 'A', 'B', (byte)0x00, (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
exchange.getIn().setHeader(SmppConstants.DATA_CODING, dataCoding);
exchange.getIn().setBody(body);
Address[] destAddrs = new Address[] {
new Address(TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
"1717")
};
expect(session.submitMultiple(eq("CMT"),
eq(TypeOfNumber.UNKNOWN),
eq(NumberingPlanIndicator.UNKNOWN),
eq("1616"),
aryEq(destAddrs),
eq(new ESMClass()),
eq((byte) 0),
eq((byte) 1),
(String) isNull(),
(String) isNull(),
eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)),
eq(ReplaceIfPresentFlag.DEFAULT),
eq(DataCodings.newInstance(dataCoding)),
eq((byte) 0),
aryEq(body)))
.andReturn(new SubmitMultiResult("1"));
replay(session);
command.execute(exchange);
verify(session);
}
示例8: bodyWithLatin1DataCodingNarrowedToCharset
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void bodyWithLatin1DataCodingNarrowedToCharset() throws Exception {
final byte dataCoding = (byte)0x03; /* ISO-8859-1 (Latin1) */
byte[] body = {(byte)0xFF, 'A', 'B', (byte)0x00, (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF};
byte[] bodyNarrowed = {'?', 'A', 'B', '\0', '?', (byte)0x7F, 'C', '?'};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
exchange.getIn().setHeader(SmppConstants.DATA_CODING, dataCoding);
exchange.getIn().setBody(body);
Address[] destAddrs = new Address[] {
new Address(TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
"1717")
};
expect(session.submitMultiple(eq("CMT"),
eq(TypeOfNumber.UNKNOWN),
eq(NumberingPlanIndicator.UNKNOWN),
eq("1616"),
aryEq(destAddrs),
eq(new ESMClass()),
eq((byte) 0),
eq((byte) 1),
(String) isNull(),
(String) isNull(),
eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)),
eq(ReplaceIfPresentFlag.DEFAULT),
eq(DataCodings.newInstance(dataCoding)),
eq((byte) 0),
aryEq(bodyNarrowed)))
.andReturn(new SubmitMultiResult("1"));
replay(session);
command.execute(exchange);
verify(session);
}
示例9: executeWithValidityPeriodAsString
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void executeWithValidityPeriodAsString() throws Exception {
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR, Arrays.asList("1919"));
exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, "000003000000000R"); // three days
exchange.getIn().setHeader(SmppConstants.PROTOCOL_ID, (byte) 1);
exchange.getIn().setHeader(SmppConstants.PRIORITY_FLAG, (byte) 2);
exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
exchange.getIn().setHeader(SmppConstants.REPLACE_IF_PRESENT_FLAG, ReplaceIfPresentFlag.REPLACE.value());
exchange.getIn().setBody("short message body");
expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"),
aryEq(new Address[]{new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.INTERNET, "1919")}),
eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("000003000000000R"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)),
eq(ReplaceIfPresentFlag.REPLACE), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes())))
.andReturn(new SubmitMultiResult("1"));
replay(session);
command.execute(exchange);
verify(session);
assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
assertNull(exchange.getOut().getHeader(SmppConstants.ERROR));
}
示例10: eightBitDataCodingOverridesDefaultAlphabet
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void eightBitDataCodingOverridesDefaultAlphabet() throws Exception {
final byte binDataCoding = (byte)0x04; /* SMPP 8-bit */
byte[] body = {(byte)0xFF, 'A', 'B', (byte)0x00, (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
exchange.getIn().setHeader(SmppConstants.ALPHABET, Alphabet.ALPHA_DEFAULT.value());
exchange.getIn().setHeader(SmppConstants.DATA_CODING, binDataCoding);
exchange.getIn().setBody(body);
Address[] destAddrs = new Address[] {
new Address(TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
"1717")
};
expect(session.submitMultiple(eq("CMT"),
eq(TypeOfNumber.UNKNOWN),
eq(NumberingPlanIndicator.UNKNOWN),
eq("1616"),
aryEq(destAddrs),
eq(new ESMClass()),
eq((byte) 0),
eq((byte) 1),
(String) isNull(),
(String) isNull(),
eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)),
eq(ReplaceIfPresentFlag.DEFAULT),
eq(DataCodings.newInstance(binDataCoding)),
eq((byte) 0),
aryEq(body)))
.andReturn(new SubmitMultiResult("1"));
replay(session);
command.execute(exchange);
verify(session);
}
示例11: execute
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void execute() throws Exception {
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
exchange.getIn().setHeader(SmppConstants.DEST_ADDR, "1919");
exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, new Date(2222222));
exchange.getIn().setHeader(SmppConstants.PROTOCOL_ID, (byte) 1);
exchange.getIn().setHeader(SmppConstants.PRIORITY_FLAG, (byte) 2);
exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
exchange.getIn().setHeader(SmppConstants.REPLACE_IF_PRESENT_FLAG, ReplaceIfPresentFlag.REPLACE.value());
exchange.getIn().setBody("short message body");
expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"),
eq(TypeOfNumber.INTERNATIONAL), eq(NumberingPlanIndicator.INTERNET), eq("1919"),
eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("-300101003702200+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)),
eq(ReplaceIfPresentFlag.REPLACE.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes())))
.andReturn("1");
replay(session);
command.execute(exchange);
verify(session);
assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
}
示例12: getResponseMessage
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void getResponseMessage() {
Exchange inOnlyExchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOnly);
Exchange inOutExchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
assertSame(inOnlyExchange.getIn(), command.getResponseMessage(inOnlyExchange));
assertSame(inOutExchange.getOut(), command.getResponseMessage(inOutExchange));
}
示例13: createExchange
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Exchange createExchange(Protocol.Message message, Object request) {
ExchangePattern pattern = ExchangePattern.InOut;
if (message.getResponse().equals(Schema.Type.NULL)) {
pattern = ExchangePattern.InOnly;
}
Exchange exchange = createExchange(pattern);
exchange.getIn().setBody(request);
exchange.getIn().setHeader(AvroConstants.AVRO_MESSAGE_NAME, message.getName());
return exchange;
}
示例14: executeLongBody
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
@Ignore()
public void executeLongBody() throws Exception {
byte[] firstSM = new byte[]{5, 0, 3, 1, 2, 1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51};
byte[] secondSM = new byte[]{52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setBody("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901");
expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"),
eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1),
(String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()),
eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq(firstSM)))
.andReturn("1");
expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"),
eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1),
(String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()),
eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(secondSM)))
.andReturn("2");
replay(session);
command.execute(exchange);
verify(session);
assertEquals(Arrays.asList("1", "2"), exchange.getOut().getHeader(SmppConstants.ID));
assertEquals(2, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
}
示例15: executeLongBodyTruncation
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void executeLongBodyTruncation() throws Exception {
byte[] firstSM = new byte[]{49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57};
Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
exchange.getIn().setHeader(SmppConstants.ID, "1");
exchange.getIn().setHeader(SmppConstants.SPLITTING_POLICY, "TRUNCATE");
exchange.getIn().setBody("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901");
expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"),
eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1),
(String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()),
eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq(firstSM)))
.andReturn("1");
replay(session);
command.execute(exchange);
verify(session);
assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
}