Skip to content

Commit

Permalink
fix: stabilize unit test testUpgradePopularSpacesPortlet - EXO-66907 (#…
Browse files Browse the repository at this point in the history
…173)

Stabilize unit test testUpgradePopularSpacesPortlet by forcing the reload of the portal container to get all configuration and create all tables of the PORTAL layer.
  • Loading branch information
ahamdi authored Oct 19, 2023
1 parent 801b615 commit c021bbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ public class PopularSpacesRemovePreferencesTest extends AbstractKernelTest {
protected EntityManagerService entityManagerService;
protected Page testPage;

public PopularSpacesRemovePreferencesTest() {
setForceContainerReload(true);
}

@Before
public void setUp() {
container = PortalContainer.getInstance();
public void setUp() throws Exception {
super.setUp();
container = getContainer();
pageService = container.getComponentInstanceOfType(PageService.class);
dataStorage = container.getComponentInstanceOfType(DataStorage.class);
entityManagerService = container.getComponentInstanceOfType(EntityManagerService.class);

begin();
}

@Test
Expand Down Expand Up @@ -75,7 +81,7 @@ public void testUpgradePopularSpacesPortlet() throws Exception {
@After
public void tearDown() throws Exception {
pageService.destroyPage(testPage.getPageKey());
RequestLifeCycle.end();
end();
}

private Page createPage(String pageName, String contentId) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.exoplatform.commons.api.settings.data.Context;
import org.exoplatform.commons.api.settings.data.Scope;
import org.exoplatform.commons.persistence.impl.EntityManagerService;
import org.exoplatform.component.test.AbstractKernelTest;
import org.exoplatform.component.test.ConfigurationUnit;
import org.exoplatform.component.test.ConfiguredBy;
import org.exoplatform.component.test.ContainerScope;
Expand Down Expand Up @@ -33,8 +34,12 @@
import static org.junit.Assert.*;

@RunWith(MockitoJUnitRunner.class)
@ConfiguredBy({ @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/portal/configuration.xml") })
public class SpaceApplicationMigrationTest {
@ConfiguredBy({
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/portal/configuration.xml"),
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/exo.portal.component.portal-configuration-local.xml"),
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "org/exoplatform/portal/config/conf/configuration.xml")
})
public class SpaceApplicationMigrationTest extends AbstractKernelTest {

protected PortalContainer container;

Expand All @@ -50,9 +55,13 @@ public class SpaceApplicationMigrationTest {

private SpaceApplicationMigration spaceApplicationMigration;

public SpaceApplicationMigrationTest() {
setForceContainerReload(true);
}

@Before
public void setUp() {
container = PortalContainer.getInstance();
container = getContainer();
this.spaceService = container.getComponentInstanceOfType(SpaceService.class);
this.navigationService = container.getComponentInstanceOfType(NavigationService.class);
this.identityRegistry = container.getComponentInstanceOfType(IdentityRegistry.class);
Expand Down

0 comments on commit c021bbd

Please sign in to comment.