Hello Taher, Taher Alkhateeb <[email protected]> writes:
> An example could shed some light here perhaps? What kind of examples would help you? AIUI It would be for the people using this feature outside of the framework to provide examples why we should keep it in. > What do you want to remove from where? Here is what I precisely want to remove.
>From 66150cc98d2b7b84ee5aa4dee1e25f60556577e6 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin <[email protected]> Date: Sun, 21 Oct 2018 16:02:38 +0200 Subject: [PATCH] Disallow using alternate dispatcher and delegator for integration tests --- framework/testtools/dtd/test-suite.xsd | 2 -- .../ofbiz/testtools/ModelTestSuite.java | 23 +++++-------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git framework/testtools/dtd/test-suite.xsd framework/testtools/dtd/test-suite.xsd index ee1767aa2f..76cdf1a523 100644 --- framework/testtools/dtd/test-suite.xsd +++ framework/testtools/dtd/test-suite.xsd @@ -45,8 +45,6 @@ under the License. </xs:element> <xs:attributeGroup name="attlist.test-suite"> <xs:attribute type="xs:string" name="suite-name" use="required"/> - <xs:attribute type="xs:string" name="delegator-name" default="test"/> - <xs:attribute type="xs:string" name="dispatcher-name" default="test-dispatcher"/> </xs:attributeGroup> <xs:element name="test-case"> <xs:annotation><xs:documentation></xs:documentation></xs:annotation> diff --git framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java index 5c166beb5d..e666e4451a 100644 --- framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java +++ framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java @@ -50,31 +50,20 @@ import junit.framework.TestSuite; * Use this class in a JUnit test runner to bootstrap the Test Suite runner. */ public class ModelTestSuite { - public static final String module = ModelTestSuite.class.getName(); + public static final String DELEGATOR_NAME = "test"; + public static final String DISPATCHER_NAME = "test-dispatcher"; protected String suiteName; - protected String originalDelegatorName; - protected String originalDispatcherName; - protected Delegator delegator; protected LocalDispatcher dispatcher; - - protected List<Test> testList = new ArrayList<Test>(); + protected List<Test> testList = new ArrayList<>(); public ModelTestSuite(Element mainElement, String testCase) { - this.suiteName = mainElement.getAttribute("suite-name"); - - this.originalDelegatorName = mainElement.getAttribute("delegator-name"); - if (UtilValidate.isEmpty(this.originalDelegatorName)) this.originalDelegatorName = "test"; - - this.originalDispatcherName = mainElement.getAttribute("dispatcher-name"); - if (UtilValidate.isEmpty(this.originalDispatcherName)) this.originalDispatcherName = "test-dispatcher"; - String uniqueSuffix = "-" + RandomStringUtils.randomAlphanumeric(10); - - this.delegator = DelegatorFactory.getDelegator(this.originalDelegatorName).makeTestDelegator(this.originalDelegatorName + uniqueSuffix); - this.dispatcher = ServiceContainer.getLocalDispatcher(originalDispatcherName + uniqueSuffix, delegator); + this.suiteName = mainElement.getAttribute("suite-name"); + this.delegator = DelegatorFactory.getDelegator(DELEGATOR_NAME).makeTestDelegator(DELEGATOR_NAME + uniqueSuffix); + this.dispatcher = ServiceContainer.getLocalDispatcher(DISPATCHER_NAME+ uniqueSuffix, delegator); for (Element testCaseElement : UtilXml.childElementList(mainElement, UtilMisc.toSet("test-case", "test-group"))) { String caseName = testCaseElement.getAttribute("case-name"); -- 2.19.1
> How is it complex? Basically each time an option is provided it adds complexity. In this particular case, perhaps a comparaison between the two models of test execution can help describing the added complexity: Current model: 1. Launch OFBiz 2. Fetch all the tests from the components 3. Keep track which delegator/dispatcher correspond to each test suite 4. Run each test by setting its corresponding delegator/dispatcher Model without option: 1. Launch OFBiz with the test delegator/dispatcher 2. Fetch all the tests from the components 3. Run the tests. Does it help? -- Mathieu Lirzin GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
