activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1325985 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
Date Fri, 13 Apr 2012 22:21:28 GMT
Author: tabish
Date: Fri Apr 13 22:21:27 2012
New Revision: 1325985

URL: http://svn.apache.org/viewvc?rev=1325985&view=rev
Log:
apply fix for: https://issues.apache.org/jira/browse/AMQ-3803

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
  (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java?rev=1325985&r1=1325984&r2=1325985&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java
Fri Apr 13 22:21:27 2012
@@ -33,7 +33,7 @@ import javax.naming.NamingException;
  * necessary when the list of nodes is provided. So the role of this class is to
  * transform properties before passing it to
  * <CODE>ActiveMQInitialContextFactory</CODE>.
- * 
+ *
  * @author Pawel Tucholski
  */
 public class ActiveMQWASInitialContextFactory extends ActiveMQInitialContextFactory {
@@ -54,7 +54,7 @@ public class ActiveMQWASInitialContextFa
      * <li>(java.naming.connectionFactoryNames,value)=>(connectionFactoryNames,value)
      * <li>(java.naming.provider.url,url1;url2)=>java.naming.provider.url,url1,url1)
      * <ul>
-     * 
+     *
      * @param environment properties for transformation
      * @return environment after transformation
      */
@@ -66,31 +66,33 @@ public class ActiveMQWASInitialContextFa
 
         while (it.hasNext()) {
             Map.Entry entry = (Map.Entry)it.next();
-            String key = (String)entry.getKey();
-            String value = (String)entry.getValue();
-
-            if (key.startsWith("java.naming.queue")) {
-                String key1 = key.substring("java.naming.queue.".length());
-                key1 = key1.replace('.', '/');
-                environment1.put("queue." + key1, value);
-            } else if (key.startsWith("java.naming.topic")) {
-                String key1 = key.substring("java.naming.topic.".length());
-                key1 = key1.replace('.', '/');
-                environment1.put("topic." + key1, value);
-            } else if (key.startsWith("java.naming.connectionFactoryNames")) {
-                String key1 = key.substring("java.naming.".length());
-                environment1.put(key1, value);
-            } else if (key.startsWith("java.naming.connection")) {
-                String key1 = key.substring("java.naming.".length());
-                environment1.put(key1, value);
-            } else if (key.startsWith(Context.PROVIDER_URL)) {
-                // websphere administration console does not exept , character
-                // in provider url, so ; must be used
-                // all ; to ,
-                value = value.replace(';', ',');
-                environment1.put(Context.PROVIDER_URL, value);
-            } else {
-                environment1.put(key, value);
+            if (entry.getKey() instanceof String && entry.getValue() instanceof String)
{
+                String key = (String)entry.getKey();
+                String value = (String)entry.getValue();
+
+                if (key.startsWith("java.naming.queue")) {
+                    String key1 = key.substring("java.naming.queue.".length());
+                    key1 = key1.replace('.', '/');
+                    environment1.put("queue." + key1, value);
+                } else if (key.startsWith("java.naming.topic")) {
+                    String key1 = key.substring("java.naming.topic.".length());
+                    key1 = key1.replace('.', '/');
+                    environment1.put("topic." + key1, value);
+                } else if (key.startsWith("java.naming.connectionFactoryNames")) {
+                    String key1 = key.substring("java.naming.".length());
+                    environment1.put(key1, value);
+                } else if (key.startsWith("java.naming.connection")) {
+                    String key1 = key.substring("java.naming.".length());
+                    environment1.put(key1, value);
+                } else if (key.startsWith(Context.PROVIDER_URL)) {
+                    // websphere administration console does not accept the , character
+                    // in provider url, so ; must be used
+                    // all ; to ,
+                    value = value.replace(';', ',');
+                    environment1.put(Context.PROVIDER_URL, value);
+                } else {
+                    environment1.put(key, value);
+                }
             }
         }
 

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java?rev=1325985&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
Fri Apr 13 22:21:27 2012
@@ -0,0 +1,42 @@
+/**
+ * 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.activemq.jndi;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+
+public class ActiveMQWASInitialContextFactoryTest extends JNDITestSupport {
+
+    public void testTransformEnvironment() {
+
+        Hashtable<Object, Object> originalEnvironment = new Hashtable<Object, Object>();
+        originalEnvironment.put("java.naming.connectionFactoryNames", "ConnectionFactory");
+        originalEnvironment.put("java.naming.topic.jms.systemMessageTopic", "jms/systemMessageTopic");
+        originalEnvironment.put(Context.PROVIDER_URL, "tcp://localhost:61616;tcp://localhost:61617");
+        originalEnvironment.put("non-string", Integer.valueOf(43));
+
+        @SuppressWarnings("unchecked")
+        Hashtable<Object, Object> transformedEnvironment = new ActiveMQWASInitialContextFactory().transformEnvironment(originalEnvironment);
+        assertEquals("ConnectionFactory", "ConnectionFactory", transformedEnvironment.get("connectionFactoryNames"));
+        assertEquals("topic.jm", "jms/systemMessageTopic", transformedEnvironment.get("topic.jms/systemMessageTopic"));
+        assertEquals("java.naming.provider.url", "tcp://localhost:61616,tcp://localhost:61617",
transformedEnvironment.get("java.naming.provider.url"));
+        assertNull("non-string", transformedEnvironment.get("non-string"));
+    }
+
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message