[MNG-7194] Test missing property evaluation (#1573)

Co-authored-by: Piotrek Żygieło <pzygielo@users.noreply.github.com>
This commit is contained in:
Piotrek Żygieło 2024-06-26 05:22:09 +02:00 committed by GitHub
parent 5b4e17736b
commit 57fd0dc69b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

View File

@ -58,6 +58,8 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
import org.codehaus.plexus.util.Os;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -291,6 +293,34 @@ class PluginParameterExpressionEvaluatorTest extends AbstractCoreMavenComponentT
assertEquals("value", value);
}
@ParameterizedTest
@ValueSource(
strings = {
"prefix-${PPEET_nonexisting_ps_property}",
"${PPEET_nonexisting_ps_property}-suffix",
"prefix-${PPEET_nonexisting_ps_property}-suffix",
})
void testValueExtractionOfMissingPrefixedSuffixedProperty(String missingPropertyExpression) throws Exception {
Properties executionProperties = new Properties();
ExpressionEvaluator ee = createExpressionEvaluator(null, null, executionProperties);
Object value = ee.evaluate(missingPropertyExpression);
assertEquals(missingPropertyExpression, value);
}
@Test
void testValueExtractionOfMissingProperty() throws Exception {
Properties executionProperties = new Properties();
ExpressionEvaluator ee = createExpressionEvaluator(null, null, executionProperties);
Object value = ee.evaluate("${PPEET_nonexisting_property}");
assertNull(value);
}
@Test
void testValueExtractionFromSystemPropertiesWithMissingProject_WithDotNotation() throws Exception {
String sysprop = "PPEET.sysprop2";