Index: src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java =================================================================== --- src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java (revision 739932) +++ src/main/java/org/apache/servicemix/smpp/SmppProviderEndpoint.java (working copy) @@ -123,22 +123,18 @@ if (this.systemId == null || this.systemId.trim().length() <= 0) { throw new IllegalArgumentException("The SMPP system ID is mandatory."); } - // check for valid password - if (this.password == null || this.password.trim().length() <= 0) { - throw new IllegalArgumentException("The SMPP system password is mandatory."); - } - // check the marshaler - if (this.getMarshaler() == null) { - this.setMarshaler(new DefaultSmppMarshaler()); - } - // check the enquire link timer - if (this.enquireLinkTimer <= 0) { - throw new IllegalArgumentException("The enquireLinkTimer value must be greater than 0."); - } - // check the transaction timer - if (this.transactionTimer <= 0) { - throw new IllegalArgumentException("The transactionTimer value must be greater than 0."); - } + // check the marshaler + if (this.marshaler == null) { + this.marshaler = new DefaultSmppMarshaler(); + } + // check the enquire link timer + if (this.enquireLinkTimer <= 0) { + throw new IllegalArgumentException("The enquireLinkTimer value must be greater than 0."); + } + // check the transaction timer + if (this.transactionTimer <= 0) { + throw new IllegalArgumentException("The transactionTimer value must be greater than 0."); + } } /** @@ -367,6 +363,5 @@ */ public void setTransactionTimer(int transactionTimer) { this.transactionTimer = transactionTimer; - } - -} + } +} \ No newline at end of file Index: src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java =================================================================== --- src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java (revision 0) +++ src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java (revision 0) @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.smpp; + +import javax.jbi.management.DeploymentException; + +import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler; +import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport; + +import junit.framework.TestCase; + +/** + * JUnit test class for org.apache.servicemix.smpp.SmppProviderEndpoint + * + * @author mullerc + */ +public class SmppProviderEndpointTest extends TestCase { + + private SmppProviderEndpoint endpoint; + + protected void setUp() throws Exception { + super.setUp(); + this.endpoint = new SmppProviderEndpoint(); + } + + public void testValidateWithMinAttr() throws DeploymentException { + this.endpoint.setHost("localhost"); + this.endpoint.setSystemId("test"); + + this.endpoint.validate(); + + assertEquals("localhost", this.endpoint.getHost()); + assertEquals(2775, this.endpoint.getPort()); + assertEquals("test", this.endpoint.getSystemId()); + assertNull(this.endpoint.getPassword()); + assertEquals(50000, this.endpoint.getEnquireLinkTimer()); + assertEquals(100000, this.endpoint.getTransactionTimer()); + assertNotNull(this.endpoint.getMarshaler()); + } + + public void testValidateWithMaxAttr() throws DeploymentException { + SmppMarshalerSupport marshaler = new DefaultSmppMarshaler(); + this.endpoint.setHost("localhost"); + this.endpoint.setPort(2700); + this.endpoint.setSystemId("test"); + this.endpoint.setPassword("password"); + this.endpoint.setEnquireLinkTimer(10000); + this.endpoint.setTransactionTimer(20000); + this.endpoint.setMarshaler(marshaler); + + this.endpoint.validate(); + + assertEquals("localhost", this.endpoint.getHost()); + assertEquals(2700, this.endpoint.getPort()); + assertEquals("test", this.endpoint.getSystemId()); + assertEquals("password", this.endpoint.getPassword()); + assertEquals(10000, this.endpoint.getEnquireLinkTimer()); + assertEquals(20000, this.endpoint.getTransactionTimer()); + assertSame(marshaler, this.endpoint.getMarshaler()); + } + + public void testValidateWithoutHost() throws DeploymentException { + try { + this.endpoint.validate(); + fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // expected + } + } + + public void testValidateWithoutSystemId() throws DeploymentException { + this.endpoint.setHost("localhost"); + + try { + this.endpoint.validate(); + fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // expected + } + } + + public void testValidateInvalidEnquireLinkTimer() throws DeploymentException { + this.endpoint.setHost("localhost"); + this.endpoint.setSystemId("test"); + this.endpoint.setEnquireLinkTimer(0); + + try { + this.endpoint.validate(); + fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // expected + } + } + + public void testValidateInvalidTransactionTimer() throws DeploymentException { + this.endpoint.setHost("localhost"); + this.endpoint.setSystemId("test"); + this.endpoint.setTransactionTimer(0); + + try { + this.endpoint.validate(); + fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // expected + } + } +} \ No newline at end of file Property changes on: src/test/java/org/apache/servicemix/smpp/SmppProviderEndpointTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain