You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/10/05 16:07:10 UTC
svn commit: r582277 - in /activemq/camel/trunk/components/camel-amqp: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/camel/ src/main/java/org/apache/camel/component/
src/main/java/org/apache/camel...
Author: jstrachan
Date: Fri Oct 5 07:07:06 2007
New Revision: 582277
URL: http://svn.apache.org/viewvc?rev=582277&view=rev
Log:
an initial AMQP component using qpid's ConnectionFactory for CAMEL-164
Added:
activemq/camel/trunk/components/camel-amqp/
activemq/camel/trunk/components/camel-amqp/pom.xml (with props)
activemq/camel/trunk/components/camel-amqp/src/
activemq/camel/trunk/components/camel-amqp/src/main/
activemq/camel/trunk/components/camel-amqp/src/main/java/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/
activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java (with props)
activemq/camel/trunk/components/camel-amqp/src/main/resources/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/
activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/amqp
activemq/camel/trunk/components/camel-amqp/src/test/
activemq/camel/trunk/components/camel-amqp/src/test/java/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java (with props)
activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java (with props)
activemq/camel/trunk/components/camel-amqp/src/test/resources/
activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties (with props)
Added: activemq/camel/trunk/components/camel-amqp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/pom.xml?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/pom.xml (added)
+++ activemq/camel/trunk/components/camel-amqp/pom.xml Fri Oct 5 07:07:06 2007
@@ -0,0 +1,125 @@
+<?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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-amqp</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: AMQP</name>
+ <description>Camel AMQP support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.amqp*</camel.osgi.export.pkg>
+ <qpid-version>1.0-incubator-M1</qpid-version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jms</artifactId>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-client</artifactId>
+ <version>${qpid-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-common</artifactId>
+ <version>${qpid-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>1.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker</artifactId>
+ <version>${qpid-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: activemq/camel/trunk/components/camel-amqp/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java (added)
+++ activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java Fri Oct 5 07:07:06 2007
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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.amqp;
+
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.component.jms.JmsConfiguration;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.url.URLSyntaxException;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class AMQPComponent extends JmsComponent {
+
+ public static Component amqpComponent(String uri) throws URLSyntaxException {
+ AMQConnectionFactory connectionFactory = new AMQConnectionFactory(uri);
+ return new AMQPComponent(connectionFactory);
+ }
+
+ public AMQPComponent() {
+ init();
+ }
+
+ public AMQPComponent(JmsConfiguration configuration) {
+ super(configuration);
+ }
+
+ public AMQPComponent(CamelContext context) {
+ super(context);
+ init();
+ }
+
+
+ public AMQPComponent(AMQConnectionFactory connectionFactory) {
+ setConnectionFactory(connectionFactory);
+ }
+
+ /**
+ * Lets install the default connection factory
+ */
+ private void init() {
+ AMQConnectionFactory connectionFactory = new AMQConnectionFactory();
+ setConnectionFactory(connectionFactory);
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/amqp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/amqp?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/amqp (added)
+++ activemq/camel/trunk/components/camel-amqp/src/main/resources/META-INF/services/org/apache/camel/component/amqp Fri Oct 5 07:07:06 2007
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.amqp.AMQPComponent
Added: activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java (added)
+++ activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java Fri Oct 5 07:07:06 2007
@@ -0,0 +1,85 @@
+/**
+ * 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.amqp;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import static org.apache.camel.component.amqp.AMQPComponent.amqpComponent;
+
+/**
+ * @version $Revision: 574458 $
+ */
+public class AMQPRouteTest extends ContextTestSupport {
+ protected MockEndpoint resultEndpoint;
+ protected String componentName = "amqp";
+ protected String startEndpointUri;
+
+ public void testJmsRouteWithTextMessage() throws Exception {
+ String expectedBody = "Hello there!";
+
+ resultEndpoint.expectedBodiesReceived(expectedBody);
+ resultEndpoint.message(0).header("cheese").isEqualTo(123);
+
+ sendExchange(expectedBody);
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ public void testJmsRouteWithObjectMessage() throws Exception {
+ PurchaseOrder expectedBody = new PurchaseOrder("Beer", 10);
+
+ resultEndpoint.expectedBodiesReceived(expectedBody);
+ resultEndpoint.message(0).header("cheese").isEqualTo(123);
+
+ sendExchange(expectedBody);
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected void sendExchange(final Object expectedBody) {
+ template.sendBodyAndHeader(startEndpointUri, expectedBody, "cheese", 123);
+ }
+
+
+ @Override
+ protected void setUp() throws Exception {
+ startEndpointUri = componentName + ":queue:test.a";
+
+ super.setUp();
+
+ resultEndpoint = (MockEndpoint) context.getEndpoint("mock:result");
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ camelContext.addComponent(componentName, amqpComponent("amqp://guest:guest@/test?brokerlist='vm://:1'"));
+
+ return camelContext;
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(startEndpointUri).to(componentName + ":queue:test.b");
+ from(componentName + ":queue:test.b").to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java (added)
+++ activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java Fri Oct 5 07:07:06 2007
@@ -0,0 +1,67 @@
+/**
+ * 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.amqp;
+
+import java.io.Serializable;
+
+/**
+ * A simple POJO for testing
+ *
+ * @version $Revision: 563665 $
+ */
+public class PurchaseOrder implements Serializable {
+ private String product;
+ private double amount;
+
+ public PurchaseOrder(String product, double amount) {
+ this.product = product;
+ this.amount = amount;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+ if (this.getClass() != other.getClass()) {
+ return false;
+ }
+ PurchaseOrder that = (PurchaseOrder) other;
+ return this.product.equals(that.product) && this.amount == that.amount;
+ }
+
+ @Override
+ public int hashCode() {
+ return product.hashCode() * 37 + (int) Math.round(amount);
+ }
+
+ @Override
+ public String toString() {
+ return "PurchaseOrder[" + product + " x " + amount + "]";
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public String getProduct() {
+ return product;
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/PurchaseOrder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties?rev=582277&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties Fri Oct 5 07:07:06 2007
@@ -0,0 +1,53 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.activemq.spring=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-test.log
+log4j.appender.out.append=true
+
Propchange: activemq/camel/trunk/components/camel-amqp/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native