You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2007/05/10 20:09:35 UTC

svn commit: r536956 - in /activemq/camel/trunk/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/ test/resources/org/apache/camel/component/jms/

Author: jstrachan
Date: Thu May 10 11:09:34 2007
New Revision: 536956

URL: http://svn.apache.org/viewvc?view=rev&rev=536956
Log:
added a test case showing how to explicitly configure a component using Spring XML

Added:
    activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
    activemq/camel/trunk/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml
Modified:
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
    activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?view=diff&rev=536956&r1=536955&r2=536956
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java Thu May 10 11:09:34 2007
@@ -17,18 +17,20 @@
  */
 package org.apache.camel.component.jms;
 
-import static org.apache.camel.util.ObjectHelper.removeStartingCharacters;
-
-import java.util.Map;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Session;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.util.IntrospectionSupport;
+import static org.apache.camel.util.ObjectHelper.removeStartingCharacters;
 import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.jms.support.converter.MessageConverter;
+import org.springframework.jms.listener.serversession.ServerSessionFactory;
+import org.springframework.core.task.TaskExecutor;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+import javax.jms.ExceptionListener;
+import java.util.Map;
 
 /**
  * @version $Revision:520964 $
@@ -140,6 +142,143 @@
      */
     public void setConfiguration(JmsConfiguration configuration) {
         this.configuration = configuration;
+    }
+
+
+    public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) {
+        getConfiguration().setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
+    }
+
+    public void setAcknowledgementMode(int consumerAcknowledgementMode) {
+        getConfiguration().setAcknowledgementMode(consumerAcknowledgementMode);
+    }
+
+    public void setAcknowledgementModeName(String consumerAcknowledgementMode) {
+        getConfiguration().setAcknowledgementModeName(consumerAcknowledgementMode);
+    }
+
+    public void setAutoStartup(boolean autoStartup) {
+        getConfiguration().setAutoStartup(autoStartup);
+    }
+
+    public void setCacheLevel(int cacheLevel) {
+        getConfiguration().setCacheLevel(cacheLevel);
+    }
+
+    public void setCacheLevelName(String cacheName) {
+        getConfiguration().setCacheLevelName(cacheName);
+    }
+
+    public void setClientId(String consumerClientId) {
+        getConfiguration().setClientId(consumerClientId);
+    }
+
+    public void setConcurrentConsumers(int concurrentConsumers) {
+        getConfiguration().setConcurrentConsumers(concurrentConsumers);
+    }
+
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        getConfiguration().setConnectionFactory(connectionFactory);
+    }
+
+    public void setConsumerType(ConsumerType consumerType) {
+        getConfiguration().setConsumerType(consumerType);
+    }
+
+    public void setDeliveryPersistent(boolean deliveryPersistent) {
+        getConfiguration().setDeliveryPersistent(deliveryPersistent);
+    }
+
+    public void setDurableSubscriptionName(String durableSubscriptionName) {
+        getConfiguration().setDurableSubscriptionName(durableSubscriptionName);
+    }
+
+    public void setExceptionListener(ExceptionListener exceptionListener) {
+        getConfiguration().setExceptionListener(exceptionListener);
+    }
+
+    public void setExplicitQosEnabled(boolean explicitQosEnabled) {
+        getConfiguration().setExplicitQosEnabled(explicitQosEnabled);
+    }
+
+    public void setExposeListenerSession(boolean exposeListenerSession) {
+        getConfiguration().setExposeListenerSession(exposeListenerSession);
+    }
+
+    public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) {
+        getConfiguration().setIdleTaskExecutionLimit(idleTaskExecutionLimit);
+    }
+
+    public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
+        getConfiguration().setMaxConcurrentConsumers(maxConcurrentConsumers);
+    }
+
+    public void setMaxMessagesPerTask(int maxMessagesPerTask) {
+        getConfiguration().setMaxMessagesPerTask(maxMessagesPerTask);
+    }
+
+    public void setMessageConverter(MessageConverter messageConverter) {
+        getConfiguration().setMessageConverter(messageConverter);
+    }
+
+    public void setMessageIdEnabled(boolean messageIdEnabled) {
+        getConfiguration().setMessageIdEnabled(messageIdEnabled);
+    }
+
+    public void setMessageTimestampEnabled(boolean messageTimestampEnabled) {
+        getConfiguration().setMessageTimestampEnabled(messageTimestampEnabled);
+    }
+
+    public void setPriority(int priority) {
+        getConfiguration().setPriority(priority);
+    }
+
+    public void setPubSubNoLocal(boolean pubSubNoLocal) {
+        getConfiguration().setPubSubNoLocal(pubSubNoLocal);
+    }
+
+    public void setReceiveTimeout(long receiveTimeout) {
+        getConfiguration().setReceiveTimeout(receiveTimeout);
+    }
+
+    public void setRecoveryInterval(long recoveryInterval) {
+        getConfiguration().setRecoveryInterval(recoveryInterval);
+    }
+
+    public void setServerSessionFactory(ServerSessionFactory serverSessionFactory) {
+        getConfiguration().setServerSessionFactory(serverSessionFactory);
+    }
+
+    public void setSubscriptionDurable(boolean subscriptionDurable) {
+        getConfiguration().setSubscriptionDurable(subscriptionDurable);
+    }
+
+    public void setTaskExecutor(TaskExecutor taskExecutor) {
+        getConfiguration().setTaskExecutor(taskExecutor);
+    }
+
+    public void setTimeToLive(long timeToLive) {
+        getConfiguration().setTimeToLive(timeToLive);
+    }
+
+    public void setTransacted(boolean consumerTransacted) {
+        getConfiguration().setTransacted(consumerTransacted);
+    }
+
+    public void setTransactionManager(PlatformTransactionManager transactionManager) {
+        getConfiguration().setTransactionManager(transactionManager);
+    }
+
+    public void setTransactionName(String transactionName) {
+        getConfiguration().setTransactionName(transactionName);
+    }
+
+    public void setTransactionTimeout(int transactionTimeout) {
+        getConfiguration().setTransactionTimeout(transactionTimeout);
+    }
+
+    public void setUseVersion102(boolean useVersion102) {
+        getConfiguration().setUseVersion102(useVersion102);
     }
 
     /**

Modified: activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java?view=diff&rev=536956&r1=536955&r2=536956
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java (original)
+++ activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java Thu May 10 11:09:34 2007
@@ -30,7 +30,9 @@
  * @version $Revision$
  */
 public class JmsRouteTest extends ContextTestSupport {
-    private MockEndpoint resultEndpoint;
+    protected MockEndpoint resultEndpoint;
+    protected String startEndpointUri = "activemq:queue:test.a";
+;
 
     public void testJmsRouteWithTextMessage() throws Exception {
         String expectedBody = "Hello there!";
@@ -55,7 +57,7 @@
     }
 
     protected void sendExchange(final Object expectedBody) {
-        template.sendBody("activemq:queue:test.a", expectedBody, "cheese", 123);
+        template.sendBody(startEndpointUri, expectedBody, "cheese", 123);
     }
 
 
@@ -78,7 +80,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("activemq:queue:test.a").to("activemq:queue:test.b");
+                from(startEndpointUri).to("activemq:queue:test.b");
                 from("activemq:queue:test.b").to("mock:result");
 
                 JmsEndpoint endpoint1 = (JmsEndpoint) endpoint("activemq:topic:quote.IONA");

Added: activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java?view=auto&rev=536956
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java (added)
+++ activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java Thu May 10 11:09:34 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.jms;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: $
+ */
+public class JmsRouteUsingSpringTest extends JmsRouteTest {
+    private ClassPathXmlApplicationContext applicationContext;
+
+    protected CamelContext createCamelContext() throws Exception {
+        applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml");
+        return SpringCamelContext.springCamelContext(applicationContext);
+    }
+
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        applicationContext.close();
+    }
+}

Added: activemq/camel/trunk/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml?view=auto&rev=536956
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml (added)
+++ activemq/camel/trunk/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml Thu May 10 11:09:34 2007
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/camel-1.0.xsd http://activemq.apache.org/camel/schema/camel-1.0.xsd
+    ">
+
+  <!-- START SNIPPET: example -->
+  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+  </camelContext>
+
+  <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
+    <property name="connectionFactory">
+      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+      </bean>
+    </property>
+  </bean>
+  <!-- END SNIPPET: example -->
+
+</beans>