camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [07/13] camel git commit: CAMEL-11149: SPI - Allow to plugin different headers map implementation
Date Thu, 25 May 2017 09:33:19 GMT
CAMEL-11149: SPI - Allow to plugin different headers map implementation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/23b3cc70
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/23b3cc70
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/23b3cc70

Branch: refs/heads/master
Commit: 23b3cc7094ea491f41e1a2914fb954cb156c816e
Parents: 1184a52
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu May 25 10:14:06 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu May 25 11:09:53 2017 +0200

----------------------------------------------------------------------
 .../component/quickfixj/QuickfixjComponent.java |   9 +-
 .../quickfixj/QuickfixjConvertersTest.java      |  13 +-
 .../camel/component/smpp/SmppBinding.java       |  10 +-
 .../camel/component/smpp/SmppEndpoint.java      |   6 +-
 .../camel/component/smpp/SmppBindingTest.java   |  21 +-
 .../camel/component/smpp/SmppEndpointTest.java  | 265 -------------------
 .../camel/component/smpp/SmppMessageTest.java   |  27 +-
 7 files changed, 53 insertions(+), 298 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
index 7598161..4bbae5c 100644
--- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
+++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
@@ -23,7 +23,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.StartupListener;
-import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.spi.Metadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,7 +32,7 @@ import quickfix.MessageFactory;
 import quickfix.MessageStoreFactory;
 import quickfix.SessionSettings;
 
