From baa26707f8749b56a5c2a123eddb03aa29c30777 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 3 Nov 2025 22:52:16 +0000 Subject: [PATCH] JUnit Jupiter best practices Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.junit.JupiterBestPractices?organizationId=NzQ1YmJlODUtZjNkMy00OTNkLThhNDAtZWJmZDg4N2U1ZjU1 Co-authored-by: Moderne --- .../EnvarBasedValueSourceTest.java | 27 +----- .../FeedbackingValueSourceTest.java | 10 +- .../InterpolatorFilterReaderTest.java | 30 +++--- .../PrefixAwareRecursionInterceptorTest.java | 8 +- .../PrefixedObjectValueSourceTest.java | 8 +- .../PrefixedValueSourceWrapperTest.java | 8 +- .../PropertiesBasedValueSourceTest.java | 6 +- .../RegexBasedInterpolatorTest.java | 41 +++----- .../StringSearchInterpolatorTest.java | 73 ++++++-------- .../fixed/EnvarBasedValueSourceTest.java | 27 +----- .../FixedStringSearchInterpolatorTest.java | 97 ++++++++----------- ...DelimiterInterpolatorFilterReaderTest.java | 34 +++---- ...DelimiterStringSearchInterpolatorTest.java | 21 ++-- .../FieldBasedObjectInterpolatorTest.java | 22 ++--- .../interpolation/util/StringUtilsTest.java | 4 +- 15 files changed, 164 insertions(+), 252 deletions(-) diff --git a/src/test/java/org/codehaus/plexus/interpolation/EnvarBasedValueSourceTest.java b/src/test/java/org/codehaus/plexus/interpolation/EnvarBasedValueSourceTest.java index 8a3c76c..6e40102 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/EnvarBasedValueSourceTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/EnvarBasedValueSourceTest.java @@ -1,22 +1,5 @@ package org.codehaus.plexus.interpolation; -/* - * Copyright 2007 The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -28,15 +11,15 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -public class EnvarBasedValueSourceTest { +class EnvarBasedValueSourceTest { @BeforeEach - public void setUp() { + void setUp() { EnvarBasedValueSource.resetStatics(); } @Test - void testNoArgConstructorIsCaseSensitive() throws IOException { + void noArgConstructorIsCaseSensitive() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -54,7 +37,7 @@ public Map getEnvMap() { } @Test - void testCaseInsensitive() throws IOException { + void caseInsensitive() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -72,7 +55,7 @@ public Map getEnvMap() { } @Test - void testGetRealEnvironmentVariable() throws IOException { + void getRealEnvironmentVariable() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.DefaultEnvVarSource()); EnvarBasedValueSource source = new EnvarBasedValueSource(); diff --git a/src/test/java/org/codehaus/plexus/interpolation/FeedbackingValueSourceTest.java b/src/test/java/org/codehaus/plexus/interpolation/FeedbackingValueSourceTest.java index f6304ad..909e4fa 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/FeedbackingValueSourceTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/FeedbackingValueSourceTest.java @@ -23,10 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public class FeedbackingValueSourceTest { +class FeedbackingValueSourceTest { @Test - public void testStandalone() { + void standalone() { ValueSource valueSource = new FeedbackingValueSource(); assertNull(valueSource.getValue("test")); assertEquals(1, valueSource.getFeedback().size()); @@ -34,7 +34,7 @@ public void testStandalone() { } @Test - public void testAfterResolvedExpression() throws InterpolationException { + void afterResolvedExpression() throws Exception { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val"))); interpolator.addValueSource(new FeedbackingValueSource()); @@ -43,7 +43,7 @@ public void testAfterResolvedExpression() throws InterpolationException { } @Test - public void testBeforeResolvedExpression() throws InterpolationException { + void beforeResolvedExpression() throws Exception { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.addValueSource(new FeedbackingValueSource("Resolving ${expression}")); interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val"))); @@ -53,7 +53,7 @@ public void testBeforeResolvedExpression() throws InterpolationException { } @Test - public void testAfterNotResolvedExpression() throws InterpolationException { + void afterNotResolvedExpression() throws Exception { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val"))); interpolator.addValueSource(new FeedbackingValueSource()); diff --git a/src/test/java/org/codehaus/plexus/interpolation/InterpolatorFilterReaderTest.java b/src/test/java/org/codehaus/plexus/interpolation/InterpolatorFilterReaderTest.java index 0be913d..c01870a 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/InterpolatorFilterReaderTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/InterpolatorFilterReaderTest.java @@ -41,13 +41,13 @@ * @author cstamas * */ -public class InterpolatorFilterReaderTest { +class InterpolatorFilterReaderTest { /* * Added and commented by jdcasey@03-Feb-2005 because it is a bug in the InterpolationFilterReader. * kenneyw@15-04-2005 fixed the bug. */ @Test - public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception { + void shouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception { Map m = new HashMap(); m.put("test", "TestValue"); @@ -60,7 +60,7 @@ public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() t * kenneyw@14-04-2005 Added test to check above fix. */ @Test - public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Exception { + void shouldNotInterpolateExpressionWithMissingEndToken() throws Exception { Map m = new HashMap(); m.put("test", "TestValue"); @@ -70,7 +70,7 @@ public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Excep } @Test - public void testShouldNotInterpolateWithMalformedStartToken() throws Exception { + void shouldNotInterpolateWithMalformedStartToken() throws Exception { Map m = new HashMap(); m.put("test", "testValue"); @@ -80,7 +80,7 @@ public void testShouldNotInterpolateWithMalformedStartToken() throws Exception { } @Test - public void testShouldNotInterpolateWithMalformedEndToken() throws Exception { + void shouldNotInterpolateWithMalformedEndToken() throws Exception { Map m = new HashMap(); m.put("test", "testValue"); @@ -90,7 +90,7 @@ public void testShouldNotInterpolateWithMalformedEndToken() throws Exception { } @Test - public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception { + void defaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -101,7 +101,7 @@ public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Excep } @Test - public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exception { + void defaultInterpolationWithInterpolatedValueAtEnd() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -112,7 +112,7 @@ public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exceptio } @Test - public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception { + void interpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -123,7 +123,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws } @Test - public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception { + void interpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -134,7 +134,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomS } @Test - public void testEscape() throws Exception { + void escape() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -145,7 +145,7 @@ public void testEscape() throws Exception { } @Test - public void testEscapeAtStart() throws Exception { + void escapeAtStart() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -156,7 +156,7 @@ public void testEscapeAtStart() throws Exception { } @Test - public void testEscapeOnlyAtStart() throws Exception { + void escapeOnlyAtStart() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -168,7 +168,7 @@ public void testEscapeOnlyAtStart() throws Exception { } @Test - public void testEscapeOnlyAtStartDefaultToken() throws Exception { + void escapeOnlyAtStartDefaultToken() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -180,7 +180,7 @@ public void testEscapeOnlyAtStartDefaultToken() throws Exception { } @Test - public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception { + void shouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception { List prefixes = new ArrayList(); prefixes.add("prefix1"); @@ -211,7 +211,7 @@ public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throw } @Test - public void testShouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception { + void shouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception { List prefixes = new ArrayList(); prefixes.add("prefix1"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/PrefixAwareRecursionInterceptorTest.java b/src/test/java/org/codehaus/plexus/interpolation/PrefixAwareRecursionInterceptorTest.java index d1f250a..d869bfe 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/PrefixAwareRecursionInterceptorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/PrefixAwareRecursionInterceptorTest.java @@ -25,10 +25,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class PrefixAwareRecursionInterceptorTest { +class PrefixAwareRecursionInterceptorTest { @Test - public void testFindExpression() { + void findExpression() { PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(Collections.singleton("prefix.")); @@ -45,7 +45,7 @@ public void testFindExpression() { } @Test - public void testFindExpressionWithDifferentPrefix() { + void findExpressionWithDifferentPrefix() { PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(Arrays.asList(new String[] {"prefix.", "other."})); @@ -61,7 +61,7 @@ public void testFindExpressionWithDifferentPrefix() { } @Test - public void testFindExpressionWithoutPrefix() { + void findExpressionWithoutPrefix() { PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(Arrays.asList(new String[] {"prefix.", "other."})); diff --git a/src/test/java/org/codehaus/plexus/interpolation/PrefixedObjectValueSourceTest.java b/src/test/java/org/codehaus/plexus/interpolation/PrefixedObjectValueSourceTest.java index 996d090..808c1ea 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/PrefixedObjectValueSourceTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/PrefixedObjectValueSourceTest.java @@ -23,10 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertNull; -public class PrefixedObjectValueSourceTest { +class PrefixedObjectValueSourceTest { @Test - public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed() { + void emptyExpressionResultsInNullReturnNoPrefixUsed() { String target = "Target object"; List prefixes = new ArrayList(); @@ -40,7 +40,7 @@ public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed() { } @Test - public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot() { + void emptyExpressionResultsInNullReturnPrefixUsedWithDot() { String target = "Target object"; List prefixes = new ArrayList(); @@ -54,7 +54,7 @@ public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot() { } @Test - public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithoutDot() { + void emptyExpressionResultsInNullReturnPrefixUsedWithoutDot() { String target = "Target object"; List prefixes = new ArrayList(); diff --git a/src/test/java/org/codehaus/plexus/interpolation/PrefixedValueSourceWrapperTest.java b/src/test/java/org/codehaus/plexus/interpolation/PrefixedValueSourceWrapperTest.java index 1e65b9b..cc3439f 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/PrefixedValueSourceWrapperTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/PrefixedValueSourceWrapperTest.java @@ -23,10 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -public class PrefixedValueSourceWrapperTest { +class PrefixedValueSourceWrapperTest { @Test - public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix() { + void shouldReturnValueForPropertyVSWRappedWithSinglePrefix() { String prefix = "prefix."; String key = "key"; String value = "value"; @@ -41,7 +41,7 @@ public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix() { } @Test - public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSinglePrefix() { + void shouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSinglePrefix() { String prefix = "prefix."; String otherPrefix = "other."; String key = "key"; @@ -57,7 +57,7 @@ public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSing } @Test - public void testShouldNullForMissingValueInPropertyVSWRappedWithSinglePrefix() { + void shouldNullForMissingValueInPropertyVSWRappedWithSinglePrefix() { String prefix = "prefix."; String key = "key"; diff --git a/src/test/java/org/codehaus/plexus/interpolation/PropertiesBasedValueSourceTest.java b/src/test/java/org/codehaus/plexus/interpolation/PropertiesBasedValueSourceTest.java index 6fe10b8..b571ec5 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/PropertiesBasedValueSourceTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/PropertiesBasedValueSourceTest.java @@ -23,10 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -public class PropertiesBasedValueSourceTest { +class PropertiesBasedValueSourceTest { @Test - public void testPropertyShouldReturnValueFromProperties() { + void propertyShouldReturnValueFromProperties() { Properties props = new Properties(); String key = "key"; @@ -40,7 +40,7 @@ public void testPropertyShouldReturnValueFromProperties() { } @Test - public void testPropertyShouldReturnNullWhenPropertyMissing() { + void propertyShouldReturnNullWhenPropertyMissing() { Properties props = new Properties(); String key = "key"; diff --git a/src/test/java/org/codehaus/plexus/interpolation/RegexBasedInterpolatorTest.java b/src/test/java/org/codehaus/plexus/interpolation/RegexBasedInterpolatorTest.java index f2debe4..17bd377 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/RegexBasedInterpolatorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/RegexBasedInterpolatorTest.java @@ -1,22 +1,5 @@ package org.codehaus.plexus.interpolation; -/* - * Copyright 2001-2008 Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -31,7 +14,7 @@ public class RegexBasedInterpolatorTest { @BeforeEach - public void setUp() { + void setUp() { EnvarBasedValueSource.resetStatics(); } @@ -40,7 +23,7 @@ public String getVar() { } @Test - public void testShouldFailOnExpressionCycle() { + void shouldFailOnExpressionCycle() { Properties props = new Properties(); props.setProperty("key1", "${key2}"); props.setProperty("key2", "${key1}"); @@ -58,7 +41,7 @@ public void testShouldFailOnExpressionCycle() { } @Test - public void testShouldResolveByMy_getVar_Method() throws InterpolationException { + void shouldResolveByMyGetVarMethod() throws Exception { RegexBasedInterpolator rbi = new RegexBasedInterpolator(); rbi.addValueSource(new ObjectBasedValueSource(this)); String result = rbi.interpolate("this is a ${this.var}", "this"); @@ -67,7 +50,7 @@ public void testShouldResolveByMy_getVar_Method() throws InterpolationException } @Test - public void testShouldResolveByContextValue() throws InterpolationException { + void shouldResolveByContextValue() throws Exception { RegexBasedInterpolator rbi = new RegexBasedInterpolator(); Map context = new HashMap(); @@ -81,7 +64,7 @@ public void testShouldResolveByContextValue() throws InterpolationException { } @Test - public void testDelimitersPassedToValueSource() throws InterpolationException { + void delimitersPassedToValueSource() throws Exception { RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); interpolator.addValueSource(new AbstractValueSource(false) { @@ -103,7 +86,7 @@ public Object getValue(String expression) { } @Test - public void testShouldResolveByEnvar() throws IOException, InterpolationException { + void shouldResolveByEnvar() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -122,7 +105,7 @@ public Map getEnvMap() { } @Test - public void testUseAlternateRegex() throws Exception { + void useAlternateRegex() throws Exception { RegexBasedInterpolator rbi = new RegexBasedInterpolator("\\@\\{(", ")?([^}]+)\\}@"); Map context = new HashMap(); @@ -136,7 +119,7 @@ public void testUseAlternateRegex() throws Exception { } @Test - public void testNPEFree() throws Exception { + void npeFree() throws Exception { RegexBasedInterpolator rbi = new RegexBasedInterpolator("\\@\\{(", ")?([^}]+)\\}@"); Map context = new HashMap(); @@ -150,7 +133,7 @@ public void testNPEFree() throws Exception { } @Test - public void testUsePostProcessor_DoesNotChangeValue() throws InterpolationException { + void usePostProcessorDoesNotChangeValue() throws Exception { RegexBasedInterpolator rbi = new RegexBasedInterpolator(); Map context = new HashMap(); @@ -170,7 +153,7 @@ public Object execute(String expression, Object value) { } @Test - public void testUsePostProcessor_ChangesValue() throws InterpolationException { + void usePostProcessorChangesValue() throws Exception { int loopNumber = 200000; @@ -225,7 +208,7 @@ public Object execute(String expression, Object value) { } @Test - public void testCacheAnswersTrue() throws InterpolationException { + void cacheAnswersTrue() throws Exception { Map ctx = new HashMap(); ctx.put("key", "value"); @@ -260,7 +243,7 @@ public Object getValue(String expression) { } @Test - public void testCacheAnswersFalse() throws InterpolationException { + void cacheAnswersFalse() throws Exception { Map ctx = new HashMap(); ctx.put("key", "value"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/StringSearchInterpolatorTest.java b/src/test/java/org/codehaus/plexus/interpolation/StringSearchInterpolatorTest.java index e1fa00a..2d29d4d 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/StringSearchInterpolatorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/StringSearchInterpolatorTest.java @@ -1,22 +1,5 @@ package org.codehaus.plexus.interpolation; -/* - * Copyright 2001-2008 Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -34,12 +17,12 @@ public class StringSearchInterpolatorTest { @BeforeEach - public void setUp() { + void setUp() { EnvarBasedValueSource.resetStatics(); } @Test - public void testLongDelimitersInContext() throws InterpolationException { + void longDelimitersInContext() throws Exception { String src = "This is a test.label for long delimiters in context."; String result = "This is a test for long delimiters in context."; @@ -53,7 +36,7 @@ public void testLongDelimitersInContext() throws InterpolationException { } @Test - public void testLongDelimitersWithNoStartContext() throws InterpolationException { + void longDelimitersWithNoStartContext() throws Exception { String src = "test.label for long delimiters in context."; String result = "test for long delimiters in context."; @@ -67,7 +50,7 @@ public void testLongDelimitersWithNoStartContext() throws InterpolationException } @Test - public void testLongDelimitersWithNoEndContext() throws InterpolationException { + void longDelimitersWithNoEndContext() throws Exception { String src = "This is a test.label"; String result = "This is a test"; @@ -81,7 +64,7 @@ public void testLongDelimitersWithNoEndContext() throws InterpolationException { } @Test - public void testLongDelimitersWithNoContext() throws InterpolationException { + void longDelimitersWithNoContext() throws Exception { String src = "test.label"; String result = "test"; @@ -95,7 +78,7 @@ public void testLongDelimitersWithNoContext() throws InterpolationException { } @Test - public void testLongDelimitersPassedToValueSource() throws InterpolationException { + void longDelimitersPassedToValueSource() throws Exception { String src = "test"; StringSearchInterpolator interpolator = new StringSearchInterpolator("", ""); @@ -119,7 +102,7 @@ public Object getValue(String expression) { } @Test - public void testSimpleSubstitution() throws InterpolationException { + void simpleSubstitution() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -130,7 +113,7 @@ public void testSimpleSubstitution() throws InterpolationException { } @Test - public void testSimpleSubstitution_TwoExpressions() throws InterpolationException { + void simpleSubstitutionTwoExpressions() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -142,7 +125,7 @@ public void testSimpleSubstitution_TwoExpressions() throws InterpolationExceptio } @Test - public void testBrokenExpression_LeaveItAlone() throws InterpolationException { + void brokenExpressionLeaveItAlone() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -153,7 +136,7 @@ public void testBrokenExpression_LeaveItAlone() throws InterpolationException { } @Test - public void testShouldFailOnExpressionCycle() { + void shouldFailOnExpressionCycle() { Properties props = new Properties(); props.setProperty("key1", "${key2}"); props.setProperty("key2", "${key1}"); @@ -171,7 +154,7 @@ public void testShouldFailOnExpressionCycle() { } @Test - public void testShouldResolveByUsingObject_List_Map() throws InterpolationException { + void shouldResolveByUsingObjectListMap() throws Exception { StringSearchInterpolator rbi = new StringSearchInterpolator(); rbi.addValueSource(new ObjectBasedValueSource(this)); String result = @@ -181,7 +164,7 @@ public void testShouldResolveByUsingObject_List_Map() throws InterpolationExcept } @Test - public void testShouldResolveByContextValue() throws InterpolationException { + void shouldResolveByContextValue() throws Exception { StringSearchInterpolator rbi = new StringSearchInterpolator(); Map context = new HashMap(); @@ -195,7 +178,7 @@ public void testShouldResolveByContextValue() throws InterpolationException { } @Test - public void testShouldResolveByEnvar() throws IOException, InterpolationException { + void shouldResolveByEnvar() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -215,7 +198,7 @@ public Map getEnvMap() { } @Test - public void testUsePostProcessor_DoesNotChangeValue() throws InterpolationException { + void usePostProcessorDoesNotChangeValue() throws Exception { StringSearchInterpolator rbi = new StringSearchInterpolator(); Map context = new HashMap(); @@ -235,7 +218,7 @@ public Object execute(String expression, Object value) { } @Test - public void testUsePostProcessor_ChangesValue() throws InterpolationException { + void usePostProcessorChangesValue() throws Exception { StringSearchInterpolator rbi = new StringSearchInterpolator(); @@ -256,7 +239,7 @@ public Object execute(String expression, Object value) { } @Test - public void testSimpleSubstitutionWithDefinedExpr() throws InterpolationException { + void simpleSubstitutionWithDefinedExpr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -267,7 +250,7 @@ public void testSimpleSubstitutionWithDefinedExpr() throws InterpolationExceptio } @Test - public void testEscape() throws InterpolationException { + void escape() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -281,7 +264,7 @@ public void testEscape() throws InterpolationException { } @Test - public void testEscapeWithLongEscapeStr() throws InterpolationException { + void escapeWithLongEscapeStr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -295,7 +278,7 @@ public void testEscapeWithLongEscapeStr() throws InterpolationException { } @Test - public void testEscapeWithLongEscapeStrAtStart() throws InterpolationException { + void escapeWithLongEscapeStrAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -309,7 +292,7 @@ public void testEscapeWithLongEscapeStrAtStart() throws InterpolationException { } @Test - public void testNotEscapeWithLongEscapeStrAtStart() throws InterpolationException { + void notEscapeWithLongEscapeStrAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -323,7 +306,7 @@ public void testNotEscapeWithLongEscapeStrAtStart() throws InterpolationExceptio } @Test - public void testEscapeNotFailWithNullEscapeStr() throws InterpolationException { + void escapeNotFailWithNullEscapeStr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -337,7 +320,7 @@ public void testEscapeNotFailWithNullEscapeStr() throws InterpolationException { } @Test - public void testOnlyEscapeExprAtStart() throws InterpolationException { + void onlyEscapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -351,7 +334,7 @@ public void testOnlyEscapeExprAtStart() throws InterpolationException { } @Test - public void testNotEscapeExprAtStart() throws InterpolationException { + void notEscapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -365,7 +348,7 @@ public void testNotEscapeExprAtStart() throws InterpolationException { } @Test - public void testEscapeExprAtStart() throws InterpolationException { + void escapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -379,7 +362,7 @@ public void testEscapeExprAtStart() throws InterpolationException { } @Test - public void testNPEFree() throws InterpolationException { + void npeFree() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -393,7 +376,7 @@ public void testNPEFree() throws InterpolationException { } @Test - public void testInterruptedInterpolate() throws InterpolationException { + void interruptedInterpolate() throws Exception { Interpolator interpolator = new StringSearchInterpolator(); RecursionInterceptor recursionInterceptor = new SimpleRecursionInterceptor(); final boolean[] error = new boolean[] {false}; @@ -431,7 +414,7 @@ public void clearFeedback() {} } @Test - public void testCacheAnswersTrue() throws InterpolationException { + void cacheAnswersTrue() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -470,7 +453,7 @@ public int getExistingCallCount() { } @Test - public void testCacheAnswersFalse() throws InterpolationException { + void cacheAnswersFalse() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/fixed/EnvarBasedValueSourceTest.java b/src/test/java/org/codehaus/plexus/interpolation/fixed/EnvarBasedValueSourceTest.java index b6ff638..fb7b102 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/fixed/EnvarBasedValueSourceTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/fixed/EnvarBasedValueSourceTest.java @@ -1,22 +1,5 @@ package org.codehaus.plexus.interpolation.fixed; -/* - * Copyright 2007 The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -28,15 +11,15 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -public class EnvarBasedValueSourceTest { +class EnvarBasedValueSourceTest { @BeforeEach - public void setUp() { + void setUp() { EnvarBasedValueSource.resetStatics(); } @Test - void testNoArgConstructorIsCaseSensitive() throws IOException { + void noArgConstructorIsCaseSensitive() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -54,7 +37,7 @@ public Map getEnvMap() { } @Test - void testCaseInsensitive() throws IOException { + void caseInsensitive() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -72,7 +55,7 @@ public Map getEnvMap() { } @Test - void testGetRealEnvironmentVariable() throws IOException { + void getRealEnvironmentVariable() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.DefaultEnvVarSource()); EnvarBasedValueSource source = new EnvarBasedValueSource(); diff --git a/src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java b/src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java index afef83e..b1d4173 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java @@ -1,21 +1,5 @@ package org.codehaus.plexus.interpolation.fixed; -/* - * Copyright 2001-2008 Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -23,7 +7,6 @@ import java.util.Properties; import org.codehaus.plexus.interpolation.FixedInterpolatorValueSource; -import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.interpolation.os.OperatingSystemUtils; @@ -37,12 +20,12 @@ public class FixedStringSearchInterpolatorTest { @BeforeEach - public void setUp() { + void setUp() { EnvarBasedValueSource.resetStatics(); } @Test - void testLongDelimitersInContext() { + void longDelimitersInContext() { String src = "This is a test.label for long delimiters in context."; String result = "This is a test for long delimiters in context."; @@ -56,7 +39,7 @@ void testLongDelimitersInContext() { } @Test - void testLongDelimitersWithNoStartContext() { + void longDelimitersWithNoStartContext() { String src = "test.label for long delimiters in context."; String result = "test for long delimiters in context."; @@ -70,7 +53,7 @@ void testLongDelimitersWithNoStartContext() { } @Test - void testLongDelimitersWithNoEndContext() { + void longDelimitersWithNoEndContext() { String src = "This is a test.label"; String result = "This is a test"; @@ -84,7 +67,7 @@ void testLongDelimitersWithNoEndContext() { } @Test - void testLongDelimitersWithNoContext() { + void longDelimitersWithNoContext() { String src = "test.label"; String result = "test"; @@ -98,7 +81,7 @@ void testLongDelimitersWithNoContext() { } @Test - void testSimpleSubstitution() { + void simpleSubstitution() { Properties p = new Properties(); p.setProperty("key", "value"); @@ -108,7 +91,7 @@ void testSimpleSubstitution() { } @Test - void testSimpleSubstitution_TwoExpressions() { + void simpleSubstitutionTwoExpressions() { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -119,7 +102,7 @@ void testSimpleSubstitution_TwoExpressions() { } @Test - void testBrokenExpression_LeaveItAlone() { + void brokenExpressionLeaveItAlone() { Properties p = new Properties(); p.setProperty("key", "value"); @@ -129,7 +112,7 @@ void testBrokenExpression_LeaveItAlone() { } @Test - void testShouldFailOnExpressionCycle() { + void shouldFailOnExpressionCycle() { Properties props = new Properties(); props.setProperty("key1", "${key2}"); props.setProperty("key2", "${key1}"); @@ -143,7 +126,7 @@ void testShouldFailOnExpressionCycle() { } @Test - void testShouldResolveByUsingObject_List_Map() throws InterpolationException { + void shouldResolveByUsingObjectListMap() throws Exception { FixedStringSearchInterpolator rbi = create(new ObjectBasedValueSource(this)); String result = rbi.interpolate("this is a ${var} ${list[1].name} ${anArray[2].name} ${map(Key with spaces).name}"); @@ -152,7 +135,7 @@ void testShouldResolveByUsingObject_List_Map() throws InterpolationException { } @Test - void testShouldResolveByContextValue() throws InterpolationException { + void shouldResolveByContextValue() throws Exception { Map context = new HashMap(); context.put("var", "testVar"); @@ -165,7 +148,7 @@ void testShouldResolveByContextValue() throws InterpolationException { } @Test - void testShouldResolveByEnvar() throws IOException, InterpolationException { + void shouldResolveByEnvar() throws Exception { OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() { public Map getEnvMap() { HashMap map = new HashMap(); @@ -183,7 +166,7 @@ public Map getEnvMap() { } @Test - void testUsePostProcessor_DoesNotChangeValue() throws InterpolationException { + void usePostProcessorDoesNotChangeValue() throws Exception { Map context = new HashMap(); context.put("test.var", "testVar"); @@ -202,7 +185,7 @@ public Object execute(String expression, Object value) { } @Test - void testUsePostProcessor_ChangesValue() throws InterpolationException { + void usePostProcessorChangesValue() throws Exception { Map context = new HashMap(); context.put("test.var", "testVar"); @@ -222,7 +205,7 @@ public Object execute(String expression, Object value) { } @Test - void testSimpleSubstitutionWithDefinedExpr() throws InterpolationException { + void simpleSubstitutionWithDefinedExpr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -232,7 +215,7 @@ void testSimpleSubstitutionWithDefinedExpr() throws InterpolationException { } @Test - void testEscape() throws InterpolationException { + void escape() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -246,7 +229,7 @@ void testEscape() throws InterpolationException { } @Test - void testEscapeWithLongEscapeStr() throws InterpolationException { + void escapeWithLongEscapeStr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -260,7 +243,7 @@ void testEscapeWithLongEscapeStr() throws InterpolationException { } @Test - void testEscapeWithLongEscapeStrAtStart() throws InterpolationException { + void escapeWithLongEscapeStrAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -274,7 +257,7 @@ void testEscapeWithLongEscapeStrAtStart() throws InterpolationException { } @Test - void testNotEscapeWithLongEscapeStrAtStart() throws InterpolationException { + void notEscapeWithLongEscapeStrAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -288,7 +271,7 @@ void testNotEscapeWithLongEscapeStrAtStart() throws InterpolationException { } @Test - void testEscapeNotFailWithNullEscapeStr() throws InterpolationException { + void escapeNotFailWithNullEscapeStr() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -302,7 +285,7 @@ void testEscapeNotFailWithNullEscapeStr() throws InterpolationException { } @Test - void testOnlyEscapeExprAtStart() throws InterpolationException { + void onlyEscapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -316,7 +299,7 @@ void testOnlyEscapeExprAtStart() throws InterpolationException { } @Test - void testNotEscapeExprAtStart() throws InterpolationException { + void notEscapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -330,7 +313,7 @@ void testNotEscapeExprAtStart() throws InterpolationException { } @Test - void testEscapeExprAtStart() throws InterpolationException { + void escapeExprAtStart() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -344,7 +327,7 @@ void testEscapeExprAtStart() throws InterpolationException { } @Test - void testNPEFree() throws InterpolationException { + void npeFree() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); @@ -358,7 +341,7 @@ void testNPEFree() throws InterpolationException { } @Test - void testInterruptedInterpolate() throws InterpolationException { + void interruptedInterpolate() throws Exception { final boolean[] error = new boolean[] {false}; FixedValueSource valueSource = new FixedValueSource() { public Object getValue(String expression, InterpolationState errorCollector) { @@ -426,7 +409,7 @@ public String getName() { } @Test - void testLinkedInterpolators() { + void linkedInterpolators() { final String EXPR = "${test.label}AND${test2}"; final String EXPR2 = "${test.label}${test2.label}AND${test2}"; @@ -439,7 +422,7 @@ void testLinkedInterpolators() { } @Test - void testDominance() { + void dominance() { final String EXPR = "${test.label}AND${test2}"; final String EXPR2 = "${test.label}${test2.label}AND${test2}"; @@ -463,25 +446,23 @@ void unresolable_linked() { } @Test - void testCyclesWithLinked() { - assertThrows(InterpolationCycleException.class, () -> { - FixedStringSearchInterpolator first = create(properttyBasedValueSource("key1", "${key2}")); - FixedStringSearchInterpolator second = create(first, properttyBasedValueSource("key2", "${key1}")); - second.interpolate("${key2}"); - }); + void cyclesWithLinked() { + FixedStringSearchInterpolator first = create(properttyBasedValueSource("key1", "${key2}")); + FixedStringSearchInterpolator second = create(first, properttyBasedValueSource("key2", "${key1}")); + assertThrows(InterpolationCycleException.class, () -> + second.interpolate("${key2}")); } @Test - void testCyclesWithLinked_betweenRootAndOther() { - assertThrows(InterpolationCycleException.class, () -> { - FixedStringSearchInterpolator first = create(properttyBasedValueSource("key1", "${key2}")); - FixedStringSearchInterpolator second = create(first, properttyBasedValueSource("key2", "${key1}")); - second.interpolate("${key1}"); - }); + void cyclesWithLinkedBetweenRootAndOther() { + FixedStringSearchInterpolator first = create(properttyBasedValueSource("key1", "${key2}")); + FixedStringSearchInterpolator second = create(first, properttyBasedValueSource("key2", "${key1}")); + assertThrows(InterpolationCycleException.class, () -> + second.interpolate("${key1}")); } @Test - void fixedInjectedIntoRegular() throws InterpolationException { + void fixedInjectedIntoRegular() throws Exception { FixedStringSearchInterpolator first = create(properttyBasedValueSource("key1", "v1")); Properties p = new Properties(); diff --git a/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterInterpolatorFilterReaderTest.java b/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterInterpolatorFilterReaderTest.java index 95ab97d..8fa7bf0 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterInterpolatorFilterReaderTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterInterpolatorFilterReaderTest.java @@ -46,13 +46,13 @@ * @author cstamas * */ -public class MultiDelimiterInterpolatorFilterReaderTest { +class MultiDelimiterInterpolatorFilterReaderTest { /* * Added and commented by jdcasey@03-Feb-2005 because it is a bug in the InterpolationFilterReader. * kenneyw@15-04-2005 fixed the bug. */ @Test - public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception { + void shouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception { Map m = new HashMap(); m.put("test", "TestValue"); @@ -65,7 +65,7 @@ public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() t * kenneyw@14-04-2005 Added test to check above fix. */ @Test - public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Exception { + void shouldNotInterpolateExpressionWithMissingEndToken() throws Exception { Map m = new HashMap(); m.put("test", "TestValue"); @@ -75,7 +75,7 @@ public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Excep } @Test - public void testShouldNotInterpolateWithMalformedStartToken() throws Exception { + void shouldNotInterpolateWithMalformedStartToken() throws Exception { Map m = new HashMap(); m.put("test", "testValue"); @@ -85,7 +85,7 @@ public void testShouldNotInterpolateWithMalformedStartToken() throws Exception { } @Test - public void testShouldNotInterpolateWithMalformedEndToken() throws Exception { + void shouldNotInterpolateWithMalformedEndToken() throws Exception { Map m = new HashMap(); m.put("test", "testValue"); @@ -95,7 +95,7 @@ public void testShouldNotInterpolateWithMalformedEndToken() throws Exception { } @Test - public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception { + void defaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -106,7 +106,7 @@ public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Excep } @Test - public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exception { + void defaultInterpolationWithInterpolatedValueAtEnd() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -117,7 +117,7 @@ public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exceptio } @Test - public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception { + void interpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -128,7 +128,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws } @Test - public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception { + void interpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -139,7 +139,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomS } @Test - public void testEscape() throws Exception { + void escape() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -150,7 +150,7 @@ public void testEscape() throws Exception { } @Test - public void testEscapeAtStart() throws Exception { + void escapeAtStart() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -161,7 +161,7 @@ public void testEscapeAtStart() throws Exception { } @Test - public void testEscapeOnlyAtStart() throws Exception { + void escapeOnlyAtStart() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -173,7 +173,7 @@ public void testEscapeOnlyAtStart() throws Exception { } @Test - public void testEscapeOnlyAtStartDefaultToken() throws Exception { + void escapeOnlyAtStartDefaultToken() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("noun", "asshole"); @@ -185,7 +185,7 @@ public void testEscapeOnlyAtStartDefaultToken() throws Exception { } @Test - public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception { + void shouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception { List prefixes = new ArrayList(); prefixes.add("prefix1"); @@ -217,7 +217,7 @@ public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throw } @Test - public void testShouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception { + void shouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception { List prefixes = new ArrayList(); prefixes.add("prefix1"); @@ -248,7 +248,7 @@ public void testShouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exc } @Test - public void testInterpolationWithMultipleTokenTypes() throws Exception { + void interpolationWithMultipleTokenTypes() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("otherName", "@name@"); @@ -259,7 +259,7 @@ public void testInterpolationWithMultipleTokenTypes() throws Exception { } @Test - public void testInterpolationWithMultipleTokenTypes_ReversedOrdering() throws Exception { + void interpolationWithMultipleTokenTypesReversedOrdering() throws Exception { Map m = new HashMap(); m.put("name", "jason"); m.put("otherName", "${name}"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterStringSearchInterpolatorTest.java b/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterStringSearchInterpolatorTest.java index 7b38a16..7639cb1 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterStringSearchInterpolatorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterStringSearchInterpolatorTest.java @@ -20,7 +20,6 @@ import java.util.Map; import org.codehaus.plexus.interpolation.AbstractValueSource; -import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.ValueSource; import org.junit.jupiter.api.Test; @@ -28,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -public class MultiDelimiterStringSearchInterpolatorTest { +class MultiDelimiterStringSearchInterpolatorTest { @Test - public void testInterpolationWithDifferentDelimiters() throws InterpolationException { + void interpolationWithDifferentDelimiters() throws Exception { Map ctx = new HashMap(); ctx.put("name", "User"); ctx.put("otherName", "@name@"); @@ -49,8 +48,8 @@ public void testInterpolationWithDifferentDelimiters() throws InterpolationExcep } @Test - public void testSuccessiveInterpolationWithDifferentDelimiters_ReversedDelimiterSequence() - throws InterpolationException { + void successiveInterpolationWithDifferentDelimitersReversedDelimiterSequence() + throws Exception { Map ctx = new HashMap(); ctx.put("name", "User"); ctx.put("otherName", "${name}"); @@ -68,7 +67,7 @@ public void testSuccessiveInterpolationWithDifferentDelimiters_ReversedDelimiter } @Test - public void testInterpolationWithMultipleEscapes() throws InterpolationException { + void interpolationWithMultipleEscapes() throws Exception { Map ctx = new HashMap(); ctx.put("name", "User"); ctx.put("otherName", "##${first} and #${last}"); @@ -86,7 +85,7 @@ public void testInterpolationWithMultipleEscapes() throws InterpolationException } @Test - public void testInterpolationWithMultipleEscapes2() throws InterpolationException { + void interpolationWithMultipleEscapes2() throws Exception { Map ctx = new HashMap(); ctx.put("name", "User"); ctx.put("otherName", "#${first} and ##${last}"); @@ -104,7 +103,7 @@ public void testInterpolationWithMultipleEscapes2() throws InterpolationExceptio } @Test - public void testInterpolationWithMultipleEscapes3() throws InterpolationException { + void interpolationWithMultipleEscapes3() throws Exception { Map ctx = new HashMap(); ctx.put("name", "User"); ctx.put("last", "beer"); @@ -123,7 +122,7 @@ public void testInterpolationWithMultipleEscapes3() throws InterpolationExceptio } @Test - public void testDelimitersPassedToValueSource() throws InterpolationException { + void delimitersPassedToValueSource() throws Exception { ValueSource vs = new AbstractValueSource(false) { @Override @@ -148,7 +147,7 @@ public Object getValue(String expression) { } @Test - public void testCacheAnswersTrue() throws InterpolationException { + void cacheAnswersTrue() throws Exception { Map ctx = new HashMap(); ctx.put("key", "value"); @@ -180,7 +179,7 @@ public Object getValue(String expression) { } @Test - public void testCacheAnswersFalse() throws InterpolationException { + void cacheAnswersFalse() throws Exception { Map ctx = new HashMap(); ctx.put("key", "value"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/object/FieldBasedObjectInterpolatorTest.java b/src/test/java/org/codehaus/plexus/interpolation/object/FieldBasedObjectInterpolatorTest.java index 08c8ad8..029162f 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/object/FieldBasedObjectInterpolatorTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/object/FieldBasedObjectInterpolatorTest.java @@ -29,10 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class FieldBasedObjectInterpolatorTest { +class FieldBasedObjectInterpolatorTest { @Test - public void testInterpolateStringArray() throws Exception { + void interpolateStringArray() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -49,7 +49,7 @@ public void testInterpolateStringArray() throws Exception { } @Test - public void testInterpolateObjectWithStringArrayField() throws Exception { + void interpolateObjectWithStringArrayField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -68,7 +68,7 @@ public void testInterpolateObjectWithStringArrayField() throws Exception { } @Test - public void testInterpolateObjectWithStringListField() throws Exception { + void interpolateObjectWithStringListField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -89,7 +89,7 @@ public void testInterpolateObjectWithStringListField() throws Exception { } @Test - public void testInterpolateObjectWithStringListFieldAndOneLiteralValue() throws Exception { + void interpolateObjectWithStringListFieldAndOneLiteralValue() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -110,7 +110,7 @@ public void testInterpolateObjectWithStringListFieldAndOneLiteralValue() throws } @Test - public void testInterpolateObjectWithUnmodifiableStringListField() throws Exception { + void interpolateObjectWithUnmodifiableStringListField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -128,7 +128,7 @@ public void testInterpolateObjectWithUnmodifiableStringListField() throws Except } @Test - public void testInterpolateObjectWithStringArrayListField() throws Exception { + void interpolateObjectWithStringArrayListField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -153,7 +153,7 @@ public void testInterpolateObjectWithStringArrayListField() throws Exception { } @Test - public void testInterpolateObjectWithStringToStringMapField() throws Exception { + void interpolateObjectWithStringToStringMapField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -174,7 +174,7 @@ public void testInterpolateObjectWithStringToStringMapField() throws Exception { } @Test - public void testInterpolateObjectWithStringToStringMapFieldAndOneLiteralValue() throws Exception { + void interpolateObjectWithStringToStringMapFieldAndOneLiteralValue() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -195,7 +195,7 @@ public void testInterpolateObjectWithStringToStringMapFieldAndOneLiteralValue() } @Test - public void testInterpolateObjectWithUnmodifiableStringToStringMapField() throws Exception { + void interpolateObjectWithUnmodifiableStringToStringMapField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); @@ -213,7 +213,7 @@ public void testInterpolateObjectWithUnmodifiableStringToStringMapField() throws } @Test - public void testInterpolateObjectWithStringToStringArrayMapField() throws Exception { + void interpolateObjectWithStringToStringArrayMapField() throws Exception { Properties p = new Properties(); p.setProperty("key", "value"); p.setProperty("key2", "value2"); diff --git a/src/test/java/org/codehaus/plexus/interpolation/util/StringUtilsTest.java b/src/test/java/org/codehaus/plexus/interpolation/util/StringUtilsTest.java index d788f63..e47766c 100644 --- a/src/test/java/org/codehaus/plexus/interpolation/util/StringUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/interpolation/util/StringUtilsTest.java @@ -19,9 +19,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class StringUtilsTest { +class StringUtilsTest { @Test - public void testCapitalizeFirstLetter() throws Exception { + void capitalizeFirstLetter() throws Exception { assertEquals("Abc", StringUtils.capitalizeFirstLetter("abc")); assertEquals("\u00cdce", StringUtils.capitalizeFirstLetter("\u00edce")); assertEquals("X", StringUtils.capitalizeFirstLetter("x"));