You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2010/09/10 10:56:04 UTC
svn commit: r995705 [1/2] - in
/servicemix/components/bindings/servicemix-smpp/trunk: ./
src/main/java/org/apache/servicemix/smpp/
src/main/java/org/apache/servicemix/smpp/marshaler/
src/main/resources/OSGI-INF/blueprint/ src/test/java/org/apache/servi...
Author: lhein
Date: Fri Sep 10 08:56:03 2010
New Revision: 995705
URL: http://svn.apache.org/viewvc?rev=995705&view=rev
Log:
applied patch on behalf of Ioannis Canellos (see SMXCOMP-788)
Modified:
servicemix/components/bindings/servicemix-smpp/trunk/pom.xml
servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppComponent.java
servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppConsumerEndpoint.java
servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java
servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java
servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java
servicemix/components/bindings/servicemix-smpp/trunk/src/main/resources/OSGI-INF/blueprint/servicemix-smpp.xml
servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppConsumerEndpointTest.java
servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java
servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppXBeanDeployerTest.java
servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SpringComponentTest.java
servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshalerTest.java
servicemix/components/bindings/servicemix-smpp/trunk/src/test/resources/spring.xml
servicemix/components/bindings/servicemix-smpp/trunk/src/test/resources/xbean/xbean.xml
Modified: servicemix/components/bindings/servicemix-smpp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/pom.xml?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/pom.xml (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/pom.xml Fri Sep 10 08:56:03 2010
@@ -28,7 +28,7 @@
<artifactId>servicemix-smpp</artifactId>
<version>2010.02-SNAPSHOT</version>
<packaging>jbi-component</packaging>
-
+
<name>Apache ServiceMix :: Components :: SMPP Binding Component</name>
<scm>
@@ -36,10 +36,10 @@
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-smpp/trunk</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/servicemix/components/bindings/servicemix-smpp/trunk</url>
</scm>
-
+
<properties>
<jsmpp-version>2.0</jsmpp-version>
-
+
<servicemix.osgi.import>
!org.apache.servicemix.smpp*,
!META-INF.services.org.apache.xbean.spring.smpp.servicemix.apache.org.smpp,
@@ -63,7 +63,7 @@
org.springframework.context
</servicemix.osgi.bundles>
</properties>
-
+
<dependencies>
<dependency>
<groupId>org.apache.servicemix</groupId>
@@ -74,7 +74,7 @@
<artifactId>org.apache.servicemix.specs.jbi-api-1.0</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<scope>provided</scope>
@@ -100,7 +100,7 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
-
+
<!-- Testing Dependencies -->
<dependency>
<groupId>junit</groupId>
@@ -124,7 +124,7 @@
</exclusions>
</dependency>
</dependencies>
-
+
<build>
<resources>
<resource>
@@ -195,5 +195,5 @@
</plugin>
</plugins>
</build>
-
+
</project>
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppComponent.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppComponent.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppComponent.java Fri Sep 10 08:56:03 2010
@@ -16,18 +16,19 @@
*/
package org.apache.servicemix.smpp;
-import java.util.List;
-
import org.apache.servicemix.common.DefaultComponent;
+import java.util.List;
+
/**
* @org.apache.xbean.XBean element="component" description="Smpp Component" SMPP
- * ServiceMix Component allowing to use SMPP protocol.
- * It provides interfaces to communicate with Message
- * Center or ESME (External Short Message Entity). SMPP
- * is stand for Short Message Peer to Peer. It is a
- * standard protocol for exchanging SMS messages between
- * SMS entities over TCP/IP or X.25 connections.
+ * ServiceMix Component allowing to use SMPP protocol.
+ * It provides interfaces to communicate with Message
+ * Center or ESME (External Short Message Entity). SMPP
+ * is stand for Short Message Peer to Peer. It is a
+ * standard protocol for exchanging SMS messages between
+ * SMS entities over TCP/IP or X.25 connections.
+ *
* @author lhein
* @author jbonofre
*/
@@ -38,7 +39,7 @@ public class SmppComponent extends Defau
/**
* Getter on the component endpoints
- *
+ *
* @return the SMPP endpoints list
*/
public SmppEndpointType[] getEndpoints() {
@@ -47,8 +48,8 @@ public class SmppComponent extends Defau
/**
* Setter on the components endpoints
- *
- * @param the SMPP endpoints list
+ *
+ * @param endpoints the SMPP endpoints list
*/
public void setEndpoints(SmppEndpointType[] endpoints) {
this.endpoints = endpoints;
@@ -65,6 +66,6 @@ public class SmppComponent extends Defau
* @see org.apache.servicemix.common.DefaultComponent#getEndpointClasses()
*/
protected Class[] getEndpointClasses() {
- return new Class[] {SmppConsumerEndpoint.class, SmppProviderEndpoint.class};
+ return new Class[]{SmppConsumerEndpoint.class, SmppProviderEndpoint.class};
}
}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppConsumerEndpoint.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppConsumerEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppConsumerEndpoint.java Fri Sep 10 08:56:03 2010
@@ -16,36 +16,28 @@
*/
package org.apache.servicemix.smpp;
-import java.io.IOException;
-
-import javax.jbi.management.DeploymentException;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.common.endpoints.ConsumerEndpoint;
import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
-import org.jsmpp.bean.AlertNotification;
-import org.jsmpp.bean.BindType;
-import org.jsmpp.bean.DeliverSm;
-import org.jsmpp.bean.NumberingPlanIndicator;
-import org.jsmpp.bean.TypeOfNumber;
+import org.jsmpp.bean.*;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.MessageReceiverListener;
import org.jsmpp.session.SMPPSession;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.*;
+import java.io.IOException;
+
/**
* A polling component which bind with jSMPP and receive SMPP messages and sends
* the SMPPs into the JBI bus as messages.
- *
- * @org.apache.xbean.XBean element="consumer"
+ *
* @author jbonofre
* @author lhein
+ *
+ * @org.apache.xbean.XBean element="consumer"
*/
public class SmppConsumerEndpoint extends ConsumerEndpoint implements SmppEndpointType {
@@ -74,6 +66,7 @@ public class SmppConsumerEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.SimpleEndpoint#start()
*/
+
@Override
public synchronized void start() throws Exception {
super.start();
@@ -85,6 +78,7 @@ public class SmppConsumerEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.SimpleEndpoint#stop()
*/
+
@Override
public synchronized void stop() throws Exception {
// disconnect now
@@ -96,6 +90,7 @@ public class SmppConsumerEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.ConsumerEndpoint#validate()
*/
+
@Override
public void validate() throws DeploymentException {
super.validate();
@@ -121,10 +116,10 @@ public class SmppConsumerEndpoint extend
if (this.transactionTimer <= 0) {
throw new IllegalArgumentException("The transactionTimer value must be greater than 0.");
}
- // check the marshaler
- if (this.marshaler == null) {
- this.marshaler = new DefaultSmppMarshaler();
- }
+ // check the marshaler
+ if (this.marshaler == null) {
+ this.marshaler = new DefaultSmppMarshaler();
+ }
}
/*
@@ -133,6 +128,7 @@ public class SmppConsumerEndpoint extend
* org.apache.servicemix.common.endpoints.AbstractEndpoint#process(javax
* .jbi.messaging.MessageExchange)
*/
+
@Override
public void process(MessageExchange exchange) throws Exception {
if (exchange.getStatus() == ExchangeStatus.DONE) {
@@ -192,10 +188,10 @@ public class SmppConsumerEndpoint extend
// connect and bind to the SMPP server
try {
session.connectAndBind(this.host, this.port, new BindParameter(BindType.BIND_RX, this.systemId,
- this.password, SYSTEM_TYPE,
- TypeOfNumber.UNKNOWN,
- NumberingPlanIndicator.UNKNOWN,
- null));
+ this.password, SYSTEM_TYPE,
+ TypeOfNumber.UNKNOWN,
+ NumberingPlanIndicator.UNKNOWN,
+ null));
} catch (IOException ioException) {
log.error("Error connecting to the SMPP server", ioException);
return;
@@ -218,12 +214,12 @@ public class SmppConsumerEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the port number to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>2775</b></i>
- *
+ *
* @param port a <code>int</code> value representing the port number
*/
public void setPort(int port) {
@@ -235,12 +231,12 @@ public class SmppConsumerEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the host name to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param host a <code>String</code> value representing the host name
*/
public void setHost(String host) {
@@ -252,12 +248,12 @@ public class SmppConsumerEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the system id to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param systemId a <code>String</code> value representing the system id
*/
public void setSystemId(String systemId) {
@@ -269,12 +265,12 @@ public class SmppConsumerEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the password to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param password a <code>String</code> value representing the password
*/
public void setPassword(String password) {
@@ -293,9 +289,9 @@ public class SmppConsumerEndpoint extend
* don't specify a marshaler, the <code>DefaultSmppMarshaler</code> will be
* used.
* </p>
- *
+ *
* @param marshaler a <code>SmppMarshaler</code> class representing the
- * marshaler
+ * marshaler
*/
public void setMarshaler(SmppMarshalerSupport marshaler) {
this.marshaler = marshaler;
@@ -311,9 +307,9 @@ public class SmppConsumerEndpoint extend
* interval.<br/>
* </p>
* <i> The default value is <b>50000</b></i>
- *
+ *
* @param enquireLinkTimer a <code>int</code> value representing the enquire
- * link timer
+ * link timer
*/
public void setEnquireLinkTimer(int enquireLinkTimer) {
this.enquireLinkTimer = enquireLinkTimer;
@@ -329,11 +325,11 @@ public class SmppConsumerEndpoint extend
* <br/>
* </p>
* <i> The default value is <b>100000</b></i>
- *
+ *
* @param transactionTimer a <code>int</code> value representing the
- * transaction timer (timeout)
+ * transaction timer (timeout)
*/
public void setTransactionTimer(int transactionTimer) {
this.transactionTimer = transactionTimer;
}
-}
\ No newline at end of file
+}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java Fri Sep 10 08:56:03 2010
@@ -16,15 +16,6 @@
*/
package org.apache.servicemix.smpp;
-import java.io.IOException;
-import java.util.Date;
-
-import javax.jbi.management.DeploymentException;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.xml.transform.TransformerException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.common.endpoints.ProviderEndpoint;
@@ -33,16 +24,7 @@ import org.apache.servicemix.smpp.marsha
import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
import org.jsmpp.InvalidResponseException;
import org.jsmpp.PDUException;
-import org.jsmpp.bean.Alphabet;
-import org.jsmpp.bean.BindType;
-import org.jsmpp.bean.ESMClass;
-import org.jsmpp.bean.GeneralDataCoding;
-import org.jsmpp.bean.MessageClass;
-import org.jsmpp.bean.MessageRequest;
-import org.jsmpp.bean.NumberingPlanIndicator;
-import org.jsmpp.bean.RegisteredDelivery;
-import org.jsmpp.bean.SMSCDeliveryReceipt;
-import org.jsmpp.bean.TypeOfNumber;
+import org.jsmpp.bean.*;
import org.jsmpp.extra.NegativeResponseException;
import org.jsmpp.extra.ResponseTimeoutException;
import org.jsmpp.session.BindParameter;
@@ -50,13 +32,22 @@ import org.jsmpp.session.SMPPSession;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+import java.io.IOException;
+import java.util.Date;
+
/**
* A provider component receives XML message from the NMR and converts into SMPP
* packet and sends it to SMS.
- *
- * @org.apache.xbean.XBean element="provider"
+ *
* @author jbonofre
* @author lhein
+ *
+ * @org.apache.xbean.XBean element="provider"
*/
public class SmppProviderEndpoint extends ProviderEndpoint implements SmppEndpointType {
@@ -84,6 +75,7 @@ public class SmppProviderEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.SimpleEndpoint#start()
*/
+
@Override
public synchronized void start() throws Exception {
super.start();
@@ -95,6 +87,7 @@ public class SmppProviderEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.SimpleEndpoint#stop()
*/
+
@Override
public synchronized void stop() throws Exception {
super.stop();
@@ -106,6 +99,7 @@ public class SmppProviderEndpoint extend
* (non-Javadoc)
* @see org.apache.servicemix.common.endpoints.AbstractEndpoint#validate()
*/
+
@Override
public void validate() throws DeploymentException {
super.validate();
@@ -123,18 +117,18 @@ public class SmppProviderEndpoint extend
if (this.systemId == null || this.systemId.trim().length() <= 0) {
throw new IllegalArgumentException("The SMPP system ID is mandatory.");
}
- // check the marshaler
- if (this.marshaler == null) {
- this.marshaler = new DefaultSmppMarshaler();
- }
- // check the enquire link timer
- if (this.enquireLinkTimer <= 0) {
- throw new IllegalArgumentException("The enquireLinkTimer value must be greater than 0.");
- }
- // check the transaction timer
- if (this.transactionTimer <= 0) {
- throw new IllegalArgumentException("The transactionTimer value must be greater than 0.");
- }
+ // check the marshaler
+ if (this.marshaler == null) {
+ this.marshaler = new DefaultSmppMarshaler();
+ }
+ // check the enquire link timer
+ if (this.enquireLinkTimer <= 0) {
+ throw new IllegalArgumentException("The enquireLinkTimer value must be greater than 0.");
+ }
+ // check the transaction timer
+ if (this.transactionTimer <= 0) {
+ throw new IllegalArgumentException("The transactionTimer value must be greater than 0.");
+ }
}
/**
@@ -150,10 +144,10 @@ public class SmppProviderEndpoint extend
// connect and bind to the SMPP server
try {
session.connectAndBind(this.host, this.port, new BindParameter(BindType.BIND_TX, this.systemId,
- this.password, SYSTEM_TYPE,
- TypeOfNumber.UNKNOWN,
- NumberingPlanIndicator.UNKNOWN,
- null));
+ this.password, SYSTEM_TYPE,
+ TypeOfNumber.UNKNOWN,
+ NumberingPlanIndicator.UNKNOWN,
+ null));
} catch (IOException ioException) {
log.error("Error connecting to the SMPP server", ioException);
return;
@@ -178,6 +172,7 @@ public class SmppProviderEndpoint extend
* (javax.jbi.messaging.MessageExchange,
* javax.jbi.messaging.NormalizedMessage)
*/
+
@Override
protected void processInOnly(MessageExchange exchange, NormalizedMessage inMsg) throws Exception {
process(exchange, inMsg);
@@ -191,9 +186,10 @@ public class SmppProviderEndpoint extend
* javax.jbi.messaging.NormalizedMessage,
* javax.jbi.messaging.NormalizedMessage)
*/
+
@Override
protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
- throws Exception {
+ throws Exception {
// we are reading the source of the NormalizedMessage multiple times
// (else we receive a IOException: Stream closed)
MessageUtil.enableContentRereadability(in);
@@ -207,29 +203,29 @@ public class SmppProviderEndpoint extend
/**
* process the incoming exchange
- *
+ *
* @param exchange the message exchange
- * @param in the in message
+ * @param in the in message
* @throws TransformerException on transformation errors
- * @throws MessagingException on messaging errors
+ * @throws MessagingException on messaging errors
*/
private void process(MessageExchange exchange, NormalizedMessage in) throws TransformerException,
- MessagingException {
+ MessagingException {
// let the marshaler create a SM content
MessageRequest sm = marshaler.fromNMS(exchange, in);
try {
log.debug("Submiting request: " + sm);
String messageId = session
- .submitShortMessage("CMT", TypeOfNumber.valueOf(sm.getSourceAddrTon()),
- NumberingPlanIndicator.valueOf(sm.getSourceAddrNpi()),
- sm.getSourceAddr(), TypeOfNumber.valueOf(sm.getDestAddrTon()),
- NumberingPlanIndicator.valueOf(sm.getDestAddrNpi()), sm.getDestAddress(),
- new ESMClass(), (byte)0, (byte)1, timeFormatter.format(new Date()), null,
- new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte)0,
- new GeneralDataCoding(false, false, MessageClass.CLASS1,
- Alphabet.ALPHA_DEFAULT), (byte)0, sm
- .getShortMessage());
+ .submitShortMessage("CMT", TypeOfNumber.valueOf(sm.getSourceAddrTon()),
+ NumberingPlanIndicator.valueOf(sm.getSourceAddrNpi()),
+ sm.getSourceAddr(), TypeOfNumber.valueOf(sm.getDestAddrTon()),
+ NumberingPlanIndicator.valueOf(sm.getDestAddrNpi()), sm.getDestAddress(),
+ new ESMClass(), (byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
+ new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0,
+ new GeneralDataCoding(false, false, MessageClass.CLASS1,
+ Alphabet.ALPHA_DEFAULT), (byte) 0, sm
+ .getShortMessage());
log.debug("Message sent with ID " + messageId);
} catch (PDUException pduException) {
@@ -255,12 +251,12 @@ public class SmppProviderEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the host name to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param host a <code>String</code> value representing the host name
*/
public void setHost(String host) {
@@ -280,12 +276,12 @@ public class SmppProviderEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the system id to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param systemId a <code>String</code> value representing the system id
*/
public void setSystemId(String systemId) {
@@ -297,12 +293,12 @@ public class SmppProviderEndpoint extend
}
/**
- * <p>
+ * <p/>
* This attribute specifies the password to use for connecting to the
* server.<br/>
- * <p>
+ * <p/>
* <i> The default value is <b>null</b></i>
- *
+ *
* @param password a <code>String</code> value representing the password
*/
public void setPassword(String password) {
@@ -321,9 +317,9 @@ public class SmppProviderEndpoint extend
* don't specify a marshaler, the <code>DefaultSmppMarshaler</code> will be
* used.
* </p>
- *
+ *
* @param marshaler a <code>SmppMarshaler</code> class representing the
- * marshaler
+ * marshaler
*/
public void setMarshaler(SmppMarshalerSupport marshaler) {
this.marshaler = marshaler;
@@ -339,9 +335,9 @@ public class SmppProviderEndpoint extend
* interval.<br/>
* </p>
* <i> The default value is <b>50000</b> milliseconds</i>
- *
+ *
* @param enquireLinkTimer a <code>int</code> value representing the enquire
- * link timer
+ * link timer
*/
public void setEnquireLinkTimer(int enquireLinkTimer) {
this.enquireLinkTimer = enquireLinkTimer;
@@ -357,11 +353,11 @@ public class SmppProviderEndpoint extend
* lifetime of a message.<br/>
* </p>
* <i> The default value is <b>100000</b> milliseconds</i>
- *
+ *
* @param transactionTimer a <code>int</code> value representing the
- * transaction timer
+ * transaction timer
*/
public void setTransactionTimer(int transactionTimer) {
this.transactionTimer = transactionTimer;
- }
-}
\ No newline at end of file
+ }
+}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java Fri Sep 10 08:56:03 2010
@@ -16,26 +16,25 @@
*/
package org.apache.servicemix.smpp.marshaler;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.xml.transform.TransformerException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.jsmpp.bean.MessageRequest;
-import org.jsmpp.bean.NumberingPlanIndicator;
-import org.jsmpp.bean.SMSCDeliveryReceipt;
-import org.jsmpp.bean.SubmitSm;
-import org.jsmpp.bean.TypeOfNumber;
+import org.jsmpp.bean.*;
+import org.jsmpp.bean.OptionalParameter.Tag;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Default SMPP Marshaler
- *
+ *
* @author jbonofre
* @author lhein
* @author mullerc
@@ -43,7 +42,6 @@ import org.w3c.dom.NodeList;
public class DefaultSmppMarshaler implements SmppMarshalerSupport {
private static final transient Log log = LogFactory.getLog(DefaultSmppMarshaler.class);
-
private final static String TAG_MESSAGE = "message";
private final static String TAG_SOURCE = "source";
private final static String TAG_DESTINATION = "destination";
@@ -53,7 +51,51 @@ public class DefaultSmppMarshaler implem
private final static String TAG_REGISTERED_DELIVERY = "registeredDelivery";
private final static String TAG_SCHEDULE_DELIVERY_TIME = "scheduleDeliveryTime";
private final static String TAG_VALIDITY_PERIOD = "validityPeriod";
-
+ //Optional Parameter Flags
+ private final static String DEST_ADDR_SUBUNIT = "DEST_ADDR_SUBUNIT";
+ private final static String DEST_NETWORK_TYPE = "DEST_NETWORK_TYPE";
+ private final static String DEST_BEARER_TYPE = "DEST_BEARER_TYPE";
+ private final static String DEST_TELEMATICS_ID = "DEST_TELEMATICS_ID";
+ private final static String SOURCE_ADDR_SUBUNIT = "SOURCE_ADDR_SUBUNIT";
+ private final static String SOURCE_NETWORK_TYPE = "SOURCE_NETWORK_TYPE";
+ private final static String SOURCE_BEARER_TYPE = "SOURCE_BEARER_TYPE";
+ private final static String SOURCE_TELEMATICS_ID = "SOURCE_TELEMATICS_ID";
+ private final static String QOS_TIME_TO_LIVE = "QOS_TIME_TO_LIVE";
+ private final static String PAYLOAD_TYPE = "PAYLOAD_TYPE";
+ private final static String ADDITIONAL_STATUS_INFO_TEXT = "ADDITIONAL_STATUS_INFO_TEXT";
+ private final static String RECEIPTED_MESSAGE_ID = "RECEIPTED_MESSAGE_ID";
+ private final static String MS_MSG_WAIT_FACILITIES = "MS_MSG_WAIT_FACILITIES";
+ private final static String PRIVACY_INDICATOR = "PRIVACY_INDICATOR";
+ private final static String SOURCE_SUBADDRESS = "SOURCE_SUBADDRESS";
+ private final static String DEST_SUBADDRESS = "DEST_SUBADDRESS";
+ private final static String USER_MESSAGE_REFERENCE = "USER_MESSAGE_REFERENCE";
+ private final static String USER_RESPONSE_CODE = "USER_RESPONSE_CODE";
+ private final static String SOURCE_PORT = "SOURCE_PORT";
+ private final static String DESTINATION_PORT = "DESTINATION_PORT";
+ private final static String SAR_MSG_REF_NUM = "SAR_MSG_REF_NUM";
+ private final static String LANGUAGE_INDICATOR = "LANGUAGE_INDICATOR";
+ private final static String SAR_TOTAL_SEGMENTS = "SAR_TOTAL_SEGMENTS";
+ private final static String SAR_SEGMENT_SEQNUM = "SAR_SEGMENT_SEQNUM";
+ private final static String SC_INTERFACE_VERSION = "SC_INTERFACE_VERSION";
+ private final static String CALLBACK_NUM_PRES_IND = "CALLBACK_NUM_PRES_IND";
+ private final static String CALLBACK_NUM_ATAG = "CALLBACK_NUM_ATAG";
+ private final static String NUMBER_OF_MESSAGES = "NUMBER_OF_MESSAGES";
+ private final static String CALLBACK_NUM = "CALLBACK_NUM";
+ private final static String DPF_RESULT = "DPF_RESULT";
+ private final static String SET_DPF = "SET_DPF";
+ private final static String MS_AVAILABILITY_STATUS = "MS_AVAILABILITY_STATUS";
+ private final static String NETWORK_ERROR_CODE = "NETWORK_ERROR_CODE";
+ private final static String MESSAGE_PAYLOAD = "MESSAGE_PAYLOAD";
+ private final static String DELIVERY_FAILURE_REASON = "DELIVERY_FAILURE_REASON";
+ private final static String MORE_MESSAGES_TO_SEND = "MORE_MESSAGES_TO_SEND";
+ private final static String MESSAGE_STATE = "MESSAGE_STATE";
+ private final static String USSD_SERVICE_OP = "USSD_SERVICE_OP";
+ private final static String DISPLAY_TIME = "DISPLAY_TIME";
+ private final static String SMS_SIGNAL = "SMS_SIGNAL";
+ private final static String MS_VALIDITY = "MS_VALIDITY";
+ private final static String ALERT_ON_MESSAGE_DELIVERY = "ALERT_ON_MESSAGE_DELIVERY";
+ private final static String ITS_REPLY_TYPE = "ITS_REPLY_TYPE";
+ private final static String ITS_SESSION_INFO = "ITS_SESSION_INFO";
private final static String TAG_MESSAGE_OPEN = "<" + TAG_MESSAGE + ">";
private final static String TAG_MESSAGE_CLOSE = "</" + TAG_MESSAGE + ">";
private final static String TAG_SOURCE_OPEN = "<" + TAG_SOURCE + ">";
@@ -72,66 +114,66 @@ public class DefaultSmppMarshaler implem
private final static String TAG_SCHEDULE_DELIVERY_TIME_CLOSE = "</" + TAG_SCHEDULE_DELIVERY_TIME + ">";
private final static String TAG_VALIDITY_PERIOD_OPEN = "<" + TAG_VALIDITY_PERIOD + ">";
private final static String TAG_VALIDITY_PERIOD_CLOSE = "</" + TAG_VALIDITY_PERIOD + ">";
-
private SourceTransformer transformer = new SourceTransformer();
- /*
- * (non-Javadoc)
- * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#fromNMS(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage)
- */
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#fromNMS(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage)
+ */
+
public MessageRequest fromNMS(MessageExchange exchange, NormalizedMessage message) throws TransformerException {
SubmitSm sm = new SubmitSm();
String ton = null;
String npi = null;
-
+
try {
Document document = transformer.toDOMDocument(message);
document.getDocumentElement().normalize();
NodeList node = null;
-
+
if ((node = getNotEmptyNodeListOrNull(document, TAG_SOURCE)) != null) {
sm.setSourceAddr(getFirstNodeValue(node));
log.debug(TAG_SOURCE + ": " + sm.getSourceAddr());
}
if ((node = getNotEmptyNodeListOrNull(document, TAG_DESTINATION)) != null) {
- sm.setDestAddress(getFirstNodeValue(node));
- log.debug(TAG_DESTINATION + ": " + sm.getDestAddress());
+ sm.setDestAddress(getFirstNodeValue(node));
+ log.debug(TAG_DESTINATION + ": " + sm.getDestAddress());
}
if ((node = getNotEmptyNodeListOrNull(document, TAG_TEXT)) != null) {
- sm.setShortMessage(getFirstNodeValue(node).getBytes());
- log.debug(TAG_TEXT + ": " + new String(sm.getShortMessage()));
+ sm.setShortMessage(getFirstNodeValue(node).getBytes());
+ log.debug(TAG_TEXT + ": " + new String(sm.getShortMessage()));
}
-
+
if ((node = getNotEmptyNodeListOrNull(document, TAG_TON)) != null) {
- ton = getFirstNodeValue(node);
+ ton = getFirstNodeValue(node);
sm.setDestAddrTon(TypeOfNumber.valueOf(ton).value());
sm.setSourceAddrTon(TypeOfNumber.valueOf(ton).value());
log.debug(TAG_TON + ": " + ton);
}
if ((node = getNotEmptyNodeListOrNull(document, TAG_NPI)) != null) {
- npi = getFirstNodeValue(node);
+ npi = getFirstNodeValue(node);
sm.setDestAddrNpi(NumberingPlanIndicator.valueOf(npi).value());
sm.setSourceAddrNpi(NumberingPlanIndicator.valueOf(npi).value());
log.debug(TAG_NPI + ": " + npi);
}
-
+
if ((node = getNotEmptyNodeListOrNull(document, TAG_REGISTERED_DELIVERY)) != null) {
String registeredDelivery = getFirstNodeValue(node);
sm.setRegisteredDelivery(SMSCDeliveryReceipt.valueOf(registeredDelivery).value());
log.debug(TAG_REGISTERED_DELIVERY + ": " + registeredDelivery);
} else {
- sm.setRegisteredDelivery(SMSCDeliveryReceipt.DEFAULT.value());
- log.debug(TAG_REGISTERED_DELIVERY + ": DEFAULT");
+ sm.setRegisteredDelivery(SMSCDeliveryReceipt.DEFAULT.value());
+ log.debug(TAG_REGISTERED_DELIVERY + ": DEFAULT");
}
if ((node = getNotEmptyNodeListOrNull(document, TAG_SCHEDULE_DELIVERY_TIME)) != null) {
sm.setScheduleDeliveryTime(getFirstNodeValue(node));
log.debug(TAG_SCHEDULE_DELIVERY_TIME + ": " + sm.getScheduleDeliveryTime());
}
-
+
if ((node = getNotEmptyNodeListOrNull(document, TAG_VALIDITY_PERIOD)) != null) {
sm.setValidityPeriod(getFirstNodeValue(node));
log.debug(TAG_VALIDITY_PERIOD + ": " + sm.getValidityPeriod());
@@ -139,7 +181,7 @@ public class DefaultSmppMarshaler implem
} catch (Exception exception) {
throw new TransformerException(exception);
}
-
+
if (sm.getSourceAddr() == null) {
throw new TransformerException("Invalid message content. Missing tag: " + TAG_SOURCE);
}
@@ -151,23 +193,24 @@ public class DefaultSmppMarshaler implem
if (ton == null) {
throw new TransformerException("Invalid message content. Missing tag: " + TAG_TON);
}
-
+
if (npi == null) {
throw new TransformerException("Invalid message content. Missing tag: " + TAG_NPI);
}
-
+ applyOptionalParametersToRequest(sm, message);
return sm;
}
- /*
- * (non-Javadoc)
- * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#toNMS(javax.jbi.messaging.NormalizedMessage, org.jsmpp.bean.MessageRequest)
- */
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#toNMS(javax.jbi.messaging.NormalizedMessage, org.jsmpp.bean.MessageRequest)
+ */
+
public void toNMS(NormalizedMessage message, MessageRequest mr) throws MessagingException {
if (message == null) {
throw new MessagingException("The NormalizedMessage is null");
}
-
+
if (mr == null) {
throw new MessagingException("The MessageRequest is null");
}
@@ -176,36 +219,36 @@ public class DefaultSmppMarshaler implem
log.error("The MessageRequest source address is not defined");
throw new MessagingException("The MessageRequest source address is not defined");
}
-
+
if (mr.getDestAddress() == null || mr.getDestAddress().trim().length() < 1) {
log.error("The MessageRequest destination address is not defined");
throw new MessagingException("The MessageRequest destination address is not defined");
}
-
+
try {
NumberingPlanIndicator.valueOf(mr.getDestAddrNpi());
} catch (IllegalArgumentException illegalArgumentException) {
log.error("The MessageRequest destination numbering plan indicator is not valid");
throw new MessagingException("The MessageRequest destination numbering plan indicator is not valid");
}
-
+
try {
TypeOfNumber.valueOf(mr.getDestAddrTon());
} catch (IllegalArgumentException illegalArgumentException) {
log.error("The MessageRequest destination type of number is not valid");
throw new MessagingException("The MessageRequest destination type of number is not valid");
}
-
+
try {
- determineSMSCDeliveryReceipt(mr.getRegisteredDelivery());
+ determineSMSCDeliveryReceipt(mr.getRegisteredDelivery());
} catch (IllegalArgumentException illegalArgumentException) {
log.error("The MessageRequest registered delivery is not valid");
throw new MessagingException("The MessageRequest registered delivery is not valid");
}
-
+
if (mr.getShortMessage() == null || mr.getShortMessage().length == 0) {
- log.warn("Received message without text content. Ignore the message");
- return;
+ log.warn("Received message without text content. Ignore the message");
+ return;
}
StringBuffer data = new StringBuffer();
@@ -230,52 +273,515 @@ public class DefaultSmppMarshaler implem
data.append(TAG_TON_OPEN);
data.append(TypeOfNumber.valueOf(mr.getDestAddrTon()).toString());
data.append(TAG_TON_CLOSE);
-
+
data.append(TAG_REGISTERED_DELIVERY_OPEN);
data.append(determineSMSCDeliveryReceipt(mr.getRegisteredDelivery()).toString());
data.append(TAG_REGISTERED_DELIVERY_CLOSE);
-
+
if (mr.getScheduleDeliveryTime() != null && mr.getScheduleDeliveryTime().trim().length() > 0) {
data.append(TAG_SCHEDULE_DELIVERY_TIME_OPEN);
data.append(mr.getScheduleDeliveryTime());
- data.append(TAG_SCHEDULE_DELIVERY_TIME_CLOSE);
+ data.append(TAG_SCHEDULE_DELIVERY_TIME_CLOSE);
}
if (mr.getValidityPeriod() != null && mr.getValidityPeriod().trim().length() > 0) {
data.append(TAG_VALIDITY_PERIOD_OPEN);
data.append(mr.getValidityPeriod());
- data.append(TAG_VALIDITY_PERIOD_CLOSE);
+ data.append(TAG_VALIDITY_PERIOD_CLOSE);
}
-
+
data.append(TAG_MESSAGE_CLOSE);
message.setContent(new StringSource(data.toString()));
+ applyOptionalParametersToNormalizedMessage(mr, message);
+ }
+
+ private void applyOptionalParametersToNormalizedMessage(MessageRequest request, NormalizedMessage message) {
+ OptionalParameter[] optionalParameter = request.getOptionalParametes();
+ if (optionalParameter != null) {
+ for (int i = 0; i < optionalParameter.length; i++) {
+ String name = Tag.valueOf(optionalParameter[i].tag).name();
+ if (optionalParameter[i] instanceof OptionalParameter.Byte) {
+ OptionalParameter.Byte parameter = (OptionalParameter.Byte) optionalParameter[i];
+ message.setProperty(name, parameter.getValue());
+ } else if (optionalParameter[i] instanceof OptionalParameter.Short) {
+ OptionalParameter.Short parameter = (OptionalParameter.Short) optionalParameter[i];
+ message.setProperty(name, parameter.getValue());
+ } else if (optionalParameter[i] instanceof OptionalParameter.Int) {
+ OptionalParameter.Int parameter = (OptionalParameter.Int) optionalParameter[i];
+ message.setProperty(name, parameter.getValue());
+ } else if (optionalParameter[i] instanceof OptionalParameter.COctetString) {
+ OptionalParameter.COctetString parameter = (OptionalParameter.COctetString) optionalParameter[i];
+ message.setProperty(name, parameter.getValueAsString());
+ } else if (optionalParameter[i] instanceof OptionalParameter.Null) {
+ OptionalParameter.Null paramter = (OptionalParameter.Null) optionalParameter[i];
+ message.setProperty(name, "");
+ }
+ }
+ }
+ }
+
+ private void applyOptionalParametersToRequest(MessageRequest request, NormalizedMessage message) {
+ List<OptionalParameter> optionalParameters = new ArrayList<OptionalParameter>();
+
+ //DEST_ADDR_SUBUNIT
+ Object destAddressSubunit = message.getProperty(DEST_ADDR_SUBUNIT);
+ if (destAddressSubunit != null) {
+ if (destAddressSubunit instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_ADDR_SUBUNIT, (Byte) destAddressSubunit));
+ } else if (destAddressSubunit instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_ADDR_SUBUNIT, Byte.valueOf((String) destAddressSubunit)));
+ }
+ }
+
+ //DEST_NETWORK_TYPE
+ Object destNetworkType = message.getProperty(DEST_NETWORK_TYPE);
+ if (destNetworkType != null) {
+ if (destNetworkType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_NETWORK_TYPE, (Byte) destNetworkType));
+ } else if (destNetworkType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_NETWORK_TYPE, Byte.valueOf((String) destNetworkType)));
+ }
+ }
+
+ //DEST_BEARER_TYPE
+ Object destBearerType = message.getProperty(DEST_BEARER_TYPE);
+ if (destBearerType != null) {
+ if (destBearerType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_BEARER_TYPE, (Byte) destBearerType));
+ } else if (destBearerType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DEST_BEARER_TYPE, Byte.valueOf((String) destBearerType)));
+ }
+ }
+
+ //DEST_TELEMATICS_ID
+ Object destTelematicsId = message.getProperty(DEST_TELEMATICS_ID);
+ if (destTelematicsId != null) {
+ if (destTelematicsId instanceof Short) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.DEST_TELEMATICS_ID, (Short) destTelematicsId));
+ } else if (destTelematicsId instanceof String) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.DEST_TELEMATICS_ID, Short.valueOf((String) destTelematicsId)));
+ }
+ }
+
+ //SOURCE_ADDR_SUBUNIT
+ Object sourceAddrSubunit = message.getProperty(SOURCE_ADDR_SUBUNIT);
+ if (sourceAddrSubunit != null) {
+ if (sourceAddrSubunit instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_ADDR_SUBUNIT, (Byte) sourceAddrSubunit));
+ } else if (sourceAddrSubunit instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_ADDR_SUBUNIT, Byte.valueOf((String) sourceAddrSubunit)));
+ }
+ }
+
+ //SOURCE_NETWORK_TYPE
+ Object sourceNetworkType = message.getProperty(SOURCE_NETWORK_TYPE);
+ if (sourceNetworkType != null) {
+ if (sourceNetworkType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_NETWORK_TYPE, (Byte) sourceNetworkType));
+ } else if (sourceNetworkType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_NETWORK_TYPE, Byte.valueOf((String) sourceNetworkType)));
+ }
+ }
+
+ //SOURCE_BEARER_TYPE
+ Object sourceBearerType = message.getProperty(SOURCE_BEARER_TYPE);
+ if (sourceBearerType != null) {
+ if (sourceBearerType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_BEARER_TYPE, (Byte) sourceBearerType));
+ } else if (sourceBearerType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_BEARER_TYPE, Byte.valueOf((String) sourceBearerType)));
+ }
+ }
+
+ //SOURCE_TELEMATICS_ID
+ Object sourceTelematicsId = message.getProperty(SOURCE_TELEMATICS_ID);
+ if (sourceTelematicsId != null) {
+ if (sourceTelematicsId instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_TELEMATICS_ID, (Byte) sourceTelematicsId));
+ } else if (sourceTelematicsId instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SOURCE_TELEMATICS_ID, Byte.valueOf((String) sourceTelematicsId)));
+ }
+ }
+
+ //QOS_TIME_TO_LIVE
+ Object qosTimeToLive = message.getProperty(QOS_TIME_TO_LIVE);
+ if (qosTimeToLive != null) {
+ if (qosTimeToLive instanceof Integer) {
+ optionalParameters.add(new OptionalParameter.Int(Tag.QOS_TIME_TO_LIVE, (Integer) qosTimeToLive));
+ } else if (qosTimeToLive instanceof String) {
+ optionalParameters.add(new OptionalParameter.Int(Tag.QOS_TIME_TO_LIVE, Integer.valueOf((String) qosTimeToLive)));
+ }
+ }
+
+
+ //PAYLOAD_TYPE
+ Object payloadType = message.getProperty(PAYLOAD_TYPE);
+ if (payloadType != null) {
+ if (payloadType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.PAYLOAD_TYPE, (Byte) payloadType));
+ } else if (payloadType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.PAYLOAD_TYPE, Byte.valueOf((String) payloadType)));
+ }
+ }
+
+ //ADDITIONAL_STATUS_INFO_TEXT
+ Object additionalStatusInfoText = message.getProperty(ADDITIONAL_STATUS_INFO_TEXT);
+ if (additionalStatusInfoText != null) {
+ if (additionalStatusInfoText instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.ADDITIONAL_STATUS_INFO_TEXT.code(), (String) additionalStatusInfoText));
+ }
+ }
+
+ //RECEIPTED_MESSAGE_ID
+ Object recipientMessageId = message.getProperty(RECEIPTED_MESSAGE_ID);
+ if (recipientMessageId != null) {
+ if (recipientMessageId instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.RECEIPTED_MESSAGE_ID.code(), (String) recipientMessageId));
+ }
+ }
+
+ //MS_MSG_WAIT_FACILITIES
+ Object msMsgWaitFacilities = message.getProperty(MS_MSG_WAIT_FACILITIES);
+ if (msMsgWaitFacilities != null) {
+ if (msMsgWaitFacilities instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_MSG_WAIT_FACILITIES, (Byte) msMsgWaitFacilities));
+ } else if (msMsgWaitFacilities instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_MSG_WAIT_FACILITIES, Byte.valueOf((String) msMsgWaitFacilities)));
+ }
+ }
+
+ //PRIVACY_INDICATOR
+ Object privacyIndicator = message.getProperty(PRIVACY_INDICATOR);
+ if (privacyIndicator != null) {
+ if (privacyIndicator instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.PRIVACY_INDICATOR, (Byte) privacyIndicator));
+ } else if (privacyIndicator instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.PRIVACY_INDICATOR, Byte.valueOf((String) privacyIndicator)));
+ }
+ }
+
+ //SOURCE_SUBADDRESS
+ Object sourceSubAddress = message.getProperty(SOURCE_SUBADDRESS);
+ if (sourceSubAddress != null) {
+ if (sourceSubAddress instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.SOURCE_SUBADDRESS.code(), (String) sourceSubAddress));
+ }
+ }
+
+ //DEST_SUBADDRESS
+ Object destSubAddress = message.getProperty(DEST_SUBADDRESS);
+ if (destSubAddress != null) {
+ if (destSubAddress instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.DEST_SUBADDRESS.code(), (String) destSubAddress));
+ }
+ }
+
+ //USER_MESSAGE_REFERENCE
+ Object userMessageReference = message.getProperty(USER_MESSAGE_REFERENCE);
+ if (userMessageReference != null) {
+ if (userMessageReference instanceof Short) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.USER_MESSAGE_REFERENCE, (Short) userMessageReference));
+ } else if (userMessageReference instanceof String) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.USER_MESSAGE_REFERENCE, Short.valueOf((String) userMessageReference)));
+ }
+ }
+
+
+ //USER_RESPONSE_CODE
+ Object userResponseCode = message.getProperty(USER_RESPONSE_CODE);
+ if (userResponseCode != null) {
+ if (userResponseCode instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.USER_RESPONSE_CODE, (Byte) userResponseCode));
+ } else if (userResponseCode instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.USER_RESPONSE_CODE, Byte.valueOf((String) userResponseCode)));
+ }
+ }
+
+
+ //SOURCE_PORT
+ Object sourcePort = message.getProperty(SOURCE_PORT);
+ if (sourcePort != null) {
+ if (sourcePort instanceof Short) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.SOURCE_PORT, (Short) sourcePort));
+ } else if (sourcePort instanceof String) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.SOURCE_PORT, Short.valueOf((String) sourcePort)));
+ }
+ }
+
+
+ //DESTINATION_PORT
+ Object desitinationPort = message.getProperty(DESTINATION_PORT);
+ if (desitinationPort != null) {
+ if (desitinationPort instanceof Short) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.DESTINATION_PORT, (Short) desitinationPort));
+ } else if (desitinationPort instanceof String) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.DESTINATION_PORT, Short.valueOf((String) desitinationPort)));
+ }
+ }
+
+ //SAR_MSG_REF_NUM
+ Object sarMsgRefNum = message.getProperty(SAR_MSG_REF_NUM);
+ if (sarMsgRefNum != null) {
+ if (sarMsgRefNum instanceof Short) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.SAR_MSG_REF_NUM, (Short) sarMsgRefNum));
+ } else if (sarMsgRefNum instanceof String) {
+ optionalParameters.add(new OptionalParameter.Short(Tag.SAR_MSG_REF_NUM, Short.valueOf((String) sarMsgRefNum)));
+ }
+ }
+
+ //LANGUAGE_INDICATOR
+ Object languageIndicator = message.getProperty(LANGUAGE_INDICATOR);
+ if (languageIndicator != null) {
+ if (languageIndicator instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.LANGUAGE_INDICATOR, (Byte) languageIndicator));
+ } else if (languageIndicator instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.LANGUAGE_INDICATOR, Byte.valueOf((String) languageIndicator)));
+ }
+ }
+
+
+ //SAR_TOTAL_SEGMENTS
+ Object sarTotalSegments = message.getProperty(SAR_TOTAL_SEGMENTS);
+ if (sarTotalSegments != null) {
+ if (sarTotalSegments instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SAR_TOTAL_SEGMENTS, (Byte) sarTotalSegments));
+ } else if (sarTotalSegments instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SAR_TOTAL_SEGMENTS, Byte.valueOf((String) sarTotalSegments)));
+ }
+ }
+
+ //SAR_SEGMENT_SEQNUM
+ Object sarSegmentSeqNum = message.getProperty(SAR_SEGMENT_SEQNUM);
+ if (sarSegmentSeqNum != null) {
+ if (sarSegmentSeqNum instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SAR_SEGMENT_SEQNUM, (Byte) sarSegmentSeqNum));
+ } else if (sarSegmentSeqNum instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SAR_SEGMENT_SEQNUM, Byte.valueOf((String) sarSegmentSeqNum)));
+ }
+ }
+
+ //SC_INTERFACE_VERSION
+ Object scInterfaceVersion = message.getProperty(SC_INTERFACE_VERSION);
+ if (scInterfaceVersion != null) {
+ if (scInterfaceVersion instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SC_INTERFACE_VERSION, (Byte) scInterfaceVersion));
+ } else if (scInterfaceVersion instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SC_INTERFACE_VERSION, Byte.valueOf((String) scInterfaceVersion)));
+ }
+ }
+
+
+ //CALLBACK_NUM_PRES_IND
+ Object callbackNumPresInd = message.getProperty(CALLBACK_NUM_PRES_IND);
+ if (callbackNumPresInd != null) {
+ if (callbackNumPresInd instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.CALLBACK_NUM_PRES_IND, (Byte) callbackNumPresInd));
+ } else if (callbackNumPresInd instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.CALLBACK_NUM_PRES_IND, Byte.valueOf((String) callbackNumPresInd)));
+ }
+ }
+
+ //CALLBACK_NUM_ATAG
+ Object callbackNumAtag = message.getProperty(CALLBACK_NUM_ATAG);
+ if (callbackNumAtag != null) {
+ if (callbackNumAtag instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.CALLBACK_NUM_ATAG.code(), (String) callbackNumAtag));
+ }
+ }
+
+ //NUMBER_OF_MESSAGES
+ Object numberOfMessages = message.getProperty(NUMBER_OF_MESSAGES);
+ if (numberOfMessages != null) {
+ if (numberOfMessages instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.NUMBER_OF_MESSAGES, (Byte) numberOfMessages));
+ } else if (numberOfMessages instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.NUMBER_OF_MESSAGES, Byte.valueOf((String) numberOfMessages)));
+ }
+ }
+
+ //CALLBACK_NUM
+ Object callbackNum = message.getProperty(CALLBACK_NUM);
+ if (callbackNum != null) {
+ if (callbackNum instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.CALLBACK_NUM.code(), (String) callbackNum));
+ }
+ }
+
+ //DPF_RESULT
+ Object dpfResult = message.getProperty(DPF_RESULT);
+ if (dpfResult != null) {
+ if (dpfResult instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DPF_RESULT, (Byte) dpfResult));
+ } else if (dpfResult instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DPF_RESULT, Byte.valueOf((String) dpfResult)));
+ }
+ }
+
+ //SET_DPF
+ Object setDpf = message.getProperty(SET_DPF);
+ if (setDpf != null) {
+ if (setDpf instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SET_DPF, (Byte) setDpf));
+ } else if (setDpf instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SET_DPF, Byte.valueOf((String) setDpf)));
+ }
+ }
+
+ //MS_AVAILABILITY_STATUS
+ Object msAvailabilityStatus = message.getProperty(MS_AVAILABILITY_STATUS);
+ if (msAvailabilityStatus != null) {
+ if (msAvailabilityStatus instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_AVAILABILITY_STATUS, (Byte) msAvailabilityStatus));
+ } else if (msAvailabilityStatus instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_AVAILABILITY_STATUS, Byte.valueOf((String) msAvailabilityStatus)));
+ }
+ }
+
+ //NETWORK_ERROR_CODE
+ Object networkErrorCode = message.getProperty(NETWORK_ERROR_CODE);
+ if (networkErrorCode != null) {
+ if (networkErrorCode instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.NETWORK_ERROR_CODE.code(), (String) networkErrorCode));
+ }
+ }
+
+ //MESSAGE_PAYLOAD
+ Object messagePayload = message.getProperty(MESSAGE_PAYLOAD);
+ if (messagePayload != null) {
+ if (messagePayload instanceof String) {
+ optionalParameters.add(new OptionalParameter.COctetString(Tag.MESSAGE_PAYLOAD.code(), (String) messagePayload));
+ }
+ }
+
+ //DELIVERY_FAILURE_REASON
+ Object deliveryFailureReason = message.getProperty(DELIVERY_FAILURE_REASON);
+ if (deliveryFailureReason != null) {
+ if (deliveryFailureReason instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DELIVERY_FAILURE_REASON, (Byte) deliveryFailureReason));
+ } else if (deliveryFailureReason instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DELIVERY_FAILURE_REASON, Byte.valueOf((String) deliveryFailureReason)));
+ }
+ }
+
+ //MORE_MESSAGES_TO_SEND
+ Object moreMessagesToSent = message.getProperty(MORE_MESSAGES_TO_SEND);
+ if (moreMessagesToSent != null) {
+ if (moreMessagesToSent instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MORE_MESSAGES_TO_SEND, (Byte) moreMessagesToSent));
+ } else if (moreMessagesToSent instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MORE_MESSAGES_TO_SEND, Byte.valueOf((String) moreMessagesToSent)));
+ }
+ }
+
+ //MESSAGE_STATE
+ Object messageState = message.getProperty(MESSAGE_STATE);
+ if (messageState != null) {
+ if (messageState instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MESSAGE_STATE, (Byte) messageState));
+ } else if (messageState instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MESSAGE_STATE, Byte.valueOf((String) messageState)));
+ }
+ }
+
+ //USSD_SERVICE_OP
+ Object ussdServiceOP = message.getProperty(USSD_SERVICE_OP);
+ if (ussdServiceOP != null) {
+ if (ussdServiceOP instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.USSD_SERVICE_OP, (Byte) ussdServiceOP));
+ } else if (ussdServiceOP instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.USSD_SERVICE_OP, Byte.valueOf((String) ussdServiceOP)));
+ }
+ }
+
+ //DISPLAY_TIME
+ Object displayTime = message.getProperty(DISPLAY_TIME);
+ if (displayTime != null) {
+ if (displayTime instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DISPLAY_TIME, (Byte) displayTime));
+ } else if (displayTime instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.DISPLAY_TIME, Byte.valueOf((String) displayTime)));
+ }
+ }
+
+ //SMS_SIGNAL
+ Object smsSignal = message.getProperty(SMS_SIGNAL);
+ if (smsSignal != null) {
+ if (smsSignal instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SMS_SIGNAL, (Byte) smsSignal));
+ } else if (smsSignal instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.SMS_SIGNAL, Byte.valueOf((String) smsSignal)));
+ }
+ }
+
+ //ALERT_ON_MESSAGE_DELIVERY
+ Object alertOnMessageDelivery = message.getProperty(ALERT_ON_MESSAGE_DELIVERY);
+ if (alertOnMessageDelivery != null) {
+ optionalParameters.add(new OptionalParameter.Null(Tag.ALERT_ON_MESSAGE_DELIVERY));
+ }
+
+ //MS_VALIDITY
+ Object msValidity = message.getProperty(MS_VALIDITY);
+ if (msValidity != null) {
+ if (msValidity instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_VALIDITY, (Byte) msValidity));
+ } else if (msValidity instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.MS_VALIDITY, Byte.valueOf((String) msValidity)));
+ }
+ }
+
+
+ //ITS_REPLY_TYPE
+ Object itsReplyType = message.getProperty(ITS_REPLY_TYPE);
+ if (itsReplyType != null) {
+ if (itsReplyType instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.ITS_REPLY_TYPE, (Byte) itsReplyType));
+ } else if (itsReplyType instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.ITS_REPLY_TYPE, Byte.valueOf((String) itsReplyType)));
+ }
+ }
+
+
+ //ITS_SESSION_INFO
+ Object itsSessionInfo = message.getProperty(ITS_SESSION_INFO);
+ if (itsSessionInfo != null) {
+ if (itsSessionInfo instanceof Byte) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.ITS_SESSION_INFO, (Byte) itsSessionInfo));
+ } else if (itsSessionInfo instanceof String) {
+ optionalParameters.add(new OptionalParameter.Byte(Tag.ITS_SESSION_INFO, Byte.valueOf((String) itsSessionInfo)));
+ }
+ }
+
+ if (!optionalParameters.isEmpty()) {
+ request.setOptionalParametes(optionalParameters.toArray(new OptionalParameter[optionalParameters.size()]));
+ }
}
-
+
private String getFirstNodeValue(NodeList node) {
- return node.item(0).getChildNodes().item(0).getNodeValue();
+ return node.item(0).getChildNodes().item(0).getNodeValue();
}
-
+
private NodeList getNotEmptyNodeListOrNull(Document document, String nodeName) {
- NodeList node = document.getElementsByTagName(nodeName);
- return (node != null && node.getLength() > 0) ? node : null;
+ NodeList node = document.getElementsByTagName(nodeName);
+ return (node != null && node.getLength() > 0) ? node : null;
}
-
- /**
+
+ /**
* Get the <tt>SMSCDeliveryReceipt</tt> based on the specified byte value
* representation.
- *
+ *
* @param value is the byte value representation.
* @return is the enum const related to the specified byte value.
* @throws IllegalArgumentException if there is no enum const associated
- * with specified byte value.
+ * with specified byte value.
*/
- private SMSCDeliveryReceipt determineSMSCDeliveryReceipt(byte value) {
- for (SMSCDeliveryReceipt val : SMSCDeliveryReceipt.values()) {
- if (val.value() == value)
- return val;
- }
-
- throw new IllegalArgumentException("No enum const SMSCDeliveryReceipt with value " + value);
+ private SMSCDeliveryReceipt determineSMSCDeliveryReceipt(byte value) {
+ for (SMSCDeliveryReceipt val : SMSCDeliveryReceipt.values()) {
+ if (val.value() == value) {
+ return val;
+ }
+ }
+
+ throw new IllegalArgumentException("No enum const SMSCDeliveryReceipt with value " + value);
}
-}
\ No newline at end of file
+}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java Fri Sep 10 08:56:03 2010
@@ -16,34 +16,34 @@
*/
package org.apache.servicemix.smpp.marshaler;
+import org.jsmpp.bean.MessageRequest;
+
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.TransformerException;
-import org.jsmpp.bean.MessageRequest;
-
/**
* this is the common marshaler interface for all SMPP marshalers
- *
+ *
* @author jbonofre
* @author lhein
*/
public interface SmppMarshalerSupport {
/**
* Converts a normalized message from the NMR into SMPP message
- *
+ *
* @param exchange the <code>MessageExchange</code>
- * @param message the <code>NormalizedMessage</code>
+ * @param message the <code>NormalizedMessage</code>
* @return the <code>MessageRequest</code> SMS content wrapper
*/
MessageRequest fromNMS(MessageExchange exchange, NormalizedMessage message) throws TransformerException;
/**
* Converts the received SMPP message into a normalized message
- *
+ *
* @param message the <code>NormalizedMessage</code> to send on the NMR
- * @param mr the <code>MessageRequest</code> SMS content wrapper
+ * @param mr the <code>MessageRequest</code> SMS content wrapper
*/
void toNMS(NormalizedMessage message, MessageRequest mr) throws MessagingException;
}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/main/resources/OSGI-INF/blueprint/servicemix-smpp.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/main/resources/OSGI-INF/blueprint/servicemix-smpp.xml?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/main/resources/OSGI-INF/blueprint/servicemix-smpp.xml (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/main/resources/OSGI-INF/blueprint/servicemix-smpp.xml Fri Sep 10 08:56:03 2010
@@ -22,7 +22,7 @@
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
<bean id="servicemix-smpp" class="org.apache.servicemix.smpp.SmppComponent">
- <property name="executorFactory" ref="executorFactory" />
+ <property name="executorFactory" ref="executorFactory"/>
</bean>
<bean id="executorFactory" class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">
@@ -36,19 +36,19 @@
</bean>
<bean id="endpoint-tracker" class="org.apache.servicemix.common.osgi.EndpointTracker">
- <property name="component" ref="servicemix-smpp" />
+ <property name="component" ref="servicemix-smpp"/>
</bean>
<reference-list id="endpoints"
- interface="org.apache.servicemix.common.osgi.EndpointWrapper"
- availability="optional">
- <reference-listener ref="endpoint-tracker" bind-method="register" unbind-method="unregister" />
+ interface="org.apache.servicemix.common.osgi.EndpointWrapper"
+ availability="optional">
+ <reference-listener ref="endpoint-tracker" bind-method="register" unbind-method="unregister"/>
</reference-list>
<service ref="servicemix-smpp" interface="javax.jbi.component.Component">
<service-properties>
- <entry key="NAME" value="servicemix-smpp" />
- <entry key="TYPE" value="binding-component" />
+ <entry key="NAME" value="servicemix-smpp"/>
+ <entry key="TYPE" value="binding-component"/>
</service-properties>
</service>
@@ -69,7 +69,7 @@
<cm:property name="threadPoolCorePoolSize" value="8"/>
<cm:property name="threadPoolMaximumPoolSize" value="32"/>
<cm:property name="threadPoolQueueSize" value="256"/>
- </cm:default-properties>
+ </cm:default-properties>
</cm:property-placeholder>
-
+
</blueprint>
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppConsumerEndpointTest.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppConsumerEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppConsumerEndpointTest.java Fri Sep 10 08:56:03 2010
@@ -16,138 +16,137 @@
*/
package org.apache.servicemix.smpp;
+import junit.framework.TestCase;
+import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
+import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
+import org.apache.servicemix.tck.mock.MockMessageExchange;
+
import javax.jbi.management.DeploymentException;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.xml.namespace.QName;
-import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
-import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
-import org.apache.servicemix.tck.mock.MockMessageExchange;
-
-import junit.framework.TestCase;
-
/**
* JUnit test class for <code>org.apache.servicemix.smpp.SmppConsumerEndpoint</code>
- *
+ *
* @author mullerc
*/
public class SmppConsumerEndpointTest extends TestCase {
-
- private SmppConsumerEndpoint endpoint;
- protected void setUp() throws Exception {
- super.setUp();
- this.endpoint = new SmppConsumerEndpoint();
- this.endpoint.setTargetService(new QName("http://test", "service"));
- }
-
- public void testValidateWithMinAttr() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
-
- this.endpoint.validate();
-
- assertEquals("localhost", this.endpoint.getHost());
- assertEquals(2775, this.endpoint.getPort());
- assertEquals("test", this.endpoint.getSystemId());
- assertNull(this.endpoint.getPassword());
- assertEquals(50000, this.endpoint.getEnquireLinkTimer());
- assertEquals(100000, this.endpoint.getTransactionTimer());
- assertNotNull(this.endpoint.getMarshaler());
- }
-
- public void testValidateWithMaxAttr() throws DeploymentException {
- SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
- this.endpoint.setHost("localhost");
- this.endpoint.setPort(2700);
- this.endpoint.setSystemId("test");
- this.endpoint.setPassword("password");
- this.endpoint.setEnquireLinkTimer(10000);
- this.endpoint.setTransactionTimer(20000);
- this.endpoint.setMarshaler(marshaler);
-
- this.endpoint.validate();
-
- assertEquals("localhost", this.endpoint.getHost());
- assertEquals(2700, this.endpoint.getPort());
- assertEquals("test", this.endpoint.getSystemId());
- assertEquals("password", this.endpoint.getPassword());
- assertEquals(10000, this.endpoint.getEnquireLinkTimer());
- assertEquals(20000, this.endpoint.getTransactionTimer());
- assertSame(marshaler, this.endpoint.getMarshaler());
- }
-
- public void testValidateWithoutHost() throws DeploymentException {
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateWithoutSystemId() throws DeploymentException {
- this.endpoint.setHost("localhost");
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateInvalidEnquireLinkTimer() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
- this.endpoint.setEnquireLinkTimer(0);
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateInvalidTransactionTimer() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
- this.endpoint.setTransactionTimer(0);
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testProcessExchangeStatusDONE() throws Exception {
- MessageExchange exchange = new MockMessageExchange();
- exchange.setStatus(ExchangeStatus.DONE);
-
- this.endpoint.process(exchange);
- }
-
- public void testProcessExchangeStatusERROR() throws Exception {
- MessageExchange exchange = new MockMessageExchange();
- exchange.setStatus(ExchangeStatus.ERROR);
-
- this.endpoint.process(exchange);
- }
-
- public void testProcessExchangeStatusACTIVE() throws Exception {
- MessageExchange exchange = new MockMessageExchange();
- exchange.setStatus(ExchangeStatus.ACTIVE);
-
- try {
- this.endpoint.process(exchange);
- fail("MessagingException expected");
- } catch (MessagingException e) {
- // expected
- }
- }
-}
\ No newline at end of file
+ private SmppConsumerEndpoint endpoint;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.endpoint = new SmppConsumerEndpoint();
+ this.endpoint.setTargetService(new QName("http://test", "service"));
+ }
+
+ public void testValidateWithMinAttr() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+
+ this.endpoint.validate();
+
+ assertEquals("localhost", this.endpoint.getHost());
+ assertEquals(2775, this.endpoint.getPort());
+ assertEquals("test", this.endpoint.getSystemId());
+ assertNull(this.endpoint.getPassword());
+ assertEquals(50000, this.endpoint.getEnquireLinkTimer());
+ assertEquals(100000, this.endpoint.getTransactionTimer());
+ assertNotNull(this.endpoint.getMarshaler());
+ }
+
+ public void testValidateWithMaxAttr() throws DeploymentException {
+ SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
+ this.endpoint.setHost("localhost");
+ this.endpoint.setPort(2700);
+ this.endpoint.setSystemId("test");
+ this.endpoint.setPassword("password");
+ this.endpoint.setEnquireLinkTimer(10000);
+ this.endpoint.setTransactionTimer(20000);
+ this.endpoint.setMarshaler(marshaler);
+
+ this.endpoint.validate();
+
+ assertEquals("localhost", this.endpoint.getHost());
+ assertEquals(2700, this.endpoint.getPort());
+ assertEquals("test", this.endpoint.getSystemId());
+ assertEquals("password", this.endpoint.getPassword());
+ assertEquals(10000, this.endpoint.getEnquireLinkTimer());
+ assertEquals(20000, this.endpoint.getTransactionTimer());
+ assertSame(marshaler, this.endpoint.getMarshaler());
+ }
+
+ public void testValidateWithoutHost() throws DeploymentException {
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateWithoutSystemId() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateInvalidEnquireLinkTimer() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+ this.endpoint.setEnquireLinkTimer(0);
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateInvalidTransactionTimer() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+ this.endpoint.setTransactionTimer(0);
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testProcessExchangeStatusDONE() throws Exception {
+ MessageExchange exchange = new MockMessageExchange();
+ exchange.setStatus(ExchangeStatus.DONE);
+
+ this.endpoint.process(exchange);
+ }
+
+ public void testProcessExchangeStatusERROR() throws Exception {
+ MessageExchange exchange = new MockMessageExchange();
+ exchange.setStatus(ExchangeStatus.ERROR);
+
+ this.endpoint.process(exchange);
+ }
+
+ public void testProcessExchangeStatusACTIVE() throws Exception {
+ MessageExchange exchange = new MockMessageExchange();
+ exchange.setStatus(ExchangeStatus.ACTIVE);
+
+ try {
+ this.endpoint.process(exchange);
+ fail("MessagingException expected");
+ } catch (MessagingException e) {
+ // expected
+ }
+ }
+}
Modified: servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java?rev=995705&r1=995704&r2=995705&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-smpp/trunk/src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java Fri Sep 10 08:56:03 2010
@@ -16,106 +16,105 @@
*/
package org.apache.servicemix.smpp;
-import javax.jbi.management.DeploymentException;
-
+import junit.framework.TestCase;
import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
-import junit.framework.TestCase;
+import javax.jbi.management.DeploymentException;
/**
* JUnit test class for <code>org.apache.servicemix.smpp.SmppProviderEndpoint</code>
- *
+ *
* @author mullerc
*/
public class SmppProviderEndpointTest extends TestCase {
- private SmppProviderEndpoint endpoint;
-
- protected void setUp() throws Exception {
- super.setUp();
- this.endpoint = new SmppProviderEndpoint();
- }
-
- public void testValidateWithMinAttr() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
-
- this.endpoint.validate();
-
- assertEquals("localhost", this.endpoint.getHost());
- assertEquals(2775, this.endpoint.getPort());
- assertEquals("test", this.endpoint.getSystemId());
- assertNull(this.endpoint.getPassword());
- assertEquals(50000, this.endpoint.getEnquireLinkTimer());
- assertEquals(100000, this.endpoint.getTransactionTimer());
- assertNotNull(this.endpoint.getMarshaler());
- }
-
- public void testValidateWithMaxAttr() throws DeploymentException {
- SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
- this.endpoint.setHost("localhost");
- this.endpoint.setPort(2700);
- this.endpoint.setSystemId("test");
- this.endpoint.setPassword("password");
- this.endpoint.setEnquireLinkTimer(10000);
- this.endpoint.setTransactionTimer(20000);
- this.endpoint.setMarshaler(marshaler);
-
- this.endpoint.validate();
-
- assertEquals("localhost", this.endpoint.getHost());
- assertEquals(2700, this.endpoint.getPort());
- assertEquals("test", this.endpoint.getSystemId());
- assertEquals("password", this.endpoint.getPassword());
- assertEquals(10000, this.endpoint.getEnquireLinkTimer());
- assertEquals(20000, this.endpoint.getTransactionTimer());
- assertSame(marshaler, this.endpoint.getMarshaler());
- }
-
- public void testValidateWithoutHost() throws DeploymentException {
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateWithoutSystemId() throws DeploymentException {
- this.endpoint.setHost("localhost");
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateInvalidEnquireLinkTimer() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
- this.endpoint.setEnquireLinkTimer(0);
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testValidateInvalidTransactionTimer() throws DeploymentException {
- this.endpoint.setHost("localhost");
- this.endpoint.setSystemId("test");
- this.endpoint.setTransactionTimer(0);
-
- try {
- this.endpoint.validate();
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-}
\ No newline at end of file
+ private SmppProviderEndpoint endpoint;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.endpoint = new SmppProviderEndpoint();
+ }
+
+ public void testValidateWithMinAttr() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+
+ this.endpoint.validate();
+
+ assertEquals("localhost", this.endpoint.getHost());
+ assertEquals(2775, this.endpoint.getPort());
+ assertEquals("test", this.endpoint.getSystemId());
+ assertNull(this.endpoint.getPassword());
+ assertEquals(50000, this.endpoint.getEnquireLinkTimer());
+ assertEquals(100000, this.endpoint.getTransactionTimer());
+ assertNotNull(this.endpoint.getMarshaler());
+ }
+
+ public void testValidateWithMaxAttr() throws DeploymentException {
+ SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
+ this.endpoint.setHost("localhost");
+ this.endpoint.setPort(2700);
+ this.endpoint.setSystemId("test");
+ this.endpoint.setPassword("password");
+ this.endpoint.setEnquireLinkTimer(10000);
+ this.endpoint.setTransactionTimer(20000);
+ this.endpoint.setMarshaler(marshaler);
+
+ this.endpoint.validate();
+
+ assertEquals("localhost", this.endpoint.getHost());
+ assertEquals(2700, this.endpoint.getPort());
+ assertEquals("test", this.endpoint.getSystemId());
+ assertEquals("password", this.endpoint.getPassword());
+ assertEquals(10000, this.endpoint.getEnquireLinkTimer());
+ assertEquals(20000, this.endpoint.getTransactionTimer());
+ assertSame(marshaler, this.endpoint.getMarshaler());
+ }
+
+ public void testValidateWithoutHost() throws DeploymentException {
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateWithoutSystemId() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateInvalidEnquireLinkTimer() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+ this.endpoint.setEnquireLinkTimer(0);
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testValidateInvalidTransactionTimer() throws DeploymentException {
+ this.endpoint.setHost("localhost");
+ this.endpoint.setSystemId("test");
+ this.endpoint.setTransactionTimer(0);
+
+ try {
+ this.endpoint.validate();
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}