You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/08/07 15:31:29 UTC

svn commit: r1370253 - in /camel/trunk/components: ./ camel-neo4j/ camel-neo4j/src/ camel-neo4j/src/main/ camel-neo4j/src/main/java/ camel-neo4j/src/main/java/org/ camel-neo4j/src/main/java/org/apache/ camel-neo4j/src/main/java/org/apache/camel/ camel-...

Author: ningjiang
Date: Tue Aug  7 13:31:27 2012
New Revision: 1370253

URL: http://svn.apache.org/viewvc?rev=1370253&view=rev
Log:
CAMEL-5483 Added the camel-neo4j component

Added:
    camel/trunk/components/camel-neo4j/
    camel/trunk/components/camel-neo4j/pom.xml
    camel/trunk/components/camel-neo4j/src/
    camel/trunk/components/camel-neo4j/src/main/
    camel/trunk/components/camel-neo4j/src/main/java/
    camel/trunk/components/camel-neo4j/src/main/java/org/
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/BasicRelationship.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jComponent.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jEndpoint.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jException.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jOperation.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java
    camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/SpringDataRelationship.java
    camel/trunk/components/camel-neo4j/src/main/resources/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/LICENSE.txt
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/NOTICE.txt
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/neo4j
    camel/trunk/components/camel-neo4j/src/test/
    camel/trunk/components/camel-neo4j/src/test/java/
    camel/trunk/components/camel-neo4j/src/test/java/org/
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jComponentTest.java
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jEndpointTest.java
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jProducerTest.java
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateNodeIntegrationTest.java
    camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateRelationshipIntegrationTest.java
Modified:
    camel/trunk/components/pom.xml

