From a9ef5ec1bc718ba9fa62d8c4dddba3217a712f65 Mon Sep 17 00:00:00 2001 From: bbende Date: Thu, 16 Apr 2015 22:09:11 -0400 Subject: [PATCH] Upgrading to Solr 5.1.0, fixing empty javadoc, and cleaning up variable naming --- .../apache/nifi/processors/solr/GetSolr.java | 2 +- .../nifi/processors/solr/SolrProcessor.java | 8 ++--- .../solr/TestPutSolrContentStream.java | 30 ++++++++++--------- .../nifi-nar-bundles/nifi-solr-bundle/pom.xml | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/GetSolr.java b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/GetSolr.java index 0af6043033..532d5ff48e 100644 --- a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/GetSolr.java +++ b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/GetSolr.java @@ -241,7 +241,7 @@ public class GetSolr extends SolrProcessor { lastEndDatedRef.set(currDate); writeLastEndDate(); - } catch (SolrServerException e) { + } catch (SolrServerException | IOException e) { context.yield(); session.rollback(); logger.error("Failed to execute query {} due to {}", new Object[]{query, e}, e); diff --git a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrProcessor.java b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrProcessor.java index 70b71a421a..9cad214b76 100644 --- a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrProcessor.java @@ -89,11 +89,11 @@ public abstract class SolrProcessor extends AbstractProcessor { if (SOLR_TYPE_STANDARD.equals(context.getProperty(SOLR_TYPE).getValue())) { return new HttpSolrClient(context.getProperty(SOLR_LOCATION).getValue()); } else { - CloudSolrClient cloudSolrServer = new CloudSolrClient( + CloudSolrClient cloudSolrClient = new CloudSolrClient( context.getProperty(SOLR_LOCATION).getValue()); - cloudSolrServer.setDefaultCollection( + cloudSolrClient.setDefaultCollection( context.getProperty(COLLECTION).evaluateAttributeExpressions().getValue()); - return cloudSolrServer; + return cloudSolrClient; } } @@ -101,7 +101,7 @@ public abstract class SolrProcessor extends AbstractProcessor { * Returns the {@link org.apache.solr.client.solrj.SolrClient} that was created by the * {@link #createSolrClient(org.apache.nifi.processor.ProcessContext)} method * - * @return + * @return an HttpSolrClient or CloudSolrClient */ protected final SolrClient getSolrClient() { return solrClient; diff --git a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/TestPutSolrContentStream.java b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/TestPutSolrContentStream.java index 141fbb666a..4ce6928f19 100644 --- a/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/TestPutSolrContentStream.java +++ b/nifi/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/TestPutSolrContentStream.java @@ -26,6 +26,7 @@ import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; import org.junit.Assert; import org.junit.Test; +import org.mockito.Matchers; import org.mockito.Mockito; import java.io.FileInputStream; @@ -95,7 +96,7 @@ public class TestPutSolrContentStream { verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); } finally { - try { proc.getSolrClient().shutdown(); } catch (Exception e) { } + try { proc.getSolrClient().close(); } catch (Exception e) { } } } @@ -123,7 +124,7 @@ public class TestPutSolrContentStream { verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); } finally { - try { proc.getSolrClient().shutdown(); } catch (Exception e) { } + try { proc.getSolrClient().close(); } catch (Exception e) { } } } @@ -145,7 +146,7 @@ public class TestPutSolrContentStream { verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); } finally { - try { proc.getSolrClient().shutdown(); } catch (Exception e) { } + try { proc.getSolrClient().close(); } catch (Exception e) { } } } @@ -167,7 +168,7 @@ public class TestPutSolrContentStream { verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); } finally { - try { proc.getSolrClient().shutdown(); } catch (Exception e) { } + try { proc.getSolrClient().close(); } catch (Exception e) { } } } @@ -183,7 +184,7 @@ public class TestPutSolrContentStream { runner.run(); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_CONNECTION_FAILURE, 1); - verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); + verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null)); } } @@ -199,7 +200,7 @@ public class TestPutSolrContentStream { runner.run(); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1); - verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); + verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null)); } } @@ -216,7 +217,7 @@ public class TestPutSolrContentStream { runner.run(); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1); - verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); + verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null)); } } @@ -244,7 +245,7 @@ public class TestPutSolrContentStream { */ private class ExceptionThrowingProcessor extends PutSolrContentStream { - private SolrClient mockSolrServer; + private SolrClient mockSolrClient; private Throwable throwable; public ExceptionThrowingProcessor(Throwable throwable) { @@ -253,15 +254,16 @@ public class TestPutSolrContentStream { @Override protected SolrClient createSolrClient(ProcessContext context) { - mockSolrServer = Mockito.mock(SolrClient.class); + mockSolrClient = Mockito.mock(SolrClient.class); try { - when(mockSolrServer.request(any(SolrRequest.class))).thenThrow(throwable); + when(mockSolrClient.request(any(SolrRequest.class), + eq((String)null))).thenThrow(throwable); } catch (SolrServerException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } - return mockSolrServer; + return mockSolrClient; } } @@ -272,7 +274,7 @@ public class TestPutSolrContentStream { private class EmbeddedSolrServerProcessor extends PutSolrContentStream { private String coreName; - private SolrClient embeddedSolrServer; + private SolrClient embeddedSolrClient; public EmbeddedSolrServerProcessor(String coreName) { this.coreName = coreName; @@ -285,14 +287,14 @@ public class TestPutSolrContentStream { .getCodeSource().getLocation().getFile() + "../../target"; - embeddedSolrServer = EmbeddedSolrServerFactory.create( + embeddedSolrClient = EmbeddedSolrServerFactory.create( EmbeddedSolrServerFactory.DEFAULT_SOLR_HOME, EmbeddedSolrServerFactory.DEFAULT_CORE_HOME, coreName, relPath); } catch (IOException e) { Assert.fail(e.getMessage()); } - return embeddedSolrServer; + return embeddedSolrClient; } } diff --git a/nifi/nifi-nar-bundles/nifi-solr-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-solr-bundle/pom.xml index d716b88060..e027a638dd 100644 --- a/nifi/nifi-nar-bundles/nifi-solr-bundle/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-solr-bundle/pom.xml @@ -28,7 +28,7 @@ A bundle of processors that can store and retrieve data from Apache Solr - 5.0.0 + 5.1.0