Skip to content

Commit 57fd0dc

Browse files
authored
[MNG-7194] Test missing property evaluation (apache#1573)
Co-authored-by: Piotrek Żygieło <[email protected]>
1 parent 5b4e177 commit 57fd0dc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java

+30
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
5959
import org.codehaus.plexus.util.Os;
6060
import org.junit.jupiter.api.Test;
61+
import org.junit.jupiter.params.ParameterizedTest;
62+
import org.junit.jupiter.params.provider.ValueSource;
6163

6264
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
6365
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -291,6 +293,34 @@ void testValueExtractionFromSystemPropertiesWithMissingProject() throws Exceptio
291293
assertEquals("value", value);
292294
}
293295

296+
@ParameterizedTest
297+
@ValueSource(
298+
strings = {
299+
"prefix-${PPEET_nonexisting_ps_property}",
300+
"${PPEET_nonexisting_ps_property}-suffix",
301+
"prefix-${PPEET_nonexisting_ps_property}-suffix",
302+
})
303+
void testValueExtractionOfMissingPrefixedSuffixedProperty(String missingPropertyExpression) throws Exception {
304+
Properties executionProperties = new Properties();
305+
306+
ExpressionEvaluator ee = createExpressionEvaluator(null, null, executionProperties);
307+
308+
Object value = ee.evaluate(missingPropertyExpression);
309+
310+
assertEquals(missingPropertyExpression, value);
311+
}
312+
313+
@Test
314+
void testValueExtractionOfMissingProperty() throws Exception {
315+
Properties executionProperties = new Properties();
316+
317+
ExpressionEvaluator ee = createExpressionEvaluator(null, null, executionProperties);
318+
319+
Object value = ee.evaluate("${PPEET_nonexisting_property}");
320+
321+
assertNull(value);
322+
}
323+
294324
@Test
295325
void testValueExtractionFromSystemPropertiesWithMissingProject_WithDotNotation() throws Exception {
296326
String sysprop = "PPEET.sysprop2";

0 commit comments

Comments
 (0)