camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1043319 - in /camel/trunk/components/camel-irc: ./ src/main/java/org/apache/camel/component/irc/ src/test/java/org/apache/camel/component/irc/
Date Wed, 08 Dec 2010 06:40:39 GMT
Author: ningjiang
Date: Wed Dec  8 06:40:39 2010
New Revision: 1043319

URL: http://svn.apache.org/viewvc?rev=1043319&view=rev
Log:
CAMEL-3351 applied patch with thanks to Tracy

Modified:
    camel/trunk/components/camel-irc/pom.xml
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
    camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcConfigurationTest.java

Modified: camel/trunk/components/camel-irc/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/pom.xml?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/pom.xml (original)
+++ camel/trunk/components/camel-irc/pom.xml Wed Dec  8 06:40:39 2010
@@ -68,6 +68,12 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+        <groupId>org.mockito</groupId>
+        <artifactId>mockito-all</artifactId>
+        <version>1.8.5</version>
+        <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
Wed Dec  8 06:40:39 2010
@@ -35,26 +35,15 @@ import org.schwering.irc.lib.ssl.SSLIRCC
  */
 public class IrcComponent extends DefaultComponent {
     private static final transient Log LOG = LogFactory.getLog(IrcComponent.class);
-    private IrcConfiguration configuration;
     private final Map<String, IRCConnection> connectionCache = new HashMap<String,
IRCConnection>();
-    private IRCEventListener ircLogger;
-
-    public IrcComponent() {
-        configuration = new IrcConfiguration();
-    }
-
-    public IrcComponent(IrcConfiguration configuration) {
-        this.configuration = configuration;
-    }
 
     public IrcComponent(CamelContext context) {
         super(context);
-        configuration = new IrcConfiguration();
     }
 
     protected IrcEndpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        // lets make sure we copy the configuration as each endpoint can customize its own
version
-        IrcConfiguration config = getConfiguration().copy();
+        // every endpoint gets it's own configuration
+        IrcConfiguration config = new IrcConfiguration();
         config.configure(uri);
 
         IrcEndpoint endpoint = new IrcEndpoint(uri, this, config);
@@ -78,6 +67,7 @@ public class IrcComponent extends Defaul
 
     protected IRCConnection createConnection(IrcConfiguration configuration) {
         IRCConnection conn = null;
+        IRCEventListener ircLogger;
 
         if (configuration.getUsingSSL()) {
             if (LOG.isDebugEnabled()) {
@@ -85,7 +75,7 @@ public class IrcComponent extends Defaul
                         + " nick: " + configuration.getNickname() + " user: " + configuration.getUsername());
             }
             SSLIRCConnection sconn = new SSLIRCConnection(configuration.getHostname(), configuration.getPorts(),
configuration.getPassword(),
-                                                         configuration.getNickname(), configuration.getUsername(),
configuration.getRealname());
+                    configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
 
             sconn.addTrustManager(configuration.getTrustManager());
             conn = sconn;
@@ -97,7 +87,7 @@ public class IrcComponent extends Defaul
             }
 
             conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(),
configuration.getPassword(),
-                                                         configuration.getNickname(), configuration.getUsername(),
configuration.getRealname());
+                    configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
         }
         conn.setEncoding("UTF-8");
         conn.setColors(configuration.isColors());
@@ -140,13 +130,4 @@ public class IrcComponent extends Defaul
     protected IRCEventListener createIrcLogger(String hostname) {
         return new IrcLogger(LOG, hostname);
     }
-
-    public IrcConfiguration getConfiguration() {
-        return configuration;
-    }
-
-    public void setConfiguration(IrcConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
 }

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
Wed Dec  8 06:40:39 2010
@@ -20,6 +20,8 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Hashtable;
 import java.util.List;
 
 import org.apache.camel.RuntimeCamelException;
@@ -30,7 +32,7 @@ import org.schwering.irc.lib.ssl.SSLTrus
 public class IrcConfiguration implements Cloneable {
     private String target;
     private List<String> channels = new ArrayList<String>();
-    private List<String> keys = new ArrayList<String>();
+    private Dictionary<String, String> keys = new Hashtable<String, String>();
     private String hostname;
     private String password;
     private String nickname;
@@ -49,8 +51,14 @@ public class IrcConfiguration implements
     private boolean onReply;
     private boolean onTopic = true;
     private boolean onPrivmsg = true;
+    private boolean autoRejoin = true;
     private int[] ports = {6667, 6668, 6669};
-    
+
+    /*
+     * Temporary storage for when keys are listed in the parameters before channels.
+     */
+    private String channelKeys;
+
     public IrcConfiguration() {
     }
 
@@ -140,20 +148,32 @@ public class IrcConfiguration implements
                 addChannel(channel);
             }
         }
