You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bo...@apache.org on 2011/12/02 03:33:10 UTC

svn commit: r1209333 [1/3] - in /camel/trunk: apache-camel/ apache-camel/src/main/descriptors/ components/ components/camel-solr/ components/camel-solr/src/ components/camel-solr/src/main/ components/camel-solr/src/main/java/ components/camel-solr/src/...

Author: boday
Date: Fri Dec  2 02:33:04 2011
New Revision: 1209333

URL: http://svn.apache.org/viewvc?rev=1209333&view=rev
Log:
CAMEL-4539: adds the camel-solr component (thanks to Alex Cowell and Bilgin Ibryam for the initial patch).  enhancements added to include more Solr operations and Karaf features support 

Added:
    camel/trunk/components/camel-solr/
    camel/trunk/components/camel-solr/pom.xml
    camel/trunk/components/camel-solr/src/
    camel/trunk/components/camel-solr/src/main/
    camel/trunk/components/camel-solr/src/main/java/
    camel/trunk/components/camel-solr/src/main/java/org/
    camel/trunk/components/camel-solr/src/main/java/org/apache/
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java
    camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java
    camel/trunk/components/camel-solr/src/main/resources/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/LICENSE.txt
    camel/trunk/components/camel-solr/src/main/resources/META-INF/NOTICE.txt
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/component/solr
    camel/trunk/components/camel-solr/src/test/
    camel/trunk/components/camel-solr/src/test/java/
    camel/trunk/components/camel-solr/src/test/java/org/
    camel/trunk/components/camel-solr/src/test/java/org/apache/
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrCommitAndOptimizeTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
    camel/trunk/components/camel-solr/src/test/resources/
    camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
    camel/trunk/components/camel-solr/src/test/resources/data/
    camel/trunk/components/camel-solr/src/test/resources/data/books.csv
    camel/trunk/components/camel-solr/src/test/resources/data/books.xml
    camel/trunk/components/camel-solr/src/test/resources/data/tutorial.pdf   (with props)
    camel/trunk/components/camel-solr/src/test/resources/solr/
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/elevate.xml
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/protwords.txt
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/schema.xml
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/scripts.conf
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/solrconfig.xml
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/spellings.txt
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/stopwords.txt
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/stopwords_en.txt
    camel/trunk/components/camel-solr/src/test/resources/solr/conf/synonyms.txt
    camel/trunk/components/camel-solr/src/test/resources/solr/solr.xml
Modified:
    camel/trunk/apache-camel/pom.xml
    camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
    camel/trunk/components/pom.xml
    camel/trunk/parent/pom.xml
    camel/trunk/platforms/karaf/features/src/main/resources/features.xml

Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1209333&r1=1209332&r2=1209333&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Fri Dec  2 02:33:04 2011
@@ -399,6 +399,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-solr</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-spring</artifactId>
     </dependency>	
     <dependency>

Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1209333&r1=1209332&r2=1209333&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Fri Dec  2 02:33:04 2011
@@ -119,6 +119,7 @@
         <include>org.apache.camel:camel-smpp</include>
         <include>org.apache.camel:camel-snmp</include>
         <include>org.apache.camel:camel-soap</include>
+        <include>org.apache.camel:camel-solr</include>
         <include>org.apache.camel:camel-spring</include>
         <include>org.apache.camel:camel-spring-integration</include>
         <include>org.apache.camel:camel-spring-javaconfig</include>

