From e9f85bd985d67b95d3c79fd143c1e135d52421b6 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 12 Jan 2022 13:12:22 +0100 Subject: [PATCH] IDEMPIERE-5147 Fix QueryTest.testPaging failing - IDEMPIERE-5004 (#1129) Co-authored-by: hengsin --- .../org/idempiere/test/model/MappedModelFactoryTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/org.idempiere.test/src/org/idempiere/test/model/MappedModelFactoryTest.java b/org.idempiere.test/src/org/idempiere/test/model/MappedModelFactoryTest.java index 2f7a61e01d..d21bd2894a 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MappedModelFactoryTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MappedModelFactoryTest.java @@ -49,6 +49,7 @@ import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; /** * @author hengsin @@ -71,6 +72,8 @@ public class MappedModelFactoryTest extends AbstractTestCase { (rs, trxName) -> new MyTest(Env.getCtx(), rs, trxName)); PO po = MTable.get(MyTest.Table_ID).getPO(0, getTrxName()); assertTrue(po instanceof MyTest, "PO not instanceof MyTest. PO.className="+po.getClass().getName()); + mappedFactory.removeMapping(MyTest.Table_Name); + CacheMgt.get().reset(); } @Test @@ -79,10 +82,12 @@ public class MappedModelFactoryTest extends AbstractTestCase { BundleContext bc = TestActivator.context; Dictionary properties = new Hashtable(); properties.put("service.ranking", Integer.valueOf(2)); - bc.registerService(IModelFactory.class, new MyFactory(), properties); + ServiceRegistration registration = bc.registerService(IModelFactory.class, new MyFactory(), properties); CacheMgt.get().reset(); PO po = MTable.get(MyTest2.Table_ID).getPO(0, getTrxName()); assertTrue(po instanceof MyTest2, "PO not instanceof MyTest2. PO.className="+po.getClass().getName()); + registration.unregister(); + CacheMgt.get().reset(); } @Test @@ -93,6 +98,8 @@ public class MappedModelFactoryTest extends AbstractTestCase { CacheMgt.get().reset(); PO po = MTable.get(MColor.Table_ID).getPO(0, getTrxName()); assertTrue(po instanceof MyAnnotatedColorModel, "PO not instanceof MyAnnotatedColorModel. PO.className="+po.getClass().getName()); + Core.getMappedModelFactory().removeMapping(MColor.Table_Name); + CacheMgt.get().reset(); } private final static class MyFactory extends MappedModelFactory {