This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/release18.12 by this push: new 829e1ca53 Fixed: Test run was unsuccessful because of failing solr tests (OFBIZ-12595) 829e1ca53 is described below commit 829e1ca535c3ffae6e5658360b083dd0d316fc78 Author: Jacques Le Roux <jacques.le.r...@les7arts.com> AuthorDate: Wed Apr 13 14:38:15 2022 +0200 Fixed: Test run was unsuccessful because of failing solr tests (OFBIZ-12595) The previous commit for OFBIZ-12594 was only working on Windows. On *nix OSs there is no way to reliably get "--test" String from java.class.path property. Also the previous fix was brittle because relying only on 1 space separating words. This fix puts in the SolrDispatchFilter system property at the beginning of the 4 Solr tests and removes it at end of them. That presence can reliably be tested in ControlFilter that is called before SolrDispatchFilter. It allows to bypass SecurityUtil::containsFreemarkerInterpolation that would else change the parameters content type that must be application/x-www-form-urlencoded. content Thanks: Tom Pietsch for report and Mart Naum for confirmation Conflicts handled by hand --- .../java/org/apache/ofbiz/solr/test/SolrTests.java | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java b/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java index 9ce03354e..2b19ea00c 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java @@ -20,10 +20,10 @@ package org.apache.ofbiz.solr.test; -import java.util.HashMap; -import java.util.Map; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityQuery; @@ -75,11 +75,14 @@ public class SolrTests extends OFBizTestCase { throw new Exception(errorMessage); } assertTrue("Could not query search index", ServiceUtil.isSuccess(sresp)); - - } - public void testAddToSolrIndex() throws Exception{ + /** + * Test add to solr index. + * @throws Exception the exception + */ + public void testAddToSolrIndex() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); context = new HashMap<>(); context.put("productId", validTestProductId); response = dispatcher.runSync("addToSolrIndex", context); @@ -89,9 +92,15 @@ public class SolrTests extends OFBizTestCase { } assertTrue("Could not add Product to Index", ServiceUtil.isSuccess( response)); + System.clearProperty("SolrDispatchFilter"); } - public void testAddToSolrIndex_invalidProduct() throws Exception { + /** + * Test add to solr index invalid product. + * @throws Exception the exception + */ + public void testAddToSolrIndexInvalidProduct() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); context = new HashMap<>(); context.put("productId", invalidTestProductId); response = dispatcher.runSync("addToSolrIndex", context); @@ -101,9 +110,11 @@ public class SolrTests extends OFBizTestCase { } assertTrue("Could not test the addition of an invalid product to the Solr index", ServiceUtil.isSuccess( response)); + System.clearProperty("SolrDispatchFilter"); } public void testAddListToSolrIndex() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); List<Map<String, Object>> products = new ArrayList<>(); Map<String, Object> product_1 = new HashMap<>(); Map<String, Object> product_2 = new HashMap<>(); @@ -124,10 +135,15 @@ public class SolrTests extends OFBizTestCase { throw new Exception(errorMessage); } assertTrue("Could not add products to index", ServiceUtil.isSuccess(response)); - + System.clearProperty("SolrDispatchFilter"); } - public void testAddListToSolrIndex_invalidProducts() throws Exception { + /** + * Test add list to solr index invalid products. + * @throws Exception the exception + */ + public void testAddListToSolrIndexInvalidProducts() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); List<Map<String, Object>> products = new ArrayList<>(); Map<String, Object> product_1 = new HashMap<>(); Map<String, Object> product_2 = new HashMap<>(); @@ -151,7 +167,7 @@ public class SolrTests extends OFBizTestCase { throw new Exception(errorMessage); } assertTrue("Could not test adding invalid products to index", ServiceUtil.isSuccess(response)); - + System.clearProperty("SolrDispatchFilter"); } }