+
+        if (keys.size() == 0 && channelKeys != null) {
+            setKeys(channelKeys);
+        }
     }
 
     public void setKeys(String keys) {
-        String[] s = keys.split(",");
-        for (String key : s) {
-            this.keys.add(key);
+        if (channels.size() == 0) {
+            // keys are listed in the parameters before channels
+            // store the string and process after channels
+            channelKeys = keys;
+        } else {
+            String[] s = keys.split(",");
+            int index = 0;
+            for (String key : s) {
+                this.keys.put(channels.get(index), key);
+                index++;
+            }
         }
     }
 
-    public void setKeys(List<String> keys) {
-        this.keys = keys;
+    public String getKey(String channel) {
+        return keys.get(channel);
     }
 
-    public List<String> getKeys() {
+    public Dictionary<String, String> getKeys() {
         return keys;
     }
 
@@ -313,6 +333,14 @@ public class IrcConfiguration implements
         this.onPrivmsg = onPrivmsg;
     }
 
+    public boolean isAutoRejoin() {
+        return autoRejoin;
+    }
+
+    public void setAutoRejoin(boolean autoRejoin) {
+        this.autoRejoin = autoRejoin;
+    }
+
     public String toString() {
         return "IrcConfiguration[hostname: " + hostname + ", ports=" + Arrays.toString(ports)
+ ", target: " + target + ", username=" + username + "]";
     }

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
Wed Dec  8 06:40:39 2010
@@ -16,12 +16,9 @@
  */
 package org.apache.camel.component.irc;
 
-import java.util.List;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.schwering.irc.lib.IRCConnection;
@@ -35,7 +32,7 @@ public class IrcConsumer extends Default
     private final IrcConfiguration configuration;
     private final IrcEndpoint endpoint;
     private final IRCConnection connection;
-    private FilteredIRCEventAdapter listener;
+    private  IRCEventAdapter listener;
 
     public IrcConsumer(IrcEndpoint endpoint, Processor processor, IRCConnection connection)
{
         super(endpoint, processor);
@@ -61,39 +58,24 @@ public class IrcConsumer extends Default
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-
-        listener = new FilteredIRCEventAdapter();
+        listener = getListener();
         connection.addIRCEventListener(listener);
+        endpoint.joinChannels();
+    }
 
-        List<String> channels = endpoint.getConfiguration().getChannels();
-        for (String channel : channels) {
-
-            // find key for channel
-            int ndx = channels.indexOf(channel);
-            String key = null;
-            if (ndx >= 0) {
-                List<String> keys = endpoint.getConfiguration().getKeys();
-                if (keys.size() > 0 && ndx < keys.size()) {
-                    key = keys.get(ndx);
-                }
-            }
+    public IRCConnection getConnection() {
+        return connection;
+    }
 
-            if (ObjectHelper.isNotEmpty(key)) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Joining: " + channel + " using " + connection.getClass().getName()
+ " with key " + key);
-                }
-                connection.doJoin(channel, key);
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Joining: " + channel + " using " + connection.getClass().getName());
-                }
-                connection.doJoin(channel);
-            }
+    public IRCEventAdapter getListener() {
+        if (listener == null) {
+            listener = new FilteredIRCEventAdapter();
         }
+        return listener;
     }
 
-    public IRCConnection getConnection() {
-        return connection;
+    public void setListener(IRCEventAdapter listener) {
+        this.listener = listener;
     }
 
     class FilteredIRCEventAdapter extends IRCEventAdapter {
@@ -136,6 +118,12 @@ public class IrcConsumer extends Default
 
         @Override
         public void onKick(String channel, IRCUser user, String passiveNick, String msg)
{
+
+            // check to see if I got kick and if so rejoin if autoRejoin is on
+            if (passiveNick.equals(connection.getNick()) && configuration.isAutoRejoin())
{
+                endpoint.joinChannel(channel);
+            }
+
             if (configuration.isOnKick()) {
                 Exchange exchange = endpoint.createOnKickExchange(channel, user, passiveNick,
msg);
                 try {
@@ -205,6 +193,11 @@ public class IrcConsumer extends Default
                 }
             }
         }
+
+        @Override
+        public void onError(int num, String msg) {
+        }
+
     }
 
 }

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
Wed Dec  8 06:40:39 2010
@@ -16,11 +16,20 @@
  */
 package org.apache.camel.component.irc;
 
+import java.util.List;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.util.ObjectHelper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCEventAdapter;
 import org.schwering.irc.lib.IRCModeParser;
 import org.schwering.irc.lib.IRCUser;
 
