diff --git a/dotCMS/src/integration-test/java/com/dotcms/osgi/OSGIUtilTest.java b/dotCMS/src/integration-test/java/com/dotcms/osgi/OSGIUtilTest.java index acaeb8eee8d5..4cc9278e7f75 100644 --- a/dotCMS/src/integration-test/java/com/dotcms/osgi/OSGIUtilTest.java +++ b/dotCMS/src/integration-test/java/com/dotcms/osgi/OSGIUtilTest.java @@ -5,12 +5,12 @@ import com.dotmarketing.util.OSGIUtil; import org.apache.commons.io.FileUtils; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.mockito.Mockito; import java.io.File; @@ -24,27 +24,18 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class OSGIUtilTest { - private static String FELIX_BASE_DIR; private static final String FELIX_BASE_DIR_KEY = "felix.base.dir"; @BeforeClass public static void prepare() throws Exception { IntegrationTestInitService.getInstance().init(); - FELIX_BASE_DIR = Config.getStringProperty(FELIX_BASE_DIR_KEY, Config.CONTEXT.getRealPath("/WEB-INF") + File.separator + "felix"); + Mockito.when(Config.CONTEXT.getRealPath("/WEB-INF/felix")).thenReturn(Config.getStringProperty("context.path.felix","/WEB-INF/felix")); // Initialize OSGI initializeOSGIFramework(); } - @AfterClass - public static void restartOSGIAfterFinishing() { - Config.setProperty(FELIX_BASE_DIR_KEY, FELIX_BASE_DIR); - - // Restores original state of the OSGi framework - restartOSGi(); - } - /** * Initialize Mock OSGI Framework */ @@ -68,6 +59,14 @@ private static void restartOSGi() { initializeOSGIFramework(); } + /** + * Restart the OSGI Framework + */ + private static void restartOSGi(String felixBasePath) { + Config.setProperty(FELIX_BASE_DIR_KEY, felixBasePath); + restartOSGi(); + } + /** * Test the felix deploy path is the default path */ @@ -109,7 +108,7 @@ public void test03CustomFelixDeployPath() throws Exception { removeFolder(deployFelixPath); removeFolder(customFelixPath); - Config.setProperty(FELIX_BASE_DIR_KEY, FELIX_BASE_DIR); + restartOSGi(contextFelixPath); } /** @@ -131,7 +130,7 @@ public void test04CustomFelixUndeployPath() throws Exception { removeFolder(undeployFelixPath); removeFolder(customFelixPath); - Config.setProperty(FELIX_BASE_DIR_KEY, FELIX_BASE_DIR); + restartOSGi(contextFelixPath); } /**