You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dk...@apache.org on 2011/12/02 18:03:50 UTC
svn commit: r1209585 [16/22] - in /camel/trunk: ./ apache-camel/
buildingtools/ camel-core/ camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/api/management/
camel-core/src/main/java/org/apache/camel/builder/ camel-co...
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java Fri Dec 2 17:03:07 2011
@@ -1,33 +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;
- }
-}
+/**
+ * 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;
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java Fri Dec 2 17:03:07 2011
@@ -1,35 +1,35 @@
-/**
- * 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_ROLLBACK = "ROLLBACK";
- 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();
- }
-}
+/**
+ * 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_ROLLBACK = "ROLLBACK";
+ 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();
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java Fri Dec 2 17:03:07 2011
@@ -1,103 +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;
- }
-}
+/**
+ * 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;
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java Fri Dec 2 17:03:07 2011
@@ -1,110 +1,110 @@
-/**
- * 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_ROLLBACK)) {
- solrServer.rollback();
- } 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();
- }
-}
+/**
+ * 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_ROLLBACK)) {
+ solrServer.rollback();
+ } 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();
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java Fri Dec 2 17:03:07 2011
@@ -1,44 +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";
- }
-}
+/**
+ * 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";
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java Fri Dec 2 17:03:07 2011
@@ -1,46 +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;
- }
-}
+/**
+ * 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;
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrAddBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java Fri Dec 2 17:03:07 2011
@@ -1,92 +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();
- }
-}
+/**
+ * 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();
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java Fri Dec 2 17:03:07 2011
@@ -1,55 +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());
- }
-}
+/**
+ * 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());
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrDeleteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java Fri Dec 2 17:03:07 2011
@@ -1,47 +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");
- }
- };
- }
-}
+/**
+ * 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");
+ }
+ };
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrServerMissingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java Fri Dec 2 17:03:07 2011
@@ -1,118 +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);
- }
-}
+/**
+ * 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);
+ }
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrTransactionsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrTransactionsTest.java?rev=1209585&r1=1209584&r2=1209585&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrTransactionsTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrTransactionsTest.java Fri Dec 2 17:03:07 2011
@@ -1,73 +1,73 @@
-/**
- * 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 SolrTransactionsTest 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 testRollback() throws Exception {
-
- //insert and verify
- solrInsertTestEntry();
- assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
-
- //rollback
- template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_ROLLBACK);
-
- //verify after rollback
- 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 after commit (again)
- assertEquals("wrong number of entries found", 0, 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());
- }
-
-}
+/**
+ * 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 SolrTransactionsTest 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 testRollback() throws Exception {
+
+ //insert and verify
+ solrInsertTestEntry();
+ assertEquals("wrong number of entries found", 0, executeSolrQuery("id:" + TEST_ID).getResults().getNumFound());
+
+ //rollback
+ template.sendBodyAndHeader("direct:start", null, SolrConstants.OPERATION, SolrConstants.OPERATION_ROLLBACK);
+
+ //verify after rollback
+ 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 after commit (again)
+ assertEquals("wrong number of entries found", 0, 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());
+ }
+
+}
Propchange: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrTransactionsTest.java
------------------------------------------------------------------------------
svn:eol-style = native