diff --git a/spring-integration-smpp/gradle.properties b/spring-integration-smpp/gradle.properties index f212918..bebfcbc 100644 --- a/spring-integration-smpp/gradle.properties +++ b/spring-integration-smpp/gradle.properties @@ -1 +1 @@ -version=2.2.0.BUILD-SNAPSHOT +version=1.0.0.BUILD-SNAPSHOT diff --git a/spring-integration-smpp/publish-maven.gradle b/spring-integration-smpp/publish-maven.gradle index 1f053ad..d7dd294 100644 --- a/spring-integration-smpp/publish-maven.gradle +++ b/spring-integration-smpp/publish-maven.gradle @@ -31,7 +31,7 @@ def customizePom(pom, gradleProject) { generatedPom.project { name = gradleProject.description description = gradleProject.description - url = 'https://github.com/SpringSource/spring-integration' + url = 'https://github.com/SpringSource/spring-integration-extensions' organization { name = 'SpringSource' url = 'http://springsource.org' @@ -44,17 +44,27 @@ def customizePom(pom, gradleProject) { } } scm { - url = 'https://github.com/SpringSource/spring-integration' - connection = 'scm:git:git://github.com/SpringSource/spring-integration' - developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration' + url = 'https://github.com/SpringSource/spring-integration-extensions' + connection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions' + developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions' } developers { developer { - id = 'not specified' + id = 'otnateos' name = 'Johanes Soetanto' email = 'not specified' } + developer { + id = 'ghillert' + name = 'Gunnar Hillert' + email = 'ghillert@vmware.com' + } + developer { + id = 'joshlong' + name = 'Josh Long' + email = 'jolong@vmware.com' + } } } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParser.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParser.java index e5c4f29..032039b 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParser.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,29 +27,29 @@ import org.w3c.dom.Element; * The Smpp Inbound Channel adapter parser * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppInboundChannelAdapterParser extends AbstractChannelAdapterParser { - @Override - protected boolean shouldGenerateId() { - return false; - } + @Override + protected boolean shouldGenerateId() { + return false; + } - @Override - protected boolean shouldGenerateIdAsFallback() { - return true; - } + @Override + protected boolean shouldGenerateIdAsFallback() { + return true; + } - @Override - protected AbstractBeanDefinition doParse(Element e, ParserContext context, String channelName) { - final BeanDefinitionBuilder builder = BeanDefinitionBuilder - .genericBeanDefinition(SmppInboundChannelAdapter.class); - SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", context, builder); - builder.addPropertyReference("channel", channelName); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "auto-startup","autoStartup"); - return builder.getBeanDefinition(); - } + @Override + protected AbstractBeanDefinition doParse(Element e, ParserContext context, String channelName) { + final BeanDefinitionBuilder builder = BeanDefinitionBuilder + .genericBeanDefinition(SmppInboundChannelAdapter.class); + SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", context, builder); + builder.addPropertyReference("channel", channelName); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "auto-startup","autoStartup"); + return builder.getBeanDefinition(); + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParser.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParser.java index 3683e6f..ab2448c 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParser.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,40 +26,40 @@ import org.w3c.dom.Element; * The Parser for Smpp Inbound Gateway. * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppInboundGatewayParser extends AbstractInboundGatewayParser { - @Override - protected Class getBeanClass(Element element) { - return SmppInboundGateway.class; - } + @Override + protected Class getBeanClass(Element element) { + return SmppInboundGateway.class; + } - @Override - protected boolean isEligibleAttribute(String n) { - return !n.equals("source-address") && !n.equals("source-ton") && !n.equals("smpp-session-ref") - && !n.equals("request-mapper") && !n.equals("reply-mapper") - && super.isEligibleAttribute(n); - } + @Override + protected boolean isEligibleAttribute(String n) { + return !n.equals("source-address") && !n.equals("source-ton") && !n.equals("smpp-session-ref") + && !n.equals("request-mapper") && !n.equals("reply-mapper") + && super.isEligibleAttribute(n); + } - @Override - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - super.doParse(element, parserContext, builder); - // because session need parserContext - SmppParserUtils.setSession(element, "smpp-session-ref", "session", "smppSession", parserContext, builder); - } + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { + super.doParse(element, parserContext, builder); + // because session need parserContext + SmppParserUtils.setSession(element, "smpp-session-ref", "session", "smppSession", parserContext, builder); + } - @Override - protected void doPostProcess(BeanDefinitionBuilder builder, Element e) { - // value - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); - SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "reply-timeout", "replyTimeout"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "request-timeout", "requestTimeout"); + @Override + protected void doPostProcess(BeanDefinitionBuilder builder, Element e) { + // value + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); + SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "reply-timeout", "replyTimeout"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "request-timeout", "requestTimeout"); - // reference - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "request-mapper", "requestMapper"); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "reply-mapper", "replyMapper"); - } + // reference + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "request-mapper", "requestMapper"); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "reply-mapper", "replyMapper"); + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppNamespaceHandler.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppNamespaceHandler.java index 4a0d3d3..d93c71d 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppNamespaceHandler.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHa * The namespace handler for the Smpp namespace * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppNamespaceHandler extends AbstractIntegrationNamespaceHandler { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParser.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParser.java index 143a9a4..e1aca20 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParser.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.w3c.dom.Element; * The parser for the Smpp Outbound Channel Adapter. * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { @@ -40,12 +40,12 @@ public class SmppOutboundChannelAdapterParser extends AbstractOutboundChannelAda @Override protected AbstractBeanDefinition parseConsumer(Element e, ParserContext parserContext) { final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SmppOutboundChannelAdapter.class); - // value attributes - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); - SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); - // reference attributes - SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", parserContext, builder); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "time-formatter", "timeFormatter"); + // value attributes + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); + SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); + // reference attributes + SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", parserContext, builder); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "time-formatter", "timeFormatter"); return builder.getBeanDefinition(); } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParser.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParser.java index 4450650..b193e6a 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParser.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,25 +24,25 @@ import org.w3c.dom.Element; /** * The Parser for Smpp Outbound Gateway. - * + * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppOutboundGatewayParser extends AbstractConsumerEndpointParser { @Override protected BeanDefinitionBuilder parseHandler(Element e, ParserContext parserContext) { final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SmppOutboundGateway.class); - // value attributes - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); + // value attributes + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "source-address", "defaultSourceAddress"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "reply-timeout", "sendTimeout"); - SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "order"); - // reference attributes - SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", parserContext, builder); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "reply-channel", "outputChannel"); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "time-formatter", "timeFormatter"); - return builder; + SmppParserUtils.setTon(e, "source-ton", "defaultSourceAddressTypeOfNumber", builder); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, e, "order"); + // reference attributes + SmppParserUtils.setSession(e, "smpp-session-ref", "session", "smppSession", parserContext, builder); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "reply-channel", "outputChannel"); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, e, "time-formatter", "timeFormatter"); + return builder; } @Override diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppParserUtils.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppParserUtils.java index 4a877ec..7697b31 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppParserUtils.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/config/xml/SmppParserUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.w3c.dom.Element; * respective {@link BeanDefinition}s. * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public final class SmppParserUtils { @@ -45,89 +45,89 @@ public final class SmppParserUtils { throw new AssertionError(); } - static void setSession(Element e, String sessionAttribute, String sessionChild, String propName, - ParserContext context, BeanDefinitionBuilder builder) { - final String sessionRef = e.getAttribute(sessionAttribute); - final Element sessionElement = DomUtils.getChildElementByTagName(e, sessionChild); - if(StringUtils.hasText(sessionRef)) { - if(sessionElement != null) { - context.getReaderContext().error("Child element '"+sessionChild+"' is not allowed when attribute '" - +sessionAttribute+"' has been specified", context.extractSource(sessionElement)); - } - builder.addPropertyReference(propName, sessionRef); - } else if(sessionElement != null) { - final String ref = sessionElement.getAttribute("ref"); - // - BeanComponentDefinition innerBean = IntegrationNamespaceUtils - .parseInnerHandlerDefinition(sessionElement, context); - if (StringUtils.hasText(ref)) { - builder.addPropertyReference(propName, ref); - } else if (innerBean != null) { - builder.addPropertyValue(propName, innerBean); - } - } else { - context.getReaderContext().error("Child element '"+sessionChild+"' or '"+sessionAttribute+"' attribute " - + "need to be specified", context.extractSource(e)); - } - } + static void setSession(Element e, String sessionAttribute, String sessionChild, String propName, + ParserContext context, BeanDefinitionBuilder builder) { + final String sessionRef = e.getAttribute(sessionAttribute); + final Element sessionElement = DomUtils.getChildElementByTagName(e, sessionChild); + if(StringUtils.hasText(sessionRef)) { + if(sessionElement != null) { + context.getReaderContext().error("Child element '"+sessionChild+"' is not allowed when attribute '" + +sessionAttribute+"' has been specified", context.extractSource(sessionElement)); + } + builder.addPropertyReference(propName, sessionRef); + } else if(sessionElement != null) { + final String ref = sessionElement.getAttribute("ref"); + // + BeanComponentDefinition innerBean = IntegrationNamespaceUtils + .parseInnerHandlerDefinition(sessionElement, context); + if (StringUtils.hasText(ref)) { + builder.addPropertyReference(propName, ref); + } else if (innerBean != null) { + builder.addPropertyValue(propName, innerBean); + } + } else { + context.getReaderContext().error("Child element '"+sessionChild+"' or '"+sessionAttribute+"' attribute " + + "need to be specified", context.extractSource(e)); + } + } - static void setTon(Element e, String tonAttribute, String propName, BeanDefinitionBuilder builder) { - final String ton = e.getAttribute(tonAttribute); - if (StringUtils.hasText(ton)) { - final RootBeanDefinition tonDef = new RootBeanDefinition(TypeOfNumber.class); - tonDef.setUniqueFactoryMethodName("valueOf"); - tonDef.getConstructorArgumentValues().addGenericArgumentValue(getByteTon(ton)); - builder.addPropertyValue(propName, tonDef); - } - } + static void setTon(Element e, String tonAttribute, String propName, BeanDefinitionBuilder builder) { + final String ton = e.getAttribute(tonAttribute); + if (StringUtils.hasText(ton)) { + final RootBeanDefinition tonDef = new RootBeanDefinition(TypeOfNumber.class); + tonDef.setUniqueFactoryMethodName("valueOf"); + tonDef.getConstructorArgumentValues().addGenericArgumentValue(getByteTon(ton)); + builder.addPropertyValue(propName, tonDef); + } + } - static void setNpi(Element e, String npiAttribute, String propName, BeanDefinitionBuilder builder) { - final String npi = e.getAttribute(npiAttribute); - if (StringUtils.hasText(npi)) { - final RootBeanDefinition npiDef = new RootBeanDefinition(NumberingPlanIndicator.class); - npiDef.setUniqueFactoryMethodName("valueOf"); - npiDef.getConstructorArgumentValues().addGenericArgumentValue(getByteNpi(npi)); - builder.addPropertyValue(propName, npiDef); - } - } + static void setNpi(Element e, String npiAttribute, String propName, BeanDefinitionBuilder builder) { + final String npi = e.getAttribute(npiAttribute); + if (StringUtils.hasText(npi)) { + final RootBeanDefinition npiDef = new RootBeanDefinition(NumberingPlanIndicator.class); + npiDef.setUniqueFactoryMethodName("valueOf"); + npiDef.getConstructorArgumentValues().addGenericArgumentValue(getByteNpi(npi)); + builder.addPropertyValue(propName, npiDef); + } + } - static void setBindType(Element e, String bindAttribute, String propName, BeanDefinitionBuilder builder) { - final String bt = e.getAttribute(bindAttribute); - if (StringUtils.hasText(bt)) { - final RootBeanDefinition bindTypeDef = new RootBeanDefinition(BindType.class); - bindTypeDef.setUniqueFactoryMethodName("valueOf"); - bindTypeDef.getConstructorArgumentValues().addGenericArgumentValue(getByteBind(bt)); - builder.addPropertyValue(propName, bindTypeDef); - } - } + static void setBindType(Element e, String bindAttribute, String propName, BeanDefinitionBuilder builder) { + final String bt = e.getAttribute(bindAttribute); + if (StringUtils.hasText(bt)) { + final RootBeanDefinition bindTypeDef = new RootBeanDefinition(BindType.class); + bindTypeDef.setUniqueFactoryMethodName("valueOf"); + bindTypeDef.getConstructorArgumentValues().addGenericArgumentValue(getByteBind(bt)); + builder.addPropertyValue(propName, bindTypeDef); + } + } - private static byte getByteTon(String t) { - if ("ABBREVIATED".equals(t)) return SMPPConstant.TON_ABBREVIATED; - if ("ALPHANUMERIC".equals(t)) return SMPPConstant.TON_ALPHANUMERIC; - if ("SUBSCRIBER_NUMBER".equals(t))return SMPPConstant.TON_SUBSCRIBER_NUMBER; - if ("NETWORK_SPECIFIC".equals(t))return SMPPConstant.TON_NETWORK_SPECIFIC; - if ("NATIONAL".equals(t)) return SMPPConstant.TON_NATIONAL; - if ("INTERNATIONAL".equals(t))return SMPPConstant.TON_INTERNATIONAL; - return SMPPConstant.TON_UNKNOWN; - } + private static byte getByteTon(String t) { + if ("ABBREVIATED".equals(t)) return SMPPConstant.TON_ABBREVIATED; + if ("ALPHANUMERIC".equals(t)) return SMPPConstant.TON_ALPHANUMERIC; + if ("SUBSCRIBER_NUMBER".equals(t))return SMPPConstant.TON_SUBSCRIBER_NUMBER; + if ("NETWORK_SPECIFIC".equals(t))return SMPPConstant.TON_NETWORK_SPECIFIC; + if ("NATIONAL".equals(t)) return SMPPConstant.TON_NATIONAL; + if ("INTERNATIONAL".equals(t))return SMPPConstant.TON_INTERNATIONAL; + return SMPPConstant.TON_UNKNOWN; + } - private static byte getByteNpi(String n) { - if ("WAP".equals(n)) return SMPPConstant.NPI_WAP; - if ("INTERNET".equals(n)) return SMPPConstant.NPI_INTERNET; - if ("ERMES".equals(n)) return SMPPConstant.NPI_ERMES; - if ("PRIVATE".equals(n)) return SMPPConstant.NPI_PRIVATE; - if ("NATIONAL".equals(n)) return SMPPConstant.NPI_NATIONAL; - if ("LAND_MOBILE".equals(n)) return SMPPConstant.NPI_LAND_MOBILE; - if ("TELEX".equals(n)) return SMPPConstant.NPI_TELEX; - if ("DATA".equals(n)) return SMPPConstant.NPI_DATA; - if ("ISDN".equals(n)) return SMPPConstant.NPI_ISDN; - return SMPPConstant.NPI_UNKNOWN; - } + private static byte getByteNpi(String n) { + if ("WAP".equals(n)) return SMPPConstant.NPI_WAP; + if ("INTERNET".equals(n)) return SMPPConstant.NPI_INTERNET; + if ("ERMES".equals(n)) return SMPPConstant.NPI_ERMES; + if ("PRIVATE".equals(n)) return SMPPConstant.NPI_PRIVATE; + if ("NATIONAL".equals(n)) return SMPPConstant.NPI_NATIONAL; + if ("LAND_MOBILE".equals(n)) return SMPPConstant.NPI_LAND_MOBILE; + if ("TELEX".equals(n)) return SMPPConstant.NPI_TELEX; + if ("DATA".equals(n)) return SMPPConstant.NPI_DATA; + if ("ISDN".equals(n)) return SMPPConstant.NPI_ISDN; + return SMPPConstant.NPI_UNKNOWN; + } - private static byte getByteBind(String b) { - if ("BIND_RX".equals(b)) return SMPPConstant.CID_BIND_RECEIVER; - if ("BIND_TX".equals(b)) return SMPPConstant.CID_BIND_TRANSMITTER; - return SMPPConstant.CID_BIND_TRANSCEIVER; - } + private static byte getByteBind(String b) { + if ("BIND_RX".equals(b)) return SMPPConstant.CID_BIND_RECEIVER; + if ("BIND_TX".equals(b)) return SMPPConstant.CID_BIND_TRANSMITTER; + return SMPPConstant.CID_BIND_TRANSCEIVER; + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/AbstractReceivingMessageListener.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/AbstractReceivingMessageListener.java index 02355f0..ae36adc 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/AbstractReceivingMessageListener.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/AbstractReceivingMessageListener.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.core; import org.apache.commons.logging.Log; @@ -10,7 +25,7 @@ import org.jsmpp.session.Session; /** * @author Josh Long - * @since 2.1 + * @since 1.0 */ abstract public class AbstractReceivingMessageListener implements MessageReceiverListener { @@ -28,9 +43,9 @@ abstract public class AbstractReceivingMessageListener implements MessageReceive logger.error("Failed getting delivery receipt", e); throw new RuntimeException(e); } - } else { + } else { try {// this is an actual SMS message - byte[] shortMessage = deliverSm.getShortMessage(); + byte[] shortMessage = deliverSm.getShortMessage(); String txtSms = shortMessage == null ? new String() : new String(shortMessage); logger.debug("Receiving message : " + txtSms); onTextMessage(deliverSm, txtSms); diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmesMessageSpecification.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmesMessageSpecification.java index f592fd1..3f0d826 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmesMessageSpecification.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmesMessageSpecification.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.core; import org.apache.commons.logging.Log; @@ -20,7 +35,7 @@ import static org.springframework.integration.smpp.core.SmppConstants.*; * fluent API to help make specifying all these parameters just a tiny bit easier. For internal use only. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class SmesMessageSpecification { @@ -103,12 +118,12 @@ public class SmesMessageSpecification { * this method will take an inbound Spring Integration {@link Message} and map it to a {@link SmesMessageSpecification} * which we can use to send the SMS message. * - * @param msg a new {@link Message} + * @param msg a new {@link Message} * @param smppSession the SMPPSession * @return a {@link SmesMessageSpecification} */ public static SmesMessageSpecification fromMessage(ClientSession smppSession, Message msg) { - if (log.isDebugEnabled()) log.debug("Message: "+msg); + if (log.isDebugEnabled()) log.debug("Message: "+msg); String srcAddy = valueIfHeaderExists(SRC_ADDR, msg); String dstAddy = valueIfHeaderExists(DST_ADDR, msg); String smsTxt = valueIfHeaderExists(SMS_MSG, msg); diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppConstants.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppConstants.java index c5bed67..a9df301 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppConstants.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppConstants.java @@ -1,9 +1,23 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.core; /** - * - * * @author Josh Long + * @since 1.0 */ public abstract class SmppConstants { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppHeaders.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppHeaders.java index 6d3267e..c3c21bd 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppHeaders.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/core/SmppHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ package org.springframework.integration.smpp.core; * Smpp adapter specific message headers. * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 */ public class SmppHeaders { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundChannelAdapter.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundChannelAdapter.java index e9bf475..ed45a38 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundChannelAdapter.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundChannelAdapter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.inbound; import org.jsmpp.bean.BindType; @@ -16,9 +31,9 @@ import org.springframework.util.Assert; * Supports receiving messages of a payload specified by the SMPP protocol from a short message service center (SMSC). * * @author Josh Long - * @since 2.1 - *

- * todo find some way to configure the {@link java.util.concurrent.Executor}running for the JSMPP library + * @since 1.0 + * + * TODO find some way to configure the {@link java.util.concurrent.Executor} running for the JSMPP library */ public class SmppInboundChannelAdapter extends AbstractEndpoint { @@ -46,27 +61,27 @@ public class SmppInboundChannelAdapter extends AbstractEndpoint { "receiving messages or both sending *and* receiving messages!"); } - /** - * Set smpp session - * @param s smpp session - */ + /** + * Set smpp session + * @param s smpp session + */ public void setSmppSession(ExtendedSmppSession s) { this.smppSession = s; } - private AbstractReceivingMessageListener abstractReceivingMessageListener = - new AbstractReceivingMessageListener() { - @Override - protected void onDeliveryReceipt(DeliverSm deliverSm, String ogMessageId, DeliveryReceipt deliveryReceipt) throws Exception { - // noop don't care - } + private AbstractReceivingMessageListener abstractReceivingMessageListener = + new AbstractReceivingMessageListener() { + @Override + protected void onDeliveryReceipt(DeliverSm deliverSm, String ogMessageId, DeliveryReceipt deliveryReceipt) throws Exception { + // noop don't care + } - @Override - protected void onTextMessage(DeliverSm deliverSm, String txtMessage) throws Exception { - Message msg = SmesMessageSpecification.toMessageFromSms(deliverSm, txtMessage); - messagingTemplate.send(msg); - } - }; + @Override + protected void onTextMessage(DeliverSm deliverSm, String txtMessage) throws Exception { + Message msg = SmesMessageSpecification.toMessageFromSms(deliverSm, txtMessage); + messagingTemplate.send(msg); + } + }; @Override protected void doStart() { @@ -79,9 +94,8 @@ public class SmppInboundChannelAdapter extends AbstractEndpoint { this.smppSession.stop(); } - - @Override - public String getComponentType() { - return "smpp:inbound-channel-adapter"; - } + @Override + public String getComponentType() { + return "smpp:inbound-channel-adapter"; + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundGateway.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundGateway.java index 4904851..a16633e 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundGateway.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/inbound/SmppInboundGateway.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.inbound; import org.jsmpp.bean.BindType; @@ -14,10 +29,10 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * what'running an inbound gateway in this case? Receive a text message and then automatically send a response. + * What'running an inbound gateway in this case? Receive a text message and then automatically send a response. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class SmppInboundGateway extends MessagingGatewaySupport { @@ -25,18 +40,18 @@ public class SmppInboundGateway extends MessagingGatewaySupport { private TypeOfNumber defaultSourceAddressTypeOfNumber; private String defaultSourceAddress; - /** - * Set default source address type of number. - * @param defaultSourceAddressTypeOfNumber default address type of number. - */ + /** + * Set default source address type of number. + * @param defaultSourceAddressTypeOfNumber default address type of number. + */ public void setDefaultSourceAddressTypeOfNumber(TypeOfNumber defaultSourceAddressTypeOfNumber) { this.defaultSourceAddressTypeOfNumber = defaultSourceAddressTypeOfNumber; } - /** - * Set default source address. - * @param defaultSourceAddress default source address - */ + /** + * Set default source address. + * @param defaultSourceAddress default source address + */ public void setDefaultSourceAddress(String defaultSourceAddress) { this.defaultSourceAddress = defaultSourceAddress; } @@ -126,8 +141,8 @@ public class SmppInboundGateway extends MessagingGatewaySupport { this.smppSession.stop(); } - @Override - public String getComponentType() { - return "smpp:inbound-gateway"; - } + @Override + public String getComponentType() { + return "smpp:inbound-gateway"; + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundChannelAdapter.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundChannelAdapter.java index ebad814..cef5f0a 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundChannelAdapter.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundChannelAdapter.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.outbound; import org.jsmpp.bean.BindType; @@ -21,7 +35,7 @@ import org.springframework.util.StringUtils; * This adapter supports mobile terminated (MT) messaging, where the recipient is a directory phone number. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class SmppOutboundChannelAdapter extends IntegrationObjectSupport implements MessageHandler { @@ -33,17 +47,14 @@ public class SmppOutboundChannelAdapter extends IntegrationObjectSupport impleme private ExtendedSmppSession smppSession; - @SuppressWarnings("unused") public void setDefaultSourceAddress(String defaultSourceAddress) { this.defaultSourceAddress = defaultSourceAddress; } - @SuppressWarnings("unused") public void setDefaultSourceAddressTypeOfNumber(TypeOfNumber defaultSourceAddressTypeOfNumber) { this.defaultSourceAddressTypeOfNumber = defaultSourceAddressTypeOfNumber; } - @SuppressWarnings("unused") public void setTimeFormatter(TimeFormatter timeFormatter) { this.timeFormatter = timeFormatter; } @@ -77,7 +88,7 @@ public class SmppOutboundChannelAdapter extends IntegrationObjectSupport impleme this.smppSession = s; } - @Override + @Override public void handleMessage(Message message) throws MessagingException { try { @@ -99,8 +110,8 @@ public class SmppOutboundChannelAdapter extends IntegrationObjectSupport impleme } } - @Override - public String getComponentType() { - return "smpp:outbound-channel-adapter"; - } + @Override + public String getComponentType() { + return "smpp:outbound-channel-adapter"; + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundGateway.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundGateway.java index 1f4a3d1..487053d 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundGateway.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/outbound/SmppOutboundGateway.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.outbound; import org.jsmpp.bean.BindType; @@ -26,12 +40,12 @@ import org.springframework.util.StringUtils; *

* * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class SmppOutboundGateway extends AbstractReplyProducingMessageHandler { @Override protected void onInit() { - Assert.isTrue( + Assert.isTrue( this.smppSession.getBindType().equals(BindType.BIND_TX) || this.smppSession.getBindType().equals(BindType.BIND_TRX), "the smppSession's bindType must be BindType.BIND_TX or BindType.BIND_TRX"); @@ -65,17 +79,14 @@ public class SmppOutboundGateway extends AbstractReplyProducingMessageHandler { private ExtendedSmppSession smppSession; - @SuppressWarnings("unused") public void setDefaultSourceAddress(String defaultSourceAddress) { this.defaultSourceAddress = defaultSourceAddress; } - @SuppressWarnings("unused") public void setDefaultSourceAddressTypeOfNumber(TypeOfNumber defaultSourceAddressTypeOfNumber) { this.defaultSourceAddressTypeOfNumber = defaultSourceAddressTypeOfNumber; } - @SuppressWarnings("unused") public void setTimeFormatter(TimeFormatter timeFormatter) { this.timeFormatter = timeFormatter; } @@ -95,8 +106,8 @@ public class SmppOutboundGateway extends AbstractReplyProducingMessageHandler { this.smppSession = s; } - @Override - public String getComponentType() { - return "smpp:outbound-gateway"; - } + @Override + public String getComponentType() { + return "smpp:outbound-gateway"; + } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/DelegatingMessageReceiverListener.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/DelegatingMessageReceiverListener.java index 6fdf8f4..af32c51 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/DelegatingMessageReceiverListener.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/DelegatingMessageReceiverListener.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.session; import org.jsmpp.bean.AlertNotification; @@ -18,7 +32,7 @@ import java.util.concurrent.CopyOnWriteArraySet; * This class delegates all calls to as many {@link MessageReceiverListener}s as you'd like, regardless of when the registered listener was added. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class DelegatingMessageReceiverListener implements MessageReceiverListener { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSession.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSession.java index f3c38da..09fdad9 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSession.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSession.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.session; import org.jsmpp.bean.BindType; @@ -10,9 +24,10 @@ import org.jsmpp.session.MessageReceiverListener; *

  1. supports registration of multiple {@link org.jsmpp.session.MessageReceiverListener}s
* * @author Josh Long - * @since 2.1 + * @since 1.0 */ public interface ExtendedSmppSession extends ClientSession { + /** * a {@link MessageReceiverListener} implementation to be added to the set of existing listeners. *

diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSessionAdaptingDelegate.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSessionAdaptingDelegate.java index 131d491..79c6524 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSessionAdaptingDelegate.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/ExtendedSmppSessionAdaptingDelegate.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.session; import org.apache.commons.logging.Log; @@ -18,7 +32,7 @@ import java.io.IOException; * Adapts to the {@link ClientSession} API, while also providing the callbacks for the Spring container * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class ExtendedSmppSessionAdaptingDelegate implements /*Lifecycle,*/ ExtendedSmppSession, InitializingBean { @@ -92,8 +106,8 @@ public class ExtendedSmppSessionAdaptingDelegate implements /*Lifecycle,*/ Exten } public String submitShortMessage(String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, - String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, - String destinationAddr, ESMClass esmClass, byte protocolId, byte priorityFlag, String scheduleDeliveryTime, String validityPeriod, RegisteredDelivery registeredDelivery, byte replaceIfPresentFlag, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters) throws PDUException, ResponseTimeoutException, InvalidResponseException, NegativeResponseException, IOException { + String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, + String destinationAddr, ESMClass esmClass, byte protocolId, byte priorityFlag, String scheduleDeliveryTime, String validityPeriod, RegisteredDelivery registeredDelivery, byte replaceIfPresentFlag, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters) throws PDUException, ResponseTimeoutException, InvalidResponseException, NegativeResponseException, IOException { return session.submitShortMessage(serviceType, sourceAddrTon, sourceAddrNpi, sourceAddr, destAddrTon, destAddrNpi, destinationAddr, esmClass, protocolId, priorityFlag, scheduleDeliveryTime, validityPeriod, registeredDelivery, replaceIfPresentFlag, dataCoding, smDefaultMsgId, shortMessage, optionalParameters); } @@ -108,7 +122,7 @@ public class ExtendedSmppSessionAdaptingDelegate implements /*Lifecycle,*/ Exten } public void cancelShortMessage(String serviceType, String messageId, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, String sourceAddr, - TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, String destinationAddress) throws PDUException, ResponseTimeoutException, InvalidResponseException, NegativeResponseException, IOException { + TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, String destinationAddress) throws PDUException, ResponseTimeoutException, InvalidResponseException, NegativeResponseException, IOException { session.cancelShortMessage(serviceType, messageId, sourceAddrTon, sourceAddrNpi, sourceAddr, destAddrTon, destAddrNpi, destinationAddress); } @@ -165,6 +179,6 @@ public class ExtendedSmppSessionAdaptingDelegate implements /*Lifecycle,*/ Exten } public void afterPropertiesSet() throws Exception { - log.debug( "afterPropertiesSet!"); + log.debug( "afterPropertiesSet!"); } } diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/SmppSessionFactoryBean.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/SmppSessionFactoryBean.java index 080715b..bc1cd8d 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/SmppSessionFactoryBean.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/session/SmppSessionFactoryBean.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.session; import org.apache.commons.logging.Log; @@ -55,7 +69,7 @@ import java.util.Set; * @see org.jsmpp.session.SMPPSession#SMPPSession() * @see org.jsmpp.session.SMPPSession#connectAndBind(String, int, org.jsmpp.session.BindParameter) * @see org.jsmpp.session.SMPPSession#connectAndBind(String, int, org.jsmpp.bean.BindType, String, String, String, org.jsmpp.bean.TypeOfNumber, org.jsmpp.bean.NumberingPlanIndicator, String, long) - * @since 2.1 + * @since 1.0 */ public class SmppSessionFactoryBean implements FactoryBean, SmartLifecycle, InitializingBean { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentExecutingMethodHolder.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentExecutingMethodHolder.java index c66f633..05d7a35 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentExecutingMethodHolder.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentExecutingMethodHolder.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.util; import org.springframework.core.NamedThreadLocal; @@ -10,7 +24,7 @@ import java.lang.reflect.Method; * exception was thrown. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ abstract public class CurrentExecutingMethodHolder { diff --git a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentMethodExposingMethodInterceptor.java b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentMethodExposingMethodInterceptor.java index 063e9f8..0214d3b 100644 --- a/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentMethodExposingMethodInterceptor.java +++ b/spring-integration-smpp/src/main/java/org/springframework/integration/smpp/util/CurrentMethodExposingMethodInterceptor.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.util; import org.aopalliance.intercept.MethodInterceptor; @@ -11,7 +25,7 @@ import org.aopalliance.intercept.MethodInvocation; * In a sense, this is like JavaScript's method arity feature. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class CurrentMethodExposingMethodInterceptor implements MethodInterceptor { diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/MockSmppServer.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/MockSmppServer.java index 4d6ff19..4316588 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/MockSmppServer.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/MockSmppServer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; import org.jsmpp.PDUStringException; @@ -28,315 +43,321 @@ import java.util.concurrent.TimeoutException; *

  • Forward incoming submit_sm to client connected as Receiver/Transceiver
  • * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 */ public class MockSmppServer extends ServerResponseDeliveryAdapter implements Runnable, ServerMessageReceiverListener { - private static final Logger logger = LoggerFactory.getLogger(MockSmppServer.class); - private String systemId; - private String password; - private int port; - private Map connectionSessionMap = new HashMap(); + private static final Logger logger = LoggerFactory.getLogger(MockSmppServer.class); + private String systemId; + private String password; + private int port; + private Map connectionSessionMap = new HashMap(); - private final ExecutorService execService = Executors.newFixedThreadPool(5); - private final ExecutorService execServiceDelReceipt = Executors.newFixedThreadPool(100); - private final MessageIDGenerator messageIDGenerator = new RandomMessageIDGenerator(); + private final ExecutorService execService = Executors.newFixedThreadPool(5); + private final ExecutorService execServiceDelReceipt = Executors.newFixedThreadPool(100); + private final MessageIDGenerator messageIDGenerator = new RandomMessageIDGenerator(); - public MockSmppServer(int port, String systemId, String password) throws IOException { - this.systemId = systemId; - this.password = password; - this.port = port; - } + public MockSmppServer(int port, String systemId, String password) throws IOException { + this.systemId = systemId; + this.password = password; + this.port = port; + } - public void run() { - try { - SMPPServerSessionListener sessionListener = new SMPPServerSessionListener(port); - logger.info("Listening on port {}", port); - while (true) { - SMPPServerSession serverSession = sessionListener.accept(); - logger.info("Accepting connection for session {}", serverSession.getSessionId()); - serverSession.setMessageReceiverListener(this); - serverSession.setResponseDeliveryListener(this); - execService.execute(new WaitBindTask(serverSession, systemId, password, connectionSessionMap)); - } - } catch (IOException e) { - logger.error("IO error occurred", e); - } - } + public void run() { + try { + SMPPServerSessionListener sessionListener = new SMPPServerSessionListener(port); + logger.info("Listening on port {}", port); + while (true) { + SMPPServerSession serverSession = sessionListener.accept(); + logger.info("Accepting connection for session {}", serverSession.getSessionId()); + serverSession.setMessageReceiverListener(this); + serverSession.setResponseDeliveryListener(this); + execService.execute(new WaitBindTask(serverSession, systemId, password, connectionSessionMap)); + } + } + catch (IOException e) { + logger.error("IO error occurred", e); + } + } - public QuerySmResult onAcceptQuerySm(QuerySm querySm, - SMPPServerSession source) throws ProcessRequestException { - logger.info("Accepting query sm, but not implemented"); - return null; - } + public QuerySmResult onAcceptQuerySm(QuerySm querySm, + SMPPServerSession source) throws ProcessRequestException { + logger.info("Accepting query sm, but not implemented"); + return null; + } - public MessageId onAcceptSubmitSm(SubmitSm submitSm, - SMPPServerSession source) throws ProcessRequestException { - MessageId messageId = messageIDGenerator.newMessageId(); - logger.debug("Receiving submit_sm '{}', and will return message id {}", - new String(submitSm.getShortMessage()), messageId); - if (SMSCDeliveryReceipt.SUCCESS.containedIn(submitSm.getRegisteredDelivery()) - || SMSCDeliveryReceipt.SUCCESS_FAILURE.containedIn(submitSm.getRegisteredDelivery())) { - execServiceDelReceipt.execute(new DeliveryReceiptTask(source, submitSm, messageId)); + public MessageId onAcceptSubmitSm(SubmitSm submitSm, + SMPPServerSession source) throws ProcessRequestException { + MessageId messageId = messageIDGenerator.newMessageId(); + logger.debug("Receiving submit_sm '{}', and will return message id {}", + new String(submitSm.getShortMessage()), messageId); + if (SMSCDeliveryReceipt.SUCCESS.containedIn(submitSm.getRegisteredDelivery()) + || SMSCDeliveryReceipt.SUCCESS_FAILURE.containedIn(submitSm.getRegisteredDelivery())) { + execServiceDelReceipt.execute(new DeliveryReceiptTask(source, submitSm, messageId)); - } - // on single submit_sm we forward it to any receiver listening to specific address range - execServiceDelReceipt.execute(new MessageForwardTask(submitSm, connectionSessionMap)); - return messageId; - } + } + // on single submit_sm we forward it to any receiver listening to specific address range + execServiceDelReceipt.execute(new MessageForwardTask(submitSm, connectionSessionMap)); + return messageId; + } - public void onSubmitSmRespSent(MessageId messageId, - SMPPServerSession source) { - logger.debug("submit_sm_resp with message_id {} has been sent", messageId); - } + public void onSubmitSmRespSent(MessageId messageId, + SMPPServerSession source) { + logger.debug("submit_sm_resp with message_id {} has been sent", messageId); + } - public SubmitMultiResult onAcceptSubmitMulti(SubmitMulti submitMulti, - SMPPServerSession source) throws ProcessRequestException { - MessageId messageId = messageIDGenerator.newMessageId(); - logger.debug("Receiving submit_multi_sm '{}', and will return message id {}", - new String(submitMulti.getShortMessage()), messageId); - if (SMSCDeliveryReceipt.SUCCESS.containedIn(submitMulti.getRegisteredDelivery()) - || SMSCDeliveryReceipt.SUCCESS_FAILURE.containedIn(submitMulti.getRegisteredDelivery())) { - execServiceDelReceipt.execute(new DeliveryReceiptTask(source, submitMulti, messageId)); - } + public SubmitMultiResult onAcceptSubmitMulti(SubmitMulti submitMulti, + SMPPServerSession source) throws ProcessRequestException { + MessageId messageId = messageIDGenerator.newMessageId(); + logger.debug("Receiving submit_multi_sm '{}', and will return message id {}", + new String(submitMulti.getShortMessage()), messageId); + if (SMSCDeliveryReceipt.SUCCESS.containedIn(submitMulti.getRegisteredDelivery()) + || SMSCDeliveryReceipt.SUCCESS_FAILURE.containedIn(submitMulti.getRegisteredDelivery())) { + execServiceDelReceipt.execute(new DeliveryReceiptTask(source, submitMulti, messageId)); + } - return new SubmitMultiResult(messageId.getValue(), new UnsuccessDelivery[0]); - } + return new SubmitMultiResult(messageId.getValue(), new UnsuccessDelivery[0]); + } - public DataSmResult onAcceptDataSm(DataSm dataSm, Session source) - throws ProcessRequestException { - return null; - } + public DataSmResult onAcceptDataSm(DataSm dataSm, Session source) + throws ProcessRequestException { + return null; + } - public void onAcceptCancelSm(CancelSm cancelSm, SMPPServerSession source) - throws ProcessRequestException { - } + public void onAcceptCancelSm(CancelSm cancelSm, SMPPServerSession source) + throws ProcessRequestException { + } - public void onAcceptReplaceSm(ReplaceSm replaceSm, SMPPServerSession source) - throws ProcessRequestException { - } + public void onAcceptReplaceSm(ReplaceSm replaceSm, SMPPServerSession source) + throws ProcessRequestException { + } - private static class WaitBindTask implements Runnable { - private final SMPPServerSession serverSession; - private final String systemId; - private final String password; - private final Map connectionSessionMap; + private static class WaitBindTask implements Runnable { + private final SMPPServerSession serverSession; + private final String systemId; + private final String password; + private final Map connectionSessionMap; - public WaitBindTask(SMPPServerSession serverSession, String systemId, String password, - Map connectionSessionMap) { - this.serverSession = serverSession; - this.systemId = systemId; - this.password = password; - this.connectionSessionMap = connectionSessionMap; - } + public WaitBindTask(SMPPServerSession serverSession, String systemId, String password, + Map connectionSessionMap) { + this.serverSession = serverSession; + this.systemId = systemId; + this.password = password; + this.connectionSessionMap = connectionSessionMap; + } - private void registerBindRequest(BindRequest bindRequest) { - final String range = bindRequest.getAddressRange() == null ? "" : bindRequest.getAddressRange(); - connectionSessionMap.put(serverSession, range); - logger.debug("Register bind session {} on address range {}", serverSession.getSessionId(), range); - } + private void registerBindRequest(BindRequest bindRequest) { + final String range = bindRequest.getAddressRange() == null ? "" : bindRequest.getAddressRange(); + connectionSessionMap.put(serverSession, range); + logger.debug("Register bind session {} on address range {}", serverSession.getSessionId(), range); + } - public void run() { - try { - BindRequest bindRequest = serverSession.waitForBind(1000); - try { - if(bindRequest.getSystemId().equals(systemId) && bindRequest.getPassword().equals(password)) { - bindRequest.accept(systemId); - registerBindRequest(bindRequest); - } else { - logger.error("Invalid systemId/password"); - bindRequest.reject(SMPPConstant.STAT_ESME_RINVPASWD); - } - } catch (PDUStringException e) { - logger.error("Invalid system id", e); - bindRequest.reject(SMPPConstant.STAT_ESME_RSYSERR); - } + public void run() { + try { + BindRequest bindRequest = serverSession.waitForBind(1000); + try { + if(bindRequest.getSystemId().equals(systemId) && bindRequest.getPassword().equals(password)) { + bindRequest.accept(systemId); + registerBindRequest(bindRequest); + } + else { + logger.error("Invalid systemId/password"); + bindRequest.reject(SMPPConstant.STAT_ESME_RINVPASWD); + } + } + catch (PDUStringException e) { + logger.error("Invalid system id", e); + bindRequest.reject(SMPPConstant.STAT_ESME_RSYSERR); + } - } catch (IllegalStateException e) { - logger.error("System error", e); - } catch (TimeoutException e) { - logger.warn("Wait for bind has reach timeout", e); - } catch (IOException e) { - logger.error("Failed accepting bind request for session {}", serverSession.getSessionId()); - } - } - } + } + catch (IllegalStateException e) { + logger.error("System error", e); + } + catch (TimeoutException e) { + logger.warn("Wait for bind has reach timeout", e); + } + catch (IOException e) { + logger.error("Failed accepting bind request for session {}", serverSession.getSessionId()); + } + } + } - private static class DeliveryReceiptTask implements Runnable { - private final SMPPServerSession session; - private final MessageId messageId; + private static class DeliveryReceiptTask implements Runnable { + private final SMPPServerSession session; + private final MessageId messageId; - private final TypeOfNumber sourceAddrTon; - private final NumberingPlanIndicator sourceAddrNpi; - private final String sourceAddress; + private final TypeOfNumber sourceAddrTon; + private final NumberingPlanIndicator sourceAddrNpi; + private final String sourceAddress; - private final TypeOfNumber destAddrTon; - private final NumberingPlanIndicator destAddrNpi; - private final String destAddress; + private final TypeOfNumber destAddrTon; + private final NumberingPlanIndicator destAddrNpi; + private final String destAddress; - private final int totalSubmitted; - private final int totalDelivered; + private final int totalSubmitted; + private final int totalDelivered; - private final byte[] shortMessage; + private final byte[] shortMessage; - public DeliveryReceiptTask(SMPPServerSession session, - SubmitSm submitSm, MessageId messageId) { - this.session = session; - this.messageId = messageId; + public DeliveryReceiptTask(SMPPServerSession session, + SubmitSm submitSm, MessageId messageId) { + this.session = session; + this.messageId = messageId; - // reversing destination to source - sourceAddrTon = TypeOfNumber.valueOf(submitSm.getDestAddrTon()); - sourceAddrNpi = NumberingPlanIndicator.valueOf(submitSm.getDestAddrNpi()); - sourceAddress = submitSm.getDestAddress(); + // reversing destination to source + sourceAddrTon = TypeOfNumber.valueOf(submitSm.getDestAddrTon()); + sourceAddrNpi = NumberingPlanIndicator.valueOf(submitSm.getDestAddrNpi()); + sourceAddress = submitSm.getDestAddress(); - // reversing source to destination - destAddrTon = TypeOfNumber.valueOf(submitSm.getSourceAddrTon()); - destAddrNpi = NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()); - destAddress = submitSm.getSourceAddr(); + // reversing source to destination + destAddrTon = TypeOfNumber.valueOf(submitSm.getSourceAddrTon()); + destAddrNpi = NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()); + destAddress = submitSm.getSourceAddr(); - totalSubmitted = totalDelivered = 1; + totalSubmitted = totalDelivered = 1; - shortMessage = submitSm.getShortMessage(); - } + shortMessage = submitSm.getShortMessage(); + } - public DeliveryReceiptTask(SMPPServerSession session, - SubmitMulti submitMulti, MessageId messageId) { - this.session = session; - this.messageId = messageId; + public DeliveryReceiptTask(SMPPServerSession session, + SubmitMulti submitMulti, MessageId messageId) { + this.session = session; + this.messageId = messageId; - // set to unknown and null, since it was submit_multi - sourceAddrTon = TypeOfNumber.UNKNOWN; - sourceAddrNpi = NumberingPlanIndicator.UNKNOWN; - sourceAddress = null; + // set to unknown and null, since it was submit_multi + sourceAddrTon = TypeOfNumber.UNKNOWN; + sourceAddrNpi = NumberingPlanIndicator.UNKNOWN; + sourceAddress = null; - // reversing source to destination - destAddrTon = TypeOfNumber.valueOf(submitMulti.getSourceAddrTon()); - destAddrNpi = NumberingPlanIndicator.valueOf(submitMulti.getSourceAddrNpi()); - destAddress = submitMulti.getSourceAddr(); + // reversing source to destination + destAddrTon = TypeOfNumber.valueOf(submitMulti.getSourceAddrTon()); + destAddrNpi = NumberingPlanIndicator.valueOf(submitMulti.getSourceAddrNpi()); + destAddress = submitMulti.getSourceAddr(); - // distribution list assumed only contains single address - totalSubmitted = totalDelivered = submitMulti.getDestAddresses().length; + // distribution list assumed only contains single address + totalSubmitted = totalDelivered = submitMulti.getDestAddresses().length; - shortMessage = submitMulti.getShortMessage(); - } + shortMessage = submitMulti.getShortMessage(); + } - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - 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 { + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + 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, 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()); - 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); - } - } - } + 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()); + 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); + } + } + } - private static class MessageForwardTask implements Runnable { - private final SubmitSm submitSm; - private final SMPPServerSession destination; + private static class MessageForwardTask implements Runnable { + private final SubmitSm submitSm; + private final SMPPServerSession destination; - public MessageForwardTask(SubmitSm submitSm, Map connectedSessionMap) { - this.submitSm = submitSm; + public MessageForwardTask(SubmitSm submitSm, Map connectedSessionMap) { + this.submitSm = submitSm; - // I choose possible receiver - final List possibleReceivers = new ArrayList(); - final String destAddress = submitSm.getDestAddress(); - if (destAddress != null) { - for (SMPPServerSession receiver : connectedSessionMap.keySet()) { - if (receiver.getSessionState().isReceivable()) { - // the connected session can receive and address match - if (destAddressMatch(destAddress, connectedSessionMap.get(receiver))) { - possibleReceivers.add(receiver); - } - } - } - } - if(possibleReceivers.size() > 1) - logger.warn("There are {} receivers for number {}. This may have unintended result in your test" - , possibleReceivers.size(), submitSm.getDestAddress()); - this.destination = possibleReceivers.isEmpty() ? null : possibleReceivers.get(0); - } + // I choose possible receiver + final List possibleReceivers = new ArrayList(); + final String destAddress = submitSm.getDestAddress(); + if (destAddress != null) { + for (SMPPServerSession receiver : connectedSessionMap.keySet()) { + if (receiver.getSessionState().isReceivable()) { + // the connected session can receive and address match + if (destAddressMatch(destAddress, connectedSessionMap.get(receiver))) { + possibleReceivers.add(receiver); + } + } + } + } + if(possibleReceivers.size() > 1) + logger.warn("There are {} receivers for number {}. This may have unintended result in your test" + , possibleReceivers.size(), submitSm.getDestAddress()); + this.destination = possibleReceivers.isEmpty() ? null : possibleReceivers.get(0); + } - private boolean destAddressMatch(String destAddress, String receiverAddressRange) { - if(receiverAddressRange.equals("")) - return false; // not listening to any address - if (destAddress.equals(receiverAddressRange)) - return true; - String[] listeningAddressRange = receiverAddressRange.split(","); - for (String addr : listeningAddressRange) { - if(destAddress.equals(addr)) - return true; - if(destAddress.matches(addr)) - return true; - } - return false; - } + private boolean destAddressMatch(String destAddress, String receiverAddressRange) { + if(receiverAddressRange.equals("")) + return false; // not listening to any address + if (destAddress.equals(receiverAddressRange)) + return true; + String[] listeningAddressRange = receiverAddressRange.split(","); + for (String addr : listeningAddressRange) { + if(destAddress.equals(addr)) + return true; + if(destAddress.matches(addr)) + return true; + } + return false; + } - public void run() { - if (destination == null) { - // no receiver listening for message, so nothing to do here - return; - } + public void run() { + if (destination == null) { + // no receiver listening for message, so nothing to do here + return; + } - try { - final byte[] message = submitSm.getShortMessage(); - logger.debug("Forwards incoming message {} to session {}. from {} to {}", - new String[] {new String(message), destination.getSessionId(), - submitSm.getSourceAddr(), submitSm.getDestAddress()}); - destination.deliverShortMessage("mc", - TypeOfNumber.valueOf(submitSm.getSourceAddrTon()), - NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()), - submitSm.getSourceAddr(), - TypeOfNumber.valueOf(submitSm.getDestAddrTon()), - NumberingPlanIndicator.valueOf(submitSm.getDestAddrNpi()), - submitSm.getDestAddress(), - new ESMClass(MessageMode.DEFAULT, MessageType.DEFAULT, GSMSpecificFeature.DEFAULT), - (byte) 0, - (byte) 0, - new RegisteredDelivery(0), - DataCodings.ZERO, - message); - } catch (Exception e) { - logger.error("Fail forwarding message to consumer: " + destination.getSessionId(), e); - } - } - } + try { + final byte[] message = submitSm.getShortMessage(); + logger.debug("Forwards incoming message {} to session {}. from {} to {}", + new String[] {new String(message), destination.getSessionId(), + submitSm.getSourceAddr(), submitSm.getDestAddress()}); + destination.deliverShortMessage("mc", + TypeOfNumber.valueOf(submitSm.getSourceAddrTon()), + NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()), + submitSm.getSourceAddr(), + TypeOfNumber.valueOf(submitSm.getDestAddrTon()), + NumberingPlanIndicator.valueOf(submitSm.getDestAddrNpi()), + submitSm.getDestAddress(), + new ESMClass(MessageMode.DEFAULT, MessageType.DEFAULT, GSMSpecificFeature.DEFAULT), + (byte) 0, + (byte) 0, + new RegisteredDelivery(0), + DataCodings.ZERO, + message); + } catch (Exception e) { + logger.error("Fail forwarding message to consumer: " + destination.getSessionId(), e); + } + } + } - @PostConstruct - public void onPostConstruct() { - logger.debug("Starting mock SMPP server"); - execService.submit(this); - } + @PostConstruct + public void onPostConstruct() { + logger.debug("Starting mock SMPP server"); + execService.submit(this); + } - @PreDestroy - public void onDestroy() { - logger.debug("Destroying mock SMPP server"); - connectionSessionMap.clear(); - } + @PreDestroy + public void onDestroy() { + logger.debug("Destroying mock SMPP server"); + connectionSessionMap.clear(); + } } diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppConnection.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppConnection.java index 52b2ea0..baaeca2 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppConnection.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppConnection.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; import org.junit.Before; @@ -22,55 +36,58 @@ import java.util.concurrent.atomic.AtomicInteger; * Demonstrates that the {@link org.springframework.integration.smpp.session.SmppSessionFactoryBean} works, too. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ @ContextConfiguration("classpath:TestSmppConnection-context.xml") @RunWith(SpringJUnit4ClassRunner.class) public class TestSmppConnection { - @Value("${smpp.systemId}") - String destination; + @Value("${smpp.systemId}") + private String destination; - @Autowired SubscribableChannel inboundChannel; - @Autowired MessageChannel outboundChannel; - @Autowired SubscribableChannel receiptChannel; + @Autowired + private SubscribableChannel inboundChannel; - Message messageOut; + @Autowired + private MessageChannel outboundChannel; - AtomicInteger count = new AtomicInteger(); + @Autowired + private SubscribableChannel receiptChannel; - @Before - public void setUp() { - messageOut = MessageBuilder.withPayload("This is the message") - .setHeader(SmppConstants.DST_ADDR, destination) - .setHeader(SmppConstants.SRC_ADDR, destination) - .build(); - } + private Message messageOut; + private AtomicInteger count = new AtomicInteger(); + + @Before + public void setUp() { + messageOut = MessageBuilder.withPayload("This is the message") + .setHeader(SmppConstants.DST_ADDR, destination) + .setHeader(SmppConstants.SRC_ADDR, destination) + .build(); + } @Test public void testSmppConnection() throws Throwable { - MessageHandler standardInboundHandler = new MessageHandler() { - @Override - public void handleMessage(Message message) throws MessagingException { - System.out.println("Standard Inbound channel receive: " + message); - count.incrementAndGet(); - } - }; - MessageHandler receiptHandler = new MessageHandler() { - @Override - public void handleMessage(Message message) throws MessagingException { - String received = message.getPayload().toString(); - System.out.println("Outbound channel output receive receipt: " + received); - } - }; - inboundChannel.subscribe(standardInboundHandler); - receiptChannel.subscribe(receiptHandler); + MessageHandler standardInboundHandler = new MessageHandler() { + @Override + public void handleMessage(Message message) throws MessagingException { + System.out.println("Standard Inbound channel receive: " + message); + count.incrementAndGet(); + } + }; + MessageHandler receiptHandler = new MessageHandler() { + @Override + public void handleMessage(Message message) throws MessagingException { + String received = message.getPayload().toString(); + System.out.println("Outbound channel output receive receipt: " + received); + } + }; + inboundChannel.subscribe(standardInboundHandler); + receiptChannel.subscribe(receiptHandler); - outboundChannel.send(messageOut); + outboundChannel.send(messageOut); - Thread.sleep(5000); + Thread.sleep(5000); } - } diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundChannelAdapter.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundChannelAdapter.java index 8f8bfc4..33a938d 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundChannelAdapter.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundChannelAdapter.java @@ -1,7 +1,21 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.concurrent.atomic.AtomicInteger; + import org.jsmpp.bean.SMSCDeliveryReceipt; import org.junit.Assert; import org.junit.Before; @@ -19,23 +33,22 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.concurrent.atomic.AtomicInteger; - @ContextConfiguration("classpath:TestSmppInboundChannelAdapter-context.xml") @RunWith(SpringJUnit4ClassRunner.class) public class TestSmppInboundChannelAdapter { private String smsMessageToSend = "test SMPP message being sent from this time:"+ System.currentTimeMillis()+"."; - @Value("${test.dst.number}") String number; - - private Log log = LogFactory.getLog(getClass()); + @Value("${test.dst.number}") + private String number; private AtomicInteger atomicInteger = new AtomicInteger(); - @Value("#{outbound}") SubscribableChannel out; + @Value("#{outbound}") + private SubscribableChannel out; - @Value("#{inbound}") SubscribableChannel in; + @Value("#{inbound}") + private SubscribableChannel in; @Autowired private ApplicationContext context; @@ -45,7 +58,7 @@ public class TestSmppInboundChannelAdapter { Assert.assertNotNull(this.number); } - String lastReceivedSms = null ; + private String lastReceivedSms = null ; @Test public void testReceiving() throws Throwable { diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundGateway.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundGateway.java index 58b76d7..fd8179a 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundGateway.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppInboundGateway.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; import org.junit.Assert; @@ -24,7 +38,7 @@ import java.util.concurrent.atomic.AtomicInteger; @RunWith(SpringJUnit4ClassRunner.class) public class TestSmppInboundGateway { - private final Logger logger = LoggerFactory.getLogger(TestSmppInboundGateway.class); + private final Logger logger = LoggerFactory.getLogger(TestSmppInboundGateway.class); @Value("#{out1}") SubscribableChannel out1; @Value("#{out2}") SubscribableChannel out2; @@ -68,39 +82,39 @@ public class TestSmppInboundGateway { MessageHandler inboundMessageHandler = new AbstractReplyProducingMessageHandler() { - @Override - protected Object handleRequestMessage(Message requestMessage) { - logger.debug("Processing incoming message for inbound-gw and produce a reply"); - Assert.assertEquals(requestMessage.getPayload(), smsRequest); - count.incrementAndGet(); - return MessageBuilder.withPayload( - smsResponse).copyHeadersIfAbsent( requestMessage.getHeaders()).build(); + @Override + protected Object handleRequestMessage(Message requestMessage) { + logger.debug("Processing incoming message for inbound-gw and produce a reply"); + Assert.assertEquals(requestMessage.getPayload(), smsRequest); + count.incrementAndGet(); + return MessageBuilder.withPayload( + smsResponse).copyHeadersIfAbsent( requestMessage.getHeaders()).build(); - } - }; + } + }; this.in1.subscribe(inboundMessageHandler); - // this is handler for reply from inbound-gateway - MessageHandler replyHandler = new MessageHandler() { - @Override - public void handleMessage(Message message) throws MessagingException { - logger.debug("Reply handler receives: "+message.getPayload()); - Assert.assertEquals(message.getPayload(), smsResponse); - } - }; - this.in2.subscribe(replyHandler); + // this is handler for reply from inbound-gateway + MessageHandler replyHandler = new MessageHandler() { + @Override + public void handleMessage(Message message) throws MessagingException { + logger.debug("Reply handler receives: "+message.getPayload()); + Assert.assertEquals(message.getPayload(), smsResponse); + } + }; + this.in2.subscribe(replyHandler); - // outbound gateway send - logger.debug("Sending message from: {} to: {} message: '{}'", new String[] {fromPhone, toPhone, smsRequest}); - SmesMessageSpecification.newSmesMessageSpecification(outSession, this.fromPhone, this.toPhone, this.smsRequest).send(); - /*Message smsMsg = MessageBuilder.withPayload(smsRequest) - .setHeader(SmppConstants.SRC_ADDR, fromPhone) - .setHeader(SmppConstants.DST_ADDR, toPhone) - .setHeader(SmppConstants.REGISTERED_DELIVERY_MODE, SMSCDeliveryReceipt.SUCCESS) - .build(); - out2.send(smsMsg);*/ + // outbound gateway send + logger.debug("Sending message from: {} to: {} message: '{}'", new String[] {fromPhone, toPhone, smsRequest}); + SmesMessageSpecification.newSmesMessageSpecification(outSession, this.fromPhone, this.toPhone, this.smsRequest).send(); + /*Message smsMsg = MessageBuilder.withPayload(smsRequest) + .setHeader(SmppConstants.SRC_ADDR, fromPhone) + .setHeader(SmppConstants.DST_ADDR, toPhone) + .setHeader(SmppConstants.REGISTERED_DELIVERY_MODE, SMSCDeliveryReceipt.SUCCESS) + .build(); + out2.send(smsMsg);*/ - Thread.sleep(1000 * 10); + Thread.sleep(1000 * 10); Assert.assertEquals(this.count.intValue(),1); diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundChannelAdapter.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundChannelAdapter.java index ab8a29e..9361280 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundChannelAdapter.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundChannelAdapter.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; import org.apache.commons.logging.Log; @@ -19,13 +33,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * exercises the outbound adapter. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ @ContextConfiguration("classpath:TestSmppOutboundChannelAdapter-context.xml") @RunWith(SpringJUnit4ClassRunner.class) public class TestSmppOutboundChannelAdapter { - private Log log = LogFactory.getLog(getClass()); @Value("#{session}") @@ -37,11 +50,9 @@ public class TestSmppOutboundChannelAdapter { private String smsMessageToSend = "jSMPP is truly a convenient, and powerful API for SMPP " + "on the Java and Spring Integration platforms (sent " + System.currentTimeMillis() + ")"; - @Before public void start (){ - } @Test diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundGateway.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundGateway.java index d2516e7..e89e56d 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundGateway.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppOutboundGateway.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; import org.apache.commons.logging.Log; @@ -16,13 +30,13 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -/*** +/** * Simple tests for the gateway which differs from the outbound adapter only in that it supports * sending the message ID back * * * @author Josh Long - * @since 2.1 + * @since 1.0 */ @ContextConfiguration("classpath:TestSmppOutboundGateway-context.xml") @RunWith(SpringJUnit4ClassRunner.class) diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppSessionFactoryBean.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppSessionFactoryBean.java index a0a70d2..45d16b1 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppSessionFactoryBean.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/TestSmppSessionFactoryBean.java @@ -1,5 +1,22 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp; +import java.lang.reflect.Field; +import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jsmpp.bean.AlertNotification; @@ -11,8 +28,8 @@ import org.jsmpp.session.DataSmResult; import org.jsmpp.session.MessageReceiverListener; import org.jsmpp.session.SMPPSession; import org.jsmpp.session.Session; -import org.jsmpp.util.AbsoluteTimeFormatter; -import org.junit.*; +import org.junit.Assert; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -21,23 +38,22 @@ import org.springframework.integration.smpp.session.DelegatingMessageReceiverLis import org.springframework.integration.smpp.session.ExtendedSmppSession; import org.springframework.integration.smpp.session.ExtendedSmppSessionAdaptingDelegate; import org.springframework.integration.smpp.session.SmppSessionFactoryBean; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.ReflectionUtils; -import java.lang.reflect.Field; -import java.util.Set; - /** * Simple test, more of the SMPP API than anything, at the moment. *

    * Demonstrates that the {@link org.springframework.integration.smpp.session.SmppSessionFactoryBean} works, too. * * @author Josh Long - * @since 2.1 + * @since 1.0 */ @ContextConfiguration("classpath:TestSmppSessionFactoryBean-context.xml") @RunWith(SpringJUnit4ClassRunner.class) +@DirtiesContext public class TestSmppSessionFactoryBean { private Log logger = LogFactory.getLog(getClass()); @@ -46,18 +62,16 @@ public class TestSmppSessionFactoryBean { @Qualifier("session") private ExtendedSmppSessionAdaptingDelegate smppSession; - private AbsoluteTimeFormatter timeFormatter = new AbsoluteTimeFormatter(); - - @Value("${smpp.host}") + @Value("${smpp.host}") private String host; - @Value("${smpp.port}") + @Value("#{smppPort}") private int port; - @Value("${smpp.systemId}") + @Value("${smpp.systemId}") private String systemId; - @Value("${smpp.password}") + @Value("${smpp.password}") private String password; @Test @@ -128,6 +142,6 @@ public class TestSmppSessionFactoryBean { BindType bindType = smppSession.getBindType(); - Assert.assertNotNull("the bind type should not be null", bindType); + Assert.assertNotNull("the bind type should not be null", bindType); } } diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/MockSmppSessionFactory.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/MockSmppSessionFactory.java index 859f471..46c1311 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/MockSmppSessionFactory.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/MockSmppSessionFactory.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.config.xml; import org.jsmpp.bean.BindType; @@ -10,21 +24,21 @@ import static org.easymock.EasyMock.replay; /** * Mock smpp session factory for testing. * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 */ public class MockSmppSessionFactory { - public static ExtendedSmppSession getOutSmppSession() { - ExtendedSmppSession mock = createNiceMock(ExtendedSmppSession.class); - expect(mock.getBindType()).andReturn(BindType.BIND_TX).anyTimes(); - replay(mock); - return mock; - } + public static ExtendedSmppSession getOutSmppSession() { + ExtendedSmppSession mock = createNiceMock(ExtendedSmppSession.class); + expect(mock.getBindType()).andReturn(BindType.BIND_TX).anyTimes(); + replay(mock); + return mock; + } - public static ExtendedSmppSession getInSmppSession() { - ExtendedSmppSession mock = createNiceMock(ExtendedSmppSession.class); - expect(mock.getBindType()).andReturn(BindType.BIND_RX).anyTimes(); - replay(mock); - return mock; - } + public static ExtendedSmppSession getInSmppSession() { + ExtendedSmppSession mock = createNiceMock(ExtendedSmppSession.class); + expect(mock.getBindType()).andReturn(BindType.BIND_RX).anyTimes(); + replay(mock); + return mock; + } } diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.java index b786f7e..2050324 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* -uytea * Copyright 2002-2012 the original author or authors. +uytea * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -27,7 +27,7 @@ import static org.junit.Assert.*; /** * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppInboundChannelAdapterParserTests { @@ -45,10 +45,10 @@ public class SmppInboundChannelAdapterParserTests { assertEquals("out", outputChannel.getComponentName()); ExtendedSmppSession session = TestUtils.getPropertyValue(consumer, "smppSession", ExtendedSmppSession.class); - assertNotNull(session); + assertNotNull(session); - boolean autoStartup = TestUtils.getPropertyValue(consumer, "autoStartup" , Boolean.class); - assertTrue(autoStartup); + boolean autoStartup = TestUtils.getPropertyValue(consumer, "autoStartup" , Boolean.class); + assertTrue(autoStartup); } @After diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParserTests.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParserTests.java index 4aec6fd..eb3b349 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParserTests.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppInboundGatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotNull; /** * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppInboundGatewayParserTests { @@ -43,42 +43,40 @@ public class SmppInboundGatewayParserTests { public void testRetrievingInboundGatewayParser() throws Exception { setUp("SmppInboundGatewayParserTests.xml", getClass(), "smppInboundGateway"); - // reply timeout + // reply timeout long requestTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class); assertEquals(10000, requestTimeout); - // request timeout - long replyTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.receiveTimeout", Long.class); - assertEquals(5000, replyTimeout); + // request timeout + long replyTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.receiveTimeout", Long.class); + assertEquals(5000, replyTimeout); - ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); - assertNotNull(session); - System.out.println("Session: "+session); + ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); + assertNotNull(session); + System.out.println("Session: "+session); - TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); - assertEquals(ton, TypeOfNumber.INTERNATIONAL); + TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); + assertEquals(ton, TypeOfNumber.INTERNATIONAL); - String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); - assertEquals("123456789", sourceAddress); + String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); + assertEquals("123456789", sourceAddress); - // channels - AbstractMessageChannel requestChannel = TestUtils.getPropertyValue(gateway, "requestChannel", AbstractMessageChannel.class); - assertEquals("requestChannel", requestChannel.getComponentName()); - AbstractMessageChannel outputChannel = TestUtils.getPropertyValue(gateway, "replyChannel", AbstractMessageChannel.class); - assertEquals("replyChannel", outputChannel.getComponentName()); - AbstractMessageChannel errorChannel = TestUtils.getPropertyValue(gateway, "errorChannel", AbstractMessageChannel.class); - assertEquals("errorChannel", errorChannel.getComponentName()); + // channels + AbstractMessageChannel requestChannel = TestUtils.getPropertyValue(gateway, "requestChannel", AbstractMessageChannel.class); + assertEquals("requestChannel", requestChannel.getComponentName()); + AbstractMessageChannel outputChannel = TestUtils.getPropertyValue(gateway, "replyChannel", AbstractMessageChannel.class); + assertEquals("replyChannel", outputChannel.getComponentName()); + AbstractMessageChannel errorChannel = TestUtils.getPropertyValue(gateway, "errorChannel", AbstractMessageChannel.class); + assertEquals("errorChannel", errorChannel.getComponentName()); - // mappers - InboundMessageMapper inboundMessageMapper = TestUtils.getPropertyValue(gateway, "requestMapper", InboundMessageMapper.class); - assertNotNull(inboundMessageMapper); - OutboundMessageMapper outboundMessageMapper = TestUtils.getPropertyValue(gateway, "messageConverter.outboundMessageMapper", OutboundMessageMapper.class); - assertNotNull(outboundMessageMapper); + // mappers + InboundMessageMapper inboundMessageMapper = TestUtils.getPropertyValue(gateway, "requestMapper", InboundMessageMapper.class); + assertNotNull(inboundMessageMapper); + OutboundMessageMapper outboundMessageMapper = TestUtils.getPropertyValue(gateway, "messageConverter.outboundMessageMapper", OutboundMessageMapper.class); + assertNotNull(outboundMessageMapper); } - - @After public void tearDown() { if (context != null) { diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParserTests.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParserTests.java index 9e54245..61d1902 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParserTests.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -35,7 +35,7 @@ import static org.junit.Assert.assertNotNull; /** * * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppOutboundChannelAdapterParserTests { @@ -52,29 +52,29 @@ public class SmppOutboundChannelAdapterParserTests { final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(this.consumer, "inputChannel", AbstractMessageChannel.class); assertEquals("target", inputChannel.getComponentName()); - final SmppOutboundChannelAdapter gateway = TestUtils.getPropertyValue(this.consumer, "handler", SmppOutboundChannelAdapter.class); + final SmppOutboundChannelAdapter gateway = TestUtils.getPropertyValue(this.consumer, "handler", SmppOutboundChannelAdapter.class); - ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); - assertNotNull(session); + ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); + assertNotNull(session); - TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); - assertEquals(ton, TypeOfNumber.SUBSCRIBER_NUMBER); + TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); + assertEquals(ton, TypeOfNumber.SUBSCRIBER_NUMBER); - String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); - assertEquals("12345", sourceAddress); + String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); + assertEquals("12345", sourceAddress); - // this is not set, should be default value - TimeFormatter timeFormatter = TestUtils.getPropertyValue(gateway, "timeFormatter", TimeFormatter.class); - assertNotNull(timeFormatter); + // this is not set, should be default value + TimeFormatter timeFormatter = TestUtils.getPropertyValue(gateway, "timeFormatter", TimeFormatter.class); + assertNotNull(timeFormatter); - // I send message - Message message = MessageBuilder.withPayload("Yuhuu !!! i am connected using Spring Integration namespace") - .setHeader(SmppConstants.SRC_ADDR, "pavel") - .setHeader(SmppConstants.DST_ADDR, "pavel") - .build(); + // I send message + Message message = MessageBuilder.withPayload("Yuhuu !!! i am connected using Spring Integration namespace") + .setHeader(SmppConstants.SRC_ADDR, "pavel") + .setHeader(SmppConstants.DST_ADDR, "pavel") + .build(); - MessagingTemplate template = context.getBean("messagingTemplate", MessagingTemplate.class); - template.send("target", message); + MessagingTemplate template = context.getBean("messagingTemplate", MessagingTemplate.class); + template.send("target", message); } @After diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParserTests.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParserTests.java index 980be5f..0a6323a 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParserTests.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/config/xml/SmppOutboundGatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotNull; /** * @author Johanes Soetanto - * @since 2.2 + * @since 1.0 * */ public class SmppOutboundGatewayParserTests { @@ -52,28 +52,26 @@ public class SmppOutboundGatewayParserTests { long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class); assertEquals(100, sendTimeout); - ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); - assertNotNull(session); + ExtendedSmppSession session = TestUtils.getPropertyValue(gateway, "smppSession", ExtendedSmppSession.class); + assertNotNull(session); - TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); - assertEquals(ton, TypeOfNumber.NETWORK_SPECIFIC); + TypeOfNumber ton = TestUtils.getPropertyValue(gateway, "defaultSourceAddressTypeOfNumber", TypeOfNumber.class); + assertEquals(ton, TypeOfNumber.NETWORK_SPECIFIC); - String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); - assertEquals("123456789", sourceAddress); + String sourceAddress = TestUtils.getPropertyValue(gateway, "defaultSourceAddress", String.class); + assertEquals("123456789", sourceAddress); - int order = TestUtils.getPropertyValue(gateway, "order", Integer.class); - assertEquals(17, order); + int order = TestUtils.getPropertyValue(gateway, "order", Integer.class); + assertEquals(17, order); - AbstractMessageChannel outputChannel = TestUtils.getPropertyValue(gateway, "outputChannel", AbstractMessageChannel.class); - assertEquals("out", outputChannel.getComponentName()); + AbstractMessageChannel outputChannel = TestUtils.getPropertyValue(gateway, "outputChannel", AbstractMessageChannel.class); + assertEquals("out", outputChannel.getComponentName()); - // this is not set, should be default value - TimeFormatter timeFormatter = TestUtils.getPropertyValue(gateway, "timeFormatter", TimeFormatter.class); - assertNotNull(timeFormatter); + // this is not set, should be default value + TimeFormatter timeFormatter = TestUtils.getPropertyValue(gateway, "timeFormatter", TimeFormatter.class); + assertNotNull(timeFormatter); } - - @After public void tearDown() { if (context != null) { diff --git a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/util/TestCurrentExecutingMethodAdvice.java b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/util/TestCurrentExecutingMethodAdvice.java index 7b346cb..591864e 100644 --- a/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/util/TestCurrentExecutingMethodAdvice.java +++ b/spring-integration-smpp/src/test/java/org/springframework/integration/smpp/util/TestCurrentExecutingMethodAdvice.java @@ -1,3 +1,17 @@ +/* Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.integration.smpp.util; import org.apache.commons.logging.Log; @@ -8,7 +22,7 @@ import org.springframework.aop.framework.ProxyFactoryBean; /** * @author Josh Long - * @since 2.1 + * @since 1.0 */ public class TestCurrentExecutingMethodAdvice { static String currentMethodName() { @@ -19,11 +33,11 @@ public class TestCurrentExecutingMethodAdvice { public TestClassWithAMethod() { } - private Log l = LogFactory.getLog(getClass()); + private Log log = LogFactory.getLog(getClass()); public void testMe() throws Throwable { Assert.assertEquals("testMe", currentMethodName()); - l.debug("The currently executing method name is " + currentMethodName()); + log.debug("The currently executing method name is " + currentMethodName()); } } diff --git a/spring-integration-smpp/src/test/resources/TestSmppConnection-context.xml b/spring-integration-smpp/src/test/resources/TestSmppConnection-context.xml index 08e9f9b..763113d 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppConnection-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppConnection-context.xml @@ -1,51 +1,54 @@ - + - - - - - + + + - - - - - + + + + + + + + + + - + - + - - diff --git a/spring-integration-smpp/src/test/resources/TestSmppInboundChannelAdapter-context.xml b/spring-integration-smpp/src/test/resources/TestSmppInboundChannelAdapter-context.xml index b9d5b00..ba89a8d 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppInboundChannelAdapter-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppInboundChannelAdapter-context.xml @@ -8,22 +8,12 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - - - - - - - - + - + - + @@ -31,11 +21,10 @@ - + - + @@ -45,15 +34,12 @@ - + - + diff --git a/spring-integration-smpp/src/test/resources/TestSmppInboundGateway-context.xml b/spring-integration-smpp/src/test/resources/TestSmppInboundGateway-context.xml index 2cb7bb6..7f6e414 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppInboundGateway-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppInboundGateway-context.xml @@ -1,69 +1,58 @@ - - - - - - - - - + - + - + - + - + - + - - - - - + + + + + - + - + - + diff --git a/spring-integration-smpp/src/test/resources/TestSmppOutboundChannelAdapter-context.xml b/spring-integration-smpp/src/test/resources/TestSmppOutboundChannelAdapter-context.xml index cb9c79f..5ddc5e0 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppOutboundChannelAdapter-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppOutboundChannelAdapter-context.xml @@ -1,40 +1,29 @@ - + - - - - - - - - - + - + - + - + diff --git a/spring-integration-smpp/src/test/resources/TestSmppOutboundGateway-context.xml b/spring-integration-smpp/src/test/resources/TestSmppOutboundGateway-context.xml index 0e2b634..e327433 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppOutboundGateway-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppOutboundGateway-context.xml @@ -1,40 +1,30 @@ - + - - - - - - - - - + - + - + - + diff --git a/spring-integration-smpp/src/test/resources/TestSmppServer-context.xml b/spring-integration-smpp/src/test/resources/TestSmppServer-context.xml new file mode 100644 index 0000000..4cb6323 --- /dev/null +++ b/spring-integration-smpp/src/test/resources/TestSmppServer-context.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-smpp/src/test/resources/TestSmppSessionFactoryBean-context.xml b/spring-integration-smpp/src/test/resources/TestSmppSessionFactoryBean-context.xml index 32ea724..7225ca5 100644 --- a/spring-integration-smpp/src/test/resources/TestSmppSessionFactoryBean-context.xml +++ b/spring-integration-smpp/src/test/resources/TestSmppSessionFactoryBean-context.xml @@ -1,25 +1,19 @@ - + - - - - - - - + - + diff --git a/spring-integration-smpp/src/test/resources/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.xml b/spring-integration-smpp/src/test/resources/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.xml index 92e4c59..44dae24 100644 --- a/spring-integration-smpp/src/test/resources/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.xml +++ b/spring-integration-smpp/src/test/resources/org/springframework/integration/smpp/config/xml/SmppInboundChannelAdapterParserTests.xml @@ -1,6 +1,7 @@ + + + + + + + + + + + + + + + + +