activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1404896 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
Date Fri, 02 Nov 2012 08:57:40 GMT
Author: davsclaus
Date: Fri Nov  2 08:57:40 2012
New Revision: 1404896

URL: http://svn.apache.org/viewvc?rev=1404896&view=rev
Log:
AMQ-4153: Fixed issue with ActiveMQWASInitialContextFactory

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.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=1404896&r1=1404895&r2=1404896&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 Nov  2 08:57:40 2012
@@ -28,13 +28,10 @@ import javax.naming.NamingException;
  * when ActiveMQ is used as WebSphere Generic JMS Provider. It is proved that it
  * works on WebSphere 5.1. The reason for using this class is that custom
  * property defined for Generic JMS Provider are passed to InitialContextFactory
- * only if it begins with java.naming or javax.naming prefix. Additionaly
+ * only if it begins with java.naming or javax.naming prefix. Additionally
  * provider url for the JMS provider can not contain ',' character that is
  * 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
+ * transform properties before passing it to <tt>ActiveMQInitialContextFactory</tt>.
  */
 public class ActiveMQWASInitialContextFactory extends ActiveMQInitialContextFactory {
 
@@ -42,7 +39,6 @@ public class ActiveMQWASInitialContextFa
      * @see javax.naming.spi.InitialContextFactory#getInitialContext(java.util.Hashtable)
      */
     public Context getInitialContext(Hashtable environment) throws NamingException {
-
         return super.getInitialContext(transformEnvironment(environment));
     }
 
@@ -58,6 +54,7 @@ public class ActiveMQWASInitialContextFa
      * @param environment properties for transformation
      * @return environment after transformation
      */
+    @SuppressWarnings("unchecked")
     protected Hashtable transformEnvironment(Hashtable environment) {
 
         Hashtable environment1 = new Hashtable();
@@ -70,11 +67,11 @@ public class ActiveMQWASInitialContextFa
                 String key = (String)entry.getKey();
                 String value = (String)entry.getValue();
 
-                if (key.startsWith("java.naming.queue")) {
+                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")) {
+                } else if (key.startsWith("java.naming.topic.")) {
                     String key1 = key.substring("java.naming.topic.".length());
                     key1 = key1.replace('.', '/');
                     environment1.put("topic." + key1, value);
@@ -85,9 +82,8 @@ public class ActiveMQWASInitialContextFa
                     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 ,
+                    // 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 {

Modified: 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=1404896&r1=1404895&r2=1404896&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java
Fri Nov  2 08:57:40 2012
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.activemq.jndi;
 
 import java.util.Hashtable;
@@ -23,20 +22,22 @@ import javax.naming.Context;
 
 public class ActiveMQWASInitialContextFactoryTest extends JNDITestSupport {
 
+    @SuppressWarnings("unchecked")
     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));
+        originalEnvironment.put("java.naming.queue", "jms/systemMessageQueue");
 
-        @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"));
+
+        assertEquals("queue", "jms/systemMessageQueue", transformedEnvironment.get("java.naming.queue"));
     }
 
 }



Mime
View raw message