From e093a1783b81c8f5e924935304aa79b2b4537b9a Mon Sep 17 00:00:00 2001 From: "tina.tian" Date: Mon, 20 Aug 2018 15:11:16 -0700 Subject: [PATCH] LPS-84315 Fix unit test --- .../velocity/internal/VelocityTemplateTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/apps/portal-template/portal-template-velocity/src/test/java/com/liferay/portal/template/velocity/internal/VelocityTemplateTest.java b/modules/apps/portal-template/portal-template-velocity/src/test/java/com/liferay/portal/template/velocity/internal/VelocityTemplateTest.java index 9b35f0073a1e78..adfea24d342762 100644 --- a/modules/apps/portal-template/portal-template-velocity/src/test/java/com/liferay/portal/template/velocity/internal/VelocityTemplateTest.java +++ b/modules/apps/portal-template/portal-template-velocity/src/test/java/com/liferay/portal/template/velocity/internal/VelocityTemplateTest.java @@ -16,6 +16,7 @@ import com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil; import com.liferay.portal.kernel.cache.MultiVMPool; +import com.liferay.portal.kernel.cache.PortalCacheManagerNames; import com.liferay.portal.kernel.cache.SingleVMPool; import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter; import com.liferay.portal.kernel.template.StringTemplateResource; @@ -34,6 +35,7 @@ import com.liferay.portal.util.FileImpl; import com.liferay.registry.Registry; import com.liferay.registry.RegistryUtil; +import com.liferay.registry.ServiceReference; import com.liferay.registry.ServiceRegistration; import java.io.IOException; @@ -93,6 +95,10 @@ public static void setUpClass() throws Exception { TemplateResourceParser.class, new ClassLoaderResourceParser(), Collections.singletonMap( "lang.type", TemplateConstants.LANG_TYPE_VM))); + + _serviceReference = registry.getServiceReference(SingleVMPool.class); + + _singleVMPool = registry.getService(_serviceReference); } @AfterClass @@ -104,6 +110,10 @@ public static void tearDownClass() { } _serviceRegistrations.clear(); + + Registry registry = RegistryUtil.getRegistry(); + + registry.ungetService(_serviceReference); } @Before @@ -175,6 +185,8 @@ public void setUp() throws Exception { extendedProperties.setProperty( VelocityEngine.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, String.valueOf(!cacheEnabled)); + extendedProperties.setProperty( + PortalCacheManagerNames.SINGLE_VM, _singleVMPool); _velocityEngine.setExtendedProperties(extendedProperties); @@ -389,8 +401,10 @@ public void testProcessTemplate8() throws Exception { private static final String _WRONG_TEMPLATE_ID = "WRONG_TEMPLATE_ID"; + private static ServiceReference _serviceReference; private static final Set> _serviceRegistrations = Collections.newSetFromMap(new ConcurrentHashMap<>()); + private static SingleVMPool _singleVMPool; private static MockTemplateResourceLoader _templateResourceLoader; private TemplateContextHelper _templateContextHelper;