@Override
    public void execute(Exchange exchange) throws SmppException {
        byte[] message = getShortMessage(exchange.getIn());

        ReplaceSm replaceSm = createReplaceSmTempate(exchange);
        replaceSm.setShortMessage(message);

        if (log.isDebugEnabled()) {
            log.debug("Sending replacement command for a short message for exchange id '{}' and message id '{}'",
                    exchange.getExchangeId(), replaceSm.getMessageId());
        }

        try {
            session.replaceShortMessage(
                    replaceSm.getMessageId(),
                    TypeOfNumber.valueOf(replaceSm.getSourceAddrTon()),
                    NumberingPlanIndicator.valueOf(replaceSm.getSourceAddrNpi()),
                    replaceSm.getSourceAddr(),
                    replaceSm.getScheduleDeliveryTime(),
                    replaceSm.getValidityPeriod(),
                    new RegisteredDelivery(replaceSm.getRegisteredDelivery()),
                    replaceSm.getSmDefaultMsgId(),
                    replaceSm.getShortMessage());
        } catch (Exception e) {
            throw new SmppException(e);
        }

        if (log.isDebugEnabled()) {
            log.debug("Sent replacement command for a short message for exchange id '{}' and message id '{}'",
                    exchange.getExchangeId(), replaceSm.getMessageId());
        }

        Message rspMsg = ExchangeHelper.getResultMessage(exchange);
        rspMsg.setHeader(SmppConstants.ID, replaceSm.getMessageId());
    }
@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");

        command.execute(exchange);

        verify(session).replaceShortMessage(eq("1"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"),
                eq("-300101001831100+"), eq("-300101003702200+"),
                eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq((byte) 0), eq("new short message body".getBytes()));

        assertEquals("1", exchange.getMessage().getHeader(SmppConstants.ID));
    }