You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by de...@apache.org on 2015/12/14 14:02:41 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-6077 -
test
Repository: activemq
Updated Branches:
refs/heads/master 94446e53d -> 7951037f2
https://issues.apache.org/jira/browse/AMQ-6077 - test
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/7951037f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/7951037f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/7951037f
Branch: refs/heads/master
Commit: 7951037f20e8d6752ab0bbd90189a8276bc61a55
Parents: 94446e5
Author: Dejan Bosanac <de...@nighttale.net>
Authored: Mon Dec 14 14:02:31 2015 +0100
Committer: Dejan Bosanac <de...@nighttale.net>
Committed: Mon Dec 14 14:02:31 2015 +0100
----------------------------------------------------------------------
.../activemq/camel/ObjectMessageTest.java | 83 +++++++++++++++++
.../apache/activemq/camel/ObjectPayload.java | 25 ++++++
.../activemq/camel/jms-object-message.xml | 93 ++++++++++++++++++++
3 files changed, 201 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/7951037f/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
new file mode 100644
index 0000000..226cfd3
--- /dev/null
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.camel;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.jms.JmsBinding;
+import org.apache.camel.component.jms.JmsMessage;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+
+import javax.jms.*;
+import java.util.concurrent.TimeUnit;
+
+public class ObjectMessageTest extends CamelSpringTestSupport {
+
+ @Test
+ public void testUntrusted() throws Exception {
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
+ Connection conn = factory.createConnection();
+ conn.start();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = sess.createProducer(sess.createTopic("foo"));
+ ObjectMessage msg = sess.createObjectMessage();
+ ObjectPayload payload = new ObjectPayload();
+ payload.payload = "test";
+ msg.setObject(payload);
+ producer.send(msg);
+
+ Thread.sleep(1000);
+
+ MockEndpoint resultActiveMQ = resolveMandatoryEndpoint("mock:result-activemq", MockEndpoint.class);
+ resultActiveMQ.expectedMessageCount(1);
+ resultActiveMQ.assertIsSatisfied();
+ assertCorrectObjectReceived(resultActiveMQ);
+
+ MockEndpoint resultTrusted = resolveMandatoryEndpoint("mock:result-trusted", MockEndpoint.class);
+ resultTrusted.expectedMessageCount(1);
+ resultTrusted.assertIsSatisfied();
+ assertCorrectObjectReceived(resultTrusted);
+
+ MockEndpoint resultCamel = resolveMandatoryEndpoint("mock:result-camel", MockEndpoint.class);
+ resultCamel.expectedMessageCount(0);
+ resultCamel.assertIsSatisfied(1, TimeUnit.SECONDS);
+
+ }
+
+ protected void assertCorrectObjectReceived(MockEndpoint result) {
+ Exchange exchange = result.getReceivedExchanges().get(0);
+ // This should be a JMS Exchange
+ assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class));
+ JmsMessage in = (JmsMessage) exchange.getIn();
+ assertNotNull(in);
+ assertIsInstanceOf(ObjectMessage.class, in.getJmsMessage());
+
+ ObjectPayload received = exchange.getIn().getBody(ObjectPayload.class);
+ assertEquals("test", received.payload);
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ AbstractApplicationContext context = new ClassPathXmlApplicationContext("org/apache/activemq/camel/jms-object-message.xml");
+ return context;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/7951037f/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java
new file mode 100644
index 0000000..301d03c
--- /dev/null
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java
@@ -0,0 +1,25 @@
+/**
+ * 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.camel;
+
+import java.io.Serializable;
+
+public class ObjectPayload implements Serializable {
+ private static final long serialVersionUID = 121277L;
+
+ public String payload;
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/7951037f/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
new file mode 100644
index 0000000..a4534c0
--- /dev/null
+++ b/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
@@ -0,0 +1,93 @@
+<?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://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="activemq-activemq:topic:foo"/>
+ <to uri="mock:result-activemq"/>
+ </route>
+ <route>
+ <from uri="activemq-camel:topic:foo"/>
+ <to uri="mock:result-camel"/>
+ </route>
+ <route>
+ <from uri="activemq-trusted:topic:foo"/>
+ <to uri="mock:result-trusted"/>
+ </route>
+ </camelContext>
+
+ <!-- configuration for activemq-camel endpoint -->
+
+ <bean id="camelConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+ <property name="trustedPackages">
+ <list>
+ <value>org.apache.camel</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="camelConfig" class="org.apache.camel.component.jms.JmsConfiguration">
+ <property name="connectionFactory" ref="camelConnectionFactory"/>
+ </bean>
+
+ <bean id="activemq-camel" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="configuration" ref="camelConfig"/>
+ </bean>
+
+ <!-- configuration for activemq-activemq endpoint -->
+
+ <bean id="activemqConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+ <property name="trustedPackages">
+ <list>
+ <value>org.apache.activemq</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="activemqConfig" class="org.apache.camel.component.jms.JmsConfiguration">
+ <property name="connectionFactory" ref="activemqConnectionFactory"/>
+ </bean>
+
+ <bean id="activemq-activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="configuration" ref="activemqConfig"/>
+ </bean>
+
+ <!-- configuration for activemq-trusted endpoint -->
+
+ <bean id="trustedConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+ <property name="trustAllPackages" value="true"/>
+ </bean>
+
+ <bean id="trustedConfig" class="org.apache.camel.component.jms.JmsConfiguration">
+ <property name="connectionFactory" ref="trustedConnectionFactory"/>
+ </bean>
+
+ <bean id="activemq-trusted" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="configuration" ref="trustedConfig"/>
+ </bean>
+
+</beans>