@@ -30,6 +39,8 @@ import org.schwering.irc.lib.IRCUser;
  * @version $Revision$
  */
 public class IrcEndpoint extends DefaultEndpoint {
+    private static final transient Log LOG = LogFactory.getLog(IrcEndpoint.class);
+    
     private IrcBinding binding;
     private IrcConfiguration configuration;
     private IrcComponent component;
@@ -51,64 +62,55 @@ public class IrcEndpoint extends Default
     }
 
     public Exchange createOnPrivmsgExchange(String target, IRCUser user, String msg) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("PRIVMSG", target, user, msg));
         return exchange;
     }
 
     public Exchange createOnNickExchange(IRCUser user, String newNick) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("NICK", user, newNick));
         return exchange;
     }
 
     public Exchange createOnQuitExchange(IRCUser user, String msg) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("QUIT", user, msg));
         return exchange;
     }
 
     public Exchange createOnJoinExchange(String channel, IRCUser user) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("JOIN", channel, user));
         return exchange;
     }
 
     public Exchange createOnKickExchange(String channel, IRCUser user, String whoWasKickedNick,
String msg) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("KICK", channel, user, whoWasKickedNick, msg));
         return exchange;
     }
 
     public Exchange createOnModeExchange(String channel, IRCUser user, IRCModeParser modeParser)
{
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("MODE", channel, user, modeParser.getLine()));
         return exchange;
     }
 
     public Exchange createOnPartExchange(String channel, IRCUser user, String msg) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("PART", channel, user, msg));
         return exchange;
     }
 
     public Exchange createOnReplyExchange(int num, String value, String msg) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("REPLY", num, value, msg));
         return exchange;
     }
 
     public Exchange createOnTopicExchange(String channel, IRCUser user, String topic) {
-        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
+        DefaultExchange exchange = getExchange();
         exchange.setIn(new IrcMessage("TOPIC", channel, user, topic));
         return exchange;
     }
@@ -147,5 +149,63 @@ public class IrcEndpoint extends Default
     public void setConfiguration(IrcConfiguration configuration) {
         this.configuration = configuration;
     }
+
+
+    public void handleIrcError(int num, String msg) {
+        if (IRCEventAdapter.ERR_NICKNAMEINUSE == num) {
+            handleNickInUse();
+        }
+    }
+
+    private void handleNickInUse() {
+        IRCConnection connection = component.getIRCConnection(configuration);
+        String nick = connection.getNick() + "-";
+
+        // hackish but working approach to prevent an endless loop. Abort after 4 nick attempts.
+        if (nick.endsWith("----")) {
+            LOG.error("Unable to set nick: " + nick + " disconnecting");
+        } else {
+            LOG.warn("Unable to set nick: " + nick + " Retrying with " + nick + "-");
+            connection.doNick(nick);
+            // if the nick failure was doing startup channels weren't joined. So join
+            // the channels now. It's a no-op if the channels are already joined.
+            joinChannels();
+        }
+    }
+
+    private DefaultExchange getExchange() {
+        DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
+        exchange.setProperty(Exchange.BINDING, getBinding());
+        return exchange;
+    }
+
+
+    public void joinChannels() {
+        for (String channel : configuration.getChannels()) {
+            joinChannel(channel);
+        }
+    }
+
+    public void joinChannel(String channel) {
+
+        List<String> channels = configuration.getChannels();
+
+        IRCConnection connection = component.getIRCConnection(configuration);
+
+        // check for key for channel
+        String key = configuration.getKey(channel);
+
+        if (ObjectHelper.isNotEmpty(key)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Joining: " + channel + " using " + connection.getClass().getName()
+ " with key " + key);
+            }
+            connection.doJoin(channel, key);
+        } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Joining: " + channel + " using " + connection.getClass().getName());
+            }
+            connection.doJoin(channel);
+        }
+    }
 }
 

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
Wed Dec  8 06:40:39 2010
@@ -16,14 +16,15 @@
  */
 package org.apache.camel.component.irc;
 
-import java.util.List;
-
 import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCEventAdapter;
