Skip to content

Commit

Permalink
Readding expression again
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed May 22, 2024
1 parent 25f7df3 commit bec60f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@
import de.cuioss.portal.configuration.schedule.FileWatcherService;
import lombok.experimental.UtilityClass;

import java.io.Serializable;

/**
* Provides the keys used for the web.xml based configuration of the portal.
*
* @author Oliver Wolff
*/
@UtilityClass
public class PortalConfigurationKeys implements Serializable {

private static final long serialVersionUID = 6880786388570386870L;
public class PortalConfigurationKeys {

/**
* Prefix, unifying naming.
Expand Down Expand Up @@ -69,7 +65,7 @@ public class PortalConfigurationKeys implements Serializable {

private static final String LISTENER_BASE = PORTAL_BASE + "listener.";

private static final String LAZYLOADING_BASE = PORTAL_BASE + "lazyLoading.";
private static final String LAZY_LOADING_BASE = PORTAL_BASE + "lazyLoading.";

public static final String APPLICATION_CONTEXT_NAME = "application.context.name";

Expand Down Expand Up @@ -148,7 +144,7 @@ public class PortalConfigurationKeys implements Serializable {
/**
* This is used for setting the top-level menu as parent. In previous versions
* {@code null} as parent was interpreted as indicator for displaying the
* menu-item as top-level element
* menu-item as a top-level element
*/
public static final String MENU_TOP_IDENTIFIER = "top";

Expand Down Expand Up @@ -560,15 +556,15 @@ public class PortalConfigurationKeys implements Serializable {
* Defines the timeout to retrieve a backend request in seconds. After this
* timeout the request will be aborted.
*/
public static final String PORTAL_LAZYLOADING_REQUEST_RETRIEVE_TIMEOUT = LAZYLOADING_BASE
public static final String PORTAL_LAZYLOADING_REQUEST_RETRIEVE_TIMEOUT = LAZY_LOADING_BASE
+ "request.retrieve.timeout";

/**
* Defines the timeout to handle a backend request in seconds. After this
* timeout the request will be aborted. This can happen if the initial rendering
* or the ajax update request was aborted because of redirect.
*/
public static final String PORTAL_LAZYLOADING_REQUEST_HANDLE_TIMEOUT = LAZYLOADING_BASE + "request.handle.timeout";
public static final String PORTAL_LAZYLOADING_REQUEST_HANDLE_TIMEOUT = LAZY_LOADING_BASE + "request.handle.timeout";

/**
* Default portal customization directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ portal.session.timeout=20
portal.authentication.servlet.allowBasicAuth=true

# Keep in sync with 'portal.configuration.stage'
smallrye.config.profile=production
smallrye.config.profile=${portal.configuration.stage}
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,39 @@
*/
package de.cuioss.portal.configuration.impl.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_STAGE;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collections;

import jakarta.inject.Inject;

import de.cuioss.portal.configuration.impl.support.EnablePortalConfigurationLocal;
import de.cuioss.portal.configuration.util.ConfigurationHelper;
import de.cuioss.tools.collect.CollectionLiterals;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.weld.junit5.auto.EnableAutoWeld;
import org.junit.jupiter.api.Test;

import de.cuioss.portal.configuration.impl.support.EnablePortalConfigurationLocal;
import lombok.Getter;
import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_STAGE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@EnablePortalConfigurationLocal
@EnableAutoWeld
class DefaultConfigurationReplacementTest {

@Inject
@Getter
private ConfigurationResolver underTest;
public static final String PRODUCTION = "production";
public static final String PROFILE = "smallrye.config.profile";

@Test
void shouldReplaceVersionForResourceHandler() {
assertTrue(underTest.containsKey(PORTAL_STAGE));
assertNotNull(underTest.getString(PORTAL_STAGE));
void shouldProvideConfiguration() {
assertTrue(ConfigurationHelper.resolveConfigProperties().containsKey(PORTAL_STAGE));
assertEquals(PRODUCTION, ConfigurationHelper.resolveConfigProperty(PORTAL_STAGE).get());
}

@Test
void shouldEnumerateKeys() {
assertTrue(Collections.list(underTest.getKeys()).size() > 10);
void shouldProvideReplacedConfiguration() {
assertTrue(ConfigurationHelper.resolveConfigProperties().containsKey(PROFILE));
assertEquals(PRODUCTION, ConfigurationHelper.resolveConfigProperty(PORTAL_STAGE).get());
}

@Test
void shouldProvideReplacedConfigurationFromMPConfig() {
assertTrue(CollectionLiterals.mutableList(ConfigProvider.getConfig().getPropertyNames()).contains(PROFILE));
assertEquals(PRODUCTION, ConfigProvider.getConfig().getValue(PORTAL_STAGE, String.class));
}
}

0 comments on commit bec60f3

Please sign in to comment.