當前位置: 首頁>>代碼示例>>Java>>正文


Java DeliverSM類代碼示例

本文整理匯總了Java中ie.omk.smpp.message.DeliverSM的典型用法代碼示例。如果您正苦於以下問題:Java DeliverSM類的具體用法?Java DeliverSM怎麽用?Java DeliverSM使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DeliverSM類屬於ie.omk.smpp.message包,在下文中一共展示了DeliverSM類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSendRequests_BoundHandler_UnsupportedOperationException

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendRequests_BoundHandler_UnsupportedOperationException() throws BadCommandIDException, IOException {
    when(smppConnectionPool.getConnectionHandlers()).thenReturn(Collections.singletonList(mockedHandler));
    when(smppReceiverHelper.newInstance(eq(SMPPPacket.DELIVER_SM))).thenReturn(new DeliverSM());
    SMSMessage message = new SMSMessage();
    message.setId(100L);
    message.setSendDate(new Date());
    message.setStatus(MessageStatus.NEW_MESSAGE_STATE);
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.singletonList(message));
    doThrow(new UnsupportedOperationException()).when(mockedHandler).sendRequest(any(SMPPRequest.class));

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(1)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(1)).close(same(mockedHandler));
    verify(mockedHandler, times(1)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:18,代碼來源:DeliverSMSenderTaskTest.java

示例2: testSendRequests_BoundHandler_BadCommandIDException

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendRequests_BoundHandler_BadCommandIDException() throws BadCommandIDException, IOException {
    when(smppConnectionPool.getConnectionHandlers()).thenReturn(Collections.singletonList(mockedHandler));
    when(smppReceiverHelper.newInstance(eq(SMPPPacket.DELIVER_SM))).thenThrow(new BadCommandIDException());
    SMSMessage message = new SMSMessage();
    message.setId(100L);
    message.setSendDate(new Date());
    message.setStatus(MessageStatus.NEW_MESSAGE_STATE);
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.singletonList(message));

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(1)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(1)).close(same(mockedHandler));
    verify(mockedHandler, times(0)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:17,代碼來源:DeliverSMSenderTaskTest.java

示例3: testSendRequests_BoundHandler_IOException

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendRequests_BoundHandler_IOException() throws BadCommandIDException, IOException {
    when(smppConnectionPool.getConnectionHandlers()).thenReturn(Collections.singletonList(mockedHandler));
    when(smppReceiverHelper.newInstance(eq(SMPPPacket.DELIVER_SM))).thenReturn(new DeliverSM());
    doThrow(new IOException()).when(mockedHandler).sendRequest(any(SMPPRequest.class));
    SMSMessage message = new SMSMessage();
    message.setId(100L);
    message.setSendDate(new Date());
    message.setStatus(MessageStatus.NEW_MESSAGE_STATE);
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.singletonList(message));

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(1)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(1)).close(same(mockedHandler));
    verify(mockedHandler, times(1)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:18,代碼來源:DeliverSMSenderTaskTest.java

示例4: testSendRequests_BoundHandler_AnyOtherException

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendRequests_BoundHandler_AnyOtherException() throws BadCommandIDException, IOException {
    when(smppConnectionPool.getConnectionHandlers()).thenReturn(Collections.singletonList(mockedHandler));
    when(smppReceiverHelper.newInstance(eq(SMPPPacket.DELIVER_SM))).thenReturn(new DeliverSM());
    doThrow(new NullPointerException()).when(mockedHandler).sendRequest(any(SMPPRequest.class));
    SMSMessage message = new SMSMessage();
    message.setId(100L);
    message.setSendDate(new Date());
    message.setStatus(MessageStatus.MESSAGE_WAS_DELIVERED);
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.singletonList(message));

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(1)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(1)).close(same(mockedHandler));
    verify(mockedHandler, times(1)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:18,代碼來源:DeliverSMSenderTaskTest.java

示例5: executeSenderForHandler

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Override
public void executeSenderForHandler(SmppConnectionHandler handler) throws BadCommandIDException, IOException {
    log.debug("Executing tasks for handler " + handler);
    if (handler.isNotBound()) {
        log.debug("Skip processing because handler is not in bound state");
        return;
    }
    List<SMSMessage> messages = getSmsCenterService().getUpdatedMessages(handler.getUser(), DELIVER_SM_COUNT);
    log.debug(messages.size() + " messages have been found with informed flag = 0");
    for (SMSMessage message : messages) {
        StringBuilder b = new StringBuilder("id:");
        String leftPadedId = StringUtils.leftPad(String.valueOf(message.getId()), SMS_ID_LENGTH, "0");
        b.append(leftPadedId);
        b.append(" sub:000 dlvrd:000 submit date:");
        b.append(dateFormat.format(message.getSendDate().getTime()));
        b.append(" done date:");
        b.append(dateFormat.format(message.getSendDate().getTime()));
        b.append(" stat:");
        switch (message.getStatus()) {
        case MESSAGE_WAS_DELIVERED:
            b.append("DELIVRD");
            break;
        default:
            b.append("UNDELIV");
            break;
        }
        b.append(" err:000");
        b.append(" Text:" + StringUtils.left(message.getText(), SMS_TEXT_LENGTH));
        DeliverSM delSM = (DeliverSM) getSmppReceiverHelper().newInstance(SMPPPacket.DELIVER_SM);
        delSM.setSequenceNum(message.getId().intValue());
        delSM.setMessageText(b.toString());
        delSM.setEsmClass(SMPPPacket.SMC_RECEIPT);
        delSM.setOptionalParameter(Tag.MESSAGE_STATE, message.getStatus().getDbValue());
        delSM.setOptionalParameter(Tag.RECEIPTED_MESSAGE_ID, String.valueOf(message.getId()));
        handler.sendRequest(delSM);
    }
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:38,代碼來源:DeliverSMSenderTask.java

示例6: deliverSM

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Override
public void deliverSM(Connection source, DeliverSM dm) {
    log.debug("DeliverSM has been received:\n" + SmppPacketUtils.toString(dm));
    String messageText = dm.getMessageText();
    if (StringUtils.isBlank(messageText)) {
        return;
    }
    String smscId = "";
    Object stateObj = dm.getOptionalParameter(Tag.MESSAGE_STATE);
    Object smscIdObj = dm.getOptionalParameter(Tag.RECEIPTED_MESSAGE_ID);
    MessageStatus messageStatus = null;
    if ((stateObj == null) || (smscIdObj == null)) {
        Matcher textMatcher = SMPPPACKET_PATTERN.matcher(messageText);
        if (textMatcher.matches()) {
            smscId = textMatcher.group(1);
            messageStatus = messageStatusConverter.convertToMessageStatus(textMatcher.group(2));
        }
    } else {
        smscId = (String) smscIdObj;
        messageStatus = messageStatusConverter.convertToMessageStatus((Integer) stateObj);
    }
    if (messageStatus != null) {
        smscId = StringUtils.stripStart(smscId, "0");
        SMSMessage message = smsMapper.getMessageBySmscId(channel, smscId);
        if (message != null) {
            message.setStatus(messageStatus);
            smsMapper.update(message);
        }
    } else {
        log.warn("Wrong format of DELIVER_SM packet");
    }
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:33,代碼來源:SmppEventListener.java

示例7: testSendEnquireLinks_BoundHandler_NoMessages

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendEnquireLinks_BoundHandler_NoMessages() throws BadCommandIDException, IOException {
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.<SMSMessage> emptyList());

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(0)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(0)).close(same(mockedHandler));
    verify(mockedHandler, times(0)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:11,代碼來源:DeliverSMSenderTaskTest.java

示例8: testSendRequests_Ok

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testSendRequests_Ok() throws BadCommandIDException, IOException {
    when(smppConnectionPool.getConnectionHandlers()).thenReturn(Collections.singletonList(mockedHandler));
    when(smppReceiverHelper.newInstance(eq(SMPPPacket.DELIVER_SM))).thenReturn(new DeliverSM());
    final SMSMessage message = new SMSMessage();
    message.setId(100L);
    message.setSendDate(new GregorianCalendar(2012, 8, 28, 11, 00, 15).getTime());
    message.setStatus(MessageStatus.NEW_MESSAGE_STATE);
    message.setText("TEST");
    when(smsCenterService.getUpdatedMessages(any(User.class), anyInt())).thenReturn(
            Collections.singletonList(message));
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            DeliverSM packet = (DeliverSM) invocation.getArguments()[0];
            assertEquals(100, packet.getSequenceNum());
            assertEquals(
                    "id:0000000100 sub:000 dlvrd:000 submit date:1209281100 done date:1209281100 stat:UNDELIV err:000 Text:TEST",
                    packet.getMessageText());
            return null;
        }
    }).when(mockedHandler).sendRequest(any(SMPPRequest.class));

    deliverSMSenderTask.sendRequests();
    verify(smppReceiverHelper, times(1)).newInstance(eq(SMPPPacket.DELIVER_SM));
    verify(smppConnectionPool, times(0)).close(same(mockedHandler));
    verify(mockedHandler, times(1)).sendRequest(any(DeliverSM.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:29,代碼來源:DeliverSMSenderTaskTest.java

示例9: testProcessRequest

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testProcessRequest() throws IOException {
    DeliverSM request = new DeliverSM();
    request.setSequenceNum(100);
    processor.processRequest(handler, request);
    verify(smsCenterService, times(1)).setInformedFlagForMessage(eq(100L), eq(true));
    verify(handler, times(1)).resetEnquireLinkCount();
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:9,代碼來源:DeliverSmRespProcessorTest.java

示例10: testDeliverSM_StateObjNull_WrongMessage

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testDeliverSM_StateObjNull_WrongMessage() {
    DeliverSM dm = new DeliverSM();
    dm.setMessageText("WRONG MESSAGE TEXT");
    smppEventListener.deliverSM(null, dm);
    verify(smsMapper, times(0)).update(any(SMSMessage.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:8,代碼來源:SmppEventListenerTest.java

示例11: testDeliverSM_SmscIdObjNull_MessageNotFound

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testDeliverSM_SmscIdObjNull_MessageNotFound() {
    DeliverSM dm = new DeliverSM();
    dm.setOptionalParameter(Tag.MESSAGE_STATE, SMPPPacket.SM_STATE_DELIVERED);
    dm.setMessageText("id:0000100 Text:BlaBla stat:DELIVRD");
    smppEventListener.deliverSM(null, dm);
    verify(smsMapper, times(0)).update(any(SMSMessage.class));
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:9,代碼來源:SmppEventListenerTest.java

示例12: testDeliverSM_SmscIdObjNull_Found

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testDeliverSM_SmscIdObjNull_Found() {
    SMSMessage message = new SMSMessage();
    when(smsMapper.getMessageBySmscId(any(Channel.class), eq("100"))).thenReturn(message);

    DeliverSM dm = new DeliverSM();
    dm.setOptionalParameter(Tag.MESSAGE_STATE, SMPPPacket.SM_STATE_DELIVERED);
    dm.setMessageText("id:0000100 Text:BlaBla stat:DELIVRD");
    smppEventListener.deliverSM(null, dm);
    verify(smsMapper, times(1)).update(same(message));
    assertEquals(MessageStatus.MESSAGE_WAS_DELIVERED, message.getStatus());
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:13,代碼來源:SmppEventListenerTest.java

示例13: testDeliverSM_OptionalParamsNotNull

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testDeliverSM_OptionalParamsNotNull() {
    SMSMessage message = new SMSMessage();
    when(smsMapper.getMessageBySmscId(any(Channel.class), eq("100"))).thenReturn(message);

    DeliverSM dm = new DeliverSM();
    dm.setOptionalParameter(Tag.MESSAGE_STATE, SMPPPacket.SM_STATE_EXPIRED);
    dm.setOptionalParameter(Tag.RECEIPTED_MESSAGE_ID, "000100");
    dm.setMessageText("id:0000100 Text:BlaBla");
    smppEventListener.deliverSM(null, dm);
    verify(smsMapper, times(1)).update(same(message));
    assertEquals(MessageStatus.MESSAGE_WASNT_DELIVERED, message.getStatus());
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:14,代碼來源:SmppEventListenerTest.java

示例14: testToString_DeliverSM

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
@Test
public void testToString_DeliverSM() {
    DeliverSM dm = new DeliverSM();
    dm.setOptionalParameter(Tag.MESSAGE_STATE, SMPPPacket.SM_STATE_EXPIRED);
    dm.setOptionalParameter(Tag.RECEIPTED_MESSAGE_ID, "000100");
    dm.setMessageText("id:0000100 Text:BlaBla");
    String result = SmppPacketUtils.toString(dm);
    assertEquals("deliver_sm[MessageText: \"id:0000100 Text:BlaBla\"; State: 3; SmscId: 000100]", result);
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:10,代碼來源:SmppPacketUtilsTest.java

示例15: toString

import ie.omk.smpp.message.DeliverSM; //導入依賴的package包/類
public static String toString(SMPPPacket pack) {
    StringBuilder sb = new StringBuilder();
    sb.append(pack);
    if (pack instanceof DeliverSM) {
        DeliverSM dm = (DeliverSM) pack;
        sb.append("[");
        sb.append("MessageText: \"");
        sb.append(dm.getMessageText());
        sb.append("\"; ");
        sb.append("State: ");
        sb.append(dm.getOptionalParameter(Tag.MESSAGE_STATE));
        sb.append("; ");
        sb.append("SmscId: ");
        sb.append(dm.getOptionalParameter(Tag.RECEIPTED_MESSAGE_ID));
        sb.append("]");
    } else if (pack instanceof BindResp) {
        BindResp br = (BindResp) pack;
        sb.append("[");
        sb.append("CommandStatus: ");
        sb.append(br.getCommandStatus());
        sb.append("]");
    } else if (pack instanceof SubmitSMResp) {
        SubmitSMResp smr = (SubmitSMResp) pack;
        sb.append("[");
        sb.append("SeqNm: ");
        sb.append(smr.getSequenceNum());
        sb.append("; ");
        sb.append("MessageId: ");
        sb.append(smr.getMessageId());
        sb.append("; ");
        sb.append("CommandStatus: ");
        sb.append(smr.getCommandStatus());
        sb.append("]");
    } else if (pack instanceof SMPPResponse) {
        SMPPResponse sr = (SMPPResponse) pack;
        sb.append("[");
        sb.append("MessageId: ");
        sb.append(sr.getMessageId());
        sb.append("; ");
        sb.append("MessageStatus: ");
        sb.append(sr.getMessageStatus());
        sb.append("; ");
        sb.append("FinalDate: ");
        convertDateToString(sb, sr.getFinalDate());
        sb.append("]");
    }
    return sb.toString();
}
 
開發者ID:emamedov,項目名稱:smscenter,代碼行數:49,代碼來源:SmppPacketUtils.java


注:本文中的ie.omk.smpp.message.DeliverSM類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。