-public class QuickfixjComponent extends UriEndpointComponent implements StartupListener {
+public class QuickfixjComponent extends DefaultComponent implements StartupListener {
     private static final Logger LOG = LoggerFactory.getLogger(QuickfixjComponent.class);
     private static final String PARAMETER_LAZY_CREATE_ENGINE = "lazyCreateEngine";
 
@@ -52,7 +52,10 @@ public class QuickfixjComponent extends UriEndpointComponent implements
StartupL
     private boolean lazyCreateEngines;
 
     public QuickfixjComponent() {
-        super(QuickfixjEndpoint.class);
+    }
+
+    public QuickfixjComponent(CamelContext context) {
+        super(context);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
index cf790e6..b4b9917 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java
@@ -17,24 +17,19 @@
 package org.apache.camel.component.quickfixj;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
 
-import javax.management.JMException;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.component.quickfixj.converter.QuickfixjConverters;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-
 import quickfix.Acceptor;
-import quickfix.ConfigError;
 import quickfix.DataDictionary;
-import quickfix.FieldConvertError;
 import quickfix.Initiator;
 import quickfix.Message;
 import quickfix.SessionFactory;
@@ -94,7 +89,7 @@ public class QuickfixjConvertersTest extends CamelTestSupport {
     @Test
     public void convertToExchange() {
         SessionID sessionID = new SessionID("FIX.4.0", "FOO", "BAR");
-        QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent());
+        QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent(new
DefaultCamelContext()));
         
         Message message = new Message();     
         message.getHeader().setString(MsgType.FIELD, MsgType.ORDER_SINGLE);
@@ -112,7 +107,7 @@ public class QuickfixjConvertersTest extends CamelTestSupport {
     @Test
     public void convertToExchangeWithNullMessage() {
         SessionID sessionID = new SessionID("FIX.4.0", "FOO", "BAR");
-        QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent());
+        QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent(new
DefaultCamelContext()));
         
         Exchange exchange = QuickfixjConverters.toExchange(endpoint, sessionID, null, QuickfixjEventCategory.AppMessageSent);
         
@@ -219,7 +214,7 @@ public class QuickfixjConvertersTest extends CamelTestSupport {
         }
     }
 
-    private void createSession(SessionID sessionID) throws IOException, ConfigError, FieldConvertError,
JMException, Exception {
+    private void createSession(SessionID sessionID) throws Exception {
         SessionSettings settings = new SessionSettings();
         settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
         

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
index 79d9dc7..cea7573 100644
--- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
+++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.jsmpp.bean.AlertNotification;
 import org.jsmpp.bean.Alphabet;
@@ -76,8 +77,9 @@ public class SmppBinding {
     /**
      * Create a new SmppMessage from the inbound alert notification
      */
-    public SmppMessage createSmppMessage(AlertNotification alertNotification) {
+    public SmppMessage createSmppMessage(CamelContext camelContext, AlertNotification alertNotification)
{
         SmppMessage smppMessage = new SmppMessage(alertNotification, configuration);
+        smppMessage.setCamelContext(camelContext);
 
         smppMessage.setHeader(SmppConstants.MESSAGE_TYPE, SmppMessageType.AlertNotification.toString());
         smppMessage.setHeader(SmppConstants.SEQUENCE_NUMBER, alertNotification.getSequenceNumber());
@@ -96,8 +98,9 @@ public class SmppBinding {
     /**
      * Create a new SmppMessage from the inbound deliver sm or deliver receipt
      */
-    public SmppMessage createSmppMessage(DeliverSm deliverSm) throws Exception {
+    public SmppMessage createSmppMessage(CamelContext camelContext, DeliverSm deliverSm)
throws Exception {
         SmppMessage smppMessage = new SmppMessage(deliverSm, configuration);
+        smppMessage.setCamelContext(camelContext);
 
         String messagePayload = null;
 
@@ -233,8 +236,9 @@ public class SmppBinding {
         return optParams;
     }
 
-    public SmppMessage createSmppMessage(DataSm dataSm, String smppMessageId) {
+    public SmppMessage createSmppMessage(CamelContext camelContext, DataSm dataSm, String
smppMessageId) {
         SmppMessage smppMessage = new SmppMessage(dataSm, configuration);
+        smppMessage.setCamelContext(camelContext);
 
         smppMessage.setHeader(SmppConstants.MESSAGE_TYPE, SmppMessageType.DataSm.toString());
         smppMessage.setHeader(SmppConstants.ID, smppMessageId);

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppEndpoint.java
b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppEndpoint.java
index 56e6a6f..2526004 100644
--- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppEndpoint.java
+++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppEndpoint.java
@@ -92,7 +92,7 @@ public class SmppEndpoint extends DefaultEndpoint {
                                                             AlertNotification alertNotification)
{
         Exchange exchange = createExchange(exchangePattern);
         exchange.setProperty(Exchange.BINDING, getBinding());
-        exchange.setIn(getBinding().createSmppMessage(alertNotification));
+        exchange.setIn(getBinding().createSmppMessage(getCamelContext(), alertNotification));
         return exchange;
     }
 
@@ -119,7 +119,7 @@ public class SmppEndpoint extends DefaultEndpoint {
                                                     DeliverSm deliverSm) throws Exception
{
         Exchange exchange = createExchange(exchangePattern);
         exchange.setProperty(Exchange.BINDING, getBinding());
-        exchange.setIn(getBinding().createSmppMessage(deliverSm));
+        exchange.setIn(getBinding().createSmppMessage(getCamelContext(), deliverSm));
         return exchange;
     }
     
@@ -147,7 +147,7 @@ public class SmppEndpoint extends DefaultEndpoint {
     public Exchange createOnAcceptDataSm(ExchangePattern exchangePattern, DataSm dataSm,
String smppMessageId) {
         Exchange exchange = createExchange(exchangePattern);
         exchange.setProperty(Exchange.BINDING, getBinding());
-        exchange.setIn(getBinding().createSmppMessage(dataSm, smppMessageId));
+        exchange.setIn(getBinding().createSmppMessage(getCamelContext(), dataSm, smppMessageId));
         return exchange;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
index 92edbc3..5c3b545 100644
--- a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
+++ b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
@@ -54,6 +55,7 @@ import static org.junit.Assert.fail;
 public class SmppBindingTest {
     
     private SmppBinding binding;
+    private CamelContext camelContext;
 
     @Before
     public void setUp() {
@@ -62,6 +64,7 @@ public class SmppBindingTest {
                 return new Date(1251666387000L);
             }
         };
+        camelContext = new DefaultCamelContext();
     }
 
     @Test
@@ -88,7 +91,7 @@ public class SmppBindingTest {
         alertNotification.setEsmeAddr("1717");
         alertNotification.setEsmeAddrNpi(NumberingPlanIndicator.NATIONAL.value());
         alertNotification.setEsmeAddrTon(TypeOfNumber.NATIONAL.value());
-        SmppMessage smppMessage = binding.createSmppMessage(alertNotification);
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, alertNotification);
         
         assertNull(smppMessage.getBody());
         assertEquals(10, smppMessage.getHeaders().size());
@@ -111,7 +114,7 @@ public class SmppBindingTest {
         deliverSm.setShortMessage(
             "id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD
err:xxx Text:Hello SMPP world!"
                 .getBytes());
-        SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
         
         assertEquals("Hello SMPP world!", smppMessage.getBody());
         assertEquals(8, smppMessage.getHeaders().size());
@@ -140,7 +143,7 @@ public class SmppBindingTest {
             new OptionalParameter.Short(Tag.DEST_TELEMATICS_ID, (short) 1),
             new OptionalParameter.Int(Tag.QOS_TIME_TO_LIVE, 1),
             new OptionalParameter.Null(Tag.ALERT_ON_MESSAGE_DELIVERY));
-        SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
 
         assertEquals("Hello SMPP world!", smppMessage.getBody());
         assertEquals(10, smppMessage.getHeaders().size());
@@ -180,7 +183,7 @@ public class SmppBindingTest {
         deliverSm.setOptionalParameters(new OctetString(OptionalParameter.Tag.MESSAGE_PAYLOAD,
             "id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD
err:xxx Text:Hello SMPP world!"));
         try {
-            SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+            SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
 
             assertEquals("Hello SMPP world!", smppMessage.getBody());
             assertEquals(10, smppMessage.getHeaders().size());
@@ -202,7 +205,7 @@ public class SmppBindingTest {
         deliverSm.setOptionalParameters(new OptionalParameter.Short((short) 0x2153, (short)
0));
 
         try {
-            SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+            SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
             Map<Short, Object> optionalParameter = smppMessage.getHeader(SmppConstants.OPTIONAL_PARAMETER,
Map.class);
             assertEquals(Short.valueOf((short) 0), optionalParameter.get(Short.valueOf((short)
0x2153)));
         } catch (Exception e) {
@@ -225,7 +228,7 @@ public class SmppBindingTest {
         deliverSm.setScheduleDeliveryTime("090831230627004+");
         deliverSm.setValidityPeriod("090901230627004+");
         deliverSm.setServiceType("WAP");
-        SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
         
         assertEquals("Hello SMPP world!", smppMessage.getBody());
         assertEquals(13, smppMessage.getHeaders().size());
@@ -258,7 +261,7 @@ public class SmppBindingTest {
         deliverSm.setValidityPeriod("090901230627004+");
         deliverSm.setServiceType("WAP");
         deliverSm.setOptionalParameters(new OctetString(OptionalParameter.Tag.MESSAGE_PAYLOAD,
"Hello SMPP world!"));
-        SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
         
         assertEquals("Hello SMPP world!", smppMessage.getBody());
         assertEquals(13, smppMessage.getHeaders().size());
@@ -290,7 +293,7 @@ public class SmppBindingTest {
         dataSm.setDestAddrTon(TypeOfNumber.NATIONAL.value());
         dataSm.setServiceType("WAP");
         dataSm.setRegisteredDelivery((byte) 0);
-        SmppMessage smppMessage = binding.createSmppMessage(dataSm, "1");
+        SmppMessage smppMessage = binding.createSmppMessage(camelContext, dataSm, "1");
         
         assertNull(smppMessage.getBody());
         assertEquals(14, smppMessage.getHeaders().size());
@@ -334,7 +337,7 @@ public class SmppBindingTest {
 
             for (String encoding : encodings) {
                 binding.getConfiguration().setEncoding(encoding);
-                SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
+                SmppMessage smppMessage = binding.createSmppMessage(camelContext, deliverSm);
                 assertArrayEquals(
                     String.format("data coding=0x%02X; encoding=%s",
                                   dataCoding,

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppEndpointTest.java
b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppEndpointTest.java
deleted file mode 100644
index 9a50fe6..0000000
--- a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppEndpointTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * 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.camel.component.smpp;
-
-import org.apache.camel.Component;
-import org.apache.camel.Consumer;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.jsmpp.bean.AlertNotification;
-import org.jsmpp.bean.DataSm;
-import org.jsmpp.bean.DeliverSm;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-/**
- * JUnit test class for <code>org.apache.camel.component.smpp.SmppEndpoint</code>
- * 
- * @version 
- */
-public class SmppEndpointTest {
-    
-    private SmppEndpoint endpoint;
-    private SmppConfiguration configuration;
-    private Component component;
-    private SmppBinding binding;
-
-    @Before
-    public void setUp() throws Exception {
-        configuration = createMock(SmppConfiguration.class);
-        component = createMock(Component.class);
-        binding = createMock(SmppBinding.class);
-        
-        expect(component.createConfiguration("smpp://smppclient@localhost:2775")).andReturn(null);
-        expect(component.getCamelContext()).andReturn(null);
-        replay(component);
-
-        endpoint = new SmppEndpoint("smpp://smppclient@localhost:2775", component, configuration);
-        endpoint.setBinding(binding);
-    }
-
-    @Test
-    public void isLenientPropertiesShouldReturnTrue() {
-        assertTrue(endpoint.isLenientProperties());
-    }
-
-    @Test
-    public void isSingletonShouldReturnTrue() {
-        assertTrue(endpoint.isSingleton());
-    }
-
-    @Test
-    public void createEndpointUriShouldReturnTheEndpointUri() {
-        expect(configuration.getUsingSSL()).andReturn(false);
-        expect(configuration.getSystemId()).andReturn("smppclient").times(2);
-        expect(configuration.getHost()).andReturn("localhost");
-        expect(configuration.getPort()).andReturn(new Integer(2775));
-        
-        replay(configuration);
-        
-        assertEquals("smpp://smppclient@localhost:2775", endpoint.createEndpointUri());
-        
-        verify(configuration);
-    }
-
-    @Test
-    public void createEndpointUriWithoutUserShouldReturnTheEndpointUri() {
-        expect(configuration.getUsingSSL()).andReturn(false);
-        expect(configuration.getSystemId()).andReturn(null);
-        expect(configuration.getHost()).andReturn("localhost");
-        expect(configuration.getPort()).andReturn(new Integer(2775));
-        
-        replay(configuration);
-        
-        assertEquals("smpp://localhost:2775", endpoint.createEndpointUri());
-        
-        verify(configuration);
-    }
-
-    @Test
-    public void createConsumerShouldReturnASmppConsumer() throws Exception {
-        Processor processor = createMock(Processor.class);
-        
-        replay(processor);
-        
-        Consumer consumer = endpoint.createConsumer(processor);
-        
-        verify(processor);
-        
-        assertTrue(consumer instanceof SmppConsumer);
-    }
-
-    @Test
-    public void createProducerShouldReturnASmppProducer() throws Exception {
-        Producer producer = endpoint.createProducer();
-        
-        assertTrue(producer instanceof SmppProducer);
-    }
-
-    @Test
-    public void createOnAcceptAlertNotificationExchange() {
-        AlertNotification alertNotification = createMock(AlertNotification.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(alertNotification)).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(alertNotification, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptAlertNotificationExchange(alertNotification);
-        
-        verify(alertNotification, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOnly, exchange.getPattern());
-    }
-
-    @Test
-    public void createOnAcceptAlertNotificationExchangeWithExchangePattern() {
-        AlertNotification alertNotification = createMock(AlertNotification.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(alertNotification)).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(alertNotification, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptAlertNotificationExchange(ExchangePattern.InOut,
alertNotification);
-        
-        verify(alertNotification, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOut, exchange.getPattern());
-    }
-
-    @Test
-    public void createOnAcceptDeliverSmExchange() throws Exception {
-        DeliverSm deliverSm = createMock(DeliverSm.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(deliverSm)).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(deliverSm, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptDeliverSmExchange(deliverSm);
-        
-        verify(deliverSm, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOnly, exchange.getPattern());
-    }
-
-    @Test
-    public void createOnAcceptDeliverSmWithExchangePattern() throws Exception {
-        DeliverSm deliverSm = createMock(DeliverSm.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(deliverSm)).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(deliverSm, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptDeliverSmExchange(ExchangePattern.InOut,
deliverSm);
-        
-        verify(deliverSm, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOut, exchange.getPattern());
-    }
-    
-    @Test
-    public void createOnAcceptDataSm() throws Exception {
-        DataSm dataSm = createMock(DataSm.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(eq(dataSm), isA(String.class))).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(dataSm, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptDataSm(dataSm, "1");
-        
-        verify(dataSm, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOnly, exchange.getPattern());
-    }
-    
-    @Test
-    public void createOnAcceptDataSmWithExchangePattern() throws Exception {
-        DataSm dataSm = createMock(DataSm.class);
-        SmppMessage message = createMock(SmppMessage.class);
-        expect(binding.createSmppMessage(eq(dataSm), isA(String.class))).andReturn(message);
-        message.setExchange(isA(Exchange.class));
-        
-        replay(dataSm, binding, message);
-        
-        Exchange exchange = endpoint.createOnAcceptDataSm(ExchangePattern.InOut, dataSm,
"1");
-        
-        verify(dataSm, binding, message);
-        
-        assertSame(binding, exchange.getProperty(Exchange.BINDING));
-        assertSame(message, exchange.getIn());
-        assertSame(ExchangePattern.InOut, exchange.getPattern());
-    }
-
-    @Test
-    public void getConnectionStringShouldReturnTheConnectionString() {
-        expect(configuration.getUsingSSL()).andReturn(false);
-        expect(configuration.getSystemId()).andReturn("smppclient").times(2);
-        expect(configuration.getHost()).andReturn("localhost");
-        expect(configuration.getPort()).andReturn(new Integer(2775));
-        
-        replay(configuration);
-        
-        assertEquals("smpp://smppclient@localhost:2775", endpoint.getConnectionString());
-        
-        verify(configuration);
-    }
-
-    @Test
-    public void getConnectionStringWithoutUserShouldReturnTheConnectionString() {
-        expect(configuration.getUsingSSL()).andReturn(false);
-        expect(configuration.getSystemId()).andReturn(null);
-        expect(configuration.getHost()).andReturn("localhost");
-        expect(configuration.getPort()).andReturn(new Integer(2775));
-        
-        replay(configuration);
-        
-        assertEquals("smpp://localhost:2775", endpoint.getConnectionString());
-        
-        verify(configuration);
-    }
-
-    @Test
-    public void getConfigurationShouldReturnTheSetValue() {
-        assertSame(configuration, endpoint.getConfiguration());
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/23b3cc70/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java
----------------------------------------------------------------------
diff --git a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java
b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java
index 38dbc74..3762286 100644
--- a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java
+++ b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java
@@ -19,6 +19,8 @@ package org.apache.camel.component.smpp;
 import java.nio.charset.Charset;
 import java.util.Set;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.jsmpp.bean.AlertNotification;
 import org.jsmpp.bean.DataSm;
 import org.jsmpp.bean.DeliverSm;
@@ -38,10 +40,12 @@ import static org.junit.Assert.assertTrue;
 public class SmppMessageTest {
     
     private SmppMessage message;
+    private CamelContext camelContext = new DefaultCamelContext();
 
     @Test
     public void emptyConstructorShouldReturnAnInstanceWithoutACommand() {
         message = new SmppMessage(new SmppConfiguration());
+        message.setCamelContext(camelContext);
         
         assertNull(message.getCommand());
         assertTrue(message.getHeaders().isEmpty());
@@ -51,6 +55,7 @@ public class SmppMessageTest {
     public void alertNotificationConstructorShouldReturnAnInstanceWithACommandAndHeaderAttributes()
{
         AlertNotification command = new AlertNotification();
         message = new SmppMessage(command, new SmppConfiguration());
+        message.setCamelContext(camelContext);
         
         assertTrue(message.getCommand() instanceof AlertNotification);
         assertTrue(message.getHeaders().isEmpty());
@@ -61,6 +66,7 @@ public class SmppMessageTest {
     public void testSmppMessageDataSm() {
         DataSm command = new DataSm();
         message = new SmppMessage(command, new SmppConfiguration());
+        message.setCamelContext(camelContext);
         
         assertTrue(message.getCommand() instanceof DataSm);
         assertTrue(message.getHeaders().isEmpty());
@@ -71,6 +77,7 @@ public class SmppMessageTest {
     public void testSmppMessageDeliverSm() {
         DeliverSm command = new DeliverSm();
         message = new SmppMessage(command, new SmppConfiguration());
+        message.setCamelContext(camelContext);
         
         assertTrue(message.getCommand() instanceof DeliverSm);
         assertTrue(message.getHeaders().isEmpty());
@@ -83,6 +90,7 @@ public class SmppMessageTest {
         command.setSmscDeliveryReceipt();
         command.setShortMessage("id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311
stat:DELIVRD err:xxx Text:Hello SMPP world!".getBytes());
         message = new SmppMessage(command, new SmppConfiguration());
+        message.setCamelContext(camelContext);
         
         assertTrue(message.getCommand() instanceof DeliverSm);
         assertTrue(message.getHeaders().isEmpty());
@@ -92,8 +100,9 @@ public class SmppMessageTest {
     @Test
     public void newInstanceShouldReturnAnInstanceWithoutACommand() {
         message = new SmppMessage(new SmppConfiguration());
+        message.setCamelContext(camelContext);
         SmppMessage msg = message.newInstance();
-        
+
         assertNotNull(msg);
         assertNull(msg.getCommand());
         assertTrue(msg.getHeaders().isEmpty());
@@ -137,7 +146,9 @@ public class SmppMessageTest {
     @Test
     public void createBodyShouldReturnNullIfTheCommandIsNull() {
         message = new SmppMessage(new SmppConfiguration());
-        
+        message.setCamelContext(camelContext);
+
+
         assertNull(message.createBody());
     }
     
@@ -145,7 +156,8 @@ public class SmppMessageTest {
     public void createBodyShouldReturnNullIfTheCommandIsNotAMessageRequest() {
         AlertNotification command = new AlertNotification();
         message = new SmppMessage(command, new SmppConfiguration());
-        
+        message.setCamelContext(camelContext);
+
         assertNull(message.createBody());
     }
     
@@ -154,14 +166,16 @@ public class SmppMessageTest {
         DeliverSm command = new DeliverSm();
         command.setShortMessage("Hello SMPP world!".getBytes());
         message = new SmppMessage(command, new SmppConfiguration());
-        
+        message.setCamelContext(camelContext);
+
         assertEquals("Hello SMPP world!", message.createBody());
     }
     
     @Test
     public void toStringShouldReturnTheBodyIfTheCommandIsNull() {
         message = new SmppMessage(new SmppConfiguration());
-        
+        message.setCamelContext(camelContext);
+
         assertEquals("SmppMessage: null", message.toString());
     }
     
@@ -170,7 +184,8 @@ public class SmppMessageTest {
         DeliverSm command = new DeliverSm();
         command.setShortMessage("Hello SMPP world!".getBytes());
         message = new SmppMessage(command, new SmppConfiguration());
-        
+        message.setCamelContext(camelContext);
+
         assertEquals("SmppMessage: PDUHeader(0, 00000000, 00000000, 0)", message.toString());
     }
 }
\ No newline at end of file


Mime
View raw message