Added: camel/trunk/components/camel-neo4j/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/pom.xml?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/pom.xml (added)
+++ camel/trunk/components/camel-neo4j/pom.xml Tue Aug  7 13:31:27 2012
@@ -0,0 +1,107 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>2.11-SNAPSHOT</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>camel-neo4j</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: neo4j</name>
+    <description>Camel neo4j support</description>
+    
+    <properties>
+    	<spring.neo4j.version>2.0.1.RELEASE</spring.neo4j.version>
+    	<mockito.version>1.9.0</mockito.version>
+    </properties>
+
+    <dependencies>
+
+	<dependency>
+		<groupId>org.springframework.data</groupId>
+		<artifactId>spring-data-neo4j-rest</artifactId>
+		<version>${spring.neo4j.version}</version>
+	</dependency>
+		
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.mina</groupId>
+            <artifactId>mina-core</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+	<dependency>
+		<groupId>org.mockito</groupId>
+		<artifactId>mockito-all</artifactId>
+		<version>${mockito.version}</version>
+		<scope>test</scope>
+	</dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <childDelegation>false</childDelegation>
+                    <useFile>true</useFile>
+                    <forkMode>pertest</forkMode>
+                    <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+                    <includes>
+                        <include>**/*Test.java</include>
+                    </includes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/BasicRelationship.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/BasicRelationship.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/BasicRelationship.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/BasicRelationship.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,56 @@
+/**
+ * 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.neo4j;
+
+import java.util.Map;
+
+import org.neo4j.graphdb.Node;
+
+public class BasicRelationship {
+
+    private final Node start;
+    private final Node end;
+    private final String relationshipType;
+    private final Map<String, Object> properties;
+
+    public BasicRelationship(Node start, Node end, String relationshipType) {
+        this(start, end, relationshipType, null);
+    }
+
+    public BasicRelationship(Node start, Node end, String relationshipType, Map<String, Object> properties) {
+        this.start = start;
+        this.end = end;
+        this.relationshipType = relationshipType;
+        this.properties = properties;
+    }
+
+    public Node getEnd() {
+        return end;
+    }
+
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    public String getRelationshipType() {
+        return relationshipType;
+    }
+
+    public Node getStart() {
+        return start;
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jComponent.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jComponent.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jComponent.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,45 @@
+/**
+ * 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.neo4j;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Neo4jComponent extends DefaultComponent {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Neo4jComponent.class);
+
+    public Neo4jComponent() {
+    }
+
+    public Neo4jComponent(CamelContext context) {
+        super(context);
+    }
+
+    @Override
+    protected Neo4jEndpoint createEndpoint(String uri, String remaining, Map<String, Object> params)
+        throws Exception {
+        Neo4jEndpoint e = new Neo4jEndpoint(uri, remaining, this);
+        setProperties(e, params);
+        LOGGER.info("Created Neo4j Endpoint [{}]", e);
+        return e;
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jEndpoint.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jEndpoint.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jEndpoint.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,54 @@
+/**
+ * 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.neo4j;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.neo4j.graphdb.GraphDatabaseService;
+import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
+
+public class Neo4jEndpoint extends DefaultEndpoint {
+
+    public static final String HEADER_OPERATION = "Neo4jOperation";
+    public static final String HEADER_NODE_ID = "Neo4jNodeId";
+    public static final String HEADER_RELATIONSHIP_ID = "Neo4jRelationshipId";
+
+    private final GraphDatabaseService graphDatabase;
+
+    public Neo4jEndpoint(String endpointUri, String remaining, Neo4jComponent component) {
+        super(endpointUri, component);
+        graphDatabase = new SpringRestGraphDatabase(remaining);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new Neo4jProducer(this, (SpringRestGraphDatabase)graphDatabase);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jException.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jException.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jException.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jException.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,27 @@
+/**
+ * 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.neo4j;
+
+public class Neo4jException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    public Neo4jException(String message) {
+        super(message);
+    }
+
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jOperation.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jOperation.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jOperation.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jOperation.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,30 @@
+/**
+ * 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.neo4j;
+
+
+public enum Neo4jOperation {
+
+    CREATE_NODE,
+
+    REMOVE_NODE,
+
+    CREATE_RELATIONSHIP,
+
+    REMOVE_RELATIONSHIP
+
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,141 @@
+/**
+ * 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.neo4j;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.Relationship;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.neo4j.core.GraphDatabase;
+import org.springframework.data.neo4j.support.Neo4jTemplate;
+
+public class Neo4jProducer extends DefaultProducer {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Neo4jProducer.class);
+
+    private final Neo4jEndpoint endpoint;
+
+    private final GraphDatabase graphDatabase;
+
+    private final Neo4jTemplate template;
+
+    public Neo4jProducer(Neo4jEndpoint endpoint, GraphDatabase graphDatabase) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        this.graphDatabase = graphDatabase;
+        this.template = new Neo4jTemplate(graphDatabase);
+    }
+
+    public Neo4jProducer(Neo4jEndpoint endpoint, GraphDatabase graphDatabase, Neo4jTemplate template) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        this.graphDatabase = graphDatabase;
+        this.template = template;
+    }
+
+    @SuppressWarnings("unchecked")
+    Node createNode(Object body) {
+        if (body == null) {
+            return template.createNode();
+        } else if (body instanceof Map) {
+            return template.createNode((Map<String, Object>)body);
+        }
+        throw new Neo4jException("Unsupported body type for create node [" + body.getClass() + "]");
+    }
+    
+    Relationship createRelationship(Object body) {
+
+        if (body instanceof SpringDataRelationship) {
+            SpringDataRelationship<?> r = (SpringDataRelationship<?>)body;
+            Object rr = template.createRelationshipBetween(r.getStart(), r.getEnd(),
+                                                           r.getRelationshipEntityClass(),
+                                                           r.getRelationshipType(), r.isAllowDuplicates());
+            return (Relationship)rr;
+
+        } else if (body instanceof BasicRelationship) {
+            BasicRelationship r = (BasicRelationship)body;
+            Object rr = template.createRelationshipBetween(r.getStart(), r.getEnd(), r.getRelationshipType(),
+                                                           r.getProperties());
+            return (Relationship)rr;
+        }
+        throw new Neo4jException("Unsupported body type for create relationship [" + body == null
+            ? "null" : body.getClass() + "]");
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        Object body = exchange.getIn().getBody();
+        Neo4jOperation op = (Neo4jOperation)exchange.getIn().getHeader(Neo4jEndpoint.HEADER_OPERATION);
+        if (op == null) {
+            throw new Neo4jException("No operation specified for exchange " + exchange);
+        }
+
+        switch (op) {
+        case CREATE_NODE:
+            Node node = createNode(body);
+            LOGGER.debug("Node created [{}]", node);
+            exchange.getIn().setHeader(Neo4jEndpoint.HEADER_NODE_ID, node.getId());
+            break;
+        case CREATE_RELATIONSHIP:
+            Relationship r = createRelationship(body);
+            LOGGER.debug("Relationship created [{}]", r);
+            exchange.getIn().setHeader(Neo4jEndpoint.HEADER_RELATIONSHIP_ID, r.getId());
+            break;
+        case REMOVE_NODE:
+            removeNode(body);
+            break;
+        case REMOVE_RELATIONSHIP:
+            removeRelationship(body);
+            break;
+        default:
+            // do nothing here.
+        }
+    }
+
+    void removeNode(Object body) {
+        if (body instanceof Number) {
+            LOGGER.debug("Deleting node by id [" + body + "]");
+            Node node = template.getNode(((Number)body).longValue());
+            template.delete(node);
+        } else if (body instanceof Node) {
+            template.delete(body);
+        } else {
+            throw new Neo4jException("Unsupported body type for remove node [" + body == null
+                ? "null" : body.getClass() + "]");
+        }
+    }
+
+    void removeRelationship(Object body) {
+        if (body instanceof Number) {
+            LOGGER.debug("Deleting relationship by id [" + body + "]");
+            Relationship r = template.getRelationship(((Number)body).longValue());
+            template.delete(r);
+        } else if (body instanceof Relationship) {
+            template.delete(body);
+        } else if (body instanceof SpringDataRelationship) {
+            SpringDataRelationship<?> r = (SpringDataRelationship<?>)body;
+            template.deleteRelationshipBetween(r.getStart(), r.getEnd(), r.getRelationshipType());
+        } else {
+            throw new Neo4jException("Unsupported body type for remove node [" + body == null
+                ? "null" : body.getClass() + "]");
+        }
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/SpringDataRelationship.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/SpringDataRelationship.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/SpringDataRelationship.java (added)
+++ camel/trunk/components/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/SpringDataRelationship.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.neo4j;
+
+public class SpringDataRelationship<R> {
+
+    private final Object start;
+    private final Object end;
+    private final Class<R> relationshipEntityClass;
+    private final String relationshipType;
+    private final boolean allowDuplicates;
+
+    public SpringDataRelationship(Object start, Object end, Class<R> relationshipEntityClass,
+                                  String relationshipType, boolean allowDuplicates) {
+        this.start = start;
+        this.end = end;
+        this.relationshipEntityClass = relationshipEntityClass;
+        this.relationshipType = relationshipType;
+        this.allowDuplicates = allowDuplicates;
+    }
+
+    public Object getEnd() {
+        return end;
+    }
+
+    public Class<R> getRelationshipEntityClass() {
+        return relationshipEntityClass;
+    }
+
+    public String getRelationshipType() {
+        return relationshipType;
+    }
+
+    public Object getStart() {
+        return start;
+    }
+
+    public boolean isAllowDuplicates() {
+        return allowDuplicates;
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/resources/META-INF/LICENSE.txt?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-neo4j/src/main/resources/META-INF/LICENSE.txt Tue Aug  7 13:31:27 2012
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: camel/trunk/components/camel-neo4j/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/resources/META-INF/NOTICE.txt?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-neo4j/src/main/resources/META-INF/NOTICE.txt Tue Aug  7 13:31:27 2012
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Added: camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/neo4j
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/neo4j?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/neo4j (added)
+++ camel/trunk/components/camel-neo4j/src/main/resources/META-INF/services/org/apache/camel/component/neo4j Tue Aug  7 13:31:27 2012
@@ -0,0 +1,17 @@
+#
+# 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.neo4j.Neo4jComponent
\ No newline at end of file

Added: camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jComponentTest.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jComponentTest.java (added)
+++ camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jComponentTest.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,47 @@
+/**
+ * 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.neo4j;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(MockitoJUnitRunner.class)
+public class Neo4jComponentTest {
+
+    @Mock
+    private CamelContext context;
+
+    @Test
+    public void testEndpointCreated() throws Exception {
+        Map<String, Object> params = new HashMap<String, Object>();
+
+        String uri = "neo4j:http://localhost:5984/db";
+        String remaining = "http://localhost:5984/db";
+
+        Endpoint endpoint = new Neo4jComponent(context).createEndpoint(uri, remaining, params);
+        assertNotNull(endpoint);
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jEndpointTest.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jEndpointTest.java (added)
+++ camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jEndpointTest.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.neo4j;
+
+import java.net.URISyntaxException;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class Neo4jEndpointTest {
+
+    @Test
+    public void assertSingleton() throws URISyntaxException {
+        Neo4jEndpoint endpoint = new Neo4jEndpoint("neo4j:http://localhost/db", "http://localhost/db", new Neo4jComponent());
+        assertTrue(endpoint.isSingleton());
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testConsumerUnsupported() throws Exception {
+        new Neo4jEndpoint("ignored", "http://localhost:80/db", new Neo4jComponent()).createConsumer(null);
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jProducerTest.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jProducerTest.java (added)
+++ camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/Neo4jProducerTest.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,245 @@
+/**
+ * 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.neo4j;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.Relationship;
+import org.neo4j.kernel.EmbeddedGraphDatabase;
+import org.springframework.data.neo4j.support.DelegatingGraphDatabase;
+import org.springframework.data.neo4j.support.Neo4jTemplate;
+
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+
+public class Neo4jProducerTest {
+
+    private EmbeddedGraphDatabase db;
+
+    @Mock
+    private Neo4jEndpoint endpoint;
+
+    @Mock
+    private Exchange exchange;
+
+    private Neo4jProducer producer;
+
+    @Mock
+    private Message msg;
+
+    @Mock
+    private Neo4jTemplate template;
+
+    @Before
+    public void before() throws IOException {
+        initMocks(this);
+        when(exchange.getIn()).thenReturn(msg);
+        db = new EmbeddedGraphDatabase(getRandomStore());
+        producer = new Neo4jProducer(endpoint, new DelegatingGraphDatabase(db), template);
+    }
+
+    String getRandomStore() throws IOException {
+        File file = File.createTempFile("prefix", "suffix").getParentFile();
+        File dir = new File(file.getAbsolutePath() + "/neo4j-test-" + UUID.randomUUID());
+        dir.mkdir();
+        return dir.getAbsolutePath();
+    }
+
+    @Test
+    public void testCreateNodeEmptyBody() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_NODE);
+        Node node = mock(Node.class);
+        when(node.getId()).thenReturn(14L);
+        when(template.createNode()).thenReturn(node);
+        producer.process(exchange);
+        verify(template).createNode();
+        verify(msg).setHeader(Neo4jEndpoint.HEADER_NODE_ID, 14L);
+    }
+
+    @Test
+    public void testCreateNodePropertiesBody() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_NODE);
+        when(msg.getBody()).thenReturn(new HashMap<String, Object>());
+        Node node = mock(Node.class);
+        when(node.getId()).thenReturn(14L);
+        when(template.createNode(anyMap())).thenReturn(node);
+        producer.process(exchange);
+        verify(template).createNode(anyMap());
+        verify(msg).setHeader(Neo4jEndpoint.HEADER_NODE_ID, 14L);
+    }
+
+    @Test
+    public void testCreateRelationshipWithBasicBody() throws Exception {
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_RELATIONSHIP);
+
+        Node start = mock(Node.class);
+        Node end = mock(Node.class);
+        String type = "friendswith";
+
+        BasicRelationship br = new BasicRelationship(start, end, type);
+        when(msg.getBody()).thenReturn(br);
+
+        Relationship r = mock(Relationship.class);
+        when(r.getId()).thenReturn(99L);
+
+        when(template.createRelationshipBetween(start, end, type, null)).thenReturn(r);
+
+        producer.process(exchange);
+        verify(template).createRelationshipBetween(start, end, type, null);
+
+        verify(msg).setHeader(Neo4jEndpoint.HEADER_RELATIONSHIP_ID, 99L);
+    }
+
+    @Test
+    public void testCreateRelationshipWithSpringBody() throws Exception {
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_RELATIONSHIP);
+
+        Object start = new Object();
+        Object end = new Object();
+        Class entityClass = String.class;
+        String type = "friendswith";
+
+        SpringDataRelationship spring = new SpringDataRelationship(start, end, entityClass, type, true);
+        when(msg.getBody()).thenReturn(spring);
+
+        Relationship r = mock(Relationship.class);
+        when(r.getId()).thenReturn(55L);
+
+        when(template.createRelationshipBetween(start, end, entityClass, type, true)).thenReturn(r);
+
+        producer.process(exchange);
+        verify(template).createRelationshipBetween(start, end, entityClass, type, true);
+
+        verify(msg).setHeader(Neo4jEndpoint.HEADER_RELATIONSHIP_ID, 55L);
+    }
+
+    @Test(expected = Neo4jException.class)
+    public void testNullOperationFails() throws Exception {
+        producer.process(exchange);
+    }
+
+    @Test
+    public void testRemoveNodeBasicBody() throws Exception {
+
+        Node node = mock(Node.class);
+        when(node.getId()).thenReturn(14L);
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_NODE);
+        when(msg.getBody()).thenReturn(node);
+
+        producer.process(exchange);
+        verify(template).delete(node);
+    }
+
+    @Test
+    public void testRemoveNodeById() throws Exception {
+
+        Node node = mock(Node.class);
+        when(template.getNode(44L)).thenReturn(node);
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_NODE);
+        when(msg.getBody()).thenReturn(44L);
+
+        producer.process(exchange);
+        verify(template).delete(node);
+    }
+
+    @Test
+    public void testRemoveRelationshipByBasic() throws Exception {
+
+        Relationship r = mock(Relationship.class);
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_RELATIONSHIP);
+        when(msg.getBody()).thenReturn(r);
+
+        producer.process(exchange);
+        verify(template).delete(r);
+    }
+
+    @Test
+    public void testRemoveRelationshipById() throws Exception {
+
+        Relationship r = mock(Relationship.class);
+        when(template.getRelationship(51L)).thenReturn(r);
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_RELATIONSHIP);
+        when(msg.getBody()).thenReturn(51L);
+
+        producer.process(exchange);
+        verify(template).delete(r);
+    }
+
+    @Test
+    public void testRemoveRelationshipBySpringData() throws Exception {
+
+        Object start = new Object();
+        Object end = new Object();
+        Class entityClass = String.class;
+        String type = "friendswith";
+
+        SpringDataRelationship spring = new SpringDataRelationship(start, end, entityClass, type, true);
+
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_RELATIONSHIP);
+        when(msg.getBody()).thenReturn(spring);
+
+        producer.process(exchange);
+        verify(template).deleteRelationshipBetween(start, end, type);
+    }
+
+    @Test(expected = Neo4jException.class)
+    public void testUnsupportedBodyForCreateNode() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_NODE);
+        when(msg.getBody()).thenReturn(new Object());
+        producer.process(exchange);
+    }
+
+    @Test(expected = Neo4jException.class)
+    public void testUnsupportedBodyForCreateRelationship() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.CREATE_RELATIONSHIP);
+        when(msg.getBody()).thenReturn(new Object());
+        producer.process(exchange);
+    }
+
+    @Test(expected = Neo4jException.class)
+    public void testUnsupportedBodyForDeleteNode() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_NODE);
+        when(msg.getBody()).thenReturn(new Object());
+        producer.process(exchange);
+    }
+
+    @Test(expected = Neo4jException.class)
+    public void testUnsupportedBodyForDeleteRelationship() throws Exception {
+        when(msg.getHeader(Neo4jEndpoint.HEADER_OPERATION)).thenReturn(Neo4jOperation.REMOVE_RELATIONSHIP);
+        when(msg.getBody()).thenReturn(new Object());
+        producer.process(exchange);
+    }
+}

Added: camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateNodeIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateNodeIntegrationTest.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateNodeIntegrationTest.java (added)
+++ camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateNodeIntegrationTest.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,86 @@
+/**
+ * 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.neo4j;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.neo4j.graphdb.Node;
+import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
+
+public class RestNeo4jProducerCreateNodeIntegrationTest extends CamelTestSupport {
+   
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+
+    private final String neo4jEndpoint = "neo4j:http://localhost:7474/db/data/";
+
+    private final SpringRestGraphDatabase db = new SpringRestGraphDatabase("http://localhost:7474/db/data/");
+
+   
+    @EndpointInject(uri = "mock:end")
+    private MockEndpoint end;
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to(neo4jEndpoint).process(new Processor() {
+
+                    @Override
+                    public void process(Exchange arg0) throws Exception {
+                        Long id = (Long)arg0.getIn().getHeader(Neo4jEndpoint.HEADER_NODE_ID);
+                        assertNotNull(id);
+                        Node node = db.getNodeById(id);
+                        assertNotNull(node);
+                    }
+                }).to(end);
+            }
+        };
+    }
+
+    @Test
+    public void testCreateNodes() throws InterruptedException {
+
+        final int messageCount = 100;
+        end.expectedMessageCount(messageCount);
+
+        Thread t = new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                for (int k = 0; k < messageCount; k++) {
+                    template.sendBodyAndHeader(null, Neo4jEndpoint.HEADER_OPERATION,
+                                               Neo4jOperation.CREATE_NODE);
+                }
+            }
+        });
+        t.start();
+        t.join();
+        end.assertIsSatisfied();
+    }
+
+}

Added: camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateRelationshipIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateRelationshipIntegrationTest.java?rev=1370253&view=auto
==============================================================================
--- camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateRelationshipIntegrationTest.java (added)
+++ camel/trunk/components/camel-neo4j/src/test/java/org/apache/camel/component/neo4j/RestNeo4jProducerCreateRelationshipIntegrationTest.java Tue Aug  7 13:31:27 2012
@@ -0,0 +1,91 @@
+/**
+ * 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.neo4j;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.Relationship;
+import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
+import org.springframework.data.neo4j.support.Neo4jTemplate;
+
+public class RestNeo4jProducerCreateRelationshipIntegrationTest extends CamelTestSupport {
+
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+
+    private final String neo4jEndpoint = "neo4j:http://localhost:7474/db/data/";
+
+    private final Neo4jTemplate neo = new Neo4jTemplate(
+                                                        new SpringRestGraphDatabase(
+                                                                                    "http://localhost:7474/db/data/"));
+
+    @EndpointInject(uri = "mock:end")
+    private MockEndpoint end;
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to(neo4jEndpoint).process(new Processor() {
+
+                    @Override
+                    public void process(Exchange arg0) throws Exception {
+                        Long id = (Long)arg0.getIn().getHeader(Neo4jEndpoint.HEADER_RELATIONSHIP_ID);
+                        assertNotNull(id);
+                        Relationship r = neo.getRelationship(id);
+                        assertNotNull(r);
+                        assertEquals("tickles", r.getType().name());
+                    }
+                }).to(end);
+            }
+        };
+    }
+
+    @Test
+    public void testCreateNodes() throws InterruptedException {
+
+        final int messageCount = 100;
+        end.expectedMessageCount(messageCount);
+
+        Thread t = new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                for (int k = 0; k < messageCount; k++) {
+                    Node start = neo.createNode();
+                    Node end = neo.createNode();
+                    BasicRelationship r = new BasicRelationship(start, end, "tickles");
+                    template.sendBodyAndHeader(r, Neo4jEndpoint.HEADER_OPERATION,
+                                               Neo4jOperation.CREATE_RELATIONSHIP);
+                }
+            }
+        });
+        t.start();
+        t.join();
+        end.assertIsSatisfied();
+    }
+}

Modified: camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1370253&r1=1370252&r2=1370253&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Tue Aug  7 13:31:27 2012
@@ -122,6 +122,7 @@
     <module>camel-mvel</module>
     <module>camel-mybatis</module>
     <module>camel-nagios</module>
+    <module>camel-neo4j</module>
     <module>camel-netty</module>
     <module>camel-ognl</module>
     <module>camel-paxlogging</module>