+import org.schwering.irc.lib.IRCModeParser;
+import org.schwering.irc.lib.IRCUser;
 
 public class IrcProducer extends DefaultProducer {
 
@@ -34,6 +35,7 @@ public class IrcProducer extends Default
 
     private IRCConnection connection;
     private IrcEndpoint endpoint;
+    private IRCEventAdapter listener;
 
     public IrcProducer(IrcEndpoint endpoint, IRCConnection connection) {
         super(endpoint);
@@ -44,6 +46,11 @@ public class IrcProducer extends Default
     public void process(Exchange exchange) throws Exception {
         final String msg = exchange.getIn().getBody(String.class);
         final String targetChannel = exchange.getIn().getHeader(IrcConstants.IRC_TARGET,
String.class);
+
+        if (!connection.isConnected()) {
+            throw new RuntimeCamelException("Lost connection to " + connection.getHost());
+        }
+
         if (isMessageACommand(msg)) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Sending command: " + msg);
@@ -67,34 +74,12 @@ public class IrcProducer extends Default
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-
-        List<String> channels = endpoint.getConfiguration().getChannels();
-        for (String channel : endpoint.getConfiguration().getChannels()) {
-
-            // find key for channel
-            int ndx = channels.indexOf(channel);
-            String key = null;
-            if (ndx >= 0) {
-                List<String> keys = endpoint.getConfiguration().getKeys();
-                if (keys.size() > 0 && ndx < keys.size()) {
-                    key = keys.get(ndx);
-                }
-            }
-
-            if (ObjectHelper.isNotEmpty(key)) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Joining: " + channel + " using " + connection.getClass().getName()
+ " with key " + key);
-                }
-                connection.doJoin(channel, key);
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Joining: " + channel + " using " + connection.getClass().getName());
-                }
-                connection.doJoin(channel);
-            }
-        }
+        listener = getListener();
+        connection.addIRCEventListener(listener);
+        endpoint.joinChannels();
     }
 
+
     @Override
     protected void doStop() throws Exception {
         if (connection != null) {
@@ -104,6 +89,7 @@ public class IrcProducer extends Default
                 }
                 connection.doPart(channel);
             }
+            connection.removeIRCEventListener(listener);
         }
         super.doStop();
     }
@@ -117,4 +103,34 @@ public class IrcProducer extends Default
         return false;
     }
 
+    public IRCEventAdapter getListener() {
+        if (listener == null) {
+            listener = new FilteredIRCEventAdapter();
+        }
+        return listener;
+    }
+
+    public void setListener(IRCEventAdapter listener) {
+        this.listener = listener;
+    }
+
+    class FilteredIRCEventAdapter extends IRCEventAdapter {
+
+        @Override
+        public void onKick(String channel, IRCUser user, String passiveNick, String msg)
{
+
+            // check to see if I got kick and if so rejoin if autoRejoin is on
+            if (passiveNick.equals(connection.getNick()) && endpoint.getConfiguration().isAutoRejoin())
{
+                endpoint.joinChannel(channel);
+            }
+        }
+
+
+        @Override
+        public void onError(int num, String msg) {
+            IrcProducer.this.endpoint.handleIrcError(num, msg);
+        }
+
+    }
+
 }

Modified: camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcConfigurationTest.java?rev=1043319&r1=1043318&r2=1043319&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcConfigurationTest.java
(original)
+++ camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcConfigurationTest.java
Wed Dec  8 06:40:39 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.irc;
 
+import java.util.Dictionary;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -90,9 +91,9 @@ public class IrcConfigurationTest extend
         List<String> channels = conf.getChannels();
         assertEquals(2, channels.size());
         assertEquals("#camel", channels.get(0));
-        List<String> keys = conf.getKeys();
+        Dictionary<String, String> keys = conf.getKeys();
         assertEquals(2, keys.size());
-        assertEquals("foo", keys.get(1));
+        assertEquals("foo", conf.getKey("#smx"));
     }
 
     @Test
@@ -111,9 +112,9 @@ public class IrcConfigurationTest extend
         List<String> channels = conf.getChannels();
         assertEquals(2, channels.size());
         assertEquals("#camel", channels.get(0));
-        List<String> keys = conf.getKeys();
+        Dictionary<String, String> keys = conf.getKeys();
         assertEquals(1, keys.size());
-        assertEquals("foo", keys.get(0));
+        assertEquals("foo", conf.getKey("#camel"));
         assertEquals("Camel Bot", conf.getRealname());
     }
 
@@ -133,10 +134,10 @@ public class IrcConfigurationTest extend
         List<String> channels = conf.getChannels();
         assertEquals(2, channels.size());
         assertEquals("#camel", channels.get(0));
-        List<String> keys = conf.getKeys();
+        Dictionary<String, String> keys = conf.getKeys();
         assertEquals(2, keys.size());
-        assertEquals("foo", keys.get(0));
-        assertEquals("bar", keys.get(1));
+        assertEquals("foo", conf.getKey("#camel"));
+        assertEquals("bar", conf.getKey("#smx"));
         assertEquals("Camel Bot", conf.getRealname());
     }
 



Mime
View raw message