Added: camel/trunk/components/camel-solr/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/pom.xml?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/pom.xml (added)
+++ camel/trunk/components/camel-solr/pom.xml Fri Dec  2 02:33:04 2011
@@ -0,0 +1,116 @@
+<?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>
+    <artifactId>components</artifactId>
+    <groupId>org.apache.camel</groupId>
+    <version>2.9-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-solr</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Solr</name>
+  <description>Camel Solr Support</description>
+
+    <properties>
+        <camel.osgi.export.pkg>
+            org.apache.camel.component.solr.*;${camel.osgi.version}
+        </camel.osgi.export.pkg>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.solr</groupId>
+            <artifactId>solr-solrj</artifactId>
+            <version>${solr-version}</version>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.solr</groupId>
+            <artifactId>solr-core</artifactId>
+            <version>${solr-version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.solr</groupId>
+            <artifactId>solr-cell</artifactId>
+            <version>${solr-version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <version>6.1.24</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jms</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-script</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- logging -->
+        <dependency>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+          <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+</project>

Added: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java (added)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.solr;
+
+import java.util.Map;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link SolrEndpoint}.
+ */
+public class SolrComponent extends DefaultComponent {
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        Endpoint endpoint = new SolrEndpoint(uri, this, remaining);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+}

Added: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java (added)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,34 @@
+/**
+ * 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.solr;
+
+public final class SolrConstants {
+
+    public static final String FIELD = "SolrField.";
+    public static final String OPERATION = "SolrOperation";
+    public static final String PARAM = "SolrParam.";
+    public static final String OPERATION_COMMIT = "COMMIT";
+    public static final String OPERATION_OPTIMIZE = "OPTIMIZE";
+    public static final String OPERATION_INSERT = "INSERT";
+    public static final String OPERATION_ADD_BEAN = "ADD_BEAN";
+    public static final String OPERATION_DELETE_BY_ID = "DELETE_BY_ID";
+    public static final String OPERATION_DELETE_BY_QUERY = "DELETE_BY_QUERY";
+
+    private SolrConstants() {
+        throw new AssertionError();
+    }
+}

Added: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java (added)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,103 @@
+/**
+ * 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.solr;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+
+/**
+ * Represents a Solr endpoint.
+ */
+public class SolrEndpoint extends DefaultEndpoint {
+
+    private CommonsHttpSolrServer solrServer;
+    private String requestHandler;
+
+    public SolrEndpoint() {
+    }
+
+    public SolrEndpoint(String uri, SolrComponent component) {
+        super(uri, component);
+    }
+
+    public SolrEndpoint(String endpointUri) {
+        super(endpointUri);
+    }
+
+    public SolrEndpoint(String endpointUri, SolrComponent component, String address) throws Exception {
+        super(endpointUri, component);
+        solrServer = new CommonsHttpSolrServer("http://" + address);
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new SolrProducer(this);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("Consumer not supported for Solr endpoint.");
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public CommonsHttpSolrServer getSolrServer() {
+        return solrServer;
+    }
+
+    public void setMaxRetries(int maxRetries) {
+        solrServer.setMaxRetries(maxRetries);
+    }
+
+    public void setSoTimeout(int soTimeout) {
+        solrServer.setSoTimeout(soTimeout);
+    }
+
+    public void setConnectionTimeout(int connectionTimeout) {
+        solrServer.setConnectionTimeout(connectionTimeout);
+    }
+
+    public void setDefaultMaxConnectionsPerHost(int defaultMaxConnectionsPerHost) {
+        solrServer.setDefaultMaxConnectionsPerHost(defaultMaxConnectionsPerHost);
+    }
+
+    public void setMaxTotalConnections(int maxTotalConnections) {
+        solrServer.setMaxTotalConnections(maxTotalConnections);
+    }
+
+    public void setFollowRedirects(boolean followRedirects) {
+        solrServer.setFollowRedirects(followRedirects);
+    }
+
+    public void setAllowCompression(boolean allowCompression) {
+        solrServer.setAllowCompression(allowCompression);
+    }
+
+    public void setRequestHandler(String requestHandler) {
+        this.requestHandler = requestHandler;
+    }
+
+    public String getRequestHandler() {
+        return requestHandler;
+    }
+}

Added: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java (added)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,108 @@
+/**
+ * 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.solr;
+
+import java.io.File;
+import java.util.Map;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Solr producer.
+ */
+public class SolrProducer extends DefaultProducer {
+    private static final transient Logger LOG = LoggerFactory.getLogger(SolrProducer.class);
+    private SolrServer solrServer;
+
+    public SolrProducer(SolrEndpoint endpoint) {
+        super(endpoint);
+        solrServer = endpoint.getSolrServer();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        
+        String operation = (String) exchange.getIn().getHeader(SolrConstants.OPERATION);
+
+        if (operation == null) {
+            throw new IllegalArgumentException(SolrConstants.OPERATION + " header is missing");
+        }
+
+        if (operation.equalsIgnoreCase(SolrConstants.OPERATION_INSERT)) {
+            insert(exchange);
+        } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_ID)) {
+            solrServer.deleteById(exchange.getIn().getBody(String.class));
+        } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_QUERY)) {
+            solrServer.deleteByQuery(exchange.getIn().getBody(String.class));
+        } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_ADD_BEAN)) {
+            solrServer.addBean(exchange.getIn().getBody());
+        } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_COMMIT)) {
+            solrServer.commit();
+        } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_OPTIMIZE)) {
+            solrServer.optimize();
+        } else {
+            throw new IllegalArgumentException(SolrConstants.OPERATION + " header value '" + operation + "' is not supported");
+        }
+    }
+
+    private void insert(Exchange exchange) throws Exception {
+
+        Object body = exchange.getIn().getBody();
+
+        if (body instanceof File) {
+            ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(getRequestHandler());
+            updateRequest.addFile((File) body);
+
+            for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
+                if (entry.getKey().startsWith(SolrConstants.PARAM)) {
+                    String paramName = entry.getKey().substring(SolrConstants.PARAM.length());
+                    updateRequest.setParam(paramName, entry.getValue().toString());
+                }
+            }
+
+            updateRequest.process(solrServer);
+        } else {
+            SolrInputDocument doc = new SolrInputDocument();
+            for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
+                if (entry.getKey().startsWith(SolrConstants.FIELD)) {
+                    String fieldName = entry.getKey().substring(SolrConstants.FIELD.length());
+                    doc.setField(fieldName, entry.getValue());
+                }
+            }
+
+            UpdateRequest updateRequest = new UpdateRequest(getRequestHandler());
+            updateRequest.add(doc);
+            updateRequest.process(solrServer);
+        }
+    }
+
+    private String getRequestHandler() {
+        String requestHandler = getEndpoint().getRequestHandler();
+        return (requestHandler == null) ? "/update" : requestHandler;
+    }
+
+    @Override
+    public SolrEndpoint getEndpoint() {
+        return (SolrEndpoint) super.getEndpoint();
+    }
+}

Added: camel/trunk/components/camel-solr/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/resources/META-INF/LICENSE.txt?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-solr/src/main/resources/META-INF/LICENSE.txt Fri Dec  2 02:33:04 2011
@@ -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-solr/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/resources/META-INF/NOTICE.txt?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-solr/src/main/resources/META-INF/NOTICE.txt Fri Dec  2 02:33:04 2011
@@ -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-solr/src/main/resources/META-INF/services/org/apache/camel/component/solr
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/component/solr?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/component/solr (added)
+++ camel/trunk/components/camel-solr/src/main/resources/META-INF/services/org/apache/camel/component/solr Fri Dec  2 02:33:04 2011
@@ -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.solr.SolrComponent

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,44 @@
+/**
+ * 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.solr;
+
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class InitSolrEndpointTest extends CamelTestSupport {
+
+    private String solrUrl = "solr://localhost:8999/solr";
+
+    @Test
+    public void endpointCreatedCorrectlyWithAllOptions() throws Exception {
+        SolrEndpoint solrEndpoint = (SolrEndpoint) context.getEndpoint(solrUrl + getFullOptions());
+        assertNotNull(solrEndpoint);
+    }
+
+    @Test(expected = ResolveEndpointFailedException.class)
+    public void wrongURLFormatFailsEndpointCreation() throws Exception {
+        context.getEndpoint("solr://localhost:-99/solr");
+    }
+
+    private String getFullOptions() {
+        return "?maxRetries=1&soTimeout=100&connectionTimeout=100"
+                + "&defaultMaxConnectionsPerHost=100&maxTotalConnections=100"
+                + "&followRedirects=false&allowCompression=true"
+                + "&requestHandler=/update";
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.solr;
+
+import org.apache.solr.client.solrj.beans.Field;
+import org.junit.Test;
+
+public class SolrAddBeanTest extends SolrComponentTestSupport {
+
+    @Test
+    public void testAddBean() throws Exception {
+
+        //add bean
+        Item item = new Item();
+        item.id = TEST_ID;
+        item.categories =  new String[] {"aaa", "bbb", "ccc"};
+
+        template.sendBodyAndHeader("direct:start", item, SolrConstants.OPERATION, SolrConstants.OPERATION_ADD_BEAN);
+        template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_COMMIT);
+
+        //verify
+        assertEquals("wrong number of entries found", 1, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+    }
+
+    public class Item {
+        @Field
+        String id;
+
+        @Field("cat")
+        String[] categories;
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrCommitAndOptimizeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrCommitAndOptimizeTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrCommitAndOptimizeTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrCommitAndOptimizeTest.java Fri Dec  2 02:33:04 2011
@@ -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.
+ */
+package org.apache.camel.component.solr;
+
+import java.util.HashMap;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.junit.Test;
+
+public class SolrCommitAndOptimizeTest extends SolrComponentTestSupport {
+
+    @Test
+    public void testCommit() throws Exception {
+
+        //insert and verify
+        solrInsertTestEntry();
+        assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+
+        //commit
+        template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_COMMIT);
+
+        //verify exists after commit
+        assertEquals("wrong number of entries found", 1, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+    }
+
+    @Test
+    public void testOptimize() throws Exception {
+
+        //insert and verify
+        solrInsertTestEntry();
+        assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+
+        //optimize
+        template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_OPTIMIZE);
+
+        //verify exists after optimize
+        assertEquals("wrong number of entries found", 1, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+    }
+
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.solr;
+
+import java.util.HashMap;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+public class SolrComponentTestSupport extends CamelTestSupport {
+
+    protected static final String TEST_ID = "1234";
+    protected static JettySolrRunner solrRunner;
+    protected static CommonsHttpSolrServer solrServer;
+
+    protected void solrInsertTestEntry() {
+        HashMap<String, Object> headers = new HashMap<String, Object>();
+        headers.put(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        headers.put("SolrField.id", TEST_ID);
+        template.sendBodyAndHeaders("direct:start", null, headers);
+    }
+
+    protected void solrCommit() {
+        template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_COMMIT);
+    }
+
+    protected QueryResponse executeSolrQuery(String query) throws SolrServerException {
+        SolrQuery solrQuery = new SolrQuery();
+        solrQuery.setQuery(query);
+        return solrServer.query(solrQuery);
+    }
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        // Set appropriate paths for Solr to use.
+        System.setProperty("solr.solr.home", "src/test/resources/solr");
+        System.setProperty("solr.data.dir", "target/test-classes/solr/data");
+
+        // Instruct Solr to keep the index in memory, for faster testing.
+        System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
+
+        // Start a Solr instance.
+        solrRunner = new JettySolrRunner("/solr", 8999);
+        solrRunner.start();
+
+        solrServer = new CommonsHttpSolrServer("http://localhost:8999/solr");
+    }
+
+    @AfterClass
+    public static void afterClass() throws Exception {
+        solrRunner.stop();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("solr://localhost:8999/solr");
+            }
+        };
+    }
+
+    @Before
+    public void clearIndex() throws Exception {
+        // Clear the Solr index.
+        solrServer.deleteByQuery("*:*");
+        solrServer.commit();
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java Fri Dec  2 02:33:04 2011
@@ -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.solr;
+
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.junit.Test;
+
+public class SolrDeleteTest extends SolrComponentTestSupport {
+
+    @Test
+    public void testDeleteById() throws Exception {
+
+        //insert, commit and verify
+        solrInsertTestEntry();
+        solrCommit();
+        assertEquals("wrong number of entries found", 1, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+
+        //delete
+        template.sendBodyAndHeader("direct:start", TEST_ID, SolrConstants.OPERATION, SolrConstants.OPERATION_DELETE_BY_ID);
+        solrCommit();
+
+        //verify
+        assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+    }
+
+    @Test
+    public void testDeleteByQuery() throws Exception {
+
+        //insert, commit and verify
+        solrInsertTestEntry();
+        solrCommit();
+        assertEquals("wrong number of entries found", 1, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+
+        //delete
+        template.sendBodyAndHeader("direct:start", "id:" + TEST_ID, SolrConstants.OPERATION, SolrConstants.OPERATION_DELETE_BY_QUERY);
+        solrCommit();
+
+        //verify
+        assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java Fri Dec  2 02:33:04 2011
@@ -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.solr;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.junit.Test;
+
+public class SolrServerMissingTest extends CamelTestSupport {
+
+    @Test
+    public void indexSingleDocumentToNonexistentServer() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+        template.send("direct:start", exchange);
+        assertEquals(SolrServerException.class, exchange.getException().getClass());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("solr://localhost:8999/missingSolr");
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,118 @@
+/**
+ * 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.solr;
+
+import java.io.File;
+import java.util.Arrays;
+import static junit.framework.Assert.assertEquals;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration (locations = {"/SolrSpringTest-context.xml"})
+public class SolrSpringTest extends AbstractJUnit4SpringContextTests {
+
+    private static JettySolrRunner solrRunner;
+    private static CommonsHttpSolrServer solrServer;
+
+    @Produce(uri = "direct:xml-start")
+    protected ProducerTemplate xmlRoute;
+
+    @Produce(uri = "direct:pdf-start")
+    protected ProducerTemplate pdfRoute;
+
+    @DirtiesContext
+    @Test
+    public void endToEndIndexXMLDocuments() throws Exception {
+        xmlRoute.sendBody(new File("src/test/resources/data/books.xml"));
+
+        // Check things were indexed.
+        QueryResponse response = executeSolrQuery("*:*");
+
+        assertEquals(0, response.getStatus());
+        assertEquals(4, response.getResults().getNumFound());
+
+        // Check fields were indexed correctly.
+        response = executeSolrQuery("title:Learning XML");
+
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("Learning XML", doc.getFieldValue("id"));
+        assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
+    }
+
+    @DirtiesContext
+    @Test
+    public void endToEndIndexPDFDocument() throws Exception {
+        pdfRoute.sendBody(new File("src/test/resources/data/tutorial.pdf"));
+
+        QueryResponse response = executeSolrQuery("*:*");
+
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("Solr", doc.getFieldValue("subject"));
+        assertEquals("tutorial.pdf", doc.getFieldValue("id"));
+        assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
+    }
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        // Set appropriate paths for Solr to use.
+        System.setProperty("solr.solr.home", "src/test/resources/solr");
+        System.setProperty("solr.data.dir", "target/test-classes/solr/data");
+
+        // Instruct Solr to keep the index in memory, for faster testing.
+        System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
+
+        // Start a Solr instance.
+        solrRunner = new JettySolrRunner("/solr", 8899);
+        solrRunner.start();
+
+        solrServer = new CommonsHttpSolrServer("http://localhost:8899/solr");
+    }
+
+    @AfterClass
+    public static void afterClass() throws Exception {
+        solrRunner.stop();
+    }
+
+    @Before
+    public void clearIndex() throws Exception {
+        // Clear the Solr index.
+        solrServer.deleteByQuery("*:*");
+        solrServer.commit();
+    }
+
+    private QueryResponse executeSolrQuery(String query) throws SolrServerException {
+        SolrQuery solrQuery = new SolrQuery();
+        solrQuery.setQuery(query);
+        return solrServer.query(solrQuery);
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java (added)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java Fri Dec  2 02:33:04 2011
@@ -0,0 +1,223 @@
+/**
+ * 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.solr;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrException;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class SolrUpdateTest extends SolrComponentTestSupport {
+
+    @EndpointInject(uri = "solr://localhost:8999/solr")
+    protected SolrEndpoint solrEndpoint;
+
+    @Test
+    public void indexSingleDocumentOnlyWithId() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        // Check things were indexed.
+        QueryResponse response = executeSolrQuery("id:MA147LL/A");
+
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+    }
+
+    @Test
+    public void caughtSolrExceptionIsHandledElegantly() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.name", "Missing required field throws exception.");
+
+        template.send("direct:start", exchange);
+
+        assertEquals(SolrException.class, exchange.getException().getClass());
+    }
+
+    @Test
+    public void setHeadersAsSolrFields() throws Exception {
+        Exchange exchange = createExchangeWithBody("Body is ignored");
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+        exchange.getIn().setHeader("SolrField.name", "Apple 60 GB iPod with Video Playback Black");
+        exchange.getIn().setHeader("SolrField.manu", "Apple Computer Inc.");
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("id:MA147LL/A");
+
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("Apple 60 GB iPod with Video Playback Black", doc.getFieldValue("name"));
+        assertEquals("Apple Computer Inc.", doc.getFieldValue("manu"));
+    }
+
+    @Test
+    public void setMultiValuedFieldInHeader() throws Exception {
+        String[] categories = {"electronics", "apple"};
+        Exchange exchange = createExchangeWithBody("Test body for iPod.");
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+        exchange.getIn().setHeader("SolrField.cat", categories);
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        // Check things were indexed.
+        QueryResponse response = executeSolrQuery("id:MA147LL/A");
+
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertArrayEquals(categories, ((List) doc.getFieldValue("cat")).toArray());
+    }
+
+    @Test
+    public void indexDocumentsAndThenCommit() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+        exchange.getIn().setHeader("SolrField.name", "Apple 60 GB iPod with Video Playback Black");
+        exchange.getIn().setHeader("SolrField.manu", "Apple Computer Inc.");
+        template.send("direct:start", exchange);
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(0, response.getResults().getNumFound());
+
+        solrCommit();
+
+        QueryResponse afterCommitResponse = executeSolrQuery("*:*");
+        assertEquals(0, afterCommitResponse.getStatus());
+        assertEquals(1, afterCommitResponse.getResults().getNumFound());
+    }
+
+    @Test
+    public void invalidSolrParametersAreIgnored() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+        exchange.getIn().setHeader("SolrField.name", "Apple 60 GB iPod with Video Playback Black");
+        exchange.getIn().setHeader("SolrParam.invalid-param", "this is ignored");
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+    }
+
+    @Test
+    public void indexDocumentsToCSVUpdateHandlerWithoutParameters() throws Exception {
+        solrEndpoint.setRequestHandler("/update/csv");
+
+        Exchange exchange = createExchangeWithBody(new File("src/test/resources/data/books.csv"));
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(10, response.getResults().getNumFound());
+
+        response = executeSolrQuery("id:0553573403");
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("A Game of Thrones", doc.getFieldValue("name"));
+        assertEquals(7.99f, doc.getFieldValue("price"));
+    }
+
+    @Test
+    public void indexDocumentsToCSVUpdateHandlerWithParameters() throws Exception {
+        solrEndpoint.setRequestHandler("/update/csv");
+
+        Exchange exchange = createExchangeWithBody(new File("src/test/resources/data/books.csv"));
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrParam.fieldnames", "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s");
+        exchange.getIn().setHeader("SolrParam.skip", "cat,sequence_i,genre_s");
+        exchange.getIn().setHeader("SolrParam.skipLines", 1);
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(10, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertFalse(doc.getFieldNames().contains("cat"));
+    }
+
+    @Test
+    public void indexPDFDocumentToExtractingRequestHandler() throws Exception {
+        solrEndpoint.setRequestHandler("/update/extract");
+
+        Exchange exchange = createExchangeWithBody(new File("src/test/resources/data/tutorial.pdf"));
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrParam.literal.id", "tutorial.pdf");
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("Solr", doc.getFieldValue("subject"));
+        assertEquals("tutorial.pdf", doc.getFieldValue("id"));
+        assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
+    }
+
+    @Test
+    @Ignore("No real advantage has yet been discovered to specifying the file in a header.")
+    public void indexPDFDocumentSpecifyingFileInParameters() throws Exception {
+        solrEndpoint.setRequestHandler("/update/extract");
+
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+        exchange.getIn().setHeader("SolrParam.stream.file", "src/test/resources/data/tutorial.pdf");
+        exchange.getIn().setHeader("SolrParam.literal.id", "tutorial.pdf");
+
+        template.send("direct:start", exchange);
+        solrCommit();
+
+        QueryResponse response = executeSolrQuery("*:*");
+        assertEquals(0, response.getStatus());
+        assertEquals(1, response.getResults().getNumFound());
+
+        SolrDocument doc = response.getResults().get(0);
+        assertEquals("Solr", doc.getFieldValue("subject"));
+        assertEquals("tutorial.pdf", doc.getFieldValue("id"));
+        assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
+    }
+}

Added: camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml (added)
+++ camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml Fri Dec  2 02:33:04 2011
@@ -0,0 +1,52 @@
+<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.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 id="XMLRoute">
+            <from uri="direct:xml-start" />
+            <split>
+                <xpath>/bookstore/book</xpath>
+                <convertBodyTo type="java.lang.String"/>
+                <setHeader headerName="SolrOperation">
+                    <constant>INSERT</constant>
+                </setHeader>
+                <setHeader headerName="SolrField.id">
+                    <xpath resultType="java.lang.String">//title/text()</xpath>
+                </setHeader>
+                <setHeader headerName="SolrField.title">
+                    <xpath resultType="java.lang.String">//title/text()</xpath>
+                </setHeader>
+                <setHeader headerName="SolrField.cat">
+                    <groovy>
+                        def book = new XmlParser().parseText(request.body)
+                        book.cat.collect{ it.text() } as String[]
+                    </groovy>
+                </setHeader>
+                <to uri="solr://localhost:8899/solr"/>
+            </split>
+            <setHeader headerName="SolrOperation">
+                <constant>COMMIT</constant>
+            </setHeader>
+            <to uri="solr://localhost:8899/solr"/>
+        </route>
+
+        <route id="PDFRoute">
+            <from uri="direct:pdf-start" />
+            <setHeader headerName="SolrOperation">
+                <constant>INSERT</constant>
+            </setHeader>
+            <setHeader headerName="SolrParam.literal.id">
+                <simple>${body.name}</simple>
+            </setHeader>
+            <to uri="solr://localhost:8899/solr?requestHandler=/update/extract" />
+            <setHeader headerName="SolrOperation">
+                <constant>COMMIT</constant>
+            </setHeader>
+            <to uri="solr://localhost:8899/solr"/>
+        </route>
+    </camelContext>
+
+</beans>

Added: camel/trunk/components/camel-solr/src/test/resources/data/books.csv
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/data/books.csv?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/data/books.csv (added)
+++ camel/trunk/components/camel-solr/src/test/resources/data/books.csv Fri Dec  2 02:33:04 2011
@@ -0,0 +1,11 @@
+id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s
+0553573403,book,A Game of Thrones,7.99,true,George R.R. Martin,"A Song of Ice and Fire",1,fantasy
+0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,"A Song of Ice and Fire",2,fantasy
+055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,"A Song of Ice and Fire",3,fantasy
+0553293354,book,Foundation,7.99,true,Isaac Asimov,Foundation Novels,1,scifi
+0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy
+0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi
+0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy
+0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy
+0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy
+080508049X,book,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy

Added: camel/trunk/components/camel-solr/src/test/resources/data/books.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/data/books.xml?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/data/books.xml (added)
+++ camel/trunk/components/camel-solr/src/test/resources/data/books.xml Fri Dec  2 02:33:04 2011
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Modified from the example XML file w3schools.com provides for its
+    XPath tutorial.
+
+    http://www.w3schools.com/xpath/books.xml
+-->
+<bookstore>
+
+    <book>
+        <title lang="en">Everyday Italian</title>
+        <author>Giada De Laurentiis</author>
+        <year>2005</year>
+        <price>30.00</price>
+        <cat>Cooking</cat>
+    </book>
+
+    <book>
+        <title lang="en">Harry Potter</title>
+        <author>J K. Rowling</author>
+        <year>2005</year>
+        <price>29.99</price>
+        <cat>Children</cat>
+    </book>
+
+    <book>
+        <title lang="en">XQuery Kick Start</title>
+        <author>James McGovern</author>
+        <author>Per Bothner</author>
+        <author>Kurt Cagle</author>
+        <author>James Linn</author>
+        <author>Vaidyanathan Nagarajan</author>
+        <year>2003</year>
+        <price>49.99</price>
+        <cat>Web</cat>
+        <cat>Technology</cat>
+        <cat>Computers</cat>
+    </book>
+
+    <book>
+        <title lang="en">Learning XML</title>
+        <author>Erik T. Ray</author>
+        <year>2003</year>
+        <price>39.95</price>
+        <cat>Web</cat>
+        <cat>Technology</cat>
+        <cat>Computers</cat>
+    </book>
+
+</bookstore>

Added: camel/trunk/components/camel-solr/src/test/resources/data/tutorial.pdf
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/data/tutorial.pdf?rev=1209333&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-solr/src/test/resources/data/tutorial.pdf
------------------------------------------------------------------------------
    svn:executable = *

Propchange: camel/trunk/components/camel-solr/src/test/resources/data/tutorial.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-solr/src/test/resources/solr/conf/elevate.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/solr/conf/elevate.xml?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/solr/conf/elevate.xml (added)
+++ camel/trunk/components/camel-solr/src/test/resources/solr/conf/elevate.xml Fri Dec  2 02:33:04 2011
@@ -0,0 +1,36 @@
+<?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.
+-->
+
+<!-- If this file is found in the config directory, it will only be
+     loaded once at startup.  If it is found in Solr's data
+     directory, it will be re-loaded every commit.
+-->
+
+<elevate>
+ <query text="foo bar">
+  <doc id="1" />
+  <doc id="2" />
+  <doc id="3" />
+ </query>
+ 
+ <query text="ipod">
+   <doc id="MA147LL/A" />  <!-- put the actual ipod at the top -->
+   <doc id="IW-02" exclude="true" /> <!-- exclude this cable -->
+ </query>
+ 
+</elevate>

Added: camel/trunk/components/camel-solr/src/test/resources/solr/conf/protwords.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/solr/conf/protwords.txt?rev=1209333&view=auto
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/solr/conf/protwords.txt (added)
+++ camel/trunk/components/camel-solr/src/test/resources/solr/conf/protwords.txt Fri Dec  2 02:33:04 2011
@@ -0,0 +1,21 @@
+# 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.
+
+#-----------------------------------------------------------------------
+# Use a protected word file to protect against the stemmer reducing two
+# unrelated words to the same base word.
+
+# Some non-words that normally won't be encountered,
+# just to test that they won't be stemmed.
+dontstems
+zwhacky
+