This is an automated email from the ASF dual-hosted git repository. emilles pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b1b875a79f88067b376dfc30886033512f8667d8 Author: Eric Milles <[email protected]> AuthorDate: Tue Mar 3 16:18:02 2026 -0600 junit jupiter --- src/spec/test/BaseScriptSpecTest.groovy | 11 ++++++++-- src/spec/test/ClassDesignASTTransformsTest.groovy | 4 +--- src/spec/test/ClassTest.groovy | 25 ++++++++++++++++++++++ src/spec/test/CloningASTTransformsTest.groovy | 4 ++-- src/spec/test/ClosuresSpecTest.groovy | 12 ++++++----- .../test/CodeGenerationASTTransformsTest.groovy | 3 +-- .../CompilerDirectivesASTTransformsTest.groovy | 4 ++-- src/spec/test/CustomizersTest.groovy | 2 +- .../DeclarativeConcurrencyASTTransformsTest.groovy | 4 ++-- src/spec/test/DelegatesToSpecTest.groovy | 4 ++-- src/spec/test/DesignPatternsTest.groovy | 1 + src/spec/test/DifferencesFromJavaTest.groovy | 4 ++-- src/spec/test/ExtensionModuleSpecTest.groovy | 12 ++++++----- src/spec/test/IntegrationTest.groovy | 15 ++++++++++--- .../test/LogImprovementsASTTransformsTest.groovy | 4 +--- src/spec/test/OperatorsTest.groovy | 1 + src/spec/test/PrimitiveTest.groovy | 11 +++++----- src/spec/test/RecordSpecificationTest.groovy | 10 ++++----- .../test/SaferScriptingASTTransformsTest.groovy | 6 +++--- src/spec/test/ScriptsAndClassesSpecTest.groovy | 10 ++++----- src/spec/test/SealedSpecificationTest.groovy | 11 +++++++++- src/spec/test/StyleGuideTest.groovy | 1 + src/spec/test/SwingASTTransformsTest.groovy | 5 ++--- src/spec/test/TestingASTTransformsTest.groovy | 3 +-- src/spec/test/TraitsSpecificationTest.groovy | 10 ++++----- src/spec/test/asciidoctor/Utils.groovy | 7 ++++-- src/spec/test/builder/BuilderSpecTest.groovy | 3 ++- src/spec/test/gdk/ConfigSlurperTest.groovy | 2 +- src/spec/test/gdk/ExpandoTest.groovy | 3 +-- src/spec/test/gdk/ObservableTest.groovy | 3 +-- .../test/gdk/WorkingWithCollectionsTest.groovy | 2 +- src/spec/test/gdk/WorkingWithIOSpecTest.groovy | 2 +- .../metaprogramming/ASTMatcherFilteringTest.groovy | 3 +-- .../metaprogramming/ASTMatcherTestingTest.groovy | 4 +--- .../test/metaprogramming/ASTXFormSpecTest.groovy | 3 ++- .../metaprogramming/ExpandoMetaClassTest.groovy | 6 +----- .../test/metaprogramming/GroovyObjectTest.groovy | 2 +- .../test/metaprogramming/InterceptableTest.groovy | 3 +-- .../InterceptionThroughMetaClassTest.groovy | 2 +- .../test/metaprogramming/MacroClassTest.groovy | 3 +-- .../metaprogramming/MacroExpressionTest.groovy | 3 +-- .../test/metaprogramming/MacroStatementTest.groovy | 4 +--- .../MacroVariableSubstitutionTest.groovy | 4 +--- .../MethodPropertyMissingTest.groovy | 4 +--- ...taticPropertyMissingAndMethodMissingTest.groovy | 3 +-- src/spec/test/objectorientation/MethodsTest.groovy | 3 +-- src/spec/test/semantics/GPathTest.groovy | 3 +-- src/spec/test/semantics/TheGroovyTruthTest.groovy | 3 +-- src/spec/test/support/StaticStringExtension.groovy | 2 +- src/spec/test/testingguide/GDKMethodTests.groovy | 3 +-- .../testingguide/GroovyTestCaseExampleTests.groovy | 3 +-- .../test/testingguide/JUnit4ExampleTests.groovy | 2 +- .../test/testingguide/MockingExampleTests.groovy | 12 ++++++++++- src/spec/test/typing/OptionalTypingTest.groovy | 3 +-- src/spec/test/typing/PrecompiledJavaExtension.java | 5 +---- src/spec/test/typing/Robot.groovy | 2 +- src/spec/test/typing/TypeCheckingJavaTest.java | 4 +++- src/test/java/groovy/NamedParameterHelper.java | 11 ++++++---- .../concurrentlinkedhashmap/LinkedDequeTest.java | 2 +- .../groovy/util/CharSequenceReaderTest.java | 2 +- 60 files changed, 170 insertions(+), 133 deletions(-) diff --git a/src/spec/test/BaseScriptSpecTest.groovy b/src/spec/test/BaseScriptSpecTest.groovy index e94b8db786..ce29ae67ff 100644 --- a/src/spec/test/BaseScriptSpecTest.groovy +++ b/src/spec/test/BaseScriptSpecTest.groovy @@ -18,11 +18,14 @@ */ import groovy.transform.CompileStatic +import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript @CompileStatic -class BaseScriptSpecTest { +final class BaseScriptSpecTest { + + @Test void testSimpleScript() { def script = ''' // tag::simple_script[] @@ -35,6 +38,7 @@ assert (this instanceof Script) assert o instanceof Script } + @Test void testScriptWithBinding() { // tag::integ_binding[] def binding = new Binding() // <1> @@ -46,6 +50,7 @@ assert (this instanceof Script) // end::integ_binding[] } + @Test void testBaseClassThroughConfig() { assertScript '''import org.codehaus.groovy.control.CompilerConfiguration // tag::baseclass_def[] @@ -67,6 +72,7 @@ assert (this instanceof Script) ''' } + @Test void testBaseClassThroughBaseScript() { assertScript ''' abstract class MyBaseClass extends Script { @@ -105,6 +111,7 @@ assert (this instanceof Script) ''' } + @Test void testBaseClassCustomRunMethod() { assertScript '''import org.codehaus.groovy.control.CompilerConfiguration @@ -140,6 +147,7 @@ assert (this instanceof Script) ''' } + @Test void testBaseScriptJep445Example() { assertScript '''import groovy.transform.BaseScript // tag::jep445_example[] @@ -154,5 +162,4 @@ assert (this instanceof Script) // end::jep445_example[] ''' } - } diff --git a/src/spec/test/ClassDesignASTTransformsTest.groovy b/src/spec/test/ClassDesignASTTransformsTest.groovy index 7ea9432b71..2d7b8d2e4a 100644 --- a/src/spec/test/ClassDesignASTTransformsTest.groovy +++ b/src/spec/test/ClassDesignASTTransformsTest.groovy @@ -17,12 +17,11 @@ * under the License. */ - import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class ClassDesignASTTransformsTest { +final class ClassDesignASTTransformsTest { @Test void testDelegateTransformation() { @@ -485,5 +484,4 @@ assert Factorial.factorial(50000).toString().size() == 213237 // Big number and // end::tailrecursive[] ''' } - } diff --git a/src/spec/test/ClassTest.groovy b/src/spec/test/ClassTest.groovy index 2a18cacbd5..74bae6462a 100644 --- a/src/spec/test/ClassTest.groovy +++ b/src/spec/test/ClassTest.groovy @@ -17,9 +17,14 @@ * under the License. */ +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript +import static groovy.test.GroovyAssert.shouldFail final class ClassTest { + @Test void testClassDefinition() { assertScript ''' // tag::class_definition[] @@ -41,6 +46,7 @@ final class ClassTest { ''' } + @Test void testInnerInstantiation() { assertScript ''' // tag::inner_instantiation[] @@ -59,6 +65,7 @@ final class ClassTest { ''' } + @Test void testInnerClass() { assertScript ''' // tag::inner_class[] @@ -80,6 +87,7 @@ final class ClassTest { ''' } + @Test void testInnerClass2() { assertScript ''' // tag::inner_class2[] @@ -101,6 +109,7 @@ final class ClassTest { ''' } + @Test void testAnonymousInnerClass() { assertScript ''' // tag::anonymous_inner_class[] @@ -120,6 +129,7 @@ final class ClassTest { ''' } + @Test void testAbstractClass() { assertScript ''' // tag::abstract_class[] @@ -137,6 +147,7 @@ final class ClassTest { ''' } + @Test void testConstructorPositionalParameters() { assertScript ''' // tag::constructor_positional_parameters[] @@ -161,6 +172,7 @@ final class ClassTest { ''' } + @Test void testConstructorNamedParameters() { assertScript ''' // tag::constructor_named_parameters[] @@ -179,6 +191,7 @@ final class ClassTest { ''' } + @Test void testInterfaceDefinition() { assertScript ''' // tag::interface_def_1[] @@ -232,6 +245,7 @@ final class ClassTest { assert err.message.contains("The method 'greet' must be public as it is declared abstract in interface 'Greeter'") } + @Test void testFields() { assertScript ''' // tag::field_declaration[] @@ -267,6 +281,7 @@ final class ClassTest { ''' } + @Test void testProperties() { assertScript ''' // tag::properties_definition[] @@ -379,6 +394,7 @@ final class ClassTest { ''' } + @Test void testDefineAnnotation() { assertScript ''' // tag::define_annotation[] @@ -388,6 +404,7 @@ final class ClassTest { ''' } + @Test void testAnnotationMembers() { assertScript ''' // tag::ann_member_string[] @@ -441,6 +458,7 @@ final class ClassTest { ''' } + @Test void testApplyAnnotation() { assertScript ''' @interface SomeAnnotation { @@ -500,6 +518,7 @@ final class ClassTest { ''' } + @Test void testAnnotationTarget() { assertScript ''' // tag::ann_target[] @@ -513,6 +532,7 @@ final class ClassTest { ''' } + @Test void testAnnotationRetention() { assertScript ''' // tag::ann_retention[] @@ -526,6 +546,7 @@ final class ClassTest { ''' } + @Test void testClosureAsAnnotationValue() { assertScript ''' import java.lang.annotation.Retention @@ -586,6 +607,7 @@ final class ClassTest { ''' } + @Test void testAnnotationCollector() { assertScript '''import java.lang.annotation.Retention import java.lang.annotation.RetentionPolicy @@ -635,6 +657,7 @@ import java.lang.annotation.RetentionPolicy ''' } + @Test void testAnnotationCollectorWithParams() { assertScript ''' import java.lang.annotation.Retention @@ -667,6 +690,7 @@ import java.lang.annotation.RetentionPolicy ''' } + @Test void testAnnotationCollectorWithSameParamNames() { assertScript ''' @@ -732,6 +756,7 @@ import java.lang.annotation.Retention assert err.message =~ /Attribute 'value' should have type 'java.lang.String'; but found type 'int' in @Foo/ } + @Test void testCustomProcessor() { assertScript '''import groovy.transform.AnnotationCollector import groovy.transform.CompileStatic diff --git a/src/spec/test/CloningASTTransformsTest.groovy b/src/spec/test/CloningASTTransformsTest.groovy index 02193651a9..3683f2f587 100644 --- a/src/spec/test/CloningASTTransformsTest.groovy +++ b/src/spec/test/CloningASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class CloningASTTransformsTest { +final class CloningASTTransformsTest { + @Test void testAutoCloneAnnotation() { assertScript ''' diff --git a/src/spec/test/ClosuresSpecTest.groovy b/src/spec/test/ClosuresSpecTest.groovy index 8a1876e04c..ba015fe362 100644 --- a/src/spec/test/ClosuresSpecTest.groovy +++ b/src/spec/test/ClosuresSpecTest.groovy @@ -1,7 +1,3 @@ -import org.junit.jupiter.api.Test - -import static groovy.test.GroovyAssert.assertScript - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,7 +16,13 @@ import static groovy.test.GroovyAssert.assertScript * specific language governing permissions and limitations * under the License. */ -class ClosuresSpecTest { + +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript + +final class ClosuresSpecTest { + static void sink(Closure cl) {} @Test diff --git a/src/spec/test/CodeGenerationASTTransformsTest.groovy b/src/spec/test/CodeGenerationASTTransformsTest.groovy index 41b5b30de7..4a8158e05c 100644 --- a/src/spec/test/CodeGenerationASTTransformsTest.groovy +++ b/src/spec/test/CodeGenerationASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class CodeGenerationASTTransformsTest { +final class CodeGenerationASTTransformsTest { // specification tests for the @ToString AST transformation @Test diff --git a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy index 92d4df63a9..f2c7cb2955 100644 --- a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy +++ b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -23,7 +22,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class CompilerDirectivesASTTransformsTest { +final class CompilerDirectivesASTTransformsTest { + @Test void testFieldXForm() { shouldFail(MissingPropertyException) { diff --git a/src/spec/test/CustomizersTest.groovy b/src/spec/test/CustomizersTest.groovy index ed30789bdf..9ea91ded39 100644 --- a/src/spec/test/CustomizersTest.groovy +++ b/src/spec/test/CustomizersTest.groovy @@ -47,7 +47,7 @@ import static org.codehaus.groovy.syntax.Types.PLUS_PLUS import static org.codehaus.groovy.syntax.Types.POWER import static org.codehaus.groovy.syntax.Types.REMAINDER -class CustomizersTest { +final class CustomizersTest { private CompilerConfiguration config; private GroovyShell shell; diff --git a/src/spec/test/DeclarativeConcurrencyASTTransformsTest.groovy b/src/spec/test/DeclarativeConcurrencyASTTransformsTest.groovy index 356fbffd94..0c2a1f440d 100644 --- a/src/spec/test/DeclarativeConcurrencyASTTransformsTest.groovy +++ b/src/spec/test/DeclarativeConcurrencyASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class DeclarativeConcurrencyASTTransformsTest { +final class DeclarativeConcurrencyASTTransformsTest { + @Test void testSynchronizedASTTransform() { assertScript ''' diff --git a/src/spec/test/DelegatesToSpecTest.groovy b/src/spec/test/DelegatesToSpecTest.groovy index 97d78b8c20..0e6fd7b461 100644 --- a/src/spec/test/DelegatesToSpecTest.groovy +++ b/src/spec/test/DelegatesToSpecTest.groovy @@ -17,14 +17,14 @@ * under the License. */ - import org.codehaus.groovy.control.MultipleCompilationErrorsException import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class DelegatesToSpecTest { +final class DelegatesToSpecTest { + @Test void testEmailWithoutDelegatesTo() { assertScript ''' diff --git a/src/spec/test/DesignPatternsTest.groovy b/src/spec/test/DesignPatternsTest.groovy index a8bb145591..79f453c047 100644 --- a/src/spec/test/DesignPatternsTest.groovy +++ b/src/spec/test/DesignPatternsTest.groovy @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + import gls.CompilableTestSupport import org.junit.jupiter.api.Test diff --git a/src/spec/test/DifferencesFromJavaTest.groovy b/src/spec/test/DifferencesFromJavaTest.groovy index 5471c73e57..d3a1196ea0 100644 --- a/src/spec/test/DifferencesFromJavaTest.groovy +++ b/src/spec/test/DifferencesFromJavaTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -23,7 +22,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class DifferencesFromJavaTest { +final class DifferencesFromJavaTest { + @Test void testMultiMethods() { assertScript '''import static org.junit.jupiter.api.Assertions.* diff --git a/src/spec/test/ExtensionModuleSpecTest.groovy b/src/spec/test/ExtensionModuleSpecTest.groovy index b095a3ef42..c412ae3fc0 100644 --- a/src/spec/test/ExtensionModuleSpecTest.groovy +++ b/src/spec/test/ExtensionModuleSpecTest.groovy @@ -1,7 +1,3 @@ -import org.junit.jupiter.api.Test - -import static groovy.test.GroovyAssert.assertScript - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,7 +16,13 @@ import static groovy.test.GroovyAssert.assertScript * specific language governing permissions and limitations * under the License. */ -class ExtensionModuleSpecTest { + +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript + +final class ExtensionModuleSpecTest { + @Test void testShouldAddMaxRetriesToInteger() { assertScript '''// tag::instance_extension_assert[] diff --git a/src/spec/test/IntegrationTest.groovy b/src/spec/test/IntegrationTest.groovy index c072bfdda3..ca2e71c9c9 100644 --- a/src/spec/test/IntegrationTest.groovy +++ b/src/spec/test/IntegrationTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,7 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -class IntegrationTest { + +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript + +final class IntegrationTest { + + @Test void testEval() { assertScript '''// tag::eval_me[] import groovy.util.Eval @@ -36,6 +42,7 @@ assert Eval.xyz(4, 5, 6, 'x*y+z') == 26 // <4> ''' } + @Test void testGroovyShell() { assertScript '''// tag::groovyshell_simple[] def shell = new GroovyShell() // <1> @@ -120,6 +127,7 @@ assert b1 != b2 ''' } + @Test void testGroovyShellCustomScript() { assertScript '''// tag::custom_script_imports[] import org.codehaus.groovy.control.CompilerConfiguration @@ -148,6 +156,7 @@ assert script.run() == 'Hello, Michel!' ''' } + @Test void testGroovyClassLoader() { assertScript '''// tag::gcl[] import groovy.lang.GroovyClassLoader @@ -189,6 +198,7 @@ file.delete() ''' } + @Test void testGroovyScriptEngine() { assertScript '''def tmpDir = File.createTempDir("reloading", "gse") @@ -246,5 +256,4 @@ try { } ''' } - } diff --git a/src/spec/test/LogImprovementsASTTransformsTest.groovy b/src/spec/test/LogImprovementsASTTransformsTest.groovy index 238de2bb0c..c2b37b12a4 100644 --- a/src/spec/test/LogImprovementsASTTransformsTest.groovy +++ b/src/spec/test/LogImprovementsASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class LogImprovementsASTTransformsTest { +final class LogImprovementsASTTransformsTest { @Test void testLogASTTransformation() { @@ -200,5 +199,4 @@ def g = new Greeter() g.greet() ''' } - } diff --git a/src/spec/test/OperatorsTest.groovy b/src/spec/test/OperatorsTest.groovy index 09e3b2b889..251b2ea0da 100644 --- a/src/spec/test/OperatorsTest.groovy +++ b/src/spec/test/OperatorsTest.groovy @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + import org.junit.jupiter.api.Test import java.util.regex.Matcher diff --git a/src/spec/test/PrimitiveTest.groovy b/src/spec/test/PrimitiveTest.groovy index f433d3fcf3..2e42a23b2e 100644 --- a/src/spec/test/PrimitiveTest.groovy +++ b/src/spec/test/PrimitiveTest.groovy @@ -1,7 +1,3 @@ -import org.junit.jupiter.api.Test - -import static groovy.test.GroovyAssert.assertScript - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,7 +16,12 @@ import static groovy.test.GroovyAssert.assertScript * specific language governing permissions and limitations * under the License. */ -class PrimitiveTest { + +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript + +final class PrimitiveTest { @Test void testPrimitiveReferences() { diff --git a/src/spec/test/RecordSpecificationTest.groovy b/src/spec/test/RecordSpecificationTest.groovy index 1fd22895ca..6424946521 100644 --- a/src/spec/test/RecordSpecificationTest.groovy +++ b/src/spec/test/RecordSpecificationTest.groovy @@ -17,16 +17,14 @@ * under the License. */ - -/** - * Specification tests for records - */ - import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class RecordSpecificationTest { +/** + * Specification tests for records + */ +final class RecordSpecificationTest { @Test void testSimpleRecordKeyword() { diff --git a/src/spec/test/SaferScriptingASTTransformsTest.groovy b/src/spec/test/SaferScriptingASTTransformsTest.groovy index baf5416931..cad0de2a3a 100644 --- a/src/spec/test/SaferScriptingASTTransformsTest.groovy +++ b/src/spec/test/SaferScriptingASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class SaferScriptingASTTransformsTest { +final class SaferScriptingASTTransformsTest { + @Test void testThreadInterrupt() { assertScript '''import groovy.transform.ThreadInterrupt @@ -294,6 +294,7 @@ assert Quotas.quotas['user'] < 0 // end::conditionalinterrupt_injected[] ''' } + @Test void testConditionalInterruptThrown() { assertScript '''import groovy.transform.ConditionalInterrupt @@ -352,5 +353,4 @@ assert Quotas.quotas['user'] == 'Quota exceeded' // end::conditionalinterrupt_thrown[] ''' } - } diff --git a/src/spec/test/ScriptsAndClassesSpecTest.groovy b/src/spec/test/ScriptsAndClassesSpecTest.groovy index 70295735ac..f4e4b2eff0 100644 --- a/src/spec/test/ScriptsAndClassesSpecTest.groovy +++ b/src/spec/test/ScriptsAndClassesSpecTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class ScriptsAndClassesSpecTest { +final class ScriptsAndClassesSpecTest { + @Test void testMainMethod() { assertScript ''' @@ -83,6 +83,8 @@ class ScriptsAndClassesSpecTest { @Test void testJep445Definition() { + def runScript = { scriptText -> new GroovyShell().run(scriptText, 'ScriptSnippet', new String[0]) } + runScript ''' // tag::jep445_barescript[] void main(args) { @@ -160,8 +162,4 @@ class ScriptsAndClassesSpecTest { // end::script_with_untyped_variables[] ''' } - - private static void runScript(String scriptText) { - new GroovyShell().run(scriptText, 'ScriptSnippet', [] as String[]) - } } diff --git a/src/spec/test/SealedSpecificationTest.groovy b/src/spec/test/SealedSpecificationTest.groovy index 1c938f24d5..06f8a49433 100644 --- a/src/spec/test/SealedSpecificationTest.groovy +++ b/src/spec/test/SealedSpecificationTest.groovy @@ -17,12 +17,16 @@ * under the License. */ +import org.junit.jupiter.api.Test + +import static groovy.test.GroovyAssert.assertScript /** * Specification tests for the traits feature */ -class SealedSpecificationTest { +final class SealedSpecificationTest { + @Test void testSealedADT() { assertScript ''' // tag::sealed_ADT[] @@ -43,6 +47,7 @@ assert tree.toString() == 'Node(42, Node(0, Empty, Empty), Empty)' ''' } + @Test void testSealedRecordADT() { assertScript ''' // tag::sealedRecord_ADT[] @@ -58,6 +63,7 @@ assert threePlusNegOne.toString() == 'PlusExpr[e1=ConstExpr[i=3], e2=NegExpr[e=C ''' } + @Test void testSimpleSealedHierarchyInterfaces() { assertScript ''' import groovy.transform.Sealed @@ -83,6 +89,7 @@ assert [new Circle(), new Square()]*.class.name == ['Circle', 'Square'] ''' } + @Test void testSimpleSealedHierarchyClasses() { assertScript ''' import groovy.transform.Sealed @@ -124,6 +131,7 @@ assert [new Circle(), new Square(), new Hexagon()]*.class.name == ['Circle', 'Sq ''' } + @Test void testEnum() { assertScript ''' // tag::weather_enum[] @@ -134,6 +142,7 @@ assert forecast.toString() == '[Rainy, Sunny, Cloudy]' ''' } + @Test void testSealedWeather() { assertScript ''' import groovy.transform.* diff --git a/src/spec/test/StyleGuideTest.groovy b/src/spec/test/StyleGuideTest.groovy index 7fa51961f2..a645b8023b 100644 --- a/src/spec/test/StyleGuideTest.groovy +++ b/src/spec/test/StyleGuideTest.groovy @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + import org.junit.jupiter.api.Test final class StyleGuideTest { diff --git a/src/spec/test/SwingASTTransformsTest.groovy b/src/spec/test/SwingASTTransformsTest.groovy index 97f78313a3..5a0903bff1 100644 --- a/src/spec/test/SwingASTTransformsTest.groovy +++ b/src/spec/test/SwingASTTransformsTest.groovy @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +21,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class SwingASTTransformsTest { +final class SwingASTTransformsTest { + @Test void testBindable() { assertScript '''// tag::bindable_on_class[] @@ -322,5 +322,4 @@ p.age = 145 assert changed == ['age'] as Set ''' } - } diff --git a/src/spec/test/TestingASTTransformsTest.groovy b/src/spec/test/TestingASTTransformsTest.groovy index 410ca65d4d..f725175e27 100644 --- a/src/spec/test/TestingASTTransformsTest.groovy +++ b/src/spec/test/TestingASTTransformsTest.groovy @@ -17,13 +17,12 @@ * under the License. */ - import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class TestingASTTransformsTest { +final class TestingASTTransformsTest { @Test void testNotYetImplemented() { diff --git a/src/spec/test/TraitsSpecificationTest.groovy b/src/spec/test/TraitsSpecificationTest.groovy index 7e6efac2b5..e7333cac4f 100644 --- a/src/spec/test/TraitsSpecificationTest.groovy +++ b/src/spec/test/TraitsSpecificationTest.groovy @@ -17,18 +17,16 @@ * under the License. */ - import org.codehaus.groovy.ast.ClassHelper import org.junit.jupiter.api.Test -/** - * Specification tests for the traits feature - */ - import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class TraitsSpecificationTest { +/** + * Specification tests for the traits feature + */ +final class TraitsSpecificationTest { @Test void testTraitDeclaration() { diff --git a/src/spec/test/asciidoctor/Utils.groovy b/src/spec/test/asciidoctor/Utils.groovy index af28b5031a..de9cac3a0b 100644 --- a/src/spec/test/asciidoctor/Utils.groovy +++ b/src/spec/test/asciidoctor/Utils.groovy @@ -21,8 +21,11 @@ package asciidoctor import groovy.transform.CompileStatic @CompileStatic -class Utils { - public static String stripAsciidocMarkup(String string, String newline='\n') { +final class Utils { + + private Utils() {} + + static String stripAsciidocMarkup(String string, String newline = '\n') { boolean inside = false StringBuilder sb = new StringBuilder() new StringReader(string).eachLine { line -> diff --git a/src/spec/test/builder/BuilderSpecTest.groovy b/src/spec/test/builder/BuilderSpecTest.groovy index f38180f01d..5bd349048e 100644 --- a/src/spec/test/builder/BuilderSpecTest.groovy +++ b/src/spec/test/builder/BuilderSpecTest.groovy @@ -24,7 +24,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript @CompileStatic -class BuilderSpecTest { +final class BuilderSpecTest { + @Test void testBuilderSupport() { assertScript ''' diff --git a/src/spec/test/gdk/ConfigSlurperTest.groovy b/src/spec/test/gdk/ConfigSlurperTest.groovy index 242d7246c8..3f1c8f0d5a 100644 --- a/src/spec/test/gdk/ConfigSlurperTest.groovy +++ b/src/spec/test/gdk/ConfigSlurperTest.groovy @@ -20,8 +20,8 @@ package gdk import org.junit.jupiter.api.Test +final class ConfigSlurperTest { -class ConfigSlurperTest { @Test void testWithArbitraryTypes() { // tag::arbitrary_types[] diff --git a/src/spec/test/gdk/ExpandoTest.groovy b/src/spec/test/gdk/ExpandoTest.groovy index 8e02c9a622..cdc37bafc3 100644 --- a/src/spec/test/gdk/ExpandoTest.groovy +++ b/src/spec/test/gdk/ExpandoTest.groovy @@ -20,8 +20,8 @@ package gdk import org.junit.jupiter.api.Test +final class ExpandoTest { -class ExpandoTest { @Test void testExpandoAddProperty() { // tag::expando_property[] @@ -43,5 +43,4 @@ class ExpandoTest { assert expando.say('Hi') == 'John says: Hi' // end::expando_method[] } - } diff --git a/src/spec/test/gdk/ObservableTest.groovy b/src/spec/test/gdk/ObservableTest.groovy index 0e205902bb..b51b62ffb7 100644 --- a/src/spec/test/gdk/ObservableTest.groovy +++ b/src/spec/test/gdk/ObservableTest.groovy @@ -22,12 +22,11 @@ import org.junit.jupiter.api.Test import java.beans.PropertyChangeListener -class ObservableTest { +final class ObservableTest { @Test void testObservableList() { // tag::observable_list[] - def event // <1> def listener = { if (it instanceof ObservableList.ElementEvent) { // <2> diff --git a/src/spec/test/gdk/WorkingWithCollectionsTest.groovy b/src/spec/test/gdk/WorkingWithCollectionsTest.groovy index 71a7dc5bf6..bf8a0f3854 100644 --- a/src/spec/test/gdk/WorkingWithCollectionsTest.groovy +++ b/src/spec/test/gdk/WorkingWithCollectionsTest.groovy @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript +final class WorkingWithCollectionsTest { -class WorkingWithCollectionsTest { @Test void testListLiterals() { // tag::list_literals[] diff --git a/src/spec/test/gdk/WorkingWithIOSpecTest.groovy b/src/spec/test/gdk/WorkingWithIOSpecTest.groovy index d3cf619465..94bf46c5e9 100644 --- a/src/spec/test/gdk/WorkingWithIOSpecTest.groovy +++ b/src/spec/test/gdk/WorkingWithIOSpecTest.groovy @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test import static org.junit.jupiter.api.Assumptions.assumeTrue -class WorkingWithIOSpecTest { +final class WorkingWithIOSpecTest { private final static boolean unixlike = System.getProperty('os.name').contains('Linux') || diff --git a/src/spec/test/metaprogramming/ASTMatcherFilteringTest.groovy b/src/spec/test/metaprogramming/ASTMatcherFilteringTest.groovy index a9de1cb1b8..4ca5c6eed6 100644 --- a/src/spec/test/metaprogramming/ASTMatcherFilteringTest.groovy +++ b/src/spec/test/metaprogramming/ASTMatcherFilteringTest.groovy @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming import groovy.transform.CompileStatic @@ -39,7 +38,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript -class ASTMatcherFilteringTest { +final class ASTMatcherFilteringTest { @Test void testFilteringNodes() { diff --git a/src/spec/test/metaprogramming/ASTMatcherTestingTest.groovy b/src/spec/test/metaprogramming/ASTMatcherTestingTest.groovy index 86fa13532e..94291a56b4 100644 --- a/src/spec/test/metaprogramming/ASTMatcherTestingTest.groovy +++ b/src/spec/test/metaprogramming/ASTMatcherTestingTest.groovy @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming - import org.codehaus.groovy.ast.ASTNode import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.MethodNode @@ -42,7 +40,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript import static org.codehaus.groovy.ast.tools.GeneralUtils.varX -class ASTMatcherTestingTest { +final class ASTMatcherTestingTest { // tag::testexpression[] @Test diff --git a/src/spec/test/metaprogramming/ASTXFormSpecTest.groovy b/src/spec/test/metaprogramming/ASTXFormSpecTest.groovy index 56603d1358..63b7d09a30 100644 --- a/src/spec/test/metaprogramming/ASTXFormSpecTest.groovy +++ b/src/spec/test/metaprogramming/ASTXFormSpecTest.groovy @@ -27,7 +27,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript -class ASTXFormSpecTest { +final class ASTXFormSpecTest { + @Test void testLocalTransform() { def gcl = new GroovyClassLoader() diff --git a/src/spec/test/metaprogramming/ExpandoMetaClassTest.groovy b/src/spec/test/metaprogramming/ExpandoMetaClassTest.groovy index bcbc2adf41..63b7a9d2ce 100644 --- a/src/spec/test/metaprogramming/ExpandoMetaClassTest.groovy +++ b/src/spec/test/metaprogramming/ExpandoMetaClassTest.groovy @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript - -class ExpandoMetaClassTest { +final class ExpandoMetaClassTest { @Test void testConstructors() { @@ -263,7 +262,4 @@ class ExpandoMetaClassTest { // end::emc_interface[] ''' } - - - } diff --git a/src/spec/test/metaprogramming/GroovyObjectTest.groovy b/src/spec/test/metaprogramming/GroovyObjectTest.groovy index fd7e682062..c04dd3933b 100644 --- a/src/spec/test/metaprogramming/GroovyObjectTest.groovy +++ b/src/spec/test/metaprogramming/GroovyObjectTest.groovy @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript +final class GroovyObjectTest { -class GroovyObjectTest { @Test void testInvokeMethod() { assertScript ''' diff --git a/src/spec/test/metaprogramming/InterceptableTest.groovy b/src/spec/test/metaprogramming/InterceptableTest.groovy index ef67837476..650813d7c2 100644 --- a/src/spec/test/metaprogramming/InterceptableTest.groovy +++ b/src/spec/test/metaprogramming/InterceptableTest.groovy @@ -20,9 +20,8 @@ package metaprogramming import org.junit.jupiter.api.Test - // tag::groovy_interceptable_test[] -class InterceptableTest { +final class InterceptableTest { @Test void testCheckInterception() { diff --git a/src/spec/test/metaprogramming/InterceptionThroughMetaClassTest.groovy b/src/spec/test/metaprogramming/InterceptionThroughMetaClassTest.groovy index d3097de6d6..7a20cf8995 100644 --- a/src/spec/test/metaprogramming/InterceptionThroughMetaClassTest.groovy +++ b/src/spec/test/metaprogramming/InterceptionThroughMetaClassTest.groovy @@ -22,7 +22,7 @@ import groovy.xml.Entity import org.junit.jupiter.api.Test // tag::meta_class_interception[] -class InterceptionThroughMetaClassTest { +final class InterceptionThroughMetaClassTest { @Test void testPOJOMetaClassInterception() { diff --git a/src/spec/test/metaprogramming/MacroClassTest.groovy b/src/spec/test/metaprogramming/MacroClassTest.groovy index b8166da4f5..52d35532f4 100644 --- a/src/spec/test/metaprogramming/MacroClassTest.groovy +++ b/src/spec/test/metaprogramming/MacroClassTest.groovy @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming import groovy.transform.CompileDynamic @@ -40,7 +39,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript import static org.codehaus.groovy.ast.tools.GeneralUtils.constX -class MacroClassTest { +final class MacroClassTest { @Test void testMacroClass() { diff --git a/src/spec/test/metaprogramming/MacroExpressionTest.groovy b/src/spec/test/metaprogramming/MacroExpressionTest.groovy index 99196623df..9c4325287f 100644 --- a/src/spec/test/metaprogramming/MacroExpressionTest.groovy +++ b/src/spec/test/metaprogramming/MacroExpressionTest.groovy @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming import org.codehaus.groovy.ast.ASTNode @@ -42,7 +41,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript import static org.objectweb.asm.Opcodes.ACC_PUBLIC -class MacroExpressionTest { +final class MacroExpressionTest { @Test void testCreateExpressions() { diff --git a/src/spec/test/metaprogramming/MacroStatementTest.groovy b/src/spec/test/metaprogramming/MacroStatementTest.groovy index 81a2233441..af865e22a4 100644 --- a/src/spec/test/metaprogramming/MacroStatementTest.groovy +++ b/src/spec/test/metaprogramming/MacroStatementTest.groovy @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming - import org.codehaus.groovy.ast.ASTNode import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.ClassNode @@ -42,7 +40,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript import static org.objectweb.asm.Opcodes.ACC_PUBLIC -class MacroStatementTest { +final class MacroStatementTest { @Test void testOlderASTTransformation() { diff --git a/src/spec/test/metaprogramming/MacroVariableSubstitutionTest.groovy b/src/spec/test/metaprogramming/MacroVariableSubstitutionTest.groovy index 116819a35a..52479aac67 100644 --- a/src/spec/test/metaprogramming/MacroVariableSubstitutionTest.groovy +++ b/src/spec/test/metaprogramming/MacroVariableSubstitutionTest.groovy @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package metaprogramming - import org.codehaus.groovy.ast.ASTNode import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.ClassNode @@ -44,7 +42,7 @@ import java.lang.annotation.Target import static groovy.test.GroovyAssert.assertScript import static org.objectweb.asm.Opcodes.ACC_PUBLIC -class MacroVariableSubstitutionTest { +final class MacroVariableSubstitutionTest { @Test void testVariableSubstitution() { diff --git a/src/spec/test/metaprogramming/MethodPropertyMissingTest.groovy b/src/spec/test/metaprogramming/MethodPropertyMissingTest.groovy index ce3b562960..af26b3c45e 100644 --- a/src/spec/test/metaprogramming/MethodPropertyMissingTest.groovy +++ b/src/spec/test/metaprogramming/MethodPropertyMissingTest.groovy @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript - -class MethodPropertyMissingTest { +final class MethodPropertyMissingTest { @Test void testMethodMissing() { @@ -71,5 +70,4 @@ class MethodPropertyMissingTest { //end::property_missing_getter_setter[] ''' } - } diff --git a/src/spec/test/metaprogramming/StaticPropertyMissingAndMethodMissingTest.groovy b/src/spec/test/metaprogramming/StaticPropertyMissingAndMethodMissingTest.groovy index 6893a35a55..a3953f57bf 100644 --- a/src/spec/test/metaprogramming/StaticPropertyMissingAndMethodMissingTest.groovy +++ b/src/spec/test/metaprogramming/StaticPropertyMissingAndMethodMissingTest.groovy @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript - -class StaticPropertyMissingAndMethodMissingTest { +final class StaticPropertyMissingAndMethodMissingTest { @Test void testStaticMethodMissing() { diff --git a/src/spec/test/objectorientation/MethodsTest.groovy b/src/spec/test/objectorientation/MethodsTest.groovy index ec905112a7..554dec93c3 100644 --- a/src/spec/test/objectorientation/MethodsTest.groovy +++ b/src/spec/test/objectorientation/MethodsTest.groovy @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript import static groovy.test.GroovyAssert.shouldFail -class MethodsTest { +final class MethodsTest { @Test void testMethodDefinition() { @@ -290,5 +290,4 @@ class MethodsTest { // end::multi_method_distance_interface_over_super[] ''' } - } diff --git a/src/spec/test/semantics/GPathTest.groovy b/src/spec/test/semantics/GPathTest.groovy index 86ae76d78c..568b82bc86 100644 --- a/src/spec/test/semantics/GPathTest.groovy +++ b/src/spec/test/semantics/GPathTest.groovy @@ -21,7 +21,7 @@ package semantics import groovy.xml.XmlSlurper import org.junit.jupiter.api.Test -class GPathTest { +final class GPathTest { //tag::gpath_on_reflection_1[] void aMethodFoo() { println "This is aMethodFoo." } // <0> @@ -86,5 +86,4 @@ class GPathTest { assert root.level.sublevel[1].keyVal[0].key.text() == 'anotherKey' // <4> //end::gpath_on_xml_1[] } - } diff --git a/src/spec/test/semantics/TheGroovyTruthTest.groovy b/src/spec/test/semantics/TheGroovyTruthTest.groovy index fef181016c..7a58fdea9a 100644 --- a/src/spec/test/semantics/TheGroovyTruthTest.groovy +++ b/src/spec/test/semantics/TheGroovyTruthTest.groovy @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript - -class TheGroovyTruthTest { +final class TheGroovyTruthTest { @Test void testGroovyTruth() { diff --git a/src/spec/test/support/StaticStringExtension.groovy b/src/spec/test/support/StaticStringExtension.groovy index 5ae308452c..95869ad225 100644 --- a/src/spec/test/support/StaticStringExtension.groovy +++ b/src/spec/test/support/StaticStringExtension.groovy @@ -24,4 +24,4 @@ class StaticStringExtension { // <1> 'Hello, world!' } } -// end::static_extension[] \ No newline at end of file +// end::static_extension[] diff --git a/src/spec/test/testingguide/GDKMethodTests.groovy b/src/spec/test/testingguide/GDKMethodTests.groovy index d9aa55d0fa..f9ab03e719 100644 --- a/src/spec/test/testingguide/GDKMethodTests.groovy +++ b/src/spec/test/testingguide/GDKMethodTests.groovy @@ -20,8 +20,7 @@ package testingguide import org.junit.jupiter.api.Test - -class GDKMethodTests { +final class GDKMethodTests { // tag::combinations[] @Test diff --git a/src/spec/test/testingguide/GroovyTestCaseExampleTests.groovy b/src/spec/test/testingguide/GroovyTestCaseExampleTests.groovy index 937a915ec3..8c9c96143c 100644 --- a/src/spec/test/testingguide/GroovyTestCaseExampleTests.groovy +++ b/src/spec/test/testingguide/GroovyTestCaseExampleTests.groovy @@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNull import static org.junit.jupiter.api.Assertions.assertSame import static org.junit.jupiter.api.Assertions.assertTrue -class GroovyTestCaseExampleTests { +final class GroovyTestCaseExampleTests { /* // tag::assertions[] class MyTestCase { @@ -116,5 +116,4 @@ class MyTestCase { assert 1 == 2 } // end::not_yet_implemented_ast[] - } diff --git a/src/spec/test/testingguide/JUnit4ExampleTests.groovy b/src/spec/test/testingguide/JUnit4ExampleTests.groovy index 4e12e3adec..4030b0c0bd 100644 --- a/src/spec/test/testingguide/JUnit4ExampleTests.groovy +++ b/src/spec/test/testingguide/JUnit4ExampleTests.groovy @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.shouldFail -class JUnit4ExampleTests { +final class JUnit4ExampleTests { @Test void indexOutOfBoundsAccess() { diff --git a/src/spec/test/testingguide/MockingExampleTests.groovy b/src/spec/test/testingguide/MockingExampleTests.groovy index 798acc5585..bbc3cc598f 100644 --- a/src/spec/test/testingguide/MockingExampleTests.groovy +++ b/src/spec/test/testingguide/MockingExampleTests.groovy @@ -21,6 +21,7 @@ package testingguide import groovy.mock.interceptor.MockFor import groovy.mock.interceptor.StubFor import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.Test // tag::map_coercion[] class TranslationService { @@ -57,7 +58,7 @@ import org.junit.jupiter.api.AfterEach // end::emc2[] -class MockingExampleTests { +final class MockingExampleTests { @AfterEach void tearDown() { @@ -66,6 +67,7 @@ class MockingExampleTests { GroovySystem.metaClassRegistry.setMetaClass(Book, null) } + @Test void testMapCoercion() { // tag::map_coercion[] def service = [convert: { String key -> 'some text' }] as TranslationService @@ -73,6 +75,7 @@ class MockingExampleTests { // end::map_coercion[] } + @Test void testClosureCoercion() { // tag::closure_coercion[] def service = { String key -> 'some text' } as TranslationService @@ -80,6 +83,7 @@ class MockingExampleTests { // end::closure_coercion[] } + @Test void testSAMCoercion() { // tag::sam_coercion[] BaseService service = { -> println 'doing something' } @@ -87,6 +91,7 @@ class MockingExampleTests { // end::sam_coercion[] } + @Test void testMockFor() { // tag::mockFor[] def mock = new MockFor(Person) // <1> @@ -101,6 +106,7 @@ class MockingExampleTests { // end::mockFor[] } + @Test void testStubFor() { // tag::stubFor[] def stub = new StubFor(Person) // <1> @@ -118,6 +124,7 @@ class MockingExampleTests { // end::stubFor[] } + @Test void testEMC() { // tag::emc[] String.metaClass.swapCase = {-> @@ -138,6 +145,7 @@ class MockingExampleTests { // end::emc4[] } + @Test void testEMCStaticMethod() { // tag::emc2[] Book.metaClass.static.create << { String title -> new Book(title:title) } @@ -147,6 +155,7 @@ class MockingExampleTests { // end::emc2[] } + @Test void testEMCConstructor() { // tag::emc3[] Book.metaClass.constructor << { String title -> new Book(title:title) } @@ -156,6 +165,7 @@ class MockingExampleTests { // end::emc3[] } + @Test void testEMCPerObject() { // tag::emc5[] def b = new Book(title: "The Stand") diff --git a/src/spec/test/typing/OptionalTypingTest.groovy b/src/spec/test/typing/OptionalTypingTest.groovy index 258be51cb7..241097129c 100644 --- a/src/spec/test/typing/OptionalTypingTest.groovy +++ b/src/spec/test/typing/OptionalTypingTest.groovy @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript - -class OptionalTypingTest { +final class OptionalTypingTest { @Test void testOptionalTypingInVariableDeclaration() { diff --git a/src/spec/test/typing/PrecompiledJavaExtension.java b/src/spec/test/typing/PrecompiledJavaExtension.java index a779ffb871..1396751d63 100644 --- a/src/spec/test/typing/PrecompiledJavaExtension.java +++ b/src/spec/test/typing/PrecompiledJavaExtension.java @@ -22,8 +22,6 @@ package typing; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.expr.VariableExpression; import org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension; - - import org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor; public class PrecompiledJavaExtension extends AbstractTypeCheckingExtension { // <1> @@ -41,6 +39,5 @@ public class PrecompiledJavaExtension extends AbstractTypeCheckingExtension { } return false; } - } -// end::precompiled_java_extension[] \ No newline at end of file +// end::precompiled_java_extension[] diff --git a/src/spec/test/typing/Robot.groovy b/src/spec/test/typing/Robot.groovy index 8bc80e6347..3edf67afc9 100644 --- a/src/spec/test/typing/Robot.groovy +++ b/src/spec/test/typing/Robot.groovy @@ -22,4 +22,4 @@ package typing class Robot { Robot move(int qt) { this } } -// end::example_robot_classdef[] \ No newline at end of file +// end::example_robot_classdef[] diff --git a/src/spec/test/typing/TypeCheckingJavaTest.java b/src/spec/test/typing/TypeCheckingJavaTest.java index 5ec96b25ff..d6e41351f7 100644 --- a/src/spec/test/typing/TypeCheckingJavaTest.java +++ b/src/spec/test/typing/TypeCheckingJavaTest.java @@ -19,9 +19,11 @@ package typing; import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.assertEquals; -public class TypeCheckingJavaTest { +final class TypeCheckingJavaTest { + @Test public void testJavaMethodSelection() { // tag::java_method_selection_body[] diff --git a/src/test/java/groovy/NamedParameterHelper.java b/src/test/java/groovy/NamedParameterHelper.java index 1d2aad552c..37bc75b92c 100644 --- a/src/test/java/groovy/NamedParameterHelper.java +++ b/src/test/java/groovy/NamedParameterHelper.java @@ -21,20 +21,23 @@ package groovy; import groovy.transform.NamedParam; import groovy.transform.NamedParams; -import java.util.LinkedHashMap; +import java.util.Map; + +public final class NamedParameterHelper { + + private NamedParameterHelper() {} -public class NamedParameterHelper { public static String myJavaMethod(@NamedParams({ @NamedParam(value = "foo"), @NamedParam(value = "bar", type = String.class, required = true) - }) LinkedHashMap params) { + }) Map<String,Object> params) { return "foo = " + params.get("foo") + ", bar = " + params.get("bar"); } public static String myJavaMethod(@NamedParams({ @NamedParam(value = "foo", type = String.class, required = true), @NamedParam(value = "bar", type = Integer.class) - }) LinkedHashMap params, int num) { + }) Map<String,Object> params, int num) { return "foo = " + params.get("foo") + ", bar = " + params.get("bar") + ", num = " + num; } } diff --git a/src/test/java/org/apache/groovy/util/concurrent/concurrentlinkedhashmap/LinkedDequeTest.java b/src/test/java/org/apache/groovy/util/concurrent/concurrentlinkedhashmap/LinkedDequeTest.java index 4e57a15528..5c40dbf8d9 100644 --- a/src/test/java/org/apache/groovy/util/concurrent/concurrentlinkedhashmap/LinkedDequeTest.java +++ b/src/test/java/org/apache/groovy/util/concurrent/concurrentlinkedhashmap/LinkedDequeTest.java @@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit tests for {@link LinkedDeque}. */ -class LinkedDequeTest { +final class LinkedDequeTest { private LinkedDeque<TestNode> deque = new LinkedDeque<>(); diff --git a/src/test/java/org/codehaus/groovy/util/CharSequenceReaderTest.java b/src/test/java/org/codehaus/groovy/util/CharSequenceReaderTest.java index 2da2e42f83..2417584e44 100644 --- a/src/test/java/org/codehaus/groovy/util/CharSequenceReaderTest.java +++ b/src/test/java/org/codehaus/groovy/util/CharSequenceReaderTest.java @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit tests for {@link CharSequenceReader}. */ -class CharSequenceReaderTest { +final class CharSequenceReaderTest { @Test void testReadSingleCharacter() {
