@Override
    public void execute(Exchange exchange) throws SmppException {
        QuerySm querySm = createQuerySm(exchange);

        if (log.isDebugEnabled()) {
            log.debug("Querying for a short message for exchange id '{}' and message id '{}'...",
                    exchange.getExchangeId(), querySm.getMessageId());
        }

        QuerySmResult querySmResult;
        try {
            querySmResult = session.queryShortMessage(
                    querySm.getMessageId(),
                    TypeOfNumber.valueOf(querySm.getSourceAddrTon()),
                    NumberingPlanIndicator.valueOf(querySm.getSourceAddrNpi()),
                    querySm.getSourceAddr());
        } catch (Exception e) {
            throw new SmppException(e);
        }

        if (log.isDebugEnabled()) {
            log.debug("Query for a short message for exchange id '{}' and message id '{}'",
                    exchange.getExchangeId(), querySm.getMessageId());
        }

        Message message = ExchangeHelper.getResultMessage(exchange);
        message.setHeader(SmppConstants.ID, querySm.getMessageId());
        message.setHeader(SmppConstants.ERROR, querySmResult.getErrorCode());
        message.setHeader(SmppConstants.FINAL_DATE, SmppUtils.string2Date(querySmResult.getFinalDate()));
        message.setHeader(SmppConstants.MESSAGE_STATE, querySmResult.getMessageState().name());
    }
@Test
    public void executeWithConfigurationData() throws Exception {
        Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
        exchange.getIn().setHeader(SmppConstants.COMMAND, "QuerySm");
        exchange.getIn().setHeader(SmppConstants.ID, "1");
        when(session.queryShortMessage("1", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1616"))
                .thenReturn(new QuerySmResult("-300101010000004+", MessageState.DELIVERED, (byte) 0));

        command.execute(exchange);

        assertEquals("1", exchange.getMessage().getHeader(SmppConstants.ID));
        assertEquals("DELIVERED", exchange.getMessage().getHeader(SmppConstants.MESSAGE_STATE));
        assertEquals((byte) 0, exchange.getMessage().getHeader(SmppConstants.ERROR));
        assertNotNull(exchange.getMessage().getHeader(SmppConstants.FINAL_DATE));
    }