This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch release22.01 in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/release22.01 by this push: new 656b9c20c Fixed: Test run was unsuccessful because of failing solr tests (OFBIZ-12595) 656b9c20c is described below commit 656b9c20c78b4354e864ce32c81b65879ab9ace4 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 --- .../main/java/org/apache/ofbiz/solr/test/SolrTests.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 0305a701f..e17e33bb3 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; @@ -73,8 +73,6 @@ public class SolrTests extends OFBizTestCase { throw new Exception(errorMessage); } assertTrue("Could not query search index", ServiceUtil.isSuccess(sresp)); - - } /** @@ -82,6 +80,7 @@ public class SolrTests extends OFBizTestCase { * @throws Exception the exception */ public void testAddToSolrIndex() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); context = new HashMap<>(); context.put("productId", validTestProductId); response = getDispatcher().runSync("addToSolrIndex", context); @@ -91,6 +90,7 @@ public class SolrTests extends OFBizTestCase { } assertTrue("Could not add Product to Index", ServiceUtil.isSuccess( response)); + System.clearProperty("SolrDispatchFilter"); } /** @@ -98,6 +98,7 @@ public class SolrTests extends OFBizTestCase { * @throws Exception the exception */ public void testAddToSolrIndexInvalidProduct() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); context = new HashMap<>(); context.put("productId", invalidTestProductId); response = getDispatcher().runSync("addToSolrIndex", context); @@ -107,6 +108,7 @@ 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"); } /** @@ -114,6 +116,7 @@ public class SolrTests extends OFBizTestCase { * @throws Exception the exception */ public void testAddListToSolrIndex() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); List<Map<String, Object>> products = new ArrayList<>(); Map<String, Object> product1 = new HashMap<>(); Map<String, Object> product2 = new HashMap<>(); @@ -134,7 +137,7 @@ public class SolrTests extends OFBizTestCase { throw new Exception(errorMessage); } assertTrue("Could not add products to index", ServiceUtil.isSuccess(response)); - + System.clearProperty("SolrDispatchFilter"); } /** @@ -142,6 +145,7 @@ public class SolrTests extends OFBizTestCase { * @throws Exception the exception */ public void testAddListToSolrIndexInvalidProducts() throws Exception { + System.setProperty("SolrDispatchFilter", "runsAfterControlFilter"); List<Map<String, Object>> products = new ArrayList<>(); Map<String, Object> product1 = new HashMap<>(); Map<String, Object> product2 = new HashMap<>(); @@ -165,7 +169,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"); } }