You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by to...@apache.org on 2019/10/09 10:14:57 UTC

svn commit: r1868175 - in /jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr: configuration/DefaultAnalyzersConfigurationTest.java index/SolrIndexEditorTest.java server/EmbeddedSolrServerProviderTest.java

Author: tommaso
Date: Wed Oct  9 10:14:57 2019
New Revision: 1868175

URL: http://svn.apache.org/viewvc?rev=1868175&view=rev
Log:
OAK-8244 - Close Solr clients on test finish, setting TS to NONE on DACTest

Modified:
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProviderTest.java

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java?rev=1868175&r1=1868174&r2=1868175&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java Wed Oct  9 10:14:57 2019
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import java.io.StringReader;
 import java.util.regex.Pattern;
 
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.TokenStream;
@@ -43,7 +43,7 @@ import org.junit.runner.RunWith;
  * Note that default Solr analyzers for Oak should be equivalent to the ones programmatically defined here.
  */
 @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
-@ThreadLeakAction(ThreadLeakAction.Action.WARN)
+@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
 public class DefaultAnalyzersConfigurationTest extends BaseTokenStreamTestCase {
 
     private Analyzer parentPathIndexingAnalyzer;

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java?rev=1868175&r1=1868174&r2=1868175&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java Wed Oct  9 10:14:57 2019
@@ -46,47 +46,55 @@ public class SolrIndexEditorTest {
     @Test
     public void testIndexedProperties() throws Exception {
         SolrClient solrServer = TestUtils.createSolrServer();
-        OakSolrConfiguration configuration = TestUtils.getTestConfiguration();
-        IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
-        SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
-        NodeState before = mock(NodeState.class);
-        NodeState after = mock(NodeState.class);
-        Iterable properties = (Iterable<PropertyState>) () -> Collections.singletonList(PropertyStates.createProperty("foo1", "bar")).iterator();
-        when(after.getProperties()).thenReturn(properties);
-        solrIndexEditor.leave(before, after);
-        QueryResponse queryResponse = solrServer.query(new SolrQuery("foo1:*"));
-        assertEquals(1, queryResponse.getResults().getNumFound());
+        try {
+            OakSolrConfiguration configuration = TestUtils.getTestConfiguration();
+            IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
+            SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
+            NodeState before = mock(NodeState.class);
+            NodeState after = mock(NodeState.class);
+            Iterable properties = (Iterable<PropertyState>) () -> Collections.singletonList(PropertyStates.createProperty("foo1", "bar")).iterator();
+            when(after.getProperties()).thenReturn(properties);
+            solrIndexEditor.leave(before, after);
+            QueryResponse queryResponse = solrServer.query(new SolrQuery("foo1:*"));
+            assertEquals(1, queryResponse.getResults().getNumFound());
+        } finally {
+            solrServer.close();
+        }
     }
 
     @Test
     public void testIgnoredPropertiesNotIndexed() throws Exception {
-        NodeBuilder builder = mock(NodeBuilder.class);
         SolrClient solrServer = TestUtils.createSolrServer();
-        OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
-            @NotNull
-            @Override
-            public Collection<String> getIgnoredProperties() {
-                return Collections.singletonList("foo2");
-            }
-            @NotNull
-            @Override
-            public CommitPolicy getCommitPolicy() {
-                return CommitPolicy.HARD;
-            }
-        };
-        IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
-        SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
-        NodeState before = mock(NodeState.class);
-        NodeState after = mock(NodeState.class);
-        Iterable properties = new Iterable<PropertyState>() {
-            @Override
-            public Iterator<PropertyState> iterator() {
-                return Collections.singletonList(PropertyStates.createProperty("foo2", "bar")).iterator();
-            }
-        };
-        when(after.getProperties()).thenReturn(properties);
-        solrIndexEditor.leave(before, after);
-        QueryResponse queryResponse = solrServer.query(new SolrQuery("foo2:*"));
-        assertEquals(0, queryResponse.getResults().getNumFound());
+        try {
+            OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
+                @NotNull
+                @Override
+                public Collection<String> getIgnoredProperties() {
+                    return Collections.singletonList("foo2");
+                }
+
+                @NotNull
+                @Override
+                public CommitPolicy getCommitPolicy() {
+                    return CommitPolicy.HARD;
+                }
+            };
+            IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
+            SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
+            NodeState before = mock(NodeState.class);
+            NodeState after = mock(NodeState.class);
+            Iterable properties = new Iterable<PropertyState>() {
+                @Override
+                public Iterator<PropertyState> iterator() {
+                    return Collections.singletonList(PropertyStates.createProperty("foo2", "bar")).iterator();
+                }
+            };
+            when(after.getProperties()).thenReturn(properties);
+            solrIndexEditor.leave(before, after);
+            QueryResponse queryResponse = solrServer.query(new SolrQuery("foo2:*"));
+            assertEquals(0, queryResponse.getResults().getNumFound());
+        } finally {
+            solrServer.close();
+        }
     }
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProviderTest.java?rev=1868175&r1=1868174&r2=1868175&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProviderTest.java (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProviderTest.java Wed Oct  9 10:14:57 2019
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.response.SolrPingResponse;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -30,6 +31,7 @@ import static org.junit.Assert.assertNot
 /**
  * Testcase for {@link EmbeddedSolrServerProvider}
  */
+@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
 public class EmbeddedSolrServerProviderTest {
 
     @Test
@@ -40,9 +42,13 @@ public class EmbeddedSolrServerProviderT
         EmbeddedSolrServerProvider embeddedSolrServerProvider = new EmbeddedSolrServerProvider(solrServerConfiguration);
         SolrClient solrServer = embeddedSolrServerProvider.getSolrServer();
         assertNotNull(solrServer);
-        SolrPingResponse ping = solrServer.ping();
-        assertNotNull(ping);
-        assertEquals(0, ping.getStatus());
+        try {
+            SolrPingResponse ping = solrServer.ping();
+            assertNotNull(ping);
+            assertEquals(0, ping.getStatus());
+        } finally {
+            solrServer.close();
+        }
     }
 
 }