本文整理汇总了Java中org.jsmpp.util.DeliveryReceiptState类的典型用法代码示例。如果您正苦于以下问题:Java DeliveryReceiptState类的具体用法?Java DeliveryReceiptState怎么用?Java DeliveryReceiptState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeliveryReceiptState类属于org.jsmpp.util包,在下文中一共展示了DeliveryReceiptState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSmppMessageFromDeliveryReceiptShouldReturnASmppMessage
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
@Test
public void createSmppMessageFromDeliveryReceiptShouldReturnASmppMessage() throws Exception {
DeliverSm deliverSm = new DeliverSm();
deliverSm.setSmscDeliveryReceipt();
deliverSm.setShortMessage(
"id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD err:xxx Text:Hello SMPP world!"
.getBytes());
SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
assertEquals("Hello SMPP world!", smppMessage.getBody());
assertEquals(8, smppMessage.getHeaders().size());
assertEquals("2", smppMessage.getHeader(SmppConstants.ID));
assertEquals(1, smppMessage.getHeader(SmppConstants.DELIVERED));
// To avoid the test failure when running in different TimeZone
//assertEquals(new Date(1251753060000L), smppMessage.getHeader(SmppConstants.DONE_DATE));
assertEquals("xxx", smppMessage.getHeader(SmppConstants.ERROR));
//assertEquals(new Date(1251753000000L), smppMessage.getHeader(SmppConstants.SUBMIT_DATE));
assertEquals(1, smppMessage.getHeader(SmppConstants.SUBMITTED));
assertEquals(DeliveryReceiptState.DELIVRD, smppMessage.getHeader(SmppConstants.FINAL_STATUS));
assertEquals(SmppMessageType.DeliveryReceipt.toString(), smppMessage.getHeader(SmppConstants.MESSAGE_TYPE));
assertNull(smppMessage.getHeader(SmppConstants.OPTIONAL_PARAMETERS));
}
示例2: createSmppMessageFromDeliveryReceiptWithPayloadInOptionalParameterShouldReturnASmppMessage
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
@Test
public void createSmppMessageFromDeliveryReceiptWithPayloadInOptionalParameterShouldReturnASmppMessage() {
DeliverSm deliverSm = new DeliverSm();
deliverSm.setSmscDeliveryReceipt();
deliverSm.setOptionalParameters(new OctetString(OptionalParameter.Tag.MESSAGE_PAYLOAD,
"id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD err:xxx Text:Hello SMPP world!"));
try {
SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
assertEquals("Hello SMPP world!", smppMessage.getBody());
assertEquals(10, smppMessage.getHeaders().size());
assertEquals("2", smppMessage.getHeader(SmppConstants.ID));
assertEquals(1, smppMessage.getHeader(SmppConstants.DELIVERED));
assertEquals("xxx", smppMessage.getHeader(SmppConstants.ERROR));
assertEquals(1, smppMessage.getHeader(SmppConstants.SUBMITTED));
assertEquals(DeliveryReceiptState.DELIVRD, smppMessage.getHeader(SmppConstants.FINAL_STATUS));
assertEquals(SmppMessageType.DeliveryReceipt.toString(), smppMessage.getHeader(SmppConstants.MESSAGE_TYPE));
} catch (Exception e) {
fail("Should not throw exception while creating smppMessage.");
}
}
示例3: DeliveryReceipt
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
public DeliveryReceipt(String formattedDeliveryReceipt)
throws InvalidDeliveryReceiptException {
/*
* id:IIIIIIIIII sub:SSS dlvrd:DDD submit date:YYMMDDhhmm done
* date:YYMMDDhhmm stat:DDDDDDD err:E Text: ..........
*/
try {
id = getDeliveryReceiptValue(DeliveryReceipt.DELREC_ID, formattedDeliveryReceipt);
submitted = getDeliveryReceiptIntValue(DeliveryReceipt.DELREC_SUB, formattedDeliveryReceipt);
delivered = getDeliveryReceiptIntValue(DeliveryReceipt.DELREC_DLVRD, formattedDeliveryReceipt);
submitDate = string2Date(getDeliveryReceiptValue(
DeliveryReceipt.DELREC_SUBMIT_DATE, formattedDeliveryReceipt));
doneDate = string2Date(getDeliveryReceiptValue(
DeliveryReceipt.DELREC_DONE_DATE, formattedDeliveryReceipt));
finalStatus = DeliveryReceiptState
.getByName(getDeliveryReceiptValue(
DeliveryReceipt.DELREC_STAT, formattedDeliveryReceipt));
error = getDeliveryReceiptValue(DeliveryReceipt.DELREC_ERR, formattedDeliveryReceipt);
text = getDeliveryReceiptTextValue(formattedDeliveryReceipt);
} catch (Exception e) {
throw new InvalidDeliveryReceiptException("There is an error found when parsing delivery receipt", e);
}
}
示例4: run
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
public void run() {
try {
Thread.sleep(WAIT_DURATION);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
LOG.error("Sleep interrupted", e1);
}
SessionState state = session.getSessionState();
if (!state.isReceivable()) {
LOG.debug("Not sending delivery receipt for message id {} since session state is {}", messageId, state);
return;
}
String stringValue = Integer.valueOf(messageId.getValue(), TWO_BYTES).toString();
try {
DeliveryReceipt delRec = new DeliveryReceipt(stringValue, totalSubmitted, totalDelivered, new Date(), new Date(), DeliveryReceiptState.DELIVRD, null, new String(shortMessage));
session.deliverShortMessage("mc", sourceAddrTon, sourceAddrNpi, sourceAddress, destAddrTon, destAddrNpi, destAddress, new ESMClass(MessageMode.DEFAULT,
MessageType.SMSC_DEL_RECEIPT, GSMSpecificFeature.DEFAULT), (byte) 0, (byte) 0, new RegisteredDelivery(0), DataCodings.ZERO, delRec.toString().getBytes());
LOG.debug("Sending delivery receipt for message id {}: {}", messageId, stringValue);
} catch (Exception e) {
LOG.error("Failed sending delivery_receipt for message id {}: {}", messageId, stringValue, e);
}
}
示例5: run
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
LOGGER.error("Interupted", e1);
}
SessionState state = session.getSessionState();
if (!state.isReceivable()) {
LOGGER.debug("Not sending delivery receipt for message id {} since session state is {}", messageId, state);
return;
}
String stringValue = Integer.valueOf(messageId.getValue(), 16).toString();
try {
DeliveryReceipt delRec = new DeliveryReceipt(stringValue, totalSubmitted, totalDelivered, new Date(), new Date(), DeliveryReceiptState.DELIVRD, "000", new String(shortMessage));
session.deliverShortMessage(
"mc",
sourceAddrTon, sourceAddrNpi, sourceAddress,
destAddrTon, destAddrNpi, destAddress,
new ESMClass(MessageMode.DEFAULT, MessageType.SMSC_DEL_RECEIPT, GSMSpecificFeature.DEFAULT),
(byte)0,
(byte)0,
new RegisteredDelivery(0),
DataCodings.ZERO,
delRec.toString().getBytes());
LOGGER.debug("Sending delivery receipt for message id {}: {}", messageId, stringValue);
} catch (Exception e) {
LOGGER.error("Failed sending delivery_receipt for message id " + messageId + ":" + stringValue, e);
}
}
示例6: run
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
String stringValue = Integer.valueOf(messageId.getValue(), 16).toString();
try {
DeliveryReceipt delRec = new DeliveryReceipt(stringValue, 1, 1, new Date(), new Date(), DeliveryReceiptState.DELIVRD, null, new String(submitSm.getShortMessage()));
session.deliverShortMessage(
"mc",
TypeOfNumber.valueOf(submitSm.getDestAddrTon()),
NumberingPlanIndicator.valueOf(submitSm.getDestAddrNpi()),
submitSm.getDestAddress(),
TypeOfNumber.valueOf(submitSm.getSourceAddrTon()),
NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()),
submitSm.getSourceAddr(),
new ESMClass(MessageMode.DEFAULT, MessageType.SMSC_DEL_RECEIPT, GSMSpecificFeature.DEFAULT),
(byte)0,
(byte)0,
new RegisteredDelivery(0),
DataCodings.ZERO,
delRec.toString().getBytes());
LOGGER.debug("Sending delivery receipt for message id " + messageId + ":" + stringValue);
} catch (Exception e) {
LOGGER.error("Failed sending delivery_receipt for message id " + messageId + ":" + stringValue, e);
}
}
示例7: createSmppMessageFromDeliveryReceiptWithOptionalParametersShouldReturnASmppMessage
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void createSmppMessageFromDeliveryReceiptWithOptionalParametersShouldReturnASmppMessage() throws Exception {
DeliverSm deliverSm = new DeliverSm();
deliverSm.setSmscDeliveryReceipt();
deliverSm.setShortMessage("id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD err:xxx Text:Hello SMPP world!".getBytes());
deliverSm.setOptionalParameters(
new OptionalParameter.OctetString(Tag.SOURCE_SUBADDRESS, "OctetString"),
new OptionalParameter.COctetString((short) 0x001D, "COctetString"),
new OptionalParameter.Byte(Tag.DEST_ADDR_SUBUNIT, (byte) 0x01),
new OptionalParameter.Short(Tag.DEST_TELEMATICS_ID, (short) 1),
new OptionalParameter.Int(Tag.QOS_TIME_TO_LIVE, 1),
new OptionalParameter.Null(Tag.ALERT_ON_MESSAGE_DELIVERY));
SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
assertEquals("Hello SMPP world!", smppMessage.getBody());
assertEquals(10, smppMessage.getHeaders().size());
assertEquals("2", smppMessage.getHeader(SmppConstants.ID));
assertEquals(1, smppMessage.getHeader(SmppConstants.DELIVERED));
// To avoid the test failure when running in different TimeZone
//assertEquals(new Date(1251753060000L), smppMessage.getHeader(SmppConstants.DONE_DATE));
assertEquals("xxx", smppMessage.getHeader(SmppConstants.ERROR));
//assertEquals(new Date(1251753000000L), smppMessage.getHeader(SmppConstants.SUBMIT_DATE));
assertEquals(1, smppMessage.getHeader(SmppConstants.SUBMITTED));
assertEquals(DeliveryReceiptState.DELIVRD, smppMessage.getHeader(SmppConstants.FINAL_STATUS));
assertEquals(SmppMessageType.DeliveryReceipt.toString(), smppMessage.getHeader(SmppConstants.MESSAGE_TYPE));
Map<String, Object> optionalParameters = smppMessage.getHeader(SmppConstants.OPTIONAL_PARAMETERS, Map.class);
assertEquals(6, optionalParameters.size());
assertEquals("OctetString", optionalParameters.get("SOURCE_SUBADDRESS"));
assertEquals("COctetString", optionalParameters.get("ADDITIONAL_STATUS_INFO_TEXT"));
assertEquals(Byte.valueOf((byte) 0x01), optionalParameters.get("DEST_ADDR_SUBUNIT"));
assertEquals(Short.valueOf((short) 1), optionalParameters.get("DEST_TELEMATICS_ID"));
assertEquals(Integer.valueOf(1), optionalParameters.get("QOS_TIME_TO_LIVE"));
assertNull("0x00", optionalParameters.get("ALERT_ON_MESSAGE_DELIVERY"));
Map<Short, Object> optionalParameter = smppMessage.getHeader(SmppConstants.OPTIONAL_PARAMETER, Map.class);
assertEquals(6, optionalParameter.size());
assertArrayEquals("OctetString".getBytes("UTF-8"), (byte[]) optionalParameter.get(Short.valueOf((short) 0x0202)));
assertEquals("COctetString", optionalParameter.get(Short.valueOf((short) 0x001D)));
assertEquals(Byte.valueOf((byte) 0x01), optionalParameter.get(Short.valueOf((short) 0x0005)));
assertEquals(Short.valueOf((short) 1), optionalParameter.get(Short.valueOf((short) 0x0008)));
assertEquals(Integer.valueOf(1), optionalParameter.get(Short.valueOf((short) 0x0017)));
assertNull("0x00", optionalParameter.get(Short.valueOf((short) 0x130C)));
}
示例8: getFinalStatus
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
/**
* @return Returns the finalStatus.
*/
public DeliveryReceiptState getFinalStatus() {
return finalStatus;
}
示例9: setFinalStatus
import org.jsmpp.util.DeliveryReceiptState; //导入依赖的package包/类
/**
* @param finalStatus The finalStatus to set.
*/
public void setFinalStatus(DeliveryReceiptState finalStatus) {
this.finalStatus = finalStatus;
}