You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by be...@apache.org on 2025/06/09 12:00:45 UTC
(tapestry-5) 01/01: TAP5-2809: Gradle conventions, fix unit tests
This is an automated email from the ASF dual-hosted git repository.
benw pushed a commit to branch gradle-improvements
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit d7bd5f2a450c95f012ff61969d437e4455e5070a
Author: Ben Weidig <be...@netzgut.net>
AuthorDate: Mon Jun 9 08:50:23 2025 +0200
TAP5-2809: Gradle conventions, fix unit tests
---
beanmodel/build.gradle | 35 +-
.../tapestry5/beanmodel/PropertyConduitSpec.groovy | 32 +-
build.gradle | 729 ++++++-------
buildSrc/build.gradle | 17 +-
.../main/groovy/tapestry.java-convention.gradle | 75 ++
.../tapestry.junit4-legacy-convention.gradle | 12 +
.../main/groovy/tapestry.junit5-convention.gradle | 13 +
.../groovy/tapestry.junit5-spock-convention.gradle | 11 +
.../groovy/tapestry.testing-base-convention.gradle | 61 ++
.../main/groovy/tapestry.testng-convention.gradle | 43 +
commons/build.gradle | 24 +-
genericsresolver-guava/build.gradle | 20 +-
genericsresolver-guava/src/test/conf/.gitignore | 1 -
.../internal/AbstractBeanModelSourceImplTest.java | 1083 ++++++++++----------
.../internal/GuavaBeanModelSourceImplTest.java | 1 +
gradle/libs.versions.toml | 137 +++
plastic/build.gradle | 19 +-
plastic/src/test/conf/testng.xml | 6 -
.../apache/tapestry5/plastic/PlasticUtilsTest.java | 1 -
quickstart/build.gradle | 2 +-
.../archetype-resources/build-spring-boot.gradle | 4 +-
.../archetype-resources/build.gradle | 4 +-
settings.gradle | 85 +-
sha256.gradle | 24 +-
ssh.gradle | 178 ++--
support/tapestry-core.launch | 2 +-
support/tapestry-ioc.launch | 2 +-
support/tapestry-spring.launch | 2 +-
tapestry-beanvalidator/build.gradle | 39 +-
.../TapestryBeanValidationIntegrationTests.java | 2 -
.../src/test/{conf => resources}/testng.xml | 9 +-
tapestry-clojure/build.gradle | 30 +-
.../apache/tapestry5/clojure/tests/TestModule.java | 13 +
tapestry-core/build.gradle | 116 ++-
.../tapestry5/internal/ThrowawayClassLoader.java | 3 +-
.../app1/PartialTemplateRendererTests.groovy | 32 +-
.../integration/cluster/ClusterTests.java | 23 +-
.../ComponentDependencyRegistryImplTest.java | 332 +++---
...ionApplicationStatePersistenceStrategyTest.java | 4 +-
.../test/{conf => resources}/testng-limited.xml | 0
.../src/test/{conf => resources}/testng.xml | 163 +--
tapestry-func/build.gradle | 12 +-
tapestry-func/src/test/conf/testng.xml | 8 -
.../org/apache/tapestry5/func/BaseFuncTest.java | 36 +-
.../org/apache/tapestry5/func/FlowToSetTests.java | 8 +-
.../java/org/apache/tapestry5/func/FuncTest.java | 251 ++---
.../org/apache/tapestry5/func/InterleaveTests.java | 13 +-
.../java/org/apache/tapestry5/func/MapperTest.java | 68 +-
.../java/org/apache/tapestry5/func/RangeTests.java | 15 +-
.../tapestry5/func/StringPredicateTests.java | 4 +-
.../org/apache/tapestry5/func/TakeDropTests.java | 18 +-
.../java/org/apache/tapestry5/func/TupleTests.java | 8 +-
.../org/apache/tapestry5/func/ZippedFlowTests.java | 68 +-
tapestry-hibernate-core/build.gradle | 25 +-
.../src/test/{conf => resources}/testng.xml | 0
tapestry-hibernate/build.gradle | 36 +-
.../EntityPersistentFieldStrategyTest.java | 2 -
.../internal/HibernateEntityValueEncoderTest.java | 3 +-
.../java/org/example/app0/pages/CachedForm.java | 9 +-
.../org/example/app0/pages/EncodeEntities.java | 13 +-
.../test/java/org/example/app0/pages/GridDemo.java | 8 +-
.../java/org/example/app0/pages/PersistEntity.java | 3 -
.../java/org/example/app0/pages/SSOEntity.java | 23 +-
.../org/example/app0/services/UserDAOImpl.java | 16 +-
.../src/test/{conf => resources}/testng.xml | 4 +-
tapestry-http/build.gradle | 26 +-
.../services/CorsHandlerHelperImplTest.java | 47 +-
.../services/CorsHttpServletRequestFilterTest.java | 8 +-
.../http/test/TapestryHttpIntegrationTests.java | 4 +-
.../tapestry5/http/test/services/AppModule.java | 8 +
tapestry-internal-test/build.gradle | 6 +-
tapestry-ioc-jcache/build.gradle | 45 +-
tapestry-ioc-junit/build.gradle | 13 +-
.../ioc/junit/TapestryIOCJUnit4ClassRunner.java | 150 ---
.../ioc/junit/TapestryIOCJUnitExtension.java | 108 ++
.../tapestry5/ioc/junit/TestRegistryManager.java | 226 ++--
...TapestryIOCJUnit4ClassRunnerAfterClassTest.java | 63 --
...apestryIOCJUnit4ClassRunnerAfterMethodTest.java | 65 --
.../TapestryIOCJUnit4ClassRunnerModuleDefTest.java | 69 --
.../ioc/junit/TapestryIOCJUnit5AfterClassTest.java | 74 ++
.../junit/TapestryIOCJUnit5AfterMethodTest.java | 69 ++
.../ioc/junit/TapestryIOCJUnit5ModuleDefTest.java | 74 ++
tapestry-ioc/build.gradle | 29 +-
.../ioc/internal/util/AbstractResource.java | 7 +-
.../ioc/test/internal/AdviseByMarkerModule2.java | 3 +-
.../ioc/test/internal/DecorateByMarkerModule2.java | 2 +-
.../test/internal/ServiceBuilderMethodFixture.java | 12 +-
.../ioc/test/internal/ServiceDecoratorFixture.java | 9 +-
tapestry-javadoc/build.gradle | 49 +-
.../apache/tapestry5/javadoc/ClassDescription.java | 37 +-
.../tapestry5/javadoc/ParameterDescription.java | 25 +-
.../tapestry5/javadoc/TapestryDocTaglet.java | 27 +-
tapestry-jmx/build.gradle | 21 +-
tapestry-jmx/src/test/conf/testng.xml | 12 -
tapestry-jmx/src/test/resources/testng.xml | 17 +
tapestry-jpa/build.gradle | 51 +-
.../src/test/{conf => resources}/testng.xml | 0
tapestry-json/build.gradle | 18 +-
tapestry-json/src/test/conf/testng.xml | 8 -
.../test/groovy/json/specs/CoercionsSpec.groovy | 29 -
.../test/groovy/json/specs/JSONArraySpec.groovy | 639 ------------
.../groovy/json/specs/JSONCollectorsSpec.groovy | 101 --
.../test/groovy/json/specs/JSONObjectSpec.groovy | 989 ------------------
.../src/test/groovy/json/specs/JSONSpec.groovy | 36 -
.../org/apache/tapestry5/json/CoercionsTest.java | 44 +
.../org/apache/tapestry5/json/JSONArrayTest.java | 488 +++++++++
.../apache/tapestry5/json/JSONCollectorsTest.java | 97 ++
.../org/apache/tapestry5/json/JSONObjectTest.java | 891 ++++++++++++++++
.../java/org/apache/tapestry5/json/JSONTest.java | 53 +
tapestry-kaptcha/build.gradle | 19 +-
.../kaptcha/components/KaptchaUnitTest.java | 10 +-
.../src/test/{conf => resources}/testng.xml | 1 +
tapestry-latest-java-tests/build.gradle | 27 +-
.../ioc/services/Java10And11NewFeatureTests.java | 35 +-
.../ioc/services/Java12And13NewFeatureTests.java | 15 +-
.../ioc/services/Java14NewFeatureTests.java | 14 +-
.../ioc/services/Java15To17NewFeatureTests.java | 14 +-
.../ioc/services/Java9NewFeatureTests.java | 15 +-
tapestry-mongodb/build.gradle | 33 +-
.../src/test/groovy/MongoDBSpec.groovy | 2 +
.../src/test/{conf => resources}/testng.xml | 0
tapestry-openapi-viewer/build.gradle | 9 +-
tapestry-rest-jackson/build.gradle | 19 +-
tapestry-runner/build.gradle | 28 +-
tapestry-spock/build.gradle | 26 +-
tapestry-spring/build.gradle | 30 +-
.../src/test/{conf => resources}/testng.xml | 0
tapestry-test-data/build.gradle | 4 +-
tapestry-test/build.gradle | 33 +-
.../org/apache/tapestry5/test/ErrorReporter.java | 3 +-
.../apache/tapestry5/test/SeleniumTestCase.java | 31 +-
.../tapestry5/test/TapestryTestConstants.java | 7 +-
.../src/test/{conf => resources}/testng.xml | 0
tapestry-upload/build.gradle | 29 +-
.../src/test/{conf => resources}/testng.xml | 0
tapestry-version-migrator/build.gradle | 22 +-
tapestry-webresources/build.gradle | 73 +-
.../services/web/WebResourcesTest.java | 4 +-
tapestry5-annotations/build.gradle | 2 +-
tapestry5-annotations/src/test/conf/testng.xml | 21 -
140 files changed, 4687 insertions(+), 4628 deletions(-)
diff --git a/beanmodel/build.gradle b/beanmodel/build.gradle
index 5adf920bd..c38282bd3 100644
--- a/beanmodel/build.gradle
+++ b/beanmodel/build.gradle
@@ -1,39 +1,34 @@
-import org.gradle.plugins.ide.idea.model.*
-import t5build.*
+plugins {
+ id 'tapestry.junit5-convention'
+ id 'antlr'
+}
description = "Fast class property discovery, reading and writing library based on bytecode generation. Extracted from Apache Tapestry, but not dependent on the Web framework (tapestry-core) nor the IoC one (tapestry-ioc)."
-//apply plugin: JavaPlugin
-apply plugin: 'antlr'
-
-buildDir = 'target/gradle-build'
dependencies {
- api project(":plastic")
- api project(":tapestry5-annotations")
- api project(":commons")
- implementation "org.slf4j:slf4j-api:${versions.slf4j}"
+ implementation project(":plastic")
+ implementation project(":tapestry5-annotations")
+ implementation project(":commons")
+
+ implementation libs.slf4j.api
- // ANTLR tool path used with the generateGrammarSource task
- antlr "org.antlr:antlr:3.5.2"
+ antlr libs.antlr
// Transitive will bring in the unwanted string template library as well
- implementation "org.antlr:antlr-runtime:3.5.2", {
+ implementation libs.antlr.runtime, {
exclude group: "org.antlr", module: "stringtemplate"
}
- testImplementation "org.testng:testng:${versions.testng}", { transitive = false }
- testImplementation "org.easymock:easymock:${versions.easymock}"
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
- testImplementation "org.spockframework:spock-core:${versions.spock}"
+ testImplementation platform(libs.spock.bom)
+ testImplementation libs.spock.core
}
clean.delete generateGrammarSource.outputDirectory
compileJava {
+ dependsOn generateGrammarSource
options.fork(memoryMaximumSize: '512m')
}
-test {
- useJUnit()
-}
\ No newline at end of file
+sourceSets.main.java.srcDirs += generateGrammarSource.outputDirectory
diff --git a/beanmodel/src/test/groovy/org/apache/tapestry5/beanmodel/PropertyConduitSpec.groovy b/beanmodel/src/test/groovy/org/apache/tapestry5/beanmodel/PropertyConduitSpec.groovy
index 57d43ba2a..c6134b3b2 100644
--- a/beanmodel/src/test/groovy/org/apache/tapestry5/beanmodel/PropertyConduitSpec.groovy
+++ b/beanmodel/src/test/groovy/org/apache/tapestry5/beanmodel/PropertyConduitSpec.groovy
@@ -1,14 +1,15 @@
package org.apache.tapestry5.beanmodel
-import org.apache.tapestry5.beanmodel.BeanModelSourceBuilder.CoercionTupleConfiguration
import org.apache.tapestry5.beanmodel.internal.services.PropertyAccessImpl
import org.apache.tapestry5.beanmodel.internal.services.PropertyConduitSourceImpl
import org.apache.tapestry5.beanmodel.internal.services.PropertyExpressionException
import org.apache.tapestry5.beanmodel.services.PlasticProxyFactoryImpl
import org.apache.tapestry5.beanmodel.services.PropertyConduitSource
+import org.apache.tapestry5.commons.MappedConfiguration
import org.apache.tapestry5.commons.internal.BasicTypeCoercions
import org.apache.tapestry5.commons.internal.services.StringInternerImpl
import org.apache.tapestry5.commons.internal.services.TypeCoercerImpl
+import org.apache.tapestry5.commons.services.CoercionTuple
import org.apache.tapestry5.commons.services.PlasticProxyFactory
import org.apache.tapestry5.commons.util.IntegerRange
import org.slf4j.LoggerFactory
@@ -88,6 +89,35 @@ class PropertyConduitSpec extends Specification {
}
}
+ private static class CoercionTupleConfiguration implements MappedConfiguration<CoercionTuple.Key, CoercionTuple> {
+
+ final Map<CoercionTuple.Key, CoercionTuple> tuples = [:]
+
+ @Override
+ void add(CoercionTuple.Key key, CoercionTuple tuple) {
+ tuples[key] = tuple
+ }
+
+ @Override
+ void addInstance(CoercionTuple.Key key, Class<? extends CoercionTuple> clazz) {
+ throw new RuntimeException("Not implemented")
+ }
+
+ Map<CoercionTuple.Key, CoercionTuple> getTuples() {
+ return tuples
+ }
+
+ @Override
+ void override(CoercionTuple.Key key, CoercionTuple value) {
+ throw new RuntimeException("Not implemented")
+ }
+
+ @Override
+ void overrideInstance(CoercionTuple.Key key, Class<? extends CoercionTuple> clazz) {
+ throw new RuntimeException("Not implemented")
+ }
+ }
+
RootBean root
@Shared
diff --git a/build.gradle b/build.gradle
index 94355316c..a8491487e 100755
--- a/build.gradle
+++ b/build.gradle
@@ -1,88 +1,66 @@
-description = "Apache Tapestry 5 Project"
-
-import org.apache.tools.ant.filters.ReplaceTokens
-
-apply plugin: "base"
-apply plugin: "maven-publish"
-
-apply from: "ssh.gradle"
-apply from: "md5.gradle"
-apply from: "sha256.gradle"
-
-project.ext.versions = [
- jetty: "11.0.16",
- tomcat: "10.1.13",
- testng: "7.5.1",
- easymock: "5.4.0",
- servletapi: "5.0.0",
- spock: "2.3-groovy-3.0",
- hibernate: "5.4.32.Final", // Upgrade postponed due too many API changes from 5 to 6
- slf4j: "1.7.25",
- geb: "2.0",
- selenium: "4.5.0",
- seleniumServer: "4.12.1",
- jackson: "2.13.1",
- jsonschemaGenerator: "4.20.0",
- junitJupiter: "5.10.2",
- commonsLang: "3.17.0",
- commonsIo: "2.17.0",
- webdriverManager: "5.3.1",
- injectApi: "2.0.1",
- annotationApi: "2.0.0",
- antlrRuntime: "3.5.3",
- hsqldb: "2.7.3:jdk8",
- snakeyaml: "2.3"
-]
-
-def artifactSuffix = "-jakarta"
-
-// Artifacts that have both an unsuffixed artifact from the javax branch
-// and a suffixed one from the master branch
-def suffixedArtifactNames = ["tapestry-core", "tapestry-http", "tapestry-test",
- "tapestry-runner", "tapestry-spring", "tapestry-kaptcha",
- "tapestry-openapi-viewer", "tapestry-upload", "tapestry-jmx",
- "tapestry-jpa", "tapestry-kaptcha", "tapestry-openapi-viewer",
- "tapestry-rest-jackson", "tapestry-webresources", "tapestry-cdi",
- "tapestry-ioc", "tapestry-ioc-jcache", "tapestry-jmx", "tapestry-spock",
- "tapestry-clojure", "tapestry-hibernate", "tapestry-hibernate-core",
- "tapestry-ioc-junit", "tapestry-latest-java-tests", "tapestry-mongodb",
- "tapestry-spock", "tapestry-beanvalidator"]
-
-ext.continuousIntegrationBuild = Boolean.getBoolean("ci")
-
-// Provided so that the CI server can override the normal version number for nightly builds.
-project.version = tapestryVersion()
-
-// Remember that when generating a release, this should be incremented. Also don"t forget to
-// tag the release in Git.
-// Version number is always "5.x(.y)?-SNAPSHOT" and only gets fixed, e.g. to 5.4-alpha-1
-// during a release
-
-def tapestryVersion() {
-
- def major = "5.10.0"
- def minor = ""
-
- // When building on the CI server, make sure -SNAPSHOT is appended, as it is a nightly build.
- // When building normally, or for a release, no suffix is desired.
- continuousIntegrationBuild ? major + "-SNAPSHOT" : major + minor
+plugins {
+ id 'base'
+ id 'maven-publish'
}
-// Let analysis.apache.org get in touch with our builds
-
-project.ext {
+apply from: 'ssh.gradle'
+apply from: 'md5.gradle'
+apply from: 'sha256.gradle'
- stagingUrl = "https://repository.apache.org/service/local/staging/deploy/maven2/"
- snapshotUrl = "https://repository.apache.org/content/repositories/snapshots"
+import org.apache.tools.ant.filters.ReplaceTokens
- doSign = !project.hasProperty("noSign") && project.hasProperty("signing.keyId")
+description = 'Apache Tapestry 5 Project'
+
+ext {
+ artifactSuffix = '-jakarta'
+
+ // Artifacts that have both an unsuffixed artifact from the javax branch
+ // and a suffixed one from the master branch
+ suffixedArtifactNames = [
+ 'tapestry-core',
+ 'tapestry-http',
+ 'tapestry-test',
+ 'tapestry-runner',
+ 'tapestry-spring',
+ 'tapestry-kaptcha',
+ 'tapestry-openapi-viewer',
+ 'tapestry-upload',
+ 'tapestry-jmx',
+ 'tapestry-jpa',
+ 'tapestry-kaptcha',
+ 'tapestry-openapi-viewer',
+ 'tapestry-rest-jackson',
+ 'tapestry-webresources',
+ 'tapestry-cdi',
+ 'tapestry-ioc',
+ 'tapestry-ioc-jcache',
+ 'tapestry-spock',
+ 'tapestry-clojure',
+ 'tapestry-hibernate',
+ 'tapestry-hibernate-core',
+ 'tapestry-ioc-junit',
+ 'tapestry-latest-java-tests',
+ 'tapestry-mongodb',
+ 'tapestry-spock',
+ 'tapestry-beanvalidator'
+ ]
+
+ continuousIntegrationBuild = Boolean.getBoolean('ci')
+
+ stagingUrl = 'https://repository.apache.org/service/local/staging/deploy/maven2/'
+ snapshotUrl = 'https://repository.apache.org/content/repositories/snapshots'
+ doSign = !project.hasProperty('noSign') && project.hasProperty('signing.keyId')
// apacheDeployUserName and apacheDeployPassword should be specified in ~/.gradle/gradle.properties
- deployUsernameProperty = isSnapshot() ? "snapshotDeployUserName" : "apacheDeployUserName"
- deployPasswordProperty = isSnapshot() ? "snapshotDeployPassword" : "apacheDeployPassword"
+ deployUsernameProperty = isSnapshot() ? 'snapshotDeployUserName' : 'apacheDeployUserName'
+ deployPasswordProperty = isSnapshot() ? 'snapshotDeployPassword' : 'apacheDeployPassword'
- canDeploy = [deployUsernameProperty, deployPasswordProperty, "apacheArchivesFolder"].every { project.hasProperty(it) }
+ canDeploy = [
+ deployUsernameProperty,
+ deployPasswordProperty,
+ 'apacheArchivesFolder'
+ ].every { project.hasProperty(it) }
// These are all deferred inside closures, to allow people without the necessary values in their
// gradle.properties to build locally, just not deploy. getProperty() throws an exception if the property
@@ -90,206 +68,79 @@ project.ext {
deployUsername = { getProperty(deployUsernameProperty) }
deployPassword = { getProperty(deployPasswordProperty) }
- archiveDeployFolder = { getProperty("apacheArchivesFolder") }
+ archiveDeployFolder = { getProperty('apacheArchivesFolder') }
}
-println "JDK: " + System.getProperty("java.version")
-
-//println "Can deploy? $canDeploy"
-//println "Is snapshot? isSnapshot"
-//println "deployUsernameProperty $deployUsernameProperty"
-//println "deployPasswordProperty $deployPasswordProperty"
-//println "continuousIntegrationBuild? $continuousIntegrationBuild"
-
-allprojects {
-
- apply plugin: "eclipse"
- apply plugin: "idea"
+// Provided so that the CI server can override the normal version number for nightly builds.
+project.version = tapestryVersion()
- repositories {
- mavenLocal()
- mavenCentral()
- // All things JBoss/Hibernate
- maven {
- name "JBoss"
- url "https://repository.jboss.org/nexus/content/repositories/releases/"
- }
- }
+// Remember that when generating a release, this should be incremented. Also don\t forget to
+// tag the release in Git.
+// Version number is always '5.x(.y)?-SNAPSHOT' and only gets fixed, e.g. to 5.4-alpha-1
+// during a release
+def tapestryVersion() {
- configurations {
- // Non-code artifacts, such as sources JARs and zipped JavaDocs
- meta
- }
+ def major = '5.10.0'
+ def minor = ''
+ // When building on the CI server, make sure -SNAPSHOT is appended, as it is a nightly build.
+ // When building normally, or for a release, no suffix is desired.
+ continuousIntegrationBuild ? major + '-SNAPSHOT' : major + minor
}
-idea {
- project {
- languageLevel = "8"
- }
-}
// Specific to top-level build, not set for subprojects:
-
configurations {
javadoc
published.extendsFrom archives, meta
+
if (doSign) {
published.extendsFrom signatures
}
+
binaries // additional dependencies included in the binary archive
}
+
dependencies {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
- javadoc project(":tapestry-javadoc")
+ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
+ javadoc project(':tapestry-javadoc')
}
// From tapestry-ioc:
- binaries "jakarta.inject:jakarta.inject-api:${versions.injectApi}"
- binaries "org.slf4j:slf4j-api:${versions.slf4j}"
- binaries "commons-codec:commons-codec:1.17.1"
- binaries "org.antlr:antlr-runtime:${versions.antlrRuntime}", { transitive = false }
+ binaries libs.jakarta.inject.api
+ binaries libs.slf4j.api
+ binaries libs.commons.codec
+ binaries libs.antlr.runtime, { transitive = false }
}
-String jdkVersion = System.properties['java.version']
-def jdkMajorVersion = jdkVersion.substring(0, jdkVersion.indexOf(".")) // 1, 9, 10...
-
subprojects {
-
- def specifyMaxPermSize = jdkVersion ==~ /1\.[67].+/
-
- apply plugin: "maven-publish" // for deployment
-
- configurations {
- provided
- }
-
- apply plugin: "java"
- apply plugin: "java-library"
- apply plugin: "groovy" // mostly for testing
-
- apply plugin: "project-report"
- apply plugin: "jacoco"
- apply plugin: "base"
+ apply plugin: 'tapestry.java-convention'
+ apply plugin: 'maven-publish'
+ apply plugin: 'project-report'
+ apply plugin: 'jacoco'
+ apply plugin: 'groovy'
jacoco {
- toolVersion = "0.8.7"
- }
-
- sourceCompatibility = "8"
- targetCompatibility = "8"
-
- // See http://jira.codehaus.org/browse/GRADLE-784
-
- sourceSets {
- main {
- compileClasspath += configurations.provided
- }
- test {
- compileClasspath += configurations.provided
- runtimeClasspath += configurations.provided
- }
- }
-
- idea.module {
- scopes.PROVIDED.plus += [configurations.provided]
+ toolVersion = '0.8.7'
}
- eclipse.classpath.plusConfigurations += [configurations.provided]
-
dependencies {
-
- // https://docs.gradle.org/7.3.3/userguide/upgrading_version_6.html#potential_breaking_changes,
- // Table 1. Common configuration upgrades
- testImplementation "org.spockframework:spock-core:${versions.spock}"
-
- testRuntimeOnly "org.slf4j:slf4j-log4j12:${versions.slf4j}"
- }
-
- compileTestGroovy {
- configure(groovyOptions.forkOptions) {
- memoryMaximumSize = '1g'
- jvmArgs = ['-Xms512m', '-Xmx1g']
- if (specifyMaxPermSize){
- jvmArgs << '-XX:MaxPermSize=512m'
- }
- }
- }
-
- tasks.withType(Test) {
- useTestNG()
-
- options.suites("src/test/conf/testng.xml")
- if (specifyMaxPermSize){
- maxHeapSize "400M"
- jvmArgs("-XX:MaxPermSize=200m")
- }else{
- maxHeapSize "600M"
- }
-
- // Needed to have XMLTokenStreamTests.testStreamEncoding() passing on Java 9+
- if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_9)) {
- jvmArgs("--add-opens=java.base/java.nio.charset=ALL-UNNAMED");
- }
-
- // Turn off live service reloading
-
- systemProperties["tapestry.service-reloading-enabled"] = "false"
- systemProperties["java.io.tmpdir"] = temporaryDir.absolutePath
-
- jvmArgs("-Dfile.encoding=UTF-8")
-
- environment.LANG = 'en_US.UTF-8'
-
- if (continuousIntegrationBuild) {
- // Travis runs our builds with TERM=dumb and kills it if we don't produce any
- // output for 10 minutes, so we log some task execution progress
-
- testLogging {
- exceptionFormat "full"
- }
-
- def numberOfTestsExecuted = 0
- afterTest { descriptor, result->
- numberOfTestsExecuted++
- if (numberOfTestsExecuted % 25 == 0){
- logger.lifecycle "$numberOfTestsExecuted tests executed"
- }
- }
- }
+ implementation libs.slf4j.api
+ implementation libs.bundles.groovy
}
- jar {
- // println "JAR projectDir: " + projectDir.getName().replaceAll("5", "").replaceAll("tapestry-", "").replaceAll("-", "");
- from(projectDir) {
- include "*.txt"
- into "META-INF"
- }
- manifest {
- attributes("Automatic-Module-Name": "org.apache.tapestry." + projectDir.getName()
- .replaceAll("tapestry5", "tapestry")
- .replaceAll("tapestry-", "")
- .replaceAll("-", ""))
- if (projectDir.getName().equals("tapestry-version-migrator")) {
- attributes("Main-Class": "org.apache.tapestry5.versionmigrator.Main")
- }
+ tasks.withType(GroovyCompile).configureEach {
+ if (name == 'compileTestGroovy') {
+ options.fork = true
+ options.forkOptions.memoryMaximumSize = '1g'
+ options.forkOptions.jvmArgs = ['-Xms512m', '-Xmx1g']
}
}
assemble.dependsOn(processResources, compileJava, jar)
- task sourcesJar(type: Jar) {
- dependsOn classes
- archiveClassifier = "sources"
- from sourceSets.main.allSource
- from(projectDir) {
- include "*.txt"
- into "META-INF"
- }
- }
-
artifacts {
archives sourcesJar
meta sourcesJar
@@ -308,7 +159,7 @@ subprojects {
publications {
mavenJava(MavenPublication) {
version = parent.version
- groupId = "org.apache.tapestry"
+ groupId = 'org.apache.tapestry'
if (suffixedArtifactNames.contains(project.name)) {
artifactId = project.name + artifactSuffix
}
@@ -319,25 +170,25 @@ subprojects {
name = project.name
// TODO: find some way to get the subproject description here.
// description =
- url = "https://tapestry.apache.org/"
+ url = 'https://tapestry.apache.org/'
licenses {
license {
name = 'The Apache License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:https://gitbox.apache.org/repos/asf/tapestry-5.git'
- developerConnection = 'scm:git://gitbox.apache.org/repos/asf/tapestry-5.git'
- url = 'https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=summary'
+ developerConnection = 'scm:git://gitbox.apache.org/repos/asf/tapestry-5.git'
+ url = 'https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=summary'
}
// Changes the generated pom.xml so its dependencies on suffixed artifacts
// get properly updated with suffixed artifact ids
withXml {
def artifactIdQName = new groovy.namespace.QName(
- "http://maven.apache.org/POM/4.0.0", "artifactId")
- def node = asNode();
- def dependencies = node.get("dependencies")[0]
+ 'http://maven.apache.org/POM/4.0.0', 'artifactId')
+ def node = asNode()
+ def dependencies = node.get('dependencies')[0]
if (dependencies != null) {
dependencies.'*'.forEach {
def artifactIdNode = it.getAt(artifactIdQName)[0]
@@ -348,97 +199,62 @@ subprojects {
}
}
}
- matching {
- it.name.endsWith(".jar") || it.name.endsWith(".pom")
- }
}
}
if (canDeploy) {
repositories {
mavenLocal()
- if (continuousIntegrationBuild) {
- maven {
- name = "apacheSnapshots"
- url = snapshotUrl
- credentials {
- username = deployUsername()
- password = deployPassword()
- }
- }
- }
- else {
- maven {
- name = "apacheStaging"
- url = stagingUrl
- credentials {
- username = deployUsername()
- password = deployPassword()
- }
+
+ def repoUrl = continuousIntegrationBuild ? snapshotUrl : stagingUrl
+ def repoName = continuousIntegrationBuild ? 'apacheSnapshots' : 'apacheStaging'
+
+ maven {
+ name = repoName
+ url = repoUrl
+ credentials {
+ username = deployUsername()
+ password = deployPassword()
}
}
-
}
}
}
if (doSign) {
- apply plugin: "signing"
+ apply plugin: 'signing'
signing {
sign publishing.publications.mavenJava
}
}
-
+
def actuallyPublish = !artifactSuffix.isEmpty() || suffixedArtifactNames.contains(project.name)
- // println "XXXXXX Actually publish? " + actuallyPublish + " project " + project.name + " " + "!artifactSuffix.isEmpty() " + !artifactSuffix.isEmpty()
+ // println 'XXXXXX Actually publish? ' + actuallyPublish + ' project ' + project.name + ' ' + '!artifactSuffix.isEmpty() ' + !artifactSuffix.isEmpty()
if (!actuallyPublish) {
tasks.withType(PublishToMavenRepository).configureEach { it.enabled = false }
tasks.withType(PublishToMavenLocal).configureEach { it.enabled = false }
}
task uploadPublished {
-
doFirst {
if (!canDeploy) {
- throw new InvalidUserDataException("Missing upload credentials. Set '$deployUsernameProperty' and '$deployPasswordProperty' root project properties.")
+ throw new InvalidUserDataException("Missing upload credentials. Set '${deployUsernameProperty}' and '${deployPasswordProperty}' root project properties.")
}
}
-
}
}
-subprojects.each { project.evaluationDependsOn(it.name) }
-
-subprojects {
-
- configurations.all {
-
- resolutionStrategy.force "antlr:antlr:2.7.7",
- "cglib:cglib-nodep:2.2",
- "commons-codec:commons-codec:1.10",
- "commons-io:commons-io:${versions.commonsIo}",
- "commons-logging:commons-logging:1.1.3",
- "org.hsqldb:hsqldb:${versions.hsqldb}",
- "org.antlr:antlr-runtime:${versions.antlrRuntime}",
- "org.apache.tomcat:dbcp:6.0.32",
- "org.hamcrest:hamcrest-core:1.3",
- "org.json:json:20140107",
- "org.yaml:snakeyaml:${versions.snakeyaml}",
- "xml-apis:xml-apis:1.4.01"
-
- }
-}
// Cribbed from https://github.com/hibernate/hibernate-core/blob/master/release/release.gradle#L19
task aggregateJavadoc(type: Javadoc) {
dependsOn configurations.javadoc
- group "Documentation"
+ group 'Documentation'
- description "Build the aggregated JavaDocs for all modules"
- maxMemory "512m"
- destinationDir file("$buildDir/documentation/javadocs")
+ description 'Build the aggregated JavaDocs for all modules'
+ maxMemory '512m'
+ destinationDir file("${buildDir}/documentation/javadocs")
- def tapestryStylesheet = file("src/javadoc/stylesheet7.css")
+ def tapestryStylesheet = file('src/javadoc/stylesheet7.css')
int thisYear = java.time.Year.now().getValue()
def allMainSourceSets = subprojects*.sourceSets*.main.flatten()
@@ -454,25 +270,24 @@ task aggregateJavadoc(type: Javadoc) {
docTitle "Tapestry API - ($project.version)"
bottom "${project.version} - Copyright © 2003-${thisYear} <a href=\"http://tapestry.apache.org/\">The Apache Software Foundation</a>."
use = true // 'use' seems to be a reserved word for the DSL
- links "https://docs.oracle.com/javase/8/docs/api/"
- links "https://docs.oracle.com/javaee/7/api/"
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ links 'https://docs.oracle.com/javase/8/docs/api/'
+ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
tagletPath Collections.unmodifiableList(new ArrayList<>((Set) configurations.javadoc.files))
}
// Uncomment jFlags to debug `./gradlew aggregateJavadoc`
-// jFlags '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
+ // jFlags '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
addStringOption '-source-path', files(allMainJavaSrcDirs.flatten()).asPath
addStringOption 'source', '8'
- taglets "org.apache.tapestry5.javadoc.TapestryDocTaglet"
+ taglets 'org.apache.tapestry5.javadoc.TapestryDocTaglet'
}
-
+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
- exclude "org/apache/tapestry5/spring/**"
+ exclude 'org/apache/tapestry5/spring/**'
}
- exclude "org/apache/tapestry5/internal/plastic/asm/**"
- exclude "org/apache/tapestry5/internal/webresources/**"
- exclude "org/apache/tapestry5/webresources/modules/**"
+ exclude 'org/apache/tapestry5/internal/plastic/asm/**'
+ exclude 'org/apache/tapestry5/internal/webresources/**'
+ exclude 'org/apache/tapestry5/webresources/modules/**'
source allMainJavaFiles
@@ -488,149 +303,177 @@ task aggregateJavadoc(type: Javadoc) {
copy {
from allMainJavaSrcDirs
into aggregateJavadoc.destinationDir
- exclude "**/*.java"
- exclude "**/*.xdoc"
- exclude "**/package.html"
+ exclude '**/*.java'
+ exclude '**/*.xdoc'
+ exclude '**/package.html'
}
copy {
- from file("src/javadoc/images")
+ from file('src/javadoc/images')
into aggregateJavadoc.destinationDir
}
}
}
task coffeeScriptDocs(type: Exec) {
- group "Documentation"
- description "Build docco documentation for all CoffeeScript sources"
- dependsOn project(":tapestry-core").tasks.preprocessCoffeeScript
+ group 'Documentation'
+ description 'Build docco documentation for all CoffeeScript sources'
+ dependsOn project(':tapestry-core').tasks.preprocessCoffeeScript
- def outputDir = file("$buildDir/documentation/coffeescript")
+ def outputDir = file('$buildDir/documentation/coffeescript')
def sources = files()
subprojects.each { sub ->
- sources += sub.fileTree("src/main/coffeescript", { include "**/*.coffee" })
+ def coffeeDir = sub.file('src/main/coffeescript')
+ if (coffeeDir.exists()) {
+ sources += sub.fileTree(coffeeDir) {
+ include '**/*.coffee'
+ }
+ }
}
- sources += project(":tapestry-core").tasks.preprocessCoffeeScript.outputs.files.asFileTree
+ sources += project(':tapestry-core').tasks.preprocessCoffeeScript.outputs.files.asFileTree
- // Needs to be installed via "npm install -g docco@0.6.3"
- executable isWindows() ? "docco.cmd" : "docco"
- args "--output", outputDir
- args sources.files.sort({ a, b -> a.name.compareTo b.name })
+ // Needs to be installed via 'npm install -g docco@0.6.3'
+ executable isWindows() ? 'docco.cmd' : 'docco'
+ args '--output', outputDir
+ args sources.files.sort({ a, b ->
+ a.name.compareTo b.name
+ })
}
dependencies {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
meta aggregateJavadoc.outputs.files
}
}
task combinedJacocoReport(type:JacocoReport){
- def subprojectsToConsider = subprojects.findAll {it.name != 'quickstart' && it.name != 'beanmodel' && it.name != 'commons' && it.name != 'genericsresolver-guava' && it.name != 'tapestry5-annotations' && it.name != 'tapestry-internal-test' && it.name != 'tapestry-runner' && it.name != 'tapestry-test-constants' && it.name != 'tapestry-test-data' && it.name != 'tapestry-ioc-jcache'}
- dependsOn = subprojectsToConsider.test
- additionalSourceDirs.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
- sourceDirectories.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
- classDirectories.from(files(subprojectsToConsider.sourceSets.main.output))
- executionData.from(files(subprojectsToConsider.jacocoTestReport.executionData).filter { it.exists() })
- jacocoClasspath = files(subprojectsToConsider.jacocoTestReport.jacocoClasspath)
- reports {
- html {
- required = true
- destination = file("$buildDir/reports/jacoco")
- }
- xml {
- required = false
- }
- csv {
- required = false
- }
- }
- onlyIf = {
- true
- }
+ def excludedProjects = [
+ 'quickstart',
+ 'beanmodel',
+ 'commons',
+ 'genericsresolver-guava',
+ 'tapestry5-annotations',
+ 'tapestry-internal-test',
+ 'tapestry-runner',
+ 'tapestry-test-constants',
+ 'tapestry-test-data',
+ 'tapestry-ioc-jcache'
+ ]
+
+ def subprojectsToConsider = subprojects.findAll {
+ it.name !in excludedProjects
+ }
+
+ dependsOn = subprojectsToConsider.test
+
+ additionalSourceDirs.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
+ sourceDirectories.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
+ classDirectories.from(files(subprojectsToConsider.sourceSets.main.output))
+ executionData.from(files(subprojectsToConsider.jacocoTestReport.executionData).filter {
+ it.exists()
+ })
+ jacocoClasspath = files(subprojectsToConsider.jacocoTestReport.jacocoClasspath)
+
+ reports {
+ html {
+ required = true
+ destination = file("${buildDir}/reports/jacoco")
+ }
+ xml.required = false
+ csv.required = false
+ }
}
task continuousIntegration {
// tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only added if != 8.
- def dependants = [subprojects.build, 'tapestry-core:testWithPrototype', combinedJacocoReport]
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ def dependants = [
+ subprojects.build,
+ 'tapestry-core:testWithPrototype',
+ combinedJacocoReport
+ ]
+ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
dependants << aggregateJavadoc
}
dependsOn dependants
- description "Task executed on Jenkins CI server after Git commits"
+ description 'Task executed on Jenkins CI server after Git commits'
}
+
task zippedSources(type: Zip) {
description "Creates a combined Zip file of all sub-project's sources"
- group "Release artifact"
-
- dependsOn("tapestry-beanvalidator:compileCoffeeScript")
- dependsOn("tapestry-core:compileCoffeeScript")
- dependsOn("tapestry-core:compileProcessedCoffeescript")
+ group 'Release artifact'
+
+ dependsOn('tapestry-beanvalidator:compileCoffeeScript')
+ dependsOn('tapestry-core:compileCoffeeScript')
+ dependsOn('tapestry-core:compileProcessedCoffeescript')
destinationDirectory = buildDir
- archiveBaseName = "apache-tapestry"
+ archiveBaseName = 'apache-tapestry'
version project.version
- archiveClassifier = "sources"
+ archiveClassifier = 'sources'
from project.projectDir
- exclude "out/**"
- exclude "**/*.iml"
- exclude "**/*.ipr"
- exclude "**/*.iws"
- exclude "**/.*/**"
- exclude "**/bin/**"
- exclude "**/target/**"
- exclude "**/build/**"
- exclude "**/test-output/**" // Left around by TestNG sometimes
+ exclude 'out/**'
+ exclude '**/*.iml'
+ exclude '**/*.ipr'
+ exclude '**/*.iws'
+ exclude '**/.*/**'
+ exclude '**/bin/**'
+ exclude '**/target/**'
+ exclude '**/build/**'
+ exclude '**/test-output/**' // Left around by TestNG sometimes
}
task zippedApidoc(type: Zip) {
dependsOn aggregateJavadoc
description "Zip archive of the project's aggregate JavaDoc and CoffeeScript documentation"
- group "Release artifact"
+ group 'Release artifact'
destinationDirectory = buildDir
- archiveBaseName = "apache-tapestry"
+ archiveBaseName = 'apache-tapestry'
version project.version
- archiveClassifier = "apidocs"
+ archiveClassifier = 'apidocs'
- from file("src/docroot-template"), {
+ from file('src/docroot-template'), {
filter ReplaceTokens, tokens: [version: project.version]
- include "*.html"
+ include '*.html'
}
- from file("src/docroot-template"), {
- exclude "*.html"
+ from file('src/docroot-template'), {
+ exclude '*.html'
}
- into "apidocs", { from aggregateJavadoc.outputs.files }
-
+ into 'apidocs', {
+ from aggregateJavadoc.outputs.files
+ }
- into "coffeescript", { from coffeeScriptDocs.outputs.files }
+ into 'coffeescript', {
+ from coffeeScriptDocs.outputs.files
+ }
}
task zippedBinaries(type: Zip) {
- description "Zip archive of binaries of each sub-project"
+ description 'Zip archive of binaries of each sub-project'
// TODO: Plus dependencies?
- group "Release artifact"
+ group 'Release artifact'
// This may create a few unwanted dependencies, but does
// seem to ensure that the subprojects are created
inputs.files subprojects*.configurations*.archives.artifacts.files
destinationDirectory = buildDir
- archiveBaseName = "apache-tapestry"
+ archiveBaseName = 'apache-tapestry'
version project.version
- archiveClassifier = "bin"
+ archiveClassifier = 'bin'
// This is via some experimentation
from subprojects*.configurations*.archives.artifacts*.file*.findAll {
- !(it.name.endsWith(".asc") || it.name.startsWith("quickstart"))
+ !(it.name.endsWith('.asc') || it.name.startsWith('quickstart'))
}
from configurations.binaries
@@ -638,12 +481,13 @@ task zippedBinaries(type: Zip) {
// Pick up various licenses and notices
from(projectDir) {
- include "*.txt"
+ include '*.txt'
}
- subprojects.each { sub ->
+ subprojects.each {
+ sub ->
from(sub.projectDir) {
- include "*.txt"
+ include '*.txt'
into sub.name
}
}
@@ -666,24 +510,24 @@ if (canDeploy) {
}
task generateMD5Checksums(type: GenMD5) {
- group "Release artifact"
- description "Creates MD5 checksums for archives of source and JavaDoc"
+ group 'Release artifact'
+ description 'Creates MD5 checksums for archives of source and JavaDoc'
source tasks.withType(Zip)
- outputDir "$buildDir/md5"
+ outputDir "${buildDir}/md5"
}
task generateSHA256Checksums(type: GenSHA256) {
- group "Release artifact"
- description "Creates SHA-256 checksums for archives of source and JavaDoc"
+ group 'Release artifact'
+ description 'Creates SHA-256 checksums for archives of source and JavaDoc'
source tasks.withType(Zip)
- outputDir "$buildDir/sha256"
+ outputDir "${buildDir}/sha256"
}
// This requires that you have the apacheArchivesFolder property configured in your
// ~/.gradle/gradle.properties. The folder should be a Subversion workspace for
// https://dist.apache.org/repos/dist/dev/tapestry
- // after the build, you must manually add the new files to the workspace (using "svn add")
- // then commit ("svn commit").
+ // after the build, you must manually add the new files to the workspace (using 'svn add')
+ // then commit ('svn commit').
// The files will be visible in https://dist.apache.org/repos/dist/dev/tapestry/, allowing
// committers to download and verify them.
@@ -694,8 +538,8 @@ if (canDeploy) {
// to all Apache mirrors (after about a 24 hour delay).
task copyArchives(type: Copy) {
- group "Release artifact"
- description "Copies build archives (source, bin, docs) to a configured deployment folder, along with MD5 and SHA-256 checksums and PGP signatures (if signing is enabled)"
+ group 'Release artifact'
+ description 'Copies build archives (source, bin, docs) to a configured deployment folder, along with MD5 and SHA-256 checksums and PGP signatures (if signing is enabled)'
destinationDir file(archiveDeployFolder())
@@ -706,13 +550,13 @@ if (canDeploy) {
task generateRelease {
dependsOn subprojects.assemble, subprojects.uploadPublished, subprojects.publish, copyArchives
- group "Release artifact"
- description "Generates and uploads a final release to Apache Nexus and copies archives for deployment"
+ group 'Release artifact'
+ description 'Generates and uploads a final release to Apache Nexus and copies archives for deployment'
}
}
boolean isSnapshot() {
- project.version.contains("SNAPSHOT")
+ project.version.contains('SNAPSHOT')
}
boolean isWindows() {
@@ -720,48 +564,49 @@ boolean isWindows() {
}
task updateBootstrap {
- doLast {
- def bootstrapVersion = '3.3.7'
- def target = new File(temporaryDir, 'bootstrap.zip')
- ant.get(src: "https://github.com/twbs/bootstrap/archive/v${bootstrapVersion}.zip", dest: target)
-
- def adjustDirectory = {
- def relativePath = it.relativePath
- if (relativePath.pathString.contains('/dist/')){
- relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[2..-1] as String[])
- } else {
- relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[1..-1] as String[])
- }
- println "copying $it.relativePath to $relativePath"
- it.relativePath = relativePath
-
- }
-
- copy {
- from(zipTree(target)){
- include('*/js/*.js')
- include('*/dist/fonts/*')
- eachFile adjustDirectory
- }
- from(zipTree(target)){
- include('*/dist/css/bootstrap.css')
- include('*/dist/css/bootstrap-theme.css')
- eachFile adjustDirectory
- // TAP5-2351: remove source map reference from css files
- filter({ (it ==~ /\/\*\s*# sourceMappingURL=[\S]+\s*\*\//) ? "" : it })
- }
- into('tapestry-core/src/main/resources/META-INF/assets/tapestry5/bootstrap/')
- }
-
- copy {
- from(zipTree(target)){
- include('*/js/*.js')
- include('*/dist/fonts/*')
- include('*/less/**/*.less')
-
- eachFile adjustDirectory
- }
- into('tapestry-webresources/src/test/webapp/bootstrap/')
- }
- }
+ doLast {
+ def bootstrapVersion = '3.3.7'
+ def target = new File(temporaryDir, 'bootstrap.zip')
+ ant.get(src: "https://github.com/twbs/bootstrap/archive/v${bootstrapVersion}.zip", dest: target)
+
+ def adjustDirectory = {
+ def relativePath = it.relativePath
+ if (relativePath.pathString.contains('/dist/')){
+ relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[2..-1] as String[])
+ } else {
+ relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[1..-1] as String[])
+ }
+ println "copying ${it.relativePath} to ${relativePath}"
+ it.relativePath = relativePath
+ }
+
+ copy {
+ from(zipTree(target)){
+ include('*/js/*.js')
+ include('*/dist/fonts/*')
+ eachFile adjustDirectory
+ }
+ from(zipTree(target)){
+ include('*/dist/css/bootstrap.css')
+ include('*/dist/css/bootstrap-theme.css')
+ eachFile adjustDirectory
+ // TAP5-2351: remove source map reference from css files
+ filter({
+ (it ==~ /\/\*\s*# sourceMappingURL=[\S]+\s*\*\//) ? '' : it
+ })
+ }
+ into('tapestry-core/src/main/resources/META-INF/assets/tapestry5/bootstrap/')
+ }
+
+ copy {
+ from(zipTree(target)){
+ include('*/js/*.js')
+ include('*/dist/fonts/*')
+ include('*/less/**/*.less')
+
+ eachFile adjustDirectory
+ }
+ into('tapestry-webresources/src/test/webapp/bootstrap/')
+ }
+ }
}
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index c08ff05d4..94cb7679d 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -1,17 +1,18 @@
-apply plugin: "groovy"
+plugins {
+ id 'groovy-gradle-plugin'
+}
repositories {
- mavenCentral()
+ gradlePluginPortal()
}
-
dependencies {
implementation ("ro.isdc.wro4j:wro4j-extensions:1.8.0"){
- exclude group: 'org.jruby'
- exclude module: 'spring-web'
- exclude module: 'closure-compiler'
- exclude module: 'gmaven-runtime-1.7'
- exclude module: 'less4j'
+ exclude group: 'org.jruby'
+ exclude module: 'spring-web'
+ exclude module: 'closure-compiler'
+ exclude module: 'gmaven-runtime-1.7'
+ exclude module: 'less4j'
}
gradleApi()
}
diff --git a/buildSrc/src/main/groovy/tapestry.java-convention.gradle b/buildSrc/src/main/groovy/tapestry.java-convention.gradle
new file mode 100644
index 000000000..88342f1b5
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.java-convention.gradle
@@ -0,0 +1,75 @@
+plugins {
+ id 'java-library'
+ id 'eclipse'
+ id 'idea'
+ id 'groovy'
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+
+ withSourcesJar()
+}
+
+configurations {
+ provided
+ meta
+}
+
+// Ensure the 'provided' dependencies are available on the compile classpaths.
+sourceSets {
+ main.compileClasspath += configurations.provided
+ test.compileClasspath += configurations.provided
+ test.runtimeClasspath += configurations.provided
+}
+
+// Ensure IDEs understand the 'provided' configuration and more IDE setup
+idea {
+ module {
+ scopes.PROVIDED.plus += [configurations.provided]
+ }
+}
+eclipse.classpath.plusConfigurations += [configurations.provided]
+
+
+// Enforce consistent dependency versions across all modules using constraints.
+// This prevents multiple versions of the same library from appearing in the classpath.
+// The versions themselves are defined in `gradle/libs.versions.toml`.
+dependencies {
+ constraints {
+ implementation libs.cglib.nodep
+ implementation libs.commons.codec
+ implementation libs.commons.io
+ implementation libs.commons.logging
+ implementation("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
+ implementation libs.hamcrest.core
+ implementation libs.json
+ implementation libs.snakeyaml
+ implementation libs.xml.apis
+ }
+}
+
+tasks.withType(Jar).configureEach {
+ // Include license/notice files in the final JAR.
+ from(project.projectDir) {
+ include "*.txt"
+ into "META-INF"
+ }
+
+ // JPMS compatibility
+ manifest {
+ attributes("Automatic-Module-Name": "org.apache.tapestry." + project.name
+ .replace("tapestry-", "")
+ .replace("-", "."))
+ }
+}
+
+// Override the manually created sourcesJar from the original build with the
+// standard one created by `withSourcesJar()`. This adds the META-INF files to it as well.
+tasks.named('sourcesJar', Jar) {
+ from(project.projectDir) {
+ include "*.txt"
+ into "META-INF"
+ }
+}
diff --git a/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle b/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle
new file mode 100644
index 000000000..de7f4e9bf
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.junit4-legacy-convention.gradle
@@ -0,0 +1,12 @@
+plugins {
+ id 'tapestry.testing-base-convention'
+}
+
+dependencies {
+ testImplementation libs.junit4
+ testImplementation libs.hamcrest.core
+}
+
+tasks.withType(Test).configureEach {
+ useJUnit()
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/tapestry.junit5-convention.gradle b/buildSrc/src/main/groovy/tapestry.junit5-convention.gradle
new file mode 100644
index 000000000..0d2bf88de
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.junit5-convention.gradle
@@ -0,0 +1,13 @@
+plugins {
+ id 'tapestry.testing-base-convention'
+}
+
+dependencies {
+ testImplementation platform(libs.junit.bom)
+ testImplementation libs.bundles.junit.jupiter.essentials
+ testRuntimeOnly libs.junit.jupiter.engine
+}
+
+tasks.withType(Test).configureEach {
+ useJUnitPlatform()
+}
diff --git a/buildSrc/src/main/groovy/tapestry.junit5-spock-convention.gradle b/buildSrc/src/main/groovy/tapestry.junit5-spock-convention.gradle
new file mode 100644
index 000000000..1570598ef
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.junit5-spock-convention.gradle
@@ -0,0 +1,11 @@
+plugins {
+ id 'tapestry.junit5-convention'
+ id 'groovy'
+}
+
+dependencies {
+ testImplementation libs.bundles.groovy
+
+ testImplementation platform(libs.spock.bom)
+ testImplementation libs.spock.core
+}
diff --git a/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle
new file mode 100644
index 000000000..99ff45ca5
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.testing-base-convention.gradle
@@ -0,0 +1,61 @@
+plugins {
+ id 'java-library'
+}
+
+dependencies {
+ testRuntimeOnly libs.slf4j.simple
+}
+
+tasks.withType(Test).configureEach { testTask ->
+ maxHeapSize = '600M'
+
+ systemProperties['tapestry.service-reloading-enabled'] = 'false'
+ systemProperties['java.io.tmpdir'] = temporaryDir.absolutePath
+
+ jvmArgs '-Dfile.encoding=UTF-8'
+ environment.LANG = 'en_US.UTF-8'
+
+ testLogging {
+ exceptionFormat 'full'
+ events 'passed', 'skipped', 'failed'
+ showStandardStreams = true
+ }
+
+ def total = 0, passed = 0, failed = 0, skipped = 0
+
+ afterTest { descriptor, result ->
+ switch (result.resultType) {
+ case org.gradle.api.tasks.testing.TestResult.ResultType.SUCCESS:
+ passed++
+ break
+ case org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE:
+ failed++
+ break
+ case org.gradle.api.tasks.testing.TestResult.ResultType.SKIPPED:
+ skipped++
+ break
+ }
+ total++
+ if (total % 25 == 0) {
+ logger.lifecycle "Project ${project.name}: Tests run: ${total}, Passed: ${passed}, Failed: ${failed}, Skipped: ${skipped}"
+ }
+ }
+
+ afterSuite { descriptor, result ->
+ // The root suite has a null parent. We only want to log the final summary.
+ if (descriptor.parent == null) {
+ total = passed + failed + skipped
+ // Using project.path gives a clear identifier like ":tapestry-core"
+ def projectName = project.path
+
+ // Don't log if no tests were run
+ if (total > 0) {
+ logger.lifecycle "------------------------------------------------------------------------"
+ logger.lifecycle "Test Results for ${projectName}"
+ logger.lifecycle " Tests run: ${total}, Passed: ${passed}, Failed: ${failed}, Skipped: ${skipped}"
+ logger.lifecycle "------------------------------------------------------------------------"
+ }
+ }
+ }
+}
+
diff --git a/buildSrc/src/main/groovy/tapestry.testng-convention.gradle b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle
new file mode 100644
index 000000000..2d00b95c3
--- /dev/null
+++ b/buildSrc/src/main/groovy/tapestry.testng-convention.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'tapestry.testing-base-convention'
+}
+
+dependencies {
+ testImplementation libs.testng
+ testImplementation libs.easymock
+ testImplementation libs.hamcrest.core
+}
+
+tasks.withType(Test).configureEach { testTask ->
+ /*
+ useTestNG {
+ def suiteFile = [
+ 'src/test/resources/testng.xml',
+ 'src/test/conf/testng.xml'
+ ].find { path ->
+ project.file(path).exists()
+ }
+ if (suiteFile) {
+ logger.lifecycle "!!!!!!!!!!!!!!!!!!TestNG: Using suite file: ${suiteFile}"
+ suites suiteFile // Pass the relative path string
+ } else {
+ logger.lifecycle '!!!!!!!!!!!!!!!!!TestNG: No suite file found in standard locations, using default configuration'
+ }
+ }
+ */
+
+ def suiteFile = [
+ 'src/test/resources/testng.xml',
+ 'src/test/conf/testng.xml'
+ ].find { path ->
+ project.file(path).exists()
+ }
+
+ if (suiteFile) {
+ testTask.useTestNG {
+ suites suiteFile
+ }
+ } else {
+ testTask.useTestNG()
+ }
+}
\ No newline at end of file
diff --git a/commons/build.gradle b/commons/build.gradle
index 99cb1d4d9..cf5bec443 100644
--- a/commons/build.gradle
+++ b/commons/build.gradle
@@ -1,24 +1,12 @@
-import org.gradle.plugins.ide.idea.model.*
-import t5build.*
+plugins {
+ id 'tapestry.junit5-spock-convention'
+}
description = "Project including common classes for tapestry-core, tapestry-ioc and beanmodel."
-//apply plugin: JavaPlugin
-buildDir = 'target/gradle-build'
-
dependencies {
- api project(":plastic")
- api project(":tapestry5-annotations")
- implementation project(":tapestry-func")
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
-
-jar {
- manifest {
- }
+ api project(":plastic")
+ api project(":tapestry5-annotations")
+ implementation project(":tapestry-func")
}
-
-test {
- useJUnit()
-}
\ No newline at end of file
diff --git a/genericsresolver-guava/build.gradle b/genericsresolver-guava/build.gradle
index a20be0d48..6762729eb 100644
--- a/genericsresolver-guava/build.gradle
+++ b/genericsresolver-guava/build.gradle
@@ -1,9 +1,17 @@
+plugins {
+ id 'tapestry.testng-convention'
+}
description = "Replaces the Tapestry Commons's own Java Generics resolution code with the one from Google Guava's one"
+ext.moduleLibs = [
+ guava: 'com.google.guava:guava:27.0.1-jre',
+]
+
dependencies {
- implementation project(':commons')
- testImplementation project(':tapestry-core')
- testImplementation project(':tapestry-test')
- provided implementation ('com.google.guava:guava:27.0.1-jre')
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
\ No newline at end of file
+ implementation project(':commons')
+
+ provided moduleLibs.guava
+
+ testImplementation project(':tapestry-core')
+ testImplementation project(':tapestry-test')
+}
diff --git a/genericsresolver-guava/src/test/conf/.gitignore b/genericsresolver-guava/src/test/conf/.gitignore
deleted file mode 100644
index a3f142afa..000000000
--- a/genericsresolver-guava/src/test/conf/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/testng.xml
diff --git a/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/AbstractBeanModelSourceImplTest.java b/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/AbstractBeanModelSourceImplTest.java
index c131174a5..1d3177651 100644
--- a/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/AbstractBeanModelSourceImplTest.java
+++ b/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/AbstractBeanModelSourceImplTest.java
@@ -1,5 +1,6 @@
package org.apache.tapestry5.genericsresolverguava.internal;
//Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
+
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
@@ -32,849 +33,877 @@ import org.testng.annotations.Test;
/**
* Copied from tapestry-core's tests due to the lack of a better option.
-* Tests for the bean editor model source itself, as well as the model classes.
-*/
+ * Tests for the bean editor model source itself, as well as the model classes.
+ */
+@Test
public abstract class AbstractBeanModelSourceImplTest extends IOCTestCase
{
- private BeanModelSource source;
+ private BeanModelSource source;
- protected abstract BeanModelSource create();
-
- @BeforeClass
- public void setup()
- {
- source = create();
- }
+ protected abstract BeanModelSource create();
- /**
- * Tests defaults for property names, labels and conduits.
- */
- @Test
- public void default_model_for_bean()
- {
- Messages messages = mockMessages();
+ @BeforeClass
+ public void setup()
+ {
+ source = create();
+ }
- stub_contains(messages, false);
+ /**
+ * Tests defaults for property names, labels and conduits.
+ */
+ @Test
+ public void default_model_for_bean()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- assertSame(model.getBeanType(), SimpleBean.class);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- // Based on order of the getter methods (no longer alphabetical)
+ assertSame(model.getBeanType(), SimpleBean.class);
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ // Based on order of the getter methods (no longer alphabetical)
- assertEquals(model.toString(),
- "BeanModel[org.apache.tapestry5.genericsresolverguava.internal.SimpleBean properties:firstName, lastName, age]");
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- PropertyModel age = model.get("age");
+ assertEquals(model.toString(),
+ "BeanModel[org.apache.tapestry5.genericsresolverguava.internal.SimpleBean properties:firstName, lastName, age]");
- assertEquals(age.getLabel(), "Age");
- assertSame(age.getPropertyType(), int.class);
- assertEquals(age.getDataType(), "number");
+ PropertyModel age = model.get("age");
- PropertyModel firstName = model.get("firstName");
+ assertEquals(age.getLabel(), "Age");
+ assertSame(age.getPropertyType(), int.class);
+ assertEquals(age.getDataType(), "number");
- assertEquals(firstName.getLabel(), "First Name");
- assertEquals(firstName.getPropertyType(), String.class);
- assertEquals(firstName.getDataType(), "text");
+ PropertyModel firstName = model.get("firstName");
- assertEquals(model.get("lastName").getLabel(), "Last Name");
+ assertEquals(firstName.getLabel(), "First Name");
+ assertEquals(firstName.getPropertyType(), String.class);
+ assertEquals(firstName.getDataType(), "text");
- PropertyConduit conduit = model.get("lastName").getConduit();
+ assertEquals(model.get("lastName").getLabel(), "Last Name");
- SimpleBean instance = new SimpleBean();
+ PropertyConduit conduit = model.get("lastName").getConduit();
- instance.setLastName("Lewis Ship");
+ SimpleBean instance = new SimpleBean();
- assertEquals(conduit.get(instance), "Lewis Ship");
+ instance.setLastName("Lewis Ship");
- conduit.set(instance, "TapestryDude");
+ assertEquals(conduit.get(instance), "Lewis Ship");
- assertEquals(instance.getLastName(), "TapestryDude");
+ conduit.set(instance, "TapestryDude");
- // Now, one with some type coercion.
+ assertEquals(instance.getLastName(), "TapestryDude");
- age.getConduit().set(instance, "40");
+ // Now, one with some type coercion.
- assertEquals(instance.getAge(), 40);
+ age.getConduit().set(instance, "40");
- verify();
- }
+ assertEquals(instance.getAge(), 40);
- @Test
- public void include_properties()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void include_properties()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- assertSame(model.getBeanType(), SimpleBean.class);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- model.include("lastname", "firstname");
+ assertSame(model.getBeanType(), SimpleBean.class);
- // Based on order of the getter methods (no longer alphabetical)
+ model.include("lastname", "firstname");
- assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "firstName"));
+ // Based on order of the getter methods (no longer alphabetical)
- verify();
- }
+ assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "firstName"));
- @Test
- public void add_before()
- {
- Messages messages = mockMessages();
- PropertyConduit conduit = mockPropertyConduit();
+ verify();
+ }
- Class propertyType = String.class;
+ @Test
+ public void add_before()
+ {
+ Messages messages = mockMessages();
+ PropertyConduit conduit = mockPropertyConduit();
- stub_contains(messages, false);
+ Class propertyType = String.class;
- expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
- expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
+ stub_contains(messages, false);
- replay();
+ expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
+ expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- // Note the use of case insensitivity here.
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "middleInitial", conduit);
+ // Note the use of case insensitivity here.
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "middleInitial", "lastName", "age"));
+ PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "middleInitial",
+ conduit);
- assertEquals(property.getPropertyName(), "middleInitial");
- assertSame(property.getConduit(), conduit);
- assertSame(property.getPropertyType(), propertyType);
+ assertEquals(model.getPropertyNames(),
+ Arrays.asList("firstName", "middleInitial", "lastName", "age"));
- verify();
- }
+ assertEquals(property.getPropertyName(), "middleInitial");
+ assertSame(property.getConduit(), conduit);
+ assertSame(property.getPropertyType(), propertyType);
- /**
- * TAPESTRY-2202
- */
- @Test
- public void new_instance()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ /**
+ * TAPESTRY-2202
+ */
+ @Test
+ public void new_instance()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel<SimpleBean> model = source.create(SimpleBean.class, true, messages);
+ replay();
- SimpleBean s1 = model.newInstance();
+ BeanModel<SimpleBean> model = source.create(SimpleBean.class, true, messages);
- assertNotNull(s1);
+ SimpleBean s1 = model.newInstance();
- SimpleBean s2 = model.newInstance();
+ assertNotNull(s1);
- assertNotNull(s2);
- assertNotSame(s1, s2);
+ SimpleBean s2 = model.newInstance();
- verify();
- }
+ assertNotNull(s2);
+ assertNotSame(s1, s2);
- @Test
- public void add_before_using_default_conduit()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void add_before_using_default_conduit()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- model.exclude("firstname");
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age"));
+ model.exclude("firstname");
- // Note the use of case insensitivity here.
+ assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age"));
- PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "firstName");
+ // Note the use of case insensitivity here.
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "firstName");
- assertEquals(property.getPropertyName(), "firstName");
- assertSame(property.getPropertyType(), String.class);
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- verify();
- }
+ assertEquals(property.getPropertyName(), "firstName");
+ assertSame(property.getPropertyType(), String.class);
- @Test
- public void add_after()
- {
- Messages messages = mockMessages();
- PropertyConduit conduit = mockPropertyConduit();
+ verify();
+ }
- Class propertyType = String.class;
+ @Test
+ public void add_after()
+ {
+ Messages messages = mockMessages();
+ PropertyConduit conduit = mockPropertyConduit();
- stub_contains(messages, false);
+ Class propertyType = String.class;
- expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
+ stub_contains(messages, false);
- expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
+ expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
- replay();
+ expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- PropertyModel property = model.add(RelativePosition.AFTER, "firstname", "middleInitial", conduit);
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "middleInitial", "lastName", "age"));
+ PropertyModel property = model.add(RelativePosition.AFTER, "firstname", "middleInitial",
+ conduit);
- assertEquals(property.getPropertyName(), "middleInitial");
- assertSame(property.getConduit(), conduit);
- assertSame(property.getPropertyType(), propertyType);
+ assertEquals(model.getPropertyNames(),
+ Arrays.asList("firstName", "middleInitial", "lastName", "age"));
- verify();
- }
+ assertEquals(property.getPropertyName(), "middleInitial");
+ assertSame(property.getConduit(), conduit);
+ assertSame(property.getPropertyType(), propertyType);
- @Test
- public void filtering_out_read_only_properties()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void filtering_out_read_only_properties()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(ReadOnlyBean.class, true, messages);
+ replay();
- assertEquals(model.getPropertyNames(), Arrays.asList("value"));
+ BeanModel model = source.create(ReadOnlyBean.class, true, messages);
- model = source.create(ReadOnlyBean.class, false, messages);
+ assertEquals(model.getPropertyNames(), Arrays.asList("value"));
- assertEquals(model.getPropertyNames(), Arrays.asList("value", "readOnly"));
+ model = source.create(ReadOnlyBean.class, false, messages);
- verify();
- }
+ assertEquals(model.getPropertyNames(), Arrays.asList("value", "readOnly"));
- @Test
- public void non_text_property()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void non_text_property()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(EnumBean.class, true, messages);
+ replay();
- assertEquals(model.getPropertyNames(), Arrays.asList("token"));
+ BeanModel model = source.create(EnumBean.class, true, messages);
- assertEquals(model.get("token").getDataType(), "enum");
+ assertEquals(model.getPropertyNames(), Arrays.asList("token"));
- verify();
- }
+ assertEquals(model.get("token").getDataType(), "enum");
- @Test
- public void add_duplicate_property_name_is_failure()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void add_duplicate_property_name_is_failure()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- try
- {
- model.add("age");
- unreachable();
- } catch (RuntimeException ex)
- {
- assertEquals(
- ex.getMessage(),
- "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean already contains a property model for property \'age\'.");
- }
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- verify();
- }
+ try
+ {
+ model.add("age");
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertEquals(ex.getMessage(),
+ "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean already contains a property model for property \'age\'.");
+ }
- @Test
- public void unknown_property_name()
- {
- Messages messages = mockMessages();
+ verify();
+ }
- stub_contains(messages, false);
+ @Test
+ public void unknown_property_name()
+ {
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ replay();
- try
- {
- model.get("frobozz");
- unreachable();
- } catch (UnknownValueException ex)
- {
- assertEquals(
- ex.getMessage(),
- "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean does not contain a property named \'frobozz\'.");
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName");
- }
+ try
+ {
+ model.get("frobozz");
+ unreachable();
+ }
+ catch (UnknownValueException ex)
+ {
+ assertEquals(ex.getMessage(),
+ "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean does not contain a property named \'frobozz\'.");
- verify();
- }
+ assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName");
+ }
+
+ verify();
+ }
+
+ @Test
+ public void unknown_property_id()
+ {
+ Messages messages = mockMessages();
+
+ stub_contains(messages, false);
+
+ replay();
+
+ BeanModel model = source.create(SimpleBean.class, true, messages);
+
+ model.addEmpty("shrub.foo()");
- @Test
- public void unknown_property_id()
- {
- Messages messages = mockMessages();
+ try
+ {
+ model.getById("frobozz");
+ unreachable();
+ }
+ catch (UnknownValueException ex)
+ {
+ assertEquals(ex.getMessage(),
+ "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean does not contain a property with id \'frobozz\'.");
+
+ assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName",
+ "shrubfoo");
+ }
+
+ verify();
+ }
+
+ @Test
+ public void get_added_property_by_name()
+ {
+ Messages messages = mockMessages();
- stub_contains(messages, false);
+ stub_contains(messages, false);
- replay();
+ replay();
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- model.addEmpty("shrub.foo()");
+ PropertyModel pm = model.addEmpty("shrub.foo()");
- try
- {
- model.getById("frobozz");
- unreachable();
- } catch (UnknownValueException ex)
- {
- assertEquals(
- ex.getMessage(),
- "Bean editor model for org.apache.tapestry5.genericsresolverguava.internal.SimpleBean does not contain a property with id \'frobozz\'.");
+ assertSame(model.get("Shrub.Foo()"), pm);
- assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName", "shrubfoo");
- }
+ verify();
+ }
- verify();
- }
+ @Test
+ public void get_added_property_by_id()
+ {
+ Messages messages = mockMessages();
- @Test
- public void get_added_property_by_name()
- {
- Messages messages = mockMessages();
+ stub_contains(messages, false);
- stub_contains(messages, false);
+ replay();
- replay();
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ PropertyModel pm = model.addEmpty("shrub.foo()");
- PropertyModel pm = model.addEmpty("shrub.foo()");
+ assertSame(model.getById("ShrubFoo"), pm);
- assertSame(model.get("Shrub.Foo()"), pm);
+ verify();
- verify();
- }
+ }
- @Test
- public void get_added_property_by_id()
- {
- Messages messages = mockMessages();
+ @Test
+ public void order_via_annotation()
+ {
+ Messages messages = mockMessages();
- stub_contains(messages, false);
+ stub_contains(messages, false);
- replay();
+ replay();
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ BeanModel model = source.create(StoogeBean.class, true, messages);
- PropertyModel pm = model.addEmpty("shrub.foo()");
+ assertEquals(model.getPropertyNames(), Arrays.asList("larry", "moe", "shemp", "curly"));
- assertSame(model.getById("ShrubFoo"), pm);
+ verify();
+ }
- verify();
+ @Test
+ public void edit_property_label()
+ {
+ Messages messages = mockMessages();
- }
+ stub_contains(messages, false);
- @Test
- public void order_via_annotation()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel model = source.create(SimpleBean.class, true, messages).get("age")
+ .label("Decrepitude").model();
- replay();
+ assertEquals(model.get("age").getLabel(), "Decrepitude");
- BeanModel model = source.create(StoogeBean.class, true, messages);
+ verify();
+ }
- assertEquals(model.getPropertyNames(), Arrays.asList("larry", "moe", "shemp", "curly"));
+ @Test
+ public void label_from_component_messages()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- @Test
- public void edit_property_label()
- {
- Messages messages = mockMessages();
+ train_contains(messages, "age-label", true);
+ train_get(messages, "age-label", "Decrepitude");
- stub_contains(messages, false);
+ replay();
- replay();
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- BeanModel model = source.create(SimpleBean.class, true, messages).get("age").label("Decrepitude").model();
+ assertEquals(model.get("age").getLabel(), "Decrepitude");
- assertEquals(model.get("age").getLabel(), "Decrepitude");
+ verify();
+ }
- verify();
- }
+ @Test
+ public void array_type_bean()
+ {
+ Messages messages = mockMessages();
- @Test
- public void label_from_component_messages()
- {
- Messages messages = mockMessages();
+ stub_contains(messages, false);
- stub_contains(messages, false);
+ replay();
- train_contains(messages, "age-label", true);
- train_get(messages, "age-label", "Decrepitude");
+ BeanModel model = source.create(StringArrayBean.class, true, messages);
- replay();
+ // There's not editor for string arrays yet, so it won't show up normally.
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ PropertyModel propertyModel = model.add("array");
- assertEquals(model.get("age").getLabel(), "Decrepitude");
+ assertSame(propertyModel.getPropertyType(), String[].class);
- verify();
- }
+ String[] value =
+ { "foo", "bar" };
- @Test
- public void array_type_bean()
- {
- Messages messages = mockMessages();
+ StringArrayBean bean = new StringArrayBean();
- stub_contains(messages, false);
+ PropertyConduit conduit = propertyModel.getConduit();
- replay();
+ conduit.set(bean, value);
- BeanModel model = source.create(StringArrayBean.class, true, messages);
+ assertSame(bean.getArray(), value);
- // There's not editor for string arrays yet, so it won't show up normally.
+ assertSame(conduit.get(bean), value);
- PropertyModel propertyModel = model.add("array");
+ verify();
+ }
- assertSame(propertyModel.getPropertyType(), String[].class);
+ @Test
+ public void composite_bean()
+ {
+ Messages messages = mockMessages();
- String[] value =
- {"foo", "bar"};
+ stub_contains(messages, false);
- StringArrayBean bean = new StringArrayBean();
+ train_contains(messages, "simpleage-label", true);
+ train_get(messages, "simpleage-label", "Years of Age");
- PropertyConduit conduit = propertyModel.getConduit();
+ replay();
- conduit.set(bean, value);
+ BeanModel model = source.create(CompositeBean.class, true, messages);
- assertSame(bean.getArray(), value);
+ // No editor for CompositeBean, so this will be empty.
- assertSame(conduit.get(bean), value);
+ assertEquals(model.getPropertyNames(), Collections.emptyList());
- verify();
- }
+ // There's not editor for string arrays yet, so it won't show up normally.
- @Test
- public void composite_bean()
- {
- Messages messages = mockMessages();
+ PropertyModel firstName = model.add("simple.firstName");
- stub_contains(messages, false);
+ assertEquals(firstName.getLabel(), "First Name");
- train_contains(messages, "simpleage-label", true);
- train_get(messages, "simpleage-label", "Years of Age");
+ PropertyModel age = model.add("simple.age");
+ assertEquals(age.getLabel(), "Years of Age");
- replay();
+ CompositeBean bean = new CompositeBean();
- BeanModel model = source.create(CompositeBean.class, true, messages);
+ firstName.getConduit().set(bean, "Fred");
+ age.getConduit().set(bean, "97");
- // No editor for CompositeBean, so this will be empty.
+ assertEquals(bean.getSimple().getFirstName(), "Fred");
+ assertEquals(bean.getSimple().getAge(), 97);
- assertEquals(model.getPropertyNames(), Collections.emptyList());
+ bean.getSimple().setAge(24);
- // There's not editor for string arrays yet, so it won't show up normally.
+ assertEquals(age.getConduit().get(bean), new Integer(24));
- PropertyModel firstName = model.add("simple.firstName");
+ verify();
+ }
- assertEquals(firstName.getLabel(), "First Name");
+ @Test
+ public void default_properties_exclude_write_only()
+ {
+ Messages messages = mockMessages();
- PropertyModel age = model.add("simple.age");
- assertEquals(age.getLabel(), "Years of Age");
+ stub_contains(messages, false);
- CompositeBean bean = new CompositeBean();
+ replay();
- firstName.getConduit().set(bean, "Fred");
- age.getConduit().set(bean, "97");
+ BeanModel model = source.create(WriteOnlyBean.class, false, messages);
- assertEquals(bean.getSimple().getFirstName(), "Fred");
- assertEquals(bean.getSimple().getAge(), 97);
+ assertEquals(model.getPropertyNames(), Arrays.asList("readOnly", "readWrite"));
- bean.getSimple().setAge(24);
+ verify();
+ }
- assertEquals(age.getConduit().get(bean), new Integer(24));
+ @Test
+ public void add_synthetic_property()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- @Test
- public void default_properties_exclude_write_only()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- replay();
+ PropertyModel property = model.addEmpty("placeholder");
- BeanModel model = source.create(WriteOnlyBean.class, false, messages);
+ assertFalse(property.isSortable());
+ assertSame(property.getPropertyType(), Object.class);
+ assertEquals(property.getLabel(), "Placeholder");
- assertEquals(model.getPropertyNames(), Arrays.asList("readOnly", "readWrite"));
+ verify();
+ }
- verify();
- }
+ @Test
+ public void add_missing_property_is_failure()
+ {
+ Messages messages = mockMessages();
- @Test
- public void add_synthetic_property()
- {
- Messages messages = mockMessages();
+ stub_contains(messages, false);
- stub_contains(messages, false);
+ replay();
- replay();
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ try
+ {
+ model.add("doesNotExist");
+ unreachable();
+ }
+ catch (Exception ex)
+ {
+ assertMessageContains(ex, "does not contain", "doesNotExist");
+ }
- PropertyModel property = model.addEmpty("placeholder");
+ verify();
+ }
- assertFalse(property.isSortable());
- assertSame(property.getPropertyType(), Object.class);
- assertEquals(property.getLabel(), "Placeholder");
+ @Test
+ public void exclude_property()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- @Test
- public void add_missing_property_is_failure()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- replay();
+ assertSame(model.exclude("age"), model);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName"));
- try
- {
- model.add("doesNotExist");
- unreachable();
- } catch (Exception ex)
- {
- assertMessageContains(ex, "does not contain", "doesNotExist");
- }
+ verify();
+ }
- verify();
- }
+ @Test
+ public void exclude_unknown_property_is_noop()
+ {
+ Messages messages = mockMessages();
- @Test
- public void exclude_property()
- {
- Messages messages = mockMessages();
+ stub_contains(messages, false);
- stub_contains(messages, false);
+ replay();
- replay();
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ assertSame(model.exclude("frobozz"), model);
- assertSame(model.exclude("age"), model);
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName"));
+ verify();
+ }
- verify();
- }
+ @Test
+ public void nonvisual_properties_are_excluded()
+ {
+ Messages messages = mockMessages();
- @Test
- public void exclude_unknown_property_is_noop()
- {
- Messages messages = mockMessages();
+ stub_contains(messages, false);
- stub_contains(messages, false);
+ replay();
- replay();
+ BeanModel model = source.create(NonVisualBean.class, true, messages);
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ assertEquals(model.getPropertyNames(), Arrays.asList("name"));
- assertSame(model.exclude("frobozz"), model);
+ verify();
+ }
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ @Test
+ public void reorder()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- @Test
- public void nonvisual_properties_are_excluded()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel model = source.create(SimpleBean.class, true, messages);
- replay();
+ assertSame(model.getBeanType(), SimpleBean.class);
- BeanModel model = source.create(NonVisualBean.class, true, messages);
+ // Based on order of the getter methods (no longer alphabetical)
- assertEquals(model.getPropertyNames(), Arrays.asList("name"));
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
- verify();
- }
+ // Testing a couple of things here:
+ // 1) case insensitive
+ // 2) unreferenced property names added to the end.
- @Test
- public void reorder()
- {
- Messages messages = mockMessages();
+ model.reorder("lastname", "AGE");
- stub_contains(messages, false);
+ assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age", "firstName"));
- replay();
+ verify();
+ }
- BeanModel model = source.create(SimpleBean.class, true, messages);
+ @Test
+ public void reoder_from_annotation()
+ {
+ Messages messages = mockMessages();
- assertSame(model.getBeanType(), SimpleBean.class);
+ stub_contains(messages, false);
- // Based on order of the getter methods (no longer alphabetical)
+ replay();
- assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
+ BeanModel model = source.create(PropertyOrderBean.class, true, messages);
- // Testing a couple of things here:
- // 1) case insensitive
- // 2) unreferenced property names added to the end.
+ assertEquals(model.getPropertyNames(), Arrays.asList("third", "first", "second"));
- model.reorder("lastname", "AGE");
+ verify();
+ }
- assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age", "firstName"));
+ // https://issues.apache.org/jira/browse/TAP5-1798
+ @Test
+ public void static_fields_are_ignored()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- @Test
- public void reoder_from_annotation()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel<BeanWithStaticField> model = source.createDisplayModel(BeanWithStaticField.class,
+ messages);
- replay();
+ assertListsEquals(model.getPropertyNames(), "name");
- BeanModel model = source.create(PropertyOrderBean.class, true, messages);
+ verify();
+ }
- assertEquals(model.getPropertyNames(), Arrays.asList("third", "first", "second"));
+ // https://issues.apache.org/jira/browse/TAP5-2305
+ @Test
+ public void sortable_annotation()
+ {
+ Messages messages = mockMessages();
- verify();
- }
+ stub_contains(messages, false);
- // https://issues.apache.org/jira/browse/TAP5-1798
- @Test
- public void static_fields_are_ignored()
- {
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel<SortableBean> model = source.createDisplayModel(SortableBean.class, messages);
+ model.add("nonSortableByDefault");
+ model.add("sortable");
- replay();
+ // checking whether non-@Sortable annotated properties still behave in the old ways
+ assertTrue(model.get("sortableByDefault").isSortable());
+ assertFalse(model.get("nonSortableByDefault").isSortable());
- BeanModel<BeanWithStaticField> model = source.createDisplayModel(BeanWithStaticField.class, messages);
+ // checking @Sortable itself
+ assertFalse(model.get("nonSortable").isSortable());
+ assertTrue(model.get("sortable").isSortable());
- assertListsEquals(model.getPropertyNames(), "name");
+ verify();
+ }
- verify();
- }
-
- // https://issues.apache.org/jira/browse/TAP5-2305
- @Test
- public void sortable_annotation()
- {
- Messages messages = mockMessages();
+ // https://issues.apache.org/jira/browse/TAP5-2560
+ @Test
+ public void missing_property_due_to_wrong_type_parameter_resolution()
+ {
- stub_contains(messages, false);
+ Messages messages = mockMessages();
- replay();
+ stub_contains(messages, false);
- BeanModel<SortableBean> model = source.createDisplayModel(SortableBean.class, messages);
- model.add("nonSortableByDefault");
- model.add("sortable");
-
- // checking whether non-@Sortable annotated properties still behave in the old ways
- assertTrue(model.get("sortableByDefault").isSortable());
- assertFalse(model.get("nonSortableByDefault").isSortable());
-
- // checking @Sortable itself
- assertFalse(model.get("nonSortable").isSortable());
- assertTrue(model.get("sortable").isSortable());
+ replay();
- verify();
- }
-
- // https://issues.apache.org/jira/browse/TAP5-2560
- @Test
- public void missing_property_due_to_wrong_type_parameter_resolution()
- {
+ BeanModel<FileContentUnit> beanModel = source.createDisplayModel(FileContentUnit.class,
+ messages);
- Messages messages = mockMessages();
+ // throws "org.apache.tapestry5.internal.services.PropertyExpressionException: Exception
+ // generating conduit for expression 'content.mimeType': Class
+ // org.apache.tapestry5.internal.services.AbstractBeanModelSourceImplTest$ContentData does
+ // not contain a property (or public field) named 'mimeType'." without fix
+ beanModel.add("content.mimeType");
- stub_contains(messages, false);
+ verify();
- replay();
+ }
- BeanModel<FileContentUnit> beanModel = source.createDisplayModel(FileContentUnit.class, messages);
-
- // throws "org.apache.tapestry5.internal.services.PropertyExpressionException: Exception generating conduit for expression 'content.mimeType': Class org.apache.tapestry5.internal.services.AbstractBeanModelSourceImplTest$ContentData does not contain a property (or public field) named 'mimeType'." without fix
- beanModel.add("content.mimeType");
+ // https://issues.apache.org/jira/browse/TAP5-2560
+ @Test
+ public void handling_nested_generics()
+ {
- verify();
+ Messages messages = mockMessages();
- }
-
- // https://issues.apache.org/jira/browse/TAP5-2560
- @Test
- public void handling_nested_generics()
- {
+ stub_contains(messages, false);
- Messages messages = mockMessages();
+ replay();
- stub_contains(messages, false);
+ BeanModel<BeanHolder> beanModel = source.createDisplayModel(BeanHolder.class, messages);
- replay();
+ // this line would throw an exception
+ beanModel.add("bean.value");
- BeanModel<BeanHolder> beanModel = source.createDisplayModel(BeanHolder.class, messages);
-
- // this line would throw an exception
- beanModel.add("bean.value");
+ verify();
- verify();
+ }
- }
-
// https://issues.apache.org/jira/browse/TAP5-2032
@Test
- public void tap5_2032()
+ public void tap5_2032()
{
// explodes without fix
new PropertyAccessImpl().getAdapter(ById.class);
}
-
- public interface IdentifiableEnum<E extends Enum<E>, ID extends Number>
+
+ public interface IdentifiableEnum<E extends Enum<E>, ID extends Number>
{
ID getId();
}
- public enum ById implements IdentifiableEnum<ById, Byte>
+ public enum ById implements IdentifiableEnum<ById, Byte>
{
;
- public Byte getId()
+ public Byte getId()
{
return null;
}
}
-
- final private static class SortableBean
- {
- private int sortableByDefault;
- private int nonSortable;
- private SimpleBean sortable;
- private SimpleBean nonSortableByDefault;
-
- public int getSortableByDefault()
- {
- return sortableByDefault;
- }
-
- @Sortable(false)
- public int getNonSortable()
- {
- return nonSortable;
- }
-
- @Sortable(true)
- public SimpleBean getSortable()
- {
- return sortable;
- }
-
- public SimpleBean getNonSortableByDefault()
- {
- return nonSortableByDefault;
- }
-
- }
-
- public interface NonTranslatableContentUnit<T extends ContentData> {
+
+ final private static class SortableBean
+ {
+ private int sortableByDefault;
+ private int nonSortable;
+ private SimpleBean sortable;
+ private SimpleBean nonSortableByDefault;
+
+ public int getSortableByDefault()
+ {
+ return sortableByDefault;
+ }
+
+ @Sortable(false)
+ public int getNonSortable()
+ {
+ return nonSortable;
+ }
+
+ @Sortable(true)
+ public SimpleBean getSortable()
+ {
+ return sortable;
+ }
+
+ public SimpleBean getNonSortableByDefault()
+ {
+ return nonSortableByDefault;
+ }
+
+ }
+
+ public interface NonTranslatableContentUnit<T extends ContentData>
+ {
T getContent();
}
- public interface BinaryContentUnit<T extends BinaryContent> extends NonTranslatableContentUnit<T> {
+ public interface BinaryContentUnit<T extends BinaryContent>
+ extends NonTranslatableContentUnit<T>
+ {
}
- public interface FileContentUnit extends BinaryContentUnit<FileContent> {
+ public interface FileContentUnit extends BinaryContentUnit<FileContent>
+ {
}
- public interface ContentData {
+ public interface ContentData
+ {
boolean isEmpty();
}
- public interface BinaryContent extends ContentData {
+ public interface BinaryContent extends ContentData
+ {
String getMimeType();
}
- public interface FileContent extends BinaryContent {
+ public interface FileContent extends BinaryContent
+ {
}
- public class ConcreteFileContent implements FileContentUnit {
+ public class ConcreteFileContent implements FileContentUnit
+ {
@Override
- public FileContent getContent() {
+ public FileContent getContent()
+ {
return null;
}
}
-
- public class BeanHolder {
+
+ public class BeanHolder
+ {
private final Bean bean;
- public BeanHolder(Bean bean) {
+ public BeanHolder(Bean bean)
+ {
super();
this.bean = bean;
}
-
- public Bean getBean() {
+ public Bean getBean()
+ {
return bean;
}
-
+
}
-
- public class Bean<T> implements Comparable<Bean<T>> {
+
+ public class Bean<T> implements Comparable<Bean<T>>
+ {
private final T value_;
- public Bean(T value) {
+ public Bean(T value)
+ {
value_ = value;
}
@Override
- public int compareTo(Bean<T> o) {
+ public int compareTo(Bean<T> o)
+ {
return 0;
}
- public T getValue() {
+ public T getValue()
+ {
return value_;
}
}
diff --git a/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/GuavaBeanModelSourceImplTest.java b/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/GuavaBeanModelSourceImplTest.java
index 55a7cbeee..913a8cc77 100644
--- a/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/GuavaBeanModelSourceImplTest.java
+++ b/genericsresolver-guava/src/test/java/org/apache/tapestry5/genericsresolverguava/internal/GuavaBeanModelSourceImplTest.java
@@ -13,6 +13,7 @@ package org.apache.tapestry5.genericsresolverguava.internal;
import org.apache.tapestry5.beanmodel.BeanModelSourceBuilder;
import org.apache.tapestry5.beanmodel.services.BeanModelSource;
+import org.testng.annotations.Test;
public class GuavaBeanModelSourceImplTest extends AbstractBeanModelSourceImplTest {
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 000000000..0990af421
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,137 @@
+[versions]
+
+# LOGGING
+
+slf4j = "1.7.25"
+
+# JAKARTA
+
+jakartaAnnotationApi = "2.0.0"
+jakartaInjectApi = "2.0.1"
+jakartaPersistenceApi = "3.0.0"
+jakartaServletApi = "5.0.0"
+jakartaValidationApi = "3.0.2"
+jakartaXmlBindApi = "2.3.2"
+
+# APACHE COMMONS
+
+commonsCodec = "1.13"
+commonsIo = "2.17.0"
+commonsLang = "3.17.0"
+commonsLogging = "1.1.3"
+commonsText = "1.13.1"
+
+# HIBERNATE
+
+hibernate = "5.4.32.Final"
+hsqldb = "2.7.3"
+
+# ANTLR
+
+antlr = "3.5.3"
+
+# MISC
+
+snakeyaml = "2.3"
+cglib = "2.2"
+hamcrestCore = "1.3"
+json = "20140107"
+xmlApis = "1.4.01"
+guice = "3.0"
+groovy = "3.0.13"
+
+# TESTING
+slf4j-simple = "2.0.17"
+junit5 = "5.10.2"
+junit4 = "4.13.2"
+testng = "7.5.1"
+easymock = "5.4.0"
+spock = "2.3-groovy-3.0"
+geb = "2.0"
+webdrivermanager = "5.3.1"
+selenium = "4.5.0"
+seleniumJava = "4.12.1"
+seleniumServer = "4.12.1"
+
+
+[libraries]
+
+# LOGGING
+
+slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
+slf4j-log4j12 = { module = "org.slf4j:slf4j-log4j12", version.ref = "slf4j" }
+
+# JAKARTA
+
+jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakartaAnnotationApi" }
+jakarta-inject-api = { module = "jakarta.inject:jakarta.inject-api", version.ref = "jakartaInjectApi" }
+jakarta-persistence-api = { module = "jakarta.persistence:jakarta.persistence-api", version.ref = "jakartaPersistenceApi" }
+jakarta-servlet-api = { module = "jakarta.servlet:jakarta.servlet-api", version.ref = "jakartaServletApi" }
+jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakartaValidationApi" }
+jakarta-xml-bind-api = { module = "jakarta.xml.bind:jakarta.xml.bind-api", version.ref = "jakartaXmlBindApi" }
+
+# APACHE COMMONS
+
+commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" }
+commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" }
+commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commonsLang" }
+commons-logging = { module = "commons-logging:commons-logging", version.ref = "commonsLogging" }
+commons-text = { module = "org.apache.commons:commons-text", version.ref = "commonsText" }
+
+# HIBERNATE
+
+hibernate-core = { module = "org.hibernate:hibernate-core", version.ref = "hibernate" }
+hsqldb = { module = "org.hsqldb:hsqldb", version.ref = "hsqldb" }
+
+# ANTLR
+
+antlr = { module = "org.antlr:antlr", version.ref = "antlr" }
+antlr-runtime = { module = "org.antlr:antlr-runtime", version.ref = "antlr" }
+
+# MISC
+
+snakeyaml = { module = "org.yaml:snakeyaml", version.ref = "snakeyaml" }
+cglib-nodep = { module = "cglib:cglib-nodep", version.ref = "cglib" }
+hamcrest-core = { module = "org.hamcrest:hamcrest-core", version.ref = "hamcrestCore" }
+json = { module = "org.json:json", version.ref = "json" }
+xml-apis = { module = "xml-apis:xml-apis", version.ref = "xmlApis" }
+guice = { module = "com.google.inject:guice", version.ref = "guice" }
+
+# GROOVY
+groovy-core = { group = "org.codehaus.groovy", name = "groovy", version.ref = "groovy" }
+groovy-json = { group = "org.codehaus.groovy", name = "groovy-json", version.ref = "groovy" }
+groovy-nio = { group = "org.codehaus.groovy", name = "groovy-nio", version.ref = "groovy" }
+
+# BOM
+
+junit-bom = { module = "org.junit:junit-bom", version.ref = "junit5" }
+spock-bom = { module = "org.spockframework:spock-bom", version.ref = "spock" }
+
+# TESTING
+
+slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j-simple" }
+
+junit-jupiter = { module = "org.junit.jupiter:junit-jupiter"}
+
+junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" }
+junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params" }
+junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
+junit4 = { module = "junit:junit", version.ref = "junit4" }
+
+testng = { module = "org.testng:testng", version.ref = "testng" }
+easymock = { module = "org.easymock:easymock", version.ref = "easymock" }
+spock-core = { module = "org.spockframework:spock-core" }
+geb-spock = { module = "org.gebish:geb-spock", version.ref = "geb" }
+selenium-legrc = { module = "org.seleniumhq.selenium:selenium-leg-rc", version.ref = "selenium" }
+selenium-api = { module = "org.seleniumhq.selenium:selenium-api", version.ref = "selenium" }
+selenium-java = { module = "org.seleniumhq.selenium:selenium-java", version.ref = "seleniumJava" }
+selenium-server = { module = "org.seleniumhq.selenium:selenium-server", version.ref = "seleniumServer" }
+webdrivermanager = { module = "io.github.bonigarcia:webdrivermanager", version.ref = "webdrivermanager" }
+
+
+[bundles]
+
+groovy = [ "groovy-core", "groovy-json", "groovy-nio" ]
+junit-jupiter-essentials = [ "junit-jupiter-api", "junit-jupiter-params" ]
+
+
diff --git a/plastic/build.gradle b/plastic/build.gradle
index f5bdee139..b8a53e12f 100644
--- a/plastic/build.gradle
+++ b/plastic/build.gradle
@@ -1,15 +1,12 @@
-description = "High-level runtime transformations of Java classes"
-
-dependencies {
- implementation "org.slf4j:slf4j-api:${versions.slf4j}"
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
-
-test {
- useJUnit()
+plugins {
+ id 'tapestry.junit5-spock-convention'
}
-// Add the source directory for the imported/repackaged ASM 7.0.1 code
+description = 'High-level runtime transformations of Java classes'
-sourceSets.main.java.srcDir "src/external/java"
+dependencies {
+ implementation libs.slf4j.api
+}
+// add vendored ASM
+sourceSets.main.java.srcDir 'src/external/java'
diff --git a/plastic/src/test/conf/testng.xml b/plastic/src/test/conf/testng.xml
deleted file mode 100644
index f8e52b4e2..000000000
--- a/plastic/src/test/conf/testng.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<!-- This file is only needed for compatibility with the Maven build, it is not needed for the Gradle build -->
-<suite name="Plastic" annotations="1.5" verbose="2">
- <test name="Placeholder -- Maven Build / TestNG Can't Run The Spock Tests">
- </test>
-</suite>
diff --git a/plastic/src/test/java/org/apache/tapestry5/plastic/PlasticUtilsTest.java b/plastic/src/test/java/org/apache/tapestry5/plastic/PlasticUtilsTest.java
index 399ac3960..0e066cb86 100644
--- a/plastic/src/test/java/org/apache/tapestry5/plastic/PlasticUtilsTest.java
+++ b/plastic/src/test/java/org/apache/tapestry5/plastic/PlasticUtilsTest.java
@@ -22,7 +22,6 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import org.apache.tapestry5.internal.plastic.asm.util.ASMifier;
import org.apache.tapestry5.plastic.test.PlasticUtilsTestObject;
import org.apache.tapestry5.plastic.test.PlasticUtilsTestObjectSuperclass;
import org.apache.tapestry5.plastic.test_.Enumeration;
diff --git a/quickstart/build.gradle b/quickstart/build.gradle
index 7fc50bc5a..8e6de1418 100644
--- a/quickstart/build.gradle
+++ b/quickstart/build.gradle
@@ -28,7 +28,7 @@ task addGradleWrapper(type: Exec) {
wrapperDirectory.mkdirs()
def settings = new File(wrapperDirectory, "settings.gradle")
- new FileOutputStream(settings).close();
+ new FileOutputStream(settings).close()
}
finalizedBy 'copyGradleWrapper'
diff --git a/quickstart/src/main/resources-filtered/archetype-resources/build-spring-boot.gradle b/quickstart/src/main/resources-filtered/archetype-resources/build-spring-boot.gradle
index 7d363ca57..a26e07e79 100644
--- a/quickstart/src/main/resources-filtered/archetype-resources/build-spring-boot.gradle
+++ b/quickstart/src/main/resources-filtered/archetype-resources/build-spring-boot.gradle
@@ -62,7 +62,9 @@ dependencies {
// Test
testImplementation("org.apache.tapestry:tapestry-test:${versions.tapestry}")
- testImplementation("org.junit.jupiter:junit-jupiter:${versions.junit}")
+ testImplementation platform("org.junit:junit-bom:${versions.junitJupiter}")
+ testImplementation "org.junit.jupiter:junit-jupiter"
+ testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
// Miscellaneous
implementation("org.apache.logging.log4j:log4j-api:${versions.log4j}")
diff --git a/quickstart/src/main/resources-filtered/archetype-resources/build.gradle b/quickstart/src/main/resources-filtered/archetype-resources/build.gradle
index 1806bdb31..0fb035984 100644
--- a/quickstart/src/main/resources-filtered/archetype-resources/build.gradle
+++ b/quickstart/src/main/resources-filtered/archetype-resources/build.gradle
@@ -46,7 +46,9 @@ dependencies {
// Test
testImplementation("org.apache.tapestry:tapestry-test:${versions.tapestry}")
- testImplementation("org.junit.jupiter:junit-jupiter:${versions.junit}")
+ testImplementation platform("org.junit:junit-bom:${versions.junitJupiter}")
+ testImplementation "org.junit.jupiter:junit-jupiter"
+ testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
// Miscellaneous
implementation("org.apache.logging.log4j:log4j-api:${versions.log4j}")
diff --git a/settings.gradle b/settings.gradle
index f7400a150..3d2241c7a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -3,6 +3,66 @@ plugins {
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
}
+rootProject.name = "tapestry-5"
+
+dependencyResolutionManagement {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ maven {
+ name = "JBoss"
+ url = "https://repository.jboss.org/nexus/content/repositories/releases/"
+ }
+ maven {
+ // tapestry-jpa
+ name "EclipseLink"
+ url "https://download.eclipse.org/rt/eclipselink/maven.repo/"
+ }
+ }
+}
+
+include("plastic",
+ "tapestry5-annotations",
+ "tapestry-test",
+ "tapestry-func",
+ "tapestry-ioc",
+ "tapestry-json",
+ "tapestry-http",
+ "tapestry-core",
+ "tapestry-hibernate-core",
+ "tapestry-hibernate",
+ "tapestry-jmx",
+ "tapestry-upload",
+ "tapestry-beanvalidator",
+ "tapestry-jpa",
+ "tapestry-kaptcha",
+ "quickstart",
+ "tapestry-clojure",
+ "tapestry-mongodb",
+ "tapestry-test-data",
+ "tapestry-internal-test",
+ "tapestry-ioc-junit",
+ "tapestry-webresources",
+ "tapestry-runner",
+ "tapestry-test-constants",
+ "tapestry-ioc-jcache",
+ "beanmodel",
+ "commons",
+ "genericsresolver-guava",
+ "tapestry-version-migrator",
+ "tapestry-spock",
+ "tapestry-openapi-viewer",
+ "tapestry-rest-jackson")
+
+if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
+ include "tapestry-javadoc"
+}
+
+if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
+ include "tapestry-latest-java-tests", "tapestry-spring"
+}
+
+
def isTravisCI = System.getenv('TRAVIS_JOB_ID') != null
def isJenkins = System.getenv('JENKINS_URL') != null
def isCI = isTravisCI || isJenkins
@@ -16,11 +76,16 @@ develocity {
obfuscation {
// This obfuscates the IP addresses of the build machine in the build scan.
// Alternatively, the build scan will provide the hostname for troubleshooting host-specific issues.
- ipAddresses { addresses -> addresses.collect { address -> "0.0.0.0"} }
+ ipAddresses { addresses ->
+ addresses.collect { address ->
+ "0.0.0.0"
+ }
+ }
}
}
}
+
buildCache {
local {
enabled = !isCI
@@ -30,21 +95,3 @@ buildCache {
enabled = false
}
}
-
-rootProject.name = "tapestry"
-
-include "plastic", "tapestry5-annotations", "tapestry-test", "tapestry-func", "tapestry-ioc", "tapestry-json", "tapestry-http", "tapestry-core"
-include "tapestry-hibernate-core", "tapestry-hibernate", "tapestry-jmx", "tapestry-upload"
-include "tapestry-beanvalidator", "tapestry-jpa", "tapestry-kaptcha"
-if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
- include "tapestry-javadoc"
-}
-if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
- include "tapestry-latest-java-tests", "tapestry-spring"
-}
-include "quickstart", "tapestry-clojure", "tapestry-mongodb"
-include "tapestry-test-data", 'tapestry-internal-test', "tapestry-ioc-junit"
-include "tapestry-webresources", "tapestry-runner", "tapestry-test-constants"
-include "tapestry-ioc-jcache", "beanmodel", "commons", "genericsresolver-guava", "tapestry-version-migrator"
-// include "tapestry-cdi"
-include "tapestry-spock", "tapestry-openapi-viewer", "tapestry-rest-jackson"
diff --git a/sha256.gradle b/sha256.gradle
index 8abaec5ff..5153fc8ce 100644
--- a/sha256.gradle
+++ b/sha256.gradle
@@ -2,24 +2,26 @@ import java.security.MessageDigest
class GenSHA256 extends SourceTask {
- def outputDir
+ def outputDir
- @OutputDirectory
- File getOutputDir() { project.file(outputDir) }
+ @OutputDirectory
+ File getOutputDir() {
+ project.file(outputDir)
+ }
- @TaskAction
- void writeSHA256s() {
+ @TaskAction
+ void writeSHA256s() {
- source.each { file ->
- MessageDigest digest = MessageDigest.getInstance("SHA-256")
+ source.each { file ->
+ MessageDigest digest = MessageDigest.getInstance("SHA-256")
- digest.update(file.bytes)
+ digest.update(file.bytes)
- def checksum = new BigInteger(1, digest.digest()).toString(16).padLeft(32, "0")
+ def checksum = new BigInteger(1, digest.digest()).toString(16).padLeft(32, "0")
- new File(outputDir, file.name + ".sha256").text = checksum
+ new File(outputDir, file.name + ".sha256").text = checksum
+ }
}
- }
}
project.ext.GenSHA256 = GenSHA256.class
\ No newline at end of file
diff --git a/ssh.gradle b/ssh.gradle
index e367719ce..fb5fe76df 100644
--- a/ssh.gradle
+++ b/ssh.gradle
@@ -3,122 +3,122 @@ project.ext.SshExec = SshExec.class
project.ext.SshTask = SshTask.class
configurations {
- sshAntTask
+ sshAntTask
}
dependencies {
- sshAntTask "org.apache.ant:ant-jsch:1.8.2"
+ sshAntTask "org.apache.ant:ant-jsch:1.8.2"
}
tasks.withType(SshTask) {
- sshAntClasspath = configurations.sshAntTask
+ sshAntClasspath = configurations.sshAntTask
}
class SshTask extends DefaultTask {
- @InputFiles
- FileCollection sshAntClasspath
-
- @Input
- String host
-
- @Input
- String userName
-
- @Input
- String password
-
- boolean verbose = false
-
- private boolean antInited = false
-
- protected initAnt() {
- if (!antInited) {
- ant.taskdef(name: 'scp',
- classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
- classpath: sshAntClasspath.asPath,
- loaderref: 'ssh')
- ant.taskdef(name: 'sshexec',
- classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec',
- classpath: sshAntClasspath.asPath,
- loaderref: 'ssh')
- antInited = true
+ @InputFiles
+ FileCollection sshAntClasspath
+
+ @Input
+ String host
+
+ @Input
+ String userName
+
+ @Input
+ String password
+
+ boolean verbose = false
+
+ private boolean antInited = false
+
+ protected initAnt() {
+ if (!antInited) {
+ ant.taskdef(name: 'scp',
+ classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
+ classpath: sshAntClasspath.asPath,
+ loaderref: 'ssh')
+ ant.taskdef(name: 'sshexec',
+ classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec',
+ classpath: sshAntClasspath.asPath,
+ loaderref: 'ssh')
+ antInited = true
+ }
}
- }
-
- protected withInfoLogging(Closure action) {
- def oldLogLevel = logging.level
- logging.level = [LogLevel.INFO, oldLogLevel].min()
- try {
- action()
- } finally {
- if (oldLogLevel) {
- logging.level = oldLogLevel
- }
+
+ protected withInfoLogging(Closure action) {
+ def oldLogLevel = logging.level
+ logging.level = [LogLevel.INFO, oldLogLevel].min()
+ try {
+ action()
+ } finally {
+ if (oldLogLevel) {
+ logging.level = oldLogLevel
+ }
+ }
}
- }
- def scpFile(source, destination) {
- initAnt()
- withInfoLogging {
- ant.scp(localFile: project.files(source).singleFile, remoteToFile: "${userName}@${host}:${destination}", keyfile : "${System.properties['user.home']}/.ssh/id_dsa", verbose: verbose)
+ def scpFile(source, destination) {
+ initAnt()
+ withInfoLogging {
+ ant.scp(localFile: project.files(source).singleFile, remoteToFile: "${userName}@${host}:${destination}", keyfile : "${System.properties['user.home']}/.ssh/id_dsa", verbose: verbose)
+ }
}
- }
-
- def scpDir(source, destination) {
- initAnt()
- withInfoLogging {
- ant.sshexec(host: host, username: userName, password: password, command: "mkdir -p ${destination}")
- ant.scp(remoteTodir: "${userName}@${host}:${destination}", keyfile : "${System.properties['user.home']}/.ssh/id_dsa", verbose: verbose) {
- project.files(source).addToAntBuilder(ant, "fileSet", FileCollection.AntType.FileSet)
- }
+
+ def scpDir(source, destination) {
+ initAnt()
+ withInfoLogging {
+ ant.sshexec(host: host, username: userName, password: password, command: "mkdir -p ${destination}")
+ ant.scp(remoteTodir: "${userName}@${host}:${destination}", keyfile : "${System.properties['user.home']}/.ssh/id_dsa", verbose: verbose) {
+ project.files(source).addToAntBuilder(ant, "fileSet", FileCollection.AntType.FileSet)
+ }
+ }
}
- }
- def ssh(Object... commandLine) {
- initAnt()
- withInfoLogging {
- ant.sshexec(host: host, username: userName, password: password, command: commandLine.join(' '))
+ def ssh(Object... commandLine) {
+ initAnt()
+ withInfoLogging {
+ ant.sshexec(host: host, username: userName, password: password, command: commandLine.join(' '))
+ }
}
- }
}
class Scp extends SshTask {
- @InputFiles @SkipWhenEmpty source
- @Input destination
- boolean isDir = false
-
- @TaskAction
- void doActions() {
- if (isDir) {
- scpDir(source, destination)
- return
+ @InputFiles @SkipWhenEmpty source
+ @Input destination
+ boolean isDir = false
+
+ @TaskAction
+ void doActions() {
+ if (isDir) {
+ scpDir(source, destination)
+ return
+ }
+
+ project.files(source).each { doFile(it) }
}
- project.files(source).each { doFile(it) }
- }
+ void doFile(File file) {
- void doFile(File file) {
-
- if (file.directory) {
- file.eachFile { doFile(it) }
- } else {
- scpFile(file, destination)
+ if (file.directory) {
+ file.eachFile { doFile(it) }
+ } else {
+ scpFile(file, destination)
+ }
}
- }
}
class SshExec extends SshTask {
- @Input
- List<String[]> commandLines = []
+ @Input
+ List<String[]> commandLines = []
- void commandLine(String... commandLine) {
- commandLines << commandLine
- }
+ void commandLine(String... commandLine) {
+ commandLines << commandLine
+ }
- @TaskAction
- void doActions() {
- commandLines.each { commandLine ->
- ssh(* commandLine)
+ @TaskAction
+ void doActions() {
+ commandLines.each { commandLine ->
+ ssh(* commandLine)
+ }
}
- }
}
\ No newline at end of file
diff --git a/support/tapestry-core.launch b/support/tapestry-core.launch
index 4d923c7f3..eafc3ca08 100644
--- a/support/tapestry-core.launch
+++ b/support/tapestry-core.launch
@@ -20,7 +20,7 @@
<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/>
<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="10"/>
<listAttribute key="org.testng.eclipse.SUITE_TEST_LIST">
-<listEntry value="tapestry-core/src/test/conf/testng.xml"/>
+<listEntry value="tapestry-core/src/test/resources/testng.xml"/>
</listAttribute>
<intAttribute key="org.testng.eclipse.TYPE" value="3"/>
</launchConfiguration>
diff --git a/support/tapestry-ioc.launch b/support/tapestry-ioc.launch
index 8579e1534..58dc95617 100644
--- a/support/tapestry-ioc.launch
+++ b/support/tapestry-ioc.launch
@@ -14,7 +14,7 @@
<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/>
<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="2"/>
<listAttribute key="org.testng.eclipse.SUITE_TEST_LIST">
-<listEntry value="tapestry-ioc/src/test/conf/testng.xml"/>
+<listEntry value="tapestry-ioc/src/test/resources/testng.xml"/>
</listAttribute>
<intAttribute key="org.testng.eclipse.TYPE" value="3"/>
</launchConfiguration>
diff --git a/support/tapestry-spring.launch b/support/tapestry-spring.launch
index 595617693..54d3c735b 100644
--- a/support/tapestry-spring.launch
+++ b/support/tapestry-spring.launch
@@ -20,7 +20,7 @@
<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/>
<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="10"/>
<listAttribute key="org.testng.eclipse.SUITE_TEST_LIST">
-<listEntry value="tapestry-spring/src/test/conf/testng.xml"/>
+<listEntry value="tapestry-spring/src/test/resources/testng.xml"/>
</listAttribute>
<intAttribute key="org.testng.eclipse.TYPE" value="3"/>
</launchConfiguration>
diff --git a/tapestry-beanvalidator/build.gradle b/tapestry-beanvalidator/build.gradle
index 47f4aeefb..d7c2014c3 100644
--- a/tapestry-beanvalidator/build.gradle
+++ b/tapestry-beanvalidator/build.gradle
@@ -1,34 +1,43 @@
+plugins {
+ id 'tapestry.testng-convention'
+}
+
import t5build.*
-description = "Support for JSR-303 Bean Validation via the Hibernate validator implementation"
+description = 'Support for JSR-303 Bean Validation via the Hibernate validator implementation'
+
+ext.moduleLibs = [
+ hibernateValidator: 'org.hibernate:hibernate-validator:8.0.1.Final',
+]
dependencies {
- implementation project(':tapestry-core')
+ implementation project(':tapestry-core')
- implementation "jakarta.validation:jakarta.validation-api:3.0.2"
- implementation "org.hibernate:hibernate-validator:8.0.1.Final"
+ implementation libs.jakarta.validation.api
+ implementation moduleLibs.hibernateValidator
- testImplementation project(':tapestry-test')
- implementation "org.seleniumhq.selenium:selenium-leg-rc:${versions.selenium}", {
- exclude group: "org.seleniumhq.selenium", module: "jetty-repacked"
- exclude group: "org.testng", module: "testng"
- }
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
+ implementation libs.selenium.legrc, {
+ exclude group: "org.seleniumhq.selenium", module: "jetty-repacked"
+ exclude group: "org.testng", module: "testng"
+ }
+ testImplementation project(':tapestry-test')
}
+def generatedOutputBaseDir = 'src/main/generated'
+
task compileCoffeeScript(type: CompileCoffeeScript) {
- outputDir "src/main/generated/compiled-coffeescript"
+ outputDir "${generatedOutputBaseDir}/compiled-coffeescript"
}
// Start up the test app, useful when debugging failing integration tests
task runTestApp303(type:JavaExec) {
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/webapp", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/webapp", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
-clean.delete 'src/main/generated'
+clean.delete generatedOutputBaseDir
sourceSets {
main {
diff --git a/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java b/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
index 5d84b892f..d67cee35f 100644
--- a/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
+++ b/tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
@@ -15,8 +15,6 @@ package org.apache.tapestry5.beanvalidator.integration;
import org.apache.tapestry5.test.SeleniumTestCase;
import org.apache.tapestry5.test.TapestryTestConfiguration;
-import org.openqa.selenium.By;
-import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.annotations.Test;
@Test(singleThreaded = true, groups = "integration")
diff --git a/tapestry-beanvalidator/src/test/conf/testng.xml b/tapestry-beanvalidator/src/test/resources/testng.xml
similarity index 86%
rename from tapestry-beanvalidator/src/test/conf/testng.xml
rename to tapestry-beanvalidator/src/test/resources/testng.xml
index 1b56fcbce..ea8af84ab 100644
--- a/tapestry-beanvalidator/src/test/conf/testng.xml
+++ b/tapestry-beanvalidator/src/test/resources/testng.xml
@@ -15,10 +15,15 @@
limitations under the License.
-->
-<suite name="Tapestry Bean Validator" parallel="false" thread-count="10" annotations="1.5" verbose="2">
+<suite
+ name="Tapestry Bean Validator"
+ parallel="false"
+ thread-count="10"
+ annotations="1.5"
+ verbose="2">
<test name="Tapestry Bean Validatior Integration Tests">
<packages>
- <package name="org.apache.tapestry5.beanvalidator.integration"/>
+ <package name="org.apache.tapestry5.beanvalidator.integration" />
</packages>
</test>
</suite>
diff --git a/tapestry-clojure/build.gradle b/tapestry-clojure/build.gradle
index 95cacd151..6e1bfa77c 100644
--- a/tapestry-clojure/build.gradle
+++ b/tapestry-clojure/build.gradle
@@ -1,21 +1,21 @@
-description = "Allows Clojure functions to be injected into Tapestry services and components"
+plugins {
+ id 'tapestry.junit5-spock-convention'
+}
+description = 'Allows Clojure functions to be injected into Tapestry services and components'
+
+ext.moduleLibs = [
+ clojure: 'org.clojure:clojure:1.6.0',
+]
dependencies {
- implementation project(':tapestry-ioc')
- implementation "org.clojure:clojure:1.6.0"
+ implementation project(':tapestry-ioc')
- // Added just to prove that it works (TAP5-1945)
- testImplementation project(':tapestry-core')
- testRuntimeOnly "jakarta.servlet:jakarta.servlet-api:${versions.servletapi}"
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
+ implementation moduleLibs.clojure
-test {
- useJUnit()
-}
+ // Added just to prove that it works (TAP5-1945)
+ testImplementation project(':tapestry-core')
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.clojure.modules.ClojureModule'
- }
+ testRuntimeOnly libs.jakarta.servlet.api
}
+
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.clojure.modules.ClojureModule'
diff --git a/tapestry-clojure/src/test/java/org/apache/tapestry5/clojure/tests/TestModule.java b/tapestry-clojure/src/test/java/org/apache/tapestry5/clojure/tests/TestModule.java
index 2697ddc4b..ea8b0cff8 100644
--- a/tapestry-clojure/src/test/java/org/apache/tapestry5/clojure/tests/TestModule.java
+++ b/tapestry-clojure/src/test/java/org/apache/tapestry5/clojure/tests/TestModule.java
@@ -1,9 +1,22 @@
package org.apache.tapestry5.clojure.tests;
import org.apache.tapestry5.clojure.ClojureBuilder;
+import org.apache.tapestry5.commons.MappedConfiguration;
+import org.apache.tapestry5.http.TapestryHttpConstants;
+import org.apache.tapestry5.http.internal.TapestryHttpInternalConstants;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.services.ApplicationDefaults;
+import org.apache.tapestry5.ioc.services.SymbolProvider;
public class TestModule
{
+
+ @ApplicationDefaults
+ @Contribute(SymbolProvider.class)
+ public static void contributeTestApplicationDefaults(MappedConfiguration<String, String> conf)
+ {
+ conf.add(TapestryHttpInternalConstants.TAPESTRY_APP_PACKAGE_PARAM, "test");
+ }
public static Fixture buildFixture(ClojureBuilder builder)
{
return builder.build(Fixture.class);
diff --git a/tapestry-core/build.gradle b/tapestry-core/build.gradle
index 328e1e9eb..ba2e00292 100644
--- a/tapestry-core/build.gradle
+++ b/tapestry-core/build.gradle
@@ -7,6 +7,9 @@ description = "Central module for Tapestry, containing all core services and com
project.ext {
mainGeneratedDir = "src/main/generated"
testGeneratedDir = "src/test/generated"
+ moduleVersions = [
+ httpclient: '4.5.14',
+ ]
}
clean.delete mainGeneratedDir, testGeneratedDir
@@ -17,30 +20,33 @@ dependencies {
api project(':beanmodel')
api project(':tapestry-http')
- api "org.apache.commons:commons-lang3:${versions.commonsLang}"
+ implementation libs.jakarta.annotation.api
+ implementation libs.jakarta.xml.bind.api
-
- implementation 'jakarta.annotation:jakarta.annotation-api:2.0.0'
- implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2'
-// implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
-// implementation 'com.sun.xml.ws:jaxws-rt:2.3.2'
-// implementation 'javax.xml.ws:jaxws-api:2.3.1'
+ implementation libs.commons.codec
+ implementation libs.commons.lang3
provided project(":tapestry-test")
provided project(":tapestry-test-constants")
- provided "jakarta.servlet:jakarta.servlet-api:${versions.servletapi}"
+ provided libs.jakarta.servlet.api
+
+ testImplementation platform(libs.junit.bom)
+ testImplementation libs.junit.jupiter
- implementation "commons-codec:commons-codec:1.13"
+ testImplementation libs.testng
+ testImplementation libs.easymock
+ testRuntimeOnly libs.slf4j.simple
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
- testImplementation "org.apache.httpcomponents:httpclient:4.5.14"
- testRuntimeOnly project(':tapestry-spock')
+ testImplementation "org.apache.httpcomponents:httpclient:${moduleVersions.httpclient}"
+ testImplementation project(":tapestry-spock")
- testRuntimeOnly "org.hsqldb:hsqldb:${versions.hsqldb}"
- testRuntimeOnly 'com.google.inject:guice:3.0'
+ testRuntimeOnly("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
+ testRuntimeOnly libs.guice
}
+
+
task preprocessCoffeeScript(type: PreprocessCoffeeScript) {
}
@@ -73,57 +79,73 @@ sourceSets {
compileTestGroovy.dependsOn compileTestJava
test {
- // Needed to have XMLTokenStreamTests.testStreamEncoding() passing on Java 9+
+ useTestNG()
+ // Needed to have XMLTokenStreamTests.testStreamEncoding() passing on Java 9+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_9)) {
- jvmArgs("--add-opens=java.base/java.nio.charset=ALL-UNNAMED");
+ jvmArgs("--add-opens=java.base/java.nio.charset=ALL-UNNAMED")
+ }
+
+ // TAP5-2722
+ systemProperty 'user.language', 'en'
+
+ useJUnitPlatform()
+ useTestNG {
+ def suiteFile = file('src/test/resources/testng.xml')
+ if (suiteFile.exists()) {
+ suites suiteFile
+ }
}
- // TAP5-2722
- systemProperty 'user.language', 'en'
}
task runTestApp1(type:JavaExec) {
- description 'Start app1 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app1", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app1 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app1", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestApp2(type:JavaExec) {
- description 'Start app2 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app2", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app2 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app2", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestApp3(type:JavaExec) {
- description 'Start app3 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app3", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app3 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app3", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestApp4(type:JavaExec) {
- description 'Start app4 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app4", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app4 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app4", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestApp5(type:JavaExec) {
- description 'Start app5 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app5", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app5 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app5", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestApp7(type:JavaExec) {
- description 'Start app7 integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/app7", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start app7 integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/app7", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
+
task runTestAppfolder(type:JavaExec) {
- description 'Start appFolder integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/appfolder", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start appFolder integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/appfolder", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
task testWithPrototype(type:Test) {
- systemProperties."tapestry.javascript-infrastructure-provider" = "prototype"
+ systemProperties."tapestry.javascript-infrastructure-provider" = "prototype"
}
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/ThrowawayClassLoader.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ThrowawayClassLoader.java
index 62c133210..a62357b22 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/ThrowawayClassLoader.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ThrowawayClassLoader.java
@@ -14,7 +14,8 @@
package org.apache.tapestry5.internal;
-import static org.junit.Assert.assertNotEquals;
+
+import static org.testng.Assert.assertNotEquals;
import org.apache.tapestry5.internal.plastic.PlasticInternalUtils;
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PartialTemplateRendererTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PartialTemplateRendererTests.groovy
index 5943a6928..833ee1d26 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PartialTemplateRendererTests.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PartialTemplateRendererTests.groovy
@@ -14,9 +14,7 @@
package org.apache.tapestry5.integration.app1
-import org.apache.tapestry5.services.PartialTemplateRenderer;
import org.testng.annotations.Test
-import org.junit.Assert;
/**
* Tests the {@link PartialTemplateRenderer} service.
@@ -27,37 +25,33 @@ class PartialTemplateRendererTests extends App1TestCase {
@Test
void render_block() {
-
+
open "/partialtemplaterendererdemo"
assertEquals(getAttribute("css=#original dl@class"), getAttribute("css=#serviceRenderedBlock dl@class"))
-
+
// checking whether service-rendered block is the same as the original
for (int i = 1; i <= getXpathCount("//div[@id='original']/dl/*"); i++) {
-
- assertEquals(
- getAttribute("//div[@id='original']/dl/*[" + i + "]@class"),
- getAttribute("//div[@id='serviceRenderedBlock']/dl/*[" + i + "]/@class"))
assertEquals(
- getText("//div[@id='original']/dl/*[" + i + "]"),
- getText("//div[@id='serviceRenderedBlock']/dl/*[" + i + "]"))
+ getAttribute("//div[@id='original']/dl/*[" + i + "]@class"),
+ getAttribute("//div[@id='serviceRenderedBlock']/dl/*[" + i + "]/@class"))
- }
+ assertEquals(
+ getText("//div[@id='original']/dl/*[" + i + "]"),
+ getText("//div[@id='serviceRenderedBlock']/dl/*[" + i + "]"))
+ }
// checking whether service-rendered component is the same as the original
for (int i = 1; i <= getXpathCount("//div[@id='original']/dl/*"); i++) {
-
- assertEquals(
- getAttribute("//div[@id='originalBeanDisplay']/dl/*[" + i + "]@class"),
- getAttribute("//div[@id='serviceRenderedComponent']/dl/*[" + i + "]/@class"))
assertEquals(
- getText("//div[@id='originalBeanDisplay']/dl/*[" + i + "]"),
- getText("//div[@id='serviceRenderedComponent']/dl/*[" + i + "]"))
+ getAttribute("//div[@id='originalBeanDisplay']/dl/*[" + i + "]@class"),
+ getAttribute("//div[@id='serviceRenderedComponent']/dl/*[" + i + "]/@class"))
+ assertEquals(
+ getText("//div[@id='originalBeanDisplay']/dl/*[" + i + "]"),
+ getText("//div[@id='serviceRenderedComponent']/dl/*[" + i + "]"))
}
-
}
-
}
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java
index 7e52ff03a..7f3a1f985 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java
@@ -14,19 +14,19 @@
package org.apache.tapestry5.integration.cluster;
-import com.thoughtworks.selenium.DefaultSelenium;
-import com.thoughtworks.selenium.Selenium;
-import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
-import io.github.bonigarcia.wdm.managers.FirefoxDriverManager;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
import org.apache.tapestry5.test.JettyRunner;
-import org.apache.tapestry5.test.TapestryTestConstants;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.session.DatabaseAdaptor;
import org.eclipse.jetty.server.session.DefaultSessionIdManager;
import org.eclipse.jetty.server.session.JDBCSessionDataStore;
-import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
@@ -34,13 +34,10 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.xml.XmlTest;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
+import com.thoughtworks.selenium.Selenium;
+import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
+import io.github.bonigarcia.wdm.managers.FirefoxDriverManager;
/**
* User: josh_canfield Date: 6/24/11
@@ -182,7 +179,7 @@ public class ClusterTests
private void assertText(String locator, String expected)
{
- assertEquals(expected, selenium.getText(locator));
+ assertEquals(selenium.getText(locator), expected);
}
private void clickAndWait(String s)
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentDependencyRegistryImplTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentDependencyRegistryImplTest.java
index 8115652dc..6964d5444 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentDependencyRegistryImplTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentDependencyRegistryImplTest.java
@@ -14,9 +14,9 @@
package org.apache.tapestry5.internal.services;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import java.io.File;
import java.net.MalformedURLException;
@@ -104,40 +104,41 @@ import org.testng.annotations.Test;
@SuppressWarnings("deprecation")
public class ComponentDependencyRegistryImplTest
{
-
+
private ComponentDependencyRegistryImpl componentDependencyRegistry;
-
+
private PageClassLoaderContextManager pageClassLoaderContextManager;
-
+
private ComponentClassResolver resolver;
-
+
private PlasticManager plasticManager;
-
+
private TemplateParser templateParser;
-
+
private ComponentTemplateLocator componentTemplateLocator;
-
+
@BeforeMethod
public void setup()
{
- assertFalse(
- String.format("During testing, %s shouldn't exist", ComponentDependencyRegistry.FILENAME),
- new File(ComponentDependencyRegistry.FILENAME).exists());
-
+ assertFalse(new File(ComponentDependencyRegistry.FILENAME).exists(), String.format(
+ "During testing, %s shouldn't exist", ComponentDependencyRegistry.FILENAME));
+
MockMappedConfiguration<String, URL> templateConfiguration = new MockMappedConfiguration<String, URL>();
TapestryModule.contributeTemplateParser(templateConfiguration);
- templateParser = new TemplateParserImpl(templateConfiguration.map, false, new QuietOperationTracker());
-
+ templateParser = new TemplateParserImpl(templateConfiguration.map, false,
+ new QuietOperationTracker());
+
final String rootFolder = "src/test/app1/";
final File folderFile = new File(rootFolder);
final Resource app1ContextFolderResource = new FileResource("/", folderFile);
-
- final PageTemplateLocator pageTemplateLocator = new PageTemplateLocator(app1ContextFolderResource, resolver, "");
+
+ final PageTemplateLocator pageTemplateLocator = new PageTemplateLocator(
+ app1ContextFolderResource, resolver, "");
final DefaultTemplateLocator defaultTemplateLocator = new DefaultTemplateLocator();
- componentTemplateLocator = new ComponentTemplateLocator()
+ componentTemplateLocator = new ComponentTemplateLocator()
{
@Override
- public Resource locateTemplate(ComponentModel model, Locale locale)
+ public Resource locateTemplate(ComponentModel model, Locale locale)
{
Resource resource = defaultTemplateLocator.locateTemplate(model, locale);
if (resource == null)
@@ -147,16 +148,16 @@ public class ComponentDependencyRegistryImplTest
return resource != null && resource.exists() ? resource : null;
}
};
-
+
resolver = EasyMock.createMock(ComponentClassResolver.class);
-
+
EasyMock.expect(resolver.resolvePageClassNameToPageName(EasyMock.anyString()))
.andAnswer(() -> {
String s = ((String) EasyMock.getCurrentArguments()[0]);
final String pageName = s.substring(s.lastIndexOf('.') + 1);
return pageName;
}).anyTimes();
-
+
expectResolveComponent(TextField.class);
expectResolveComponent(PasswordField.class);
expectResolveComponent(Border.class);
@@ -165,7 +166,7 @@ public class ComponentDependencyRegistryImplTest
expectResolveComponent(ActionLink.class);
expectResolveComponent(If.class);
expectResolveComponent(ErrorComponent.class);
- expectResolveComponent(EventLink.class);
+ expectResolveComponent(EventLink.class);
expectResolveComponent(Output.class);
expectResolveComponent(Delegate.class);
expectResolveComponent(TextOutput.class);
@@ -184,101 +185,105 @@ public class ComponentDependencyRegistryImplTest
expectResolveComponent(Glyphicon.class);
expectResolveComponent(SubclassWithImport.class);
expectResolveComponent(OutputRaw.class);
-
+
EasyMock.expect(resolver.resolveMixinTypeToClassName("textonlyondisabled"))
- .andReturn(TextOnlyOnDisabled.class.getName()).anyTimes();
+ .andReturn(TextOnlyOnDisabled.class.getName()).anyTimes();
EasyMock.expect(resolver.resolveMixinTypeToClassName("echovalue2"))
- .andReturn(EchoValue2.class.getName()).anyTimes();
+ .andReturn(EchoValue2.class.getName()).anyTimes();
EasyMock.expect(resolver.resolveMixinTypeToClassName("alttitledefault"))
- .andReturn(AltTitleDefault.class.getName()).anyTimes();
+ .andReturn(AltTitleDefault.class.getName()).anyTimes();
EasyMock.expect(resolver.resolveMixinTypeToClassName("formgroup"))
- .andReturn(FormGroup.class.getName()).anyTimes();
-
+ .andReturn(FormGroup.class.getName()).anyTimes();
+
EasyMock.expect(resolver.isPage(EasyMock.anyString())).andAnswer(() -> {
String string = (String) EasyMock.getCurrentArguments()[0];
return string.contains(".pages.");
}).anyTimes();
-
+
pageClassLoaderContextManager = EasyMock.createMock(PageClassLoaderContextManager.class);
plasticManager = EasyMock.createMock(PlasticManager.class);
EasyMock.expect(plasticManager.shouldInterceptClassLoading(EasyMock.anyString()))
- .andAnswer(() -> {
- String className = (String) EasyMock.getCurrentArguments()[0];
- return className.contains(".pages.") || className.contains(".mixins.") ||
- className.contains(".components.") || className.contains(".base.");
- }).anyTimes();
-
+ .andAnswer(() -> {
+ String className = (String) EasyMock.getCurrentArguments()[0];
+ return className.contains(".pages.") || className.contains(".mixins.")
+ || className.contains(".components.") || className.contains(".base.");
+ }).anyTimes();
+
componentDependencyRegistry = new ComponentDependencyRegistryImpl(
- pageClassLoaderContextManager, plasticManager, resolver, templateParser,
+ pageClassLoaderContextManager, plasticManager, resolver, templateParser,
componentTemplateLocator, ComponentDependencyRegistry.FILENAME, false);
EasyMock.replay(pageClassLoaderContextManager, plasticManager, resolver);
}
- private void expectResolveComponent(final Class<?> clasz) {
+ private void expectResolveComponent(final Class<?> clasz)
+ {
final String className = clasz.getName();
final java.lang.String simpleName = clasz.getSimpleName();
- EasyMock.expect(resolver.resolveComponentTypeToClassName(simpleName))
- .andReturn(className).anyTimes();
+ EasyMock.expect(resolver.resolveComponentTypeToClassName(simpleName)).andReturn(className)
+ .anyTimes();
EasyMock.expect(resolver.resolveComponentTypeToClassName(simpleName.toLowerCase()))
- .andReturn(className).anyTimes();
+ .andReturn(className).anyTimes();
EasyMock.expect(resolver.resolveComponentTypeToClassName(
simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1)))
- .andReturn(className).anyTimes();
+ .andReturn(className).anyTimes();
}
-
+
private void configurePCCM(boolean merging)
{
EasyMock.reset(pageClassLoaderContextManager);
EasyMock.expect(pageClassLoaderContextManager.isMerging()).andReturn(merging).anyTimes();
EasyMock.replay(pageClassLoaderContextManager);
}
-
+
@Test(timeOut = 5000)
public void listen()
{
-
+
componentDependencyRegistry.setEnableEnsureClassIsAlreadyProcessed(false);
-
+
add("foo", "bar");
add("d", "a");
add("dd", "aa");
add("dd", "a");
add("dd", "a");
-
+
final List<String> resources = Arrays.asList("a", "aa", "none");
-
+
configurePCCM(true);
List<String> result = componentDependencyRegistry.listen(resources);
- assertEquals(0, result.size());
-
+ assertEquals(result.size(), 0);
+
configurePCCM(false);
result = componentDependencyRegistry.listen(resources);
Collections.sort(result);
assertEquals(result, Arrays.asList("d", "dd"));
assertEquals("bar", getDependencies("foo").iterator().next());
- assertEquals("foo", componentDependencyRegistry.getDependents("bar").iterator().next());
-
+ assertEquals("foo", componentDependencyRegistry.getDependents("bar").iterator().next());
+
configurePCCM(false);
result = componentDependencyRegistry.listen(Collections.emptyList());
assertEquals(result, Collections.emptyList());
assertEquals(componentDependencyRegistry.getDependents("bar").size(), 0);
assertEquals(getDependencies("foo").size(), 0);
-
+
}
-
+
private Set<String> getDependencies(String className)
{
Set<String> dependencies = new HashSet<>();
- dependencies.addAll(componentDependencyRegistry.getDependencies(className, DependencyType.USAGE));
- dependencies.addAll(componentDependencyRegistry.getDependencies(className, DependencyType.SUPERCLASS));
- dependencies.addAll(componentDependencyRegistry.getDependencies(className, DependencyType.INJECT_PAGE));
+ dependencies.addAll(
+ componentDependencyRegistry.getDependencies(className, DependencyType.USAGE));
+ dependencies.addAll(
+ componentDependencyRegistry.getDependencies(className, DependencyType.SUPERCLASS));
+ dependencies.addAll(
+ componentDependencyRegistry.getDependencies(className, DependencyType.INJECT_PAGE));
return Collections.unmodifiableSet(dependencies);
}
-
+
@Test
public void dependency_methods()
{
-
+
final String foo = "foo";
final String bar = "bar";
final String something = "something";
@@ -286,22 +291,18 @@ public class ComponentDependencyRegistryImplTest
final String fulano = "fulano";
final String beltrano = "beltrano";
final String sicrano = "sicrano";
-
+
componentDependencyRegistry.setEnableEnsureClassIsAlreadyProcessed(false);
-
- assertEquals(
- "getDependents() should never return null",
- Collections.emptySet(),
- getDependencies(foo));
-
- assertEquals(
- "getDependents() should never return null",
- Collections.emptySet(),
- componentDependencyRegistry.getDependents(foo));
+
+ assertEquals(getDependencies(foo), Collections.emptySet(),
+ "getDependents() should never return null");
+
+ assertEquals(componentDependencyRegistry.getDependents(foo), Collections.emptySet(),
+ "getDependents() should never return null");
// In Brazil, Fulano, Beltrano and Sicrano are the most used people
// placeholder names, in that order.
-
+
add(foo, bar);
add(something, fulano);
add(other, beltrano);
@@ -312,7 +313,7 @@ public class ComponentDependencyRegistryImplTest
add(beltrano, null);
add(beltrano, sicrano);
add(sicrano, null);
-
+
assertEquals(new HashSet<>(Arrays.asList(fulano, beltrano)), getDependencies(other));
assertEquals(new HashSet<>(Arrays.asList(fulano)), getDependencies(something));
assertEquals(new HashSet<>(Arrays.asList()), getDependencies(fulano));
@@ -320,15 +321,20 @@ public class ComponentDependencyRegistryImplTest
assertEquals(new HashSet<>(Arrays.asList()), getDependencies(bar));
assertEquals(new HashSet<>(Arrays.asList(sicrano)), getDependencies(beltrano));
- assertEquals(new HashSet<>(Arrays.asList(foo)), componentDependencyRegistry.getDependents(bar));
- assertEquals(new HashSet<>(Arrays.asList(other, something)), componentDependencyRegistry.getDependents(fulano));
- assertEquals(new HashSet<>(Arrays.asList()), componentDependencyRegistry.getDependents(foo));
- assertEquals(new HashSet<>(Arrays.asList(other)), componentDependencyRegistry.getDependents(beltrano));
- assertEquals(new HashSet<>(Arrays.asList(beltrano)), componentDependencyRegistry.getDependents(sicrano));
-
- assertEquals(new HashSet<>(Arrays.asList(bar, fulano, sicrano)),
+ assertEquals(new HashSet<>(Arrays.asList(foo)),
+ componentDependencyRegistry.getDependents(bar));
+ assertEquals(new HashSet<>(Arrays.asList(other, something)),
+ componentDependencyRegistry.getDependents(fulano));
+ assertEquals(new HashSet<>(Arrays.asList()),
+ componentDependencyRegistry.getDependents(foo));
+ assertEquals(new HashSet<>(Arrays.asList(other)),
+ componentDependencyRegistry.getDependents(beltrano));
+ assertEquals(new HashSet<>(Arrays.asList(beltrano)),
+ componentDependencyRegistry.getDependents(sicrano));
+
+ assertEquals(new HashSet<>(Arrays.asList(bar, fulano, sicrano)),
componentDependencyRegistry.getRootClasses());
-
+
assertTrue(componentDependencyRegistry.contains(foo));
assertTrue(componentDependencyRegistry.contains(bar));
assertTrue(componentDependencyRegistry.contains(other));
@@ -346,10 +352,10 @@ public class ComponentDependencyRegistryImplTest
assertTrue(componentDependencyRegistry.getClassNames().contains(beltrano));
assertTrue(componentDependencyRegistry.getClassNames().contains(sicrano));
assertFalse(componentDependencyRegistry.getClassNames().contains("blah"));
-
+
// Testing the clear method
componentDependencyRegistry.clear(beltrano);
-
+
assertEquals(new HashSet<>(Arrays.asList(fulano)), getDependencies(other));
assertEquals(new HashSet<>(Arrays.asList(fulano)), getDependencies(something));
assertEquals(new HashSet<>(Arrays.asList()), getDependencies(fulano));
@@ -357,14 +363,20 @@ public class ComponentDependencyRegistryImplTest
assertEquals(new HashSet<>(Arrays.asList()), getDependencies(bar));
assertEquals(new HashSet<>(Arrays.asList()), getDependencies(sicrano));
- assertEquals(new HashSet<>(Arrays.asList(foo)), componentDependencyRegistry.getDependents(bar));
- assertEquals(new HashSet<>(Arrays.asList(other, something)), componentDependencyRegistry.getDependents(fulano));
- assertEquals(new HashSet<>(Arrays.asList()), componentDependencyRegistry.getDependents(foo));
- assertEquals(new HashSet<>(Arrays.asList()), componentDependencyRegistry.getDependents(beltrano));
- assertEquals(new HashSet<>(Arrays.asList()), componentDependencyRegistry.getDependents(sicrano));
-
- assertEquals(new HashSet<>(Arrays.asList(bar, fulano, sicrano)), componentDependencyRegistry.getRootClasses());
-
+ assertEquals(new HashSet<>(Arrays.asList(foo)),
+ componentDependencyRegistry.getDependents(bar));
+ assertEquals(new HashSet<>(Arrays.asList(other, something)),
+ componentDependencyRegistry.getDependents(fulano));
+ assertEquals(new HashSet<>(Arrays.asList()),
+ componentDependencyRegistry.getDependents(foo));
+ assertEquals(new HashSet<>(Arrays.asList()),
+ componentDependencyRegistry.getDependents(beltrano));
+ assertEquals(new HashSet<>(Arrays.asList()),
+ componentDependencyRegistry.getDependents(sicrano));
+
+ assertEquals(new HashSet<>(Arrays.asList(bar, fulano, sicrano)),
+ componentDependencyRegistry.getRootClasses());
+
assertTrue(componentDependencyRegistry.contains(foo));
assertTrue(componentDependencyRegistry.contains(bar));
assertTrue(componentDependencyRegistry.contains(other));
@@ -382,13 +394,13 @@ public class ComponentDependencyRegistryImplTest
assertTrue(componentDependencyRegistry.getClassNames().contains(sicrano));
assertFalse(componentDependencyRegistry.getClassNames().contains(beltrano));
assertFalse(componentDependencyRegistry.getClassNames().contains("blah"));
-
+
}
-
+
@Test
public void get_all_non_page_dependencies()
{
-
+
final String page = "page";
final String className = "root";
final String superclass = "superclass";
@@ -397,14 +409,14 @@ public class ComponentDependencyRegistryImplTest
expectedAllNonPageDependencies.add(d);
add(c, d, DependencyType.USAGE);
};
-
+
componentDependencyRegistry.setEnableEnsureClassIsAlreadyProcessed(false);
-
+
add(className, page, DependencyType.INJECT_PAGE);
-
+
add(className, superclass, DependencyType.SUPERCLASS);
expectedAllNonPageDependencies.add(superclass);
-
+
add.accept(className, "child1");
add.accept(className, "child2");
add.accept("child1", "child1.1");
@@ -412,155 +424,152 @@ public class ComponentDependencyRegistryImplTest
add.accept("child2.1", className);
add.accept(superclass, "child2.1");
add.accept(superclass, "superclassDependency");
-
+
expectedAllNonPageDependencies.remove(className);
- final Set<String> allNonPageDependencies = componentDependencyRegistry.getAllNonPageDependencies(className);
+ final Set<String> allNonPageDependencies = componentDependencyRegistry
+ .getAllNonPageDependencies(className);
assertFalse(allNonPageDependencies.contains(className));
assertEquals(expectedAllNonPageDependencies, allNonPageDependencies);
-
+
}
-
+
@Test
public void register()
{
-
+
componentDependencyRegistry.setEnableEnsureClassIsAlreadyProcessed(true);
-
+
componentDependencyRegistry.clear();
-
+
// Dynamic dependency definitions
componentDependencyRegistry.register(PropertyDisplay.class);
assertDependencies(PropertyDisplay.class, AbstractPropertyOutput.class);
componentDependencyRegistry.register(PropertyEditor.class);
assertDependencies(PropertyEditor.class);
-
+
// Superclass
componentDependencyRegistry.register(EventLink.class);
// Superclass, recursively
assertDependencies(AbstractComponentEventLink.class, AbstractLink.class);
- assertDependencies(AbstractLink.class);
-
- // @InjectComponent
+ assertDependencies(AbstractLink.class);
+
+ // @InjectComponent
// Components declared in templates
componentDependencyRegistry.register(AlertsDemo.class);
assertDependencies(AlertsDemo.class, Zone.class, // @InjectComponent
// Components declared in template
- Border.class, BeanEditForm.class, Zone.class, If.class,
- ActionLink.class, ErrorComponent.class, EventLink.class);
-
+ Border.class, BeanEditForm.class, Zone.class, If.class, ActionLink.class,
+ ErrorComponent.class, EventLink.class);
+
// Mixins defined in in templates (t:mixins="...").
componentDependencyRegistry.register(MixinParameterDefault.class);
assertDependencies(MixinParameterDefault.class, AltTitleDefault.class, // Mixin
ActionLink.class, Border.class); // Components declared in template);
-
+
// @Component, type() not defined
componentDependencyRegistry.register(OuterAny.class);
assertDependencies(OuterAny.class, Any.class);
-
+
// @Component, type() defined
componentDependencyRegistry.register(AtComponentType.class);
assertDependencies(AtComponentType.class, TextField.class, Border.class);
// @Mixin, type() not defined
componentDependencyRegistry.register(AbstractTextField.class);
- assertDependencies(AbstractTextField.class,
- RenderDisabled.class, AbstractField.class);
+ assertDependencies(AbstractTextField.class, RenderDisabled.class, AbstractField.class);
// @Mixin, type() defined
componentDependencyRegistry.register(TextOnlyOnDisabledTextField.class);
- assertDependencies(TextOnlyOnDisabledTextField.class,
- TextOnlyOnDisabled.class, TextField.class);
-
+ assertDependencies(TextOnlyOnDisabledTextField.class, TextOnlyOnDisabled.class,
+ TextField.class);
+
// @MixinClasses and @Mixins
componentDependencyRegistry.register(InstanceMixinDependencies.class);
- assertDependencies(InstanceMixinDependencies.class,
- EchoValue.class, EchoValue2.class, TextField.class);
+ assertDependencies(InstanceMixinDependencies.class, EchoValue.class, EchoValue2.class,
+ TextField.class);
// Templates with <t:extension-point>
componentDependencyRegistry.register(BaseLayoutPage.class);
- assertDependencies(BaseLayoutPage.class,
- Delegate.class, SubclassWithImport.class, Border.class);
-
+ assertDependencies(BaseLayoutPage.class, Delegate.class, SubclassWithImport.class,
+ Border.class);
+
// Templates with <t:replace>
componentDependencyRegistry.register(SubclassWithImport.class);
- assertDependencies(SubclassWithImport.class,
- OutputRaw.class, SuperclassWithImport.class, Loop.class);
-
+ assertDependencies(SubclassWithImport.class, OutputRaw.class, SuperclassWithImport.class,
+ Loop.class);
+
// Circular dependency: BlockHolder <-> BlockCaller
componentDependencyRegistry.register(BlockHolder.class);
- assertDependencies(BlockHolder.class,
- BlockCaller.class, Loop.class, ActionLink.class);
- assertDependencies(BlockCaller.class,
- BlockHolder.class, Border.class, PageLink.class, Delegate.class);
-
+ assertDependencies(BlockHolder.class, BlockCaller.class, Loop.class, ActionLink.class);
+ assertDependencies(BlockCaller.class, BlockHolder.class, Border.class, PageLink.class,
+ Delegate.class);
+
}
-
- private void assertDependencies(Class<?> clasz, Class<?>... dependencies) {
- assertEquals(
- setOf(dependencies),
- getDependencies(clasz.getName()));
+
+ private void assertDependencies(Class<?> clasz, Class<?>... dependencies)
+ {
+ assertEquals(setOf(dependencies), getDependencies(clasz.getName()));
}
- private static Set<String> setOf(Class<?> ... classes)
+ private static Set<String> setOf(Class<?>... classes)
{
- return Arrays.asList(classes).stream()
- .map(Class::getName)
- .collect(Collectors.toSet());
+ return Arrays.asList(classes).stream().map(Class::getName).collect(Collectors.toSet());
}
private void add(String component, String dependency)
{
add(component, dependency, DependencyType.USAGE);
}
-
+
private void add(String component, String dependency, DependencyType type)
{
componentDependencyRegistry.add(component, dependency, type, true);
}
@SuppressWarnings("hiding")
- private static final class MockMappedConfiguration<String, URL> implements MappedConfiguration<String, URL>
+ private static final class MockMappedConfiguration<String, URL>
+ implements MappedConfiguration<String, URL>
{
-
+
private final Map<String, URL> map = new HashMap<>();
@Override
- public void add(String key, URL value)
+ public void add(String key, URL value)
{
map.put(key, value);
}
@Override
- public void override(String key, URL value)
+ public void override(String key, URL value)
{
throw new UnsupportedOperationException();
}
@Override
- public void addInstance(String key, Class<? extends URL> clazz)
+ public void addInstance(String key, Class<? extends URL> clazz)
{
throw new UnsupportedOperationException();
}
@Override
- public void overrideInstance(String key, Class<? extends URL> clazz)
+ public void overrideInstance(String key, Class<? extends URL> clazz)
{
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException();
}
-
+
}
-
+
final private static class FileResource extends AbstractResource
{
-
+
final private File file;
-
+
final private String path;
- public FileResource(String path, File file)
+ public FileResource(String path, File file)
{
super(path);
this.file = file;
@@ -568,30 +577,31 @@ public class ComponentDependencyRegistryImplTest
}
@Override
- public java.net.URL toURL()
+ public java.net.URL toURL()
{
- try
+ try
{
final File actualFile = new File(file, path);
return actualFile.exists() ? actualFile.toURL() : null;
- } catch (MalformedURLException e)
+ }
+ catch (MalformedURLException e)
{
throw new RuntimeException(e);
}
}
@Override
- protected Resource newResource(String path)
+ protected Resource newResource(String path)
{
return new FileResource(path, file);
}
@Override
- public String toString()
+ public String toString()
{
return "FileResource [file=" + file + "/" + path + "]";
}
-
+
}
-
+
}
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
index ca7f59e6b..96d452272 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
@@ -22,8 +22,6 @@ import org.apache.tapestry5.services.ApplicationStateCreator;
import org.apache.tapestry5.services.ApplicationStatePersistenceStrategy;
import org.testng.annotations.Test;
-import spock.lang.Issue;
-
public class SessionApplicationStatePersistenceStrategyTest extends InternalBaseTestCase
{
@SuppressWarnings("unchecked")
@@ -69,7 +67,7 @@ public class SessionApplicationStatePersistenceStrategyTest extends InternalBase
@SuppressWarnings("unchecked")
@Test
- @Issue("TAP5-2537")
+ // TAP5-2537
public void check_exists_with_invalid_session()
{
Request request = mockRequest();
diff --git a/tapestry-core/src/test/conf/testng-limited.xml b/tapestry-core/src/test/resources/testng-limited.xml
similarity index 100%
rename from tapestry-core/src/test/conf/testng-limited.xml
rename to tapestry-core/src/test/resources/testng-limited.xml
diff --git a/tapestry-core/src/test/conf/testng.xml b/tapestry-core/src/test/resources/testng.xml
similarity index 55%
rename from tapestry-core/src/test/conf/testng.xml
rename to tapestry-core/src/test/resources/testng.xml
index e30025f49..e7ffac3f7 100644
--- a/tapestry-core/src/test/conf/testng.xml
+++ b/tapestry-core/src/test/resources/testng.xml
@@ -7,119 +7,160 @@
<!-- The suite may no longer be run in parallel, because of some tricky issues related to locking of class loaders. Running
in parallel causes thread deadlocks, when unmanaged tests run at the same time as Selenium-based integration tests. See TAPESTRY-2561. -->
-<suite name="Tapestry Core" annotations="1.5" verbose="2">
- <test name="Component Unit Tests" enabled="true">
+<suite
+ name="Tapestry Core"
+ annotations="1.5"
+ verbose="2">
+ <test
+ name="Component Unit Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.pagetester"/>
- <package name="org.apache.tapestry5.integration.pagelevel"/>
- <package name="org.apache.tapestry5.corelib.base"/>
- <package name="org.apache.tapestry5.corelib.components"/>
- <package name="org.apache.tapestry5.corelib.mixins"/>
- <package name="org.apache.tapestry5.corelib.internal"/>
+ <package name="org.apache.tapestry5.pagetester" />
+ <package name="org.apache.tapestry5.integration.pagelevel" />
+ <package name="org.apache.tapestry5.corelib.base" />
+ <package name="org.apache.tapestry5.corelib.components" />
+ <package name="org.apache.tapestry5.corelib.mixins" />
+ <package name="org.apache.tapestry5.corelib.internal" />
</packages>
</test>
- <test name="Service Unit Tests" enabled="true">
+ <test
+ name="Service Unit Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.root"/>
- <package name="org.apache.tapestry5.dom"/>
- <package name="org.apache.tapestry5.runtime"/>
- <package name="org.apache.tapestry5.services"/>
- <package name="org.apache.tapestry5.services.javascript"/>
- <package name="org.apache.tapestry5.util"/>
- <package name="org.apache.tapestry5.validator"/>
- <package name="org.apache.tapestry5.internal"/>
- <package name="org.apache.tapestry5.internal.beaneditor"/>
- <package name="org.apache.tapestry5.internal.bindings"/>
- <package name="org.apache.tapestry5.internal.grid"/>
- <package name="org.apache.tapestry5.internal.model"/>
- <package name="org.apache.tapestry5.internal.pageload"/>
- <package name="org.apache.tapestry5.internal.services"/>
- <package name="org.apache.tapestry5.internal.services.assets"/>
- <package name="org.apache.tapestry5.internal.services.messages"/>
- <package name="org.apache.tapestry5.internal.services.meta"/>
- <package name="org.apache.tapestry5.internal.services.templates"/>
- <package name="org.apache.tapestry5.internal.structure"/>
- <package name="org.apache.tapestry5.internal.test"/>
- <package name="org.apache.tapestry5.internal.transform"/>
- <package name="org.apache.tapestry5.internal.translator"/>
- <package name="org.apache.tapestry5.internal.util"/>
- <package name="org.apache.tapestry5.internal.services.ajax"/>
+ <package name="org.apache.tapestry5.root" />
+ <package name="org.apache.tapestry5.dom" />
+ <package name="org.apache.tapestry5.runtime" />
+ <package name="org.apache.tapestry5.services" />
+ <package name="org.apache.tapestry5.services.javascript" />
+ <package name="org.apache.tapestry5.util" />
+ <package name="org.apache.tapestry5.validator" />
+ <package name="org.apache.tapestry5.internal" />
+ <package name="org.apache.tapestry5.internal.beaneditor" />
+ <package name="org.apache.tapestry5.internal.bindings" />
+ <package name="org.apache.tapestry5.internal.grid" />
+ <package name="org.apache.tapestry5.internal.model" />
+ <package name="org.apache.tapestry5.internal.pageload" />
+ <package name="org.apache.tapestry5.internal.services" />
+ <package name="org.apache.tapestry5.internal.services.assets" />
+ <package name="org.apache.tapestry5.internal.services.messages" />
+ <package name="org.apache.tapestry5.internal.services.meta" />
+ <package name="org.apache.tapestry5.internal.services.templates" />
+ <package name="org.apache.tapestry5.internal.structure" />
+ <package name="org.apache.tapestry5.internal.test" />
+ <package name="org.apache.tapestry5.internal.transform" />
+ <package name="org.apache.tapestry5.internal.translator" />
+ <package name="org.apache.tapestry5.internal.util" />
+ <package name="org.apache.tapestry5.internal.services.ajax" />
</packages>
</test>
<!-- We break these out by which of the test applications they apply to. We have a bunch. -->
- <test name="Core Integration Tests" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/app1"/>
+ <test
+ name="Core Integration Tests"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/app1" />
<packages>
- <package name="org.apache.tapestry5.integration.app1"/>
+ <package name="org.apache.tapestry5.integration.app1" />
</packages>
</test>
- <test name="Additional Integration Tests" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/app3"/>
+ <test
+ name="Additional Integration Tests"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/app3" />
<packages>
- <package name="org.apache.tapestry5.integration.app3"/>
+ <package name="org.apache.tapestry5.integration.app3" />
</packages>
</test>
- <test name="Live Reload Tests" enabled="true">
+ <test
+ name="Live Reload Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.integration.reload"/>
+ <package name="org.apache.tapestry5.integration.reload" />
</packages>
</test>
- <test name="LinkTransformer Tests" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/linktrans"/>
+ <test
+ name="LinkTransformer Tests"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/linktrans" />
<packages>
- <package name="org.apache.tapestry5.integration.linktrans"/>
+ <package name="org.apache.tapestry5.integration.linktrans" />
</packages>
</test>
- <test name="App Skinning and Misc. Tests" enabled="true">
+ <test
+ name="App Skinning and Misc. Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.integration.app5"/>
+ <package name="org.apache.tapestry5.integration.app5" />
</packages>
</test>
- <test name="Bootstrap 4 related Tests" enabled="true">
+ <test
+ name="Bootstrap 4 related Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.integration.app7"/>
+ <package name="org.apache.tapestry5.integration.app7" />
</packages>
</test>
- <test name="Components Param Symbols Tests" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/symbolparam"/>
+ <test
+ name="Components Param Symbols Tests"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/symbolparam" />
<packages>
- <package name="org.apache.tapestry5.integration.symbolparam"/>
+ <package name="org.apache.tapestry5.integration.symbolparam" />
</packages>
</test>
- <test name="AppFolder Tests" enabled="true">
+ <test
+ name="AppFolder Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.integration.appfolder"/>
+ <package name="org.apache.tapestry5.integration.appfolder" />
</packages>
</test>
- <test name="PageTester Tests" enabled="true">
+ <test
+ name="PageTester Tests"
+ enabled="true">
<packages>
- <package name="org.apache.tapestry5.integration.pagetester"/>
+ <package name="org.apache.tapestry5.integration.pagetester" />
</packages>
</test>
- <test name="Activation Context Tests" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/activationctx"/>
+ <test
+ name="Activation Context Tests"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/activationctx" />
<packages>
- <package name="org.apache.tapestry5.integration.activationctx"/>
+ <package name="org.apache.tapestry5.integration.activationctx" />
</packages>
</test>
- <test name="Activation Context Tests 2 old behavior" enabled="true">
- <parameter name="tapestry.web-app-folder" value="src/test/activationctx2"/>
+ <test
+ name="Activation Context Tests 2 old behavior"
+ enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/activationctx2" />
<packages>
- <package name="org.apache.tapestry5.integration.activationctx2"/>
+ <package name="org.apache.tapestry5.integration.activationctx2" />
</packages>
</test>
diff --git a/tapestry-func/build.gradle b/tapestry-func/build.gradle
index fa7b059ea..d52fbe364 100644
--- a/tapestry-func/build.gradle
+++ b/tapestry-func/build.gradle
@@ -1,7 +1,9 @@
-description = "Light-weight functional programming for Flows of values"
+plugins {
+ id 'tapestry.junit5-convention'
+}
+
+description = 'Light-weight functional programming for Flows of values'
dependencies {
- testImplementation "org.testng:testng:${versions.testng}"
- testImplementation "commons-lang:commons-lang:2.6"
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
\ No newline at end of file
+ testImplementation libs.commons.lang3
+}
diff --git a/tapestry-func/src/test/conf/testng.xml b/tapestry-func/src/test/conf/testng.xml
deleted file mode 100644
index 0a06c77d9..000000000
--- a/tapestry-func/src/test/conf/testng.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Tapestry Func">
- <test name="Functional Programming Library">
- <packages>
- <package name="org.apache.tapestry5.func"/>
- </packages>
- </test>
-</suite>
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/BaseFuncTest.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/BaseFuncTest.java
index bed7e2fd3..680f32820 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/BaseFuncTest.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/BaseFuncTest.java
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,37 +17,16 @@ package org.apache.tapestry5.func;
import java.util.Arrays;
import java.util.List;
-import org.testng.Assert;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class BaseFuncTest extends Assert
+public class BaseFuncTest
{
- protected Mapper<String, Integer> stringToLength = new Mapper<String, Integer>()
- {
- @Override
- public Integer map(String input)
- {
- return input.length();
- }
- };
+ protected Mapper<String, Integer> stringToLength = String::length;
- protected Mapper<Integer, Boolean> toEven = new Mapper<Integer, Boolean>()
- {
- @Override
- public Boolean map(Integer input)
- {
- return evenp.accept(input);
- }
- };
+ protected Mapper<Integer, Boolean> toEven = input -> this.evenp.accept(input);
- protected Predicate<Number> evenp = new Predicate<Number>()
- {
- @Override
- public boolean accept(Number object)
- {
- return object.longValue() % 2 == 0;
- };
- };
+ protected Predicate<Number> evenp = object -> object.longValue() % 2 == 0;
protected Flow<Integer> filteredEmpty = F.flow(1, 3, 5, 7).filter(evenp);
@@ -58,12 +37,11 @@ public class BaseFuncTest extends Assert
protected <T> void assertListsEquals(List<T> actual, T... expected)
{
- assertEquals(actual, Arrays.asList(expected));
+ assertEquals(Arrays.asList(expected), actual);
}
protected void unreachable()
{
throw new RuntimeException("Should not be reachable.");
}
-
}
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/FlowToSetTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/FlowToSetTests.java
index 54b98541c..890e34198 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/FlowToSetTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/FlowToSetTests.java
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,14 +18,16 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class FlowToSetTests extends BaseFuncTest
{
@Test
public void empty_flow_to_set()
{
- assertSame(F.emptyFlow().toSet(), Collections.EMPTY_SET);
+ assertSame(Collections.emptySet(), F.emptyFlow().toSet());
}
@Test
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/FuncTest.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/FuncTest.java
index 8e9ed9235..07c49c1c3 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/FuncTest.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/FuncTest.java
@@ -1,4 +1,4 @@
-// Copyright 2010, 2011 The Apache Software Foundation
+// Copyright 2010, 2011, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,7 +21,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class FuncTest extends BaseFuncTest
{
@@ -44,11 +50,11 @@ public class FuncTest extends BaseFuncTest
@Test
public void map_empty_collection_is_the_empty_list()
{
- List<String> source = Arrays.asList();
+ List<String> source = Collections.emptyList();
List<Integer> lengths = F.flow(source).map(stringToLength).toList();
- assertSame(lengths, Collections.EMPTY_LIST);
+ assertSame(Collections.emptyList(), lengths);
}
@Test
@@ -58,21 +64,16 @@ public class FuncTest extends BaseFuncTest
final StringBuffer buffer = new StringBuffer();
- Worker<String> worker = new Worker<String>()
- {
- @Override
- public void work(String value)
- {
- if (buffer.length() > 0)
- buffer.append(' ');
-
- buffer.append(value);
- }
+ Worker<String> worker = value -> {
+ if (buffer.length() > 0)
+ buffer.append(' ');
+
+ buffer.append(value);
};
F.flow(source).each(worker);
- assertEquals(buffer.toString(), "Mary had a little lamb");
+ assertEquals("Mary had a little lamb", buffer.toString());
}
@Test
@@ -82,28 +83,16 @@ public class FuncTest extends BaseFuncTest
final StringBuffer buffer = new StringBuffer();
- Worker<String> worker = new Worker<String>()
- {
- @Override
- public void work(String value)
- {
- if (buffer.length() > 0)
- buffer.append(' ');
-
- buffer.append(value);
- }
+ Worker<String> worker = value -> {
+ if (buffer.length() > 0)
+ buffer.append(' ');
+
+ buffer.append(value);
};
- F.flow(source).filter(new Predicate<String>()
- {
- @Override
- public boolean accept(String object)
- {
- return object.contains("a");
- }
- }).each(worker);
+ F.flow(source).filter(object -> object.contains("a")).each(worker);
- assertEquals(buffer.toString(), "Mary had a lamb");
+ assertEquals("Mary had a lamb", buffer.toString());
}
@Test
@@ -113,21 +102,16 @@ public class FuncTest extends BaseFuncTest
final StringBuffer buffer = new StringBuffer();
- Worker<String> worker = new Worker<String>()
- {
- @Override
- public void work(String value)
- {
- if (buffer.length() > 0)
- buffer.append(' ');
-
- buffer.append(value);
- }
+ Worker<String> worker = value -> {
+ if (buffer.length() > 0)
+ buffer.append(' ');
+
+ buffer.append(value);
};
- assertSame(flow.each(worker), flow);
+ assertSame(flow, flow.each(worker));
- assertEquals(buffer.toString(), "Mary had a little lamb");
+ assertEquals("Mary had a little lamb", buffer.toString());
}
@Test
@@ -135,32 +119,22 @@ public class FuncTest extends BaseFuncTest
{
final StringBuffer buffer = new StringBuffer();
- Worker<String> appendWorker = new Worker<String>()
- {
- @Override
- public void work(String value)
- {
- if (buffer.length() > 0)
- buffer.append(' ');
-
- buffer.append(value);
- }
+ Worker<String> appendWorker = value -> {
+ if (buffer.length() > 0)
+ buffer.append(' ');
+
+ buffer.append(value);
};
- Worker<String> appendLength = new Worker<String>()
- {
- @Override
- public void work(String value)
- {
- buffer.append('(');
- buffer.append(value.length());
- buffer.append(')');
- }
+ Worker<String> appendLength = value -> {
+ buffer.append('(');
+ buffer.append(value.length());
+ buffer.append(')');
};
F.flow("Mary", "had", "a", "little", "lamb").each(F.combine(appendWorker, appendLength));
- assertEquals(buffer.toString(), "Mary(4) had(3) a(1) little(6) lamb(4)");
+ assertEquals("Mary(4) had(3) a(1) little(6) lamb(4)", buffer.toString());
}
@Test
@@ -204,7 +178,7 @@ public class FuncTest extends BaseFuncTest
List<Integer> output = F.flow(input).filter(evenp).toList();
- assertSame(output, Collections.EMPTY_LIST);
+ assertSame(Collections.emptyList(), output);
}
@Test
@@ -272,11 +246,11 @@ public class FuncTest extends BaseFuncTest
Predicate<String> isNull = F.isNull();
Predicate<String> isNotNull = F.notNull();
- assertEquals(isNull.accept(null), true);
- assertEquals(isNotNull.accept(null), false);
+ assertTrue(isNull.accept(null));
+ assertFalse(isNotNull.accept(null));
- assertEquals(isNull.accept("foo"), false);
- assertEquals(isNotNull.accept("bar"), true);
+ assertFalse(isNull.accept("foo"));
+ assertTrue(isNotNull.accept("bar"));
}
@Test
@@ -285,7 +259,7 @@ public class FuncTest extends BaseFuncTest
int total = F.flow(F.flow("Mary", "had", "a", "little", "lamb").map(stringToLength).toList()).reduce(
F.SUM_INTS, 0);
- assertEquals(total, 18);
+ assertEquals(18, total);
}
@Test
@@ -293,7 +267,7 @@ public class FuncTest extends BaseFuncTest
{
int total = F.flow("Mary", "had", "a", "little", "lamb").map(stringToLength).reduce(F.SUM_INTS, 0);
- assertEquals(total, 18);
+ assertEquals(18, total);
}
@Test
@@ -301,11 +275,11 @@ public class FuncTest extends BaseFuncTest
{
Flow<Integer> empty = F.flow();
- assertSame(empty.reverse(), empty);
+ assertSame(empty, empty.reverse());
Flow<Integer> one = F.flow(1);
- assertSame(one.reverse(), one);
+ assertSame(one, one.reverse());
}
@Test
@@ -324,7 +298,7 @@ public class FuncTest extends BaseFuncTest
Flow<Integer> empty = F.flow();
Flow<Integer> flow = F.flow(1, 2, 3);
- assertSame(empty.concat(flow), flow);
+ assertSame(flow, empty.concat(flow));
}
@Test
@@ -358,46 +332,32 @@ public class FuncTest extends BaseFuncTest
{
Flow<String> zero = F.flow();
- Comparator<String> comparator = new Comparator<String>()
- {
- @Override
- public int compare(String o1, String o2)
- {
- return o1.length() - o2.length();
- }
- };
+ Comparator<String> comparator = (o1, o2) -> o1.length() - o2.length();
- assertSame(zero.sort(), zero);
- assertSame(zero.sort(comparator), zero);
+ assertSame(zero, zero.sort());
+ assertSame(zero, zero.sort(comparator));
Flow<String> one = F.flow("Hello");
- assertSame(one.sort(), one);
- assertSame(one.sort(comparator), one);
+ assertSame(one, one.sort());
+ assertSame(one, one.sort(comparator));
}
@Test
public void sort_using_explicit_comparator()
{
Flow<String> flow = F.flow("a", "eeeee", "ccc", "bb", "dddd");
- Comparator<String> comparator = new Comparator<String>()
- {
- @Override
- public int compare(String o1, String o2)
- {
- return o1.length() - o2.length();
- }
- };
+ Comparator<String> comparator = (o1, o2) -> o1.length() - o2.length();
assertFlowValues(flow.sort(comparator), "a", "bb", "ccc", "dddd", "eeeee");
}
- @Test(expectedExceptions = ClassCastException.class)
+ @Test
public void unable_to_sort_a_flow_of_non_comparables()
{
Flow<Locale> flow = F.flow(Locale.ENGLISH, Locale.FRANCE);
- flow.sort();
+ assertThrows(ClassCastException.class, flow::sort);
}
@Test
@@ -412,19 +372,23 @@ public class FuncTest extends BaseFuncTest
total += i;
}
- assertEquals(total, 16);
+ assertEquals(16, total);
}
@Test
public void first_of_non_empty_flow()
{
- assertEquals(F.flow("Mary", "had", "a", "little", "lamb").first(), "Mary");
+ String first = F.flow("Mary", "had", "a", "little", "lamb").first();
+
+ assertEquals("Mary", first);
}
@Test
public void rest_of_non_empty_flow()
{
- assertFlowValues(F.flow("Mary", "had", "a", "little", "lamb").rest(), "had", "a", "little", "lamb");
+ Flow<String> rest = F.flow("Mary", "had", "a", "little", "lamb").rest();
+
+ assertFlowValues(rest, "had", "a", "little", "lamb");
}
@Test
@@ -451,7 +415,7 @@ public class FuncTest extends BaseFuncTest
public void list_of_empty_flow_is_empty()
{
assertTrue(filteredEmpty.isEmpty());
- assertSame(filteredEmpty.toList(), Collections.EMPTY_LIST);
+ assertSame(Collections.emptyList(), filteredEmpty.toList());
}
@Test
@@ -459,16 +423,11 @@ public class FuncTest extends BaseFuncTest
{
assertSame(filteredEmpty.reverse(), F.EMPTY_FLOW);
assertSame(filteredEmpty.sort(), F.EMPTY_FLOW);
- assertSame(filteredEmpty.sort(new Comparator<Integer>()
- {
- @Override
- public int compare(Integer o1, Integer o2)
- {
- unreachable();
+ assertSame(F.EMPTY_FLOW, filteredEmpty.sort((o1, o2) -> {
+ unreachable();
- return 0;
- }
- }), F.EMPTY_FLOW);
+ return 0;
+ }));
}
@Test
@@ -483,7 +442,7 @@ public class FuncTest extends BaseFuncTest
assertFlowValues(filteredEmpty.append(1, 2, 3).reverse(), 3, 2, 1);
}
- @Test(expectedExceptions = UnsupportedOperationException.class)
+ @Test
public void remove_on_flow_iterator_is_not_supported()
{
Flow<Integer> flow = F.flow(1, 2, 3).filter(evenp);
@@ -493,7 +452,7 @@ public class FuncTest extends BaseFuncTest
assertTrue(it.hasNext());
assertEquals(it.next(), Integer.valueOf(2));
- it.remove();
+ assertThrows(UnsupportedOperationException.class, it::remove);
}
@Test
@@ -501,22 +460,10 @@ public class FuncTest extends BaseFuncTest
{
Flow<String> flow = F.flow("Mary", "had", "a", "little", "lamb");
- List<String> result = flow.filter(new Predicate<String>()
- {
- @Override
- public boolean accept(String object)
- {
- return object.contains("a");
- }
- }).sort(new Comparator<String>()
- {
- @Override
- public int compare(String o1, String o2)
- {
- return o1.length() - o2.length();
-
- };
- }).toList();
+ List<String> result = flow
+ .filter(object -> object.contains("a"))
+ .sort((o1, o2) -> o1.length() - o2.length())
+ .toList();
assertListsEquals(result, "a", "had", "Mary", "lamb");
}
@@ -526,14 +473,7 @@ public class FuncTest extends BaseFuncTest
{
Flow<Integer> flow = F.emptyFlow();
- assertSame(flow.each(new Worker<Integer>()
- {
- @Override
- public void work(Integer value)
- {
- unreachable();
- }
- }), flow);
+ assertSame(flow, flow.each(value -> unreachable()));
}
@Test
@@ -541,7 +481,7 @@ public class FuncTest extends BaseFuncTest
{
Flow<Integer> flow = F.emptyFlow();
- assertSame(flow.remove(evenp), flow);
+ assertSame(flow, flow.remove(evenp));
}
@Test
@@ -550,28 +490,23 @@ public class FuncTest extends BaseFuncTest
Flow<Integer> flow = F.emptyFlow();
Integer initial = 99;
- assertSame(flow.reduce(new Reducer<Integer, Integer>()
- {
- @Override
- public Integer reduce(Integer accumulator, Integer value)
- {
- unreachable();
+ assertSame(initial, flow.reduce((accumulator, value) -> {
+ unreachable();
- return null;
- }
- }, initial), initial);
+ return null;
+ }, initial));
}
@Test
public void count_of_the_empty_flow_is_zero()
{
- assertEquals(F.flow().count(), 0);
+ assertEquals(0, F.flow().count());
}
@Test
public void count_of_array_flow()
{
- assertEquals(F.flow(1, 2, 3).count(), 3);
+ assertEquals(3, F.flow(1, 2, 3).count());
}
@Test
@@ -579,16 +514,16 @@ public class FuncTest extends BaseFuncTest
{
Flow<String> flow = F.flow("Mary", "had", "a", "little", "lamb");
- assertEquals(flow.filter(F.isNull()).count(), 0);
- assertEquals(flow.removeNulls().count(), 5);
+ assertEquals(0, flow.filter(F.isNull()).count());
+ assertEquals(5, flow.removeNulls().count());
}
@Test
public void count_of_a_large_flow()
{
- Flow<Integer> flow = F.series(1, 1).take(50000);
+ Flow<Integer> flow = F.series(1, 1).take(50_000);
- assertEquals(flow.count(), 50000);
+ assertEquals(50_000, flow.count());
}
@Test
@@ -611,15 +546,7 @@ public class FuncTest extends BaseFuncTest
@Test
public void lazy_flow_from_iterable()
{
- Iterable<Integer> iterable = new Iterable<Integer>()
- {
-
- @Override
- public Iterator<Integer> iterator()
- {
- return Arrays.asList(9, 7, 1).iterator();
- }
- };
+ Iterable<Integer> iterable = () -> Arrays.asList(9, 7, 1).iterator();
Flow<Integer> flow = F.flow(iterable);
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/InterleaveTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/InterleaveTests.java
index 37fe18371..e2f4dda98 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/InterleaveTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/InterleaveTests.java
@@ -1,4 +1,4 @@
-// Copyright 2011 The Apache Software Foundation
+// Copyright 2011, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
package org.apache.tapestry5.func;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class InterleaveTests extends BaseFuncTest
{
@@ -23,9 +23,9 @@ public class InterleaveTests extends BaseFuncTest
{
Flow<Integer> first = F.flow(1, 2, 3);
Flow<Integer> second = F.flow(100, 200, 300);
- Flow<Integer> third = F.flow(1000, 2000, 3000);
+ Flow<Integer> third = F.flow(1_000, 2_000, 3_000);
- assertFlowValues(first.interleave(second, third), 1, 100, 1000, 2, 200, 2000, 3, 300, 3000);
+ assertFlowValues(first.interleave(second, third), 1, 100, 1_000, 2, 200, 2_000, 3, 300, 3_000);
}
@Test
@@ -33,9 +33,8 @@ public class InterleaveTests extends BaseFuncTest
{
Flow<Integer> first = F.flow(1, 2, 3);
Flow<Integer> second = F.flow(100);
- Flow<Integer> third = F.flow(1000, 2000, 3000);
-
- assertFlowValues(first.interleave(second, third), 1, 100, 1000);
+ Flow<Integer> third = F.flow(1_000, 2_000, 3_000);
+ assertFlowValues(first.interleave(second, third), 1, 100, 1_000);
}
}
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/MapperTest.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/MapperTest.java
index 6144fa7ce..7a2a03156 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/MapperTest.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/MapperTest.java
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,23 +18,20 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MapperTest extends BaseFuncTest
{
- protected Mapper<Integer, Flow<Integer>> sequencer = new Mapper<Integer, Flow<Integer>>()
- {
-
- @Override
- public Flow<Integer> map(Integer value)
- {
- Flow<Integer> flow = F.flow();
+ protected Mapper<Integer, Flow<Integer>> sequencer = value -> {
+ Flow<Integer> flow = F.flow();
- for (int i = 0; i < value; i++)
- flow = flow.append(value);
+ for (int i = 0; i < value; i++)
+ flow = flow.append(value);
- return flow;
- }
+ return flow;
};
@Test
@@ -56,15 +53,10 @@ public class MapperTest extends BaseFuncTest
@Test
public void map_of_filtered_empty_is_empty()
{
- assertTrue(filteredEmpty.map(new Mapper<Integer, Integer>()
- {
- @Override
- public Integer map(Integer value)
- {
- unreachable();
-
- return value;
- }
+ assertTrue(filteredEmpty.map(value -> {
+ unreachable();
+
+ return value;
}).isEmpty());
}
@@ -73,7 +65,7 @@ public class MapperTest extends BaseFuncTest
{
Flow<Integer> flow = F.flow();
- assertSame(flow.mapcat(sequencer), flow);
+ assertSame(flow, flow.mapcat(sequencer));
assertTrue(filteredEmpty.mapcat(sequencer).isEmpty());
}
@@ -92,7 +84,7 @@ public class MapperTest extends BaseFuncTest
Flow<Integer> flow = F.flow("Mary", "had", "etc.").filter(F.isNull()).map(stringToLength);
assertTrue(flow.isEmpty());
- assertEquals(flow.count(), 0);
+ assertEquals(0, flow.count());
}
@Test
@@ -108,20 +100,14 @@ public class MapperTest extends BaseFuncTest
{
final AtomicInteger count = new AtomicInteger();
- Mapper<Integer, Integer> doubler = new Mapper<Integer, Integer>()
- {
- @Override
- public Integer map(Integer value)
- {
- count.incrementAndGet();
-
- return value * 2;
- }
+ Mapper<Integer, Integer> doubler = value -> {
+ count.incrementAndGet();
+ return value * 2;
};
assertFlowValues(F.range(1, 100).filter(F.gt(10)).map(doubler).take(3), 22, 24, 26);
- assertEquals(count.get(), 3);
+ assertEquals(3, count.get());
count.set(0);
@@ -129,17 +115,17 @@ public class MapperTest extends BaseFuncTest
// ever actually running the mapper to determine the final value.
assertEquals(F.range(1, 100).map(doubler).count(), 99);
- assertEquals(count.get(), 0);
+ assertEquals(0, count.get());
// Because values are now lazily evaluated as well as flows, we can count the size of a flow
// without ever actually calculating (via the mapper) an output value.
Flow<Integer> flow = F.range(1, 100).map(doubler).concat(F.range(1, 10).map(doubler));
- assertEquals(flow.count(), 108);
- assertEquals(count.get(), 0);
+ assertEquals(108, flow.count());
+ assertEquals(0, count.get());
assertFlowValues(flow.take(2), 2, 4);
- assertEquals(count.get(), 2);
+ assertEquals(2, count.get());
count.set(0);
@@ -147,7 +133,7 @@ public class MapperTest extends BaseFuncTest
// of the original flow, and previously computed values (2 and 4) are still accessible!
assertFlowValues(flow.take(3), 2, 4, 6);
- assertEquals(count.get(), 1);
+ assertEquals(1, count.get());
}
@Test
@@ -155,8 +141,8 @@ public class MapperTest extends BaseFuncTest
{
Flow<Integer> flow = F.flow(1, 2, 3);
- assertSame(flow.map(F.ADD_INTS, filteredEmpty), F.EMPTY_FLOW);
- assertSame(filteredEmpty.map(F.ADD_INTS, flow), F.EMPTY_FLOW);
+ assertSame(F.emptyFlow(), flow.map(F.ADD_INTS, filteredEmpty));
+ assertSame(F.emptyFlow(), filteredEmpty.map(F.ADD_INTS, flow));
}
@Test
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/RangeTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/RangeTests.java
index 9a8c4b265..6ccdcfa73 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/RangeTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/RangeTests.java
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,7 +14,8 @@
package org.apache.tapestry5.func;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class RangeTests extends BaseFuncTest
{
@@ -27,7 +28,6 @@ public class RangeTests extends BaseFuncTest
@Test
public void ascending_range()
{
-
assertFlowValues(F.range(5, 8), 5, 6, 7);
}
@@ -56,14 +56,7 @@ public class RangeTests extends BaseFuncTest
@Test
public void iterate()
{
- Mapper<Integer, Integer> times2 = new Mapper<Integer, Integer>()
- {
- @Override
- public Integer map(Integer value)
- {
- return 2 * value;
- }
- };
+ Mapper<Integer, Integer> times2 = value -> 2 * value;
assertFlowValues(F.iterate(1, times2).take(5), 1, 2, 4, 8, 16);
}
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/StringPredicateTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/StringPredicateTests.java
index 47d4cdf86..87ec5d93f 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/StringPredicateTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/StringPredicateTests.java
@@ -1,4 +1,4 @@
-// Copyright 2011, 2012 The Apache Software Foundation
+// Copyright 2011, 2012, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
// limitations under the License.
package org.apache.tapestry5.func;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
public class StringPredicateTests extends BaseFuncTest
{
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/TakeDropTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/TakeDropTests.java
index 88e0e2e32..e73ba0a19 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/TakeDropTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/TakeDropTests.java
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,14 +14,16 @@
package org.apache.tapestry5.func;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TakeDropTests extends BaseFuncTest
{
@Test
public void take_from_empty_list()
{
- assertSame(F.flow().take(34), F.EMPTY_FLOW);
+ assertSame(F.emptyFlow(), F.flow().take(34));
}
@Test
@@ -39,7 +41,7 @@ public class TakeDropTests extends BaseFuncTest
assertFlowValues(flow.take(99), 1, 2, 3, 4, 5);
- assertSame(flow.take(0), F.EMPTY_FLOW);
+ assertSame(F.emptyFlow(), flow.take(0));
}
@Test
@@ -48,7 +50,7 @@ public class TakeDropTests extends BaseFuncTest
// This can go much, much larger but starts taking a while. Don't hold a reference to the
// start
// of the series or it can run out of memory.
- int length = 100000;
+ int length = 100_000;
assertFlowValues(F.series(1, 1).filter(evenp).drop(length).take(3), 2 * length + 2, 2 * length + 4,
2 * length + 6);
@@ -57,7 +59,7 @@ public class TakeDropTests extends BaseFuncTest
@Test
public void drop_from_empty_is_empty()
{
- assertSame(F.flow().drop(99), F.EMPTY_FLOW);
+ assertSame(F.emptyFlow(), F.flow().drop(99));
}
@Test
@@ -75,7 +77,7 @@ public class TakeDropTests extends BaseFuncTest
@Test
public void drop_all_from_array_flow_is_empty_flow()
{
- assertSame(F.flow(1, 2, 3).drop(3), F.EMPTY_FLOW);
+ assertSame(F.emptyFlow(), F.flow(1, 2, 3).drop(3));
}
@Test
@@ -83,7 +85,7 @@ public class TakeDropTests extends BaseFuncTest
{
Flow<Integer> flow = F.flow(1, 2, 3);
- assertSame(flow.drop(0), flow);
+ assertSame(flow, flow.drop(0));
}
@Test
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/TupleTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/TupleTests.java
index 3eadf3724..0ddfa6b6f 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/TupleTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/TupleTests.java
@@ -1,5 +1,5 @@
package org.apache.tapestry5.func;
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,7 +14,11 @@ package org.apache.tapestry5.func;
// limitations under the License.
import org.apache.tapestry5.func.Tuple;
-import org.testng.annotations.Test;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TupleTests extends BaseFuncTest
{
diff --git a/tapestry-func/src/test/java/org/apache/tapestry5/func/ZippedFlowTests.java b/tapestry-func/src/test/java/org/apache/tapestry5/func/ZippedFlowTests.java
index a4b8ee632..82bde9a8f 100644
--- a/tapestry-func/src/test/java/org/apache/tapestry5/func/ZippedFlowTests.java
+++ b/tapestry-func/src/test/java/org/apache/tapestry5/func/ZippedFlowTests.java
@@ -1,4 +1,4 @@
-// Copyright 2010, 2011 The Apache Software Foundation
+// Copyright 2010, 2011, 2025 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,8 +14,12 @@
package org.apache.tapestry5.func;
-import org.apache.commons.lang.StringUtils;
-import org.testng.annotations.Test;
+import org.apache.commons.lang3.StringUtils;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.HashMap;
@@ -36,14 +40,14 @@ public class ZippedFlowTests extends BaseFuncTest
{
Map<Integer, String> map = zipped.toMap();
- assertEquals(map.size(), 3);
- assertEquals(map.get(2), "barney");
+ assertEquals(3, map.size());
+ assertEquals("barney", map.get(2));
}
@Test
public void map_to_zipped_flow()
{
- Map<Integer, String> map = new HashMap<Integer, String>();
+ Map<Integer, String> map = new HashMap<>();
map.put(1, "fred");
map.put(2, "barney");
@@ -105,7 +109,7 @@ public class ZippedFlowTests extends BaseFuncTest
@Test
public void first_tuple_from_zipped_flow()
{
- assertEquals(zipped.drop(2).first(), Tuple.create(3, "wilma"));
+ assertEquals(Tuple.create(3, "wilma"), zipped.drop(2).first());
}
@Test
@@ -124,28 +128,28 @@ public class ZippedFlowTests extends BaseFuncTest
ZippedFlow<Integer, String> extendedFlow = zipped.concat(Arrays.asList(null, pebbles, null));
ZippedFlow<Integer, String> noNulls = extendedFlow.removeNulls();
- assertEquals(extendedFlow.count(), 6);
- assertEquals(noNulls.count(), 4);
+ assertEquals(6, extendedFlow.count());
+ assertEquals(4, noNulls.count());
- assertEquals(noNulls.reverse().seconds().first(), "pebbles");
+ assertEquals("pebbles", noNulls.reverse().seconds().first());
}
@Test
public void rest_of_zipped_flow()
{
- assertEquals(zipped.rest().first().second, "barney");
+ assertEquals("barney", zipped.rest().first().second);
}
@Test
public void count_of_zipped_flow()
{
- assertEquals(zipped.count(), 3);
+ assertEquals(3, zipped.count());
}
@Test
public void take_from_zipped_flow()
{
- assertEquals(zipped.take(2).reverse().first().second, "barney");
+ assertEquals("barney", zipped.take(2).reverse().first().second);
}
@Test
@@ -153,39 +157,23 @@ public class ZippedFlowTests extends BaseFuncTest
{
final AtomicInteger count = new AtomicInteger();
- zipped.each(new Worker<Tuple<Integer, String>>()
- {
- @Override
- public void work(Tuple<Integer, String> value)
- {
- count.addAndGet(value.second.length());
- }
-
- });
+ zipped.each(value -> count.addAndGet(value.second.length()));
- assertEquals(count.get(), 15);
+ assertEquals(15, count.get());
}
@Test
public void reduce_zipped_flow()
{
- int totalLength = zipped.reduce(new Reducer<Integer, Tuple<Integer, String>>()
- {
- @Override
- public Integer reduce(Integer accumulator, Tuple<Integer, String> value)
- {
- return accumulator + value.second.length();
- }
-
- }, 0);
+ int totalLength = zipped.reduce((acc, value) -> acc + value.second.length(), 0);
- assertEquals(totalLength, 15);
+ assertEquals(15, totalLength);
}
@Test
public void remove_from_zipped_flow()
{
- assertEquals(zipped.remove(F.notNull()).count(), 0);
+ assertEquals(0, zipped.remove(F.notNull()).count());
}
@SuppressWarnings("unchecked")
@@ -198,21 +186,21 @@ public class ZippedFlowTests extends BaseFuncTest
ZippedFlow<Integer, String> zipped2 = zipped.concat(asList);
- assertEquals(zipped2.count(), 4);
+ assertEquals(4, zipped2.count());
- assertEquals(zipped2.reverse().seconds().first(), "bam-bam");
+ assertEquals("bam-bam", zipped2.reverse().seconds().first());
}
@Test
public void firsts()
{
- assertEquals(zipped.reverse().firsts().first(), (Integer) 3);
+ assertEquals((Integer)3, zipped.reverse().firsts().first());
}
@Test
public void seconds()
{
- assertEquals(zipped.seconds().first(), "fred");
+ assertEquals("fred", zipped.seconds().first());
}
@Test
@@ -229,7 +217,7 @@ public class ZippedFlowTests extends BaseFuncTest
}).first();
- assertEquals(firstTuple.first, "derf");
- assertEquals(firstTuple.second, "1-4");
+ assertEquals("derf", firstTuple.first);
+ assertEquals("1-4", firstTuple.second);
}
}
diff --git a/tapestry-hibernate-core/build.gradle b/tapestry-hibernate-core/build.gradle
index 3e541327a..88e63acaf 100644
--- a/tapestry-hibernate-core/build.gradle
+++ b/tapestry-hibernate-core/build.gradle
@@ -1,21 +1,22 @@
-description = "Basic Hibernate services for Tapestry, useable outside of a Tapestry web application"
+plugins {
+ id 'tapestry.testng-convention'
+}
+
+description = 'Basic Hibernate services for Tapestry, useable outside of a Tapestry web application'
+ext.moduleLibs = [
+ jaxbRuntime: 'org.glassfish.jaxb:jaxb-runtime:2.3.2',
+]
dependencies {
implementation project(':tapestry-ioc')
- api group: 'org.hibernate', name: 'hibernate-core', version: versions.hibernate
-
- implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
+ api libs.hibernate.core
+
+ implementation moduleLibs.jaxbRuntime
testImplementation project(':tapestry-test')
- testImplementation "org.easymock:easymock:${versions.easymock}"
- testImplementation "org.testng:testng:${versions.testng}", { transitive = false }
- testRuntimeOnly "org.hsqldb:hsqldb:${versions.hsqldb}"
+ testRuntimeOnly("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
}
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.modules.HibernateCoreModule'
- }
-}
\ No newline at end of file
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.modules.HibernateCoreModule'
diff --git a/tapestry-hibernate-core/src/test/conf/testng.xml b/tapestry-hibernate-core/src/test/resources/testng.xml
similarity index 100%
rename from tapestry-hibernate-core/src/test/conf/testng.xml
rename to tapestry-hibernate-core/src/test/resources/testng.xml
diff --git a/tapestry-hibernate/build.gradle b/tapestry-hibernate/build.gradle
index f13cdcde9..0cee4c56d 100644
--- a/tapestry-hibernate/build.gradle
+++ b/tapestry-hibernate/build.gradle
@@ -1,24 +1,28 @@
-description = "Provides support for simple CRUD applications built on top of Tapestry and Hibernate"
+plugins {
+ id 'tapestry.testng-convention'
+}
+
+description = 'Provides support for simple CRUD applications built on top of Tapestry and Hibernate'
+
+ext.moduleLibs = [
+ jbossLogging: 'org.jboss.logging:jboss-logging:3.3.0.Final',
+]
dependencies {
- api project(':tapestry-core')
- api project(':tapestry-hibernate-core')
- implementation "org.jboss.logging:jboss-logging:3.3.0.Final"
+ api project(':tapestry-core')
+ api project(':tapestry-hibernate-core')
- testImplementation project(':tapestry-test')
-
- testRuntimeOnly "org.hsqldb:hsqldb:${versions.hsqldb}"
-}
+ implementation moduleLibs.jbossLogging
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.web.modules.HibernateModule'
- }
+ testImplementation project(':tapestry-test')
+ testRuntimeOnly("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
}
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.web.modules.HibernateModule'
+
task runTestApp0(type:JavaExec) {
- description 'Start tapestry-hibernate integration test app, useful when debugging failing integration tests'
- main = 'org.apache.tapestry5.test.JettyRunner'
- args "-d", "src/test/webapp", "-p", "8080"
- classpath += project.sourceSets.test.runtimeClasspath
+ description 'Start tapestry-hibernate integration test app, useful when debugging failing integration tests'
+ main = 'org.apache.tapestry5.test.JettyRunner'
+ args "-d", "src/test/webapp", "-p", "8080"
+ classpath += project.sourceSets.test.runtimeClasspath
}
diff --git a/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/EntityPersistentFieldStrategyTest.java b/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/EntityPersistentFieldStrategyTest.java
index cfe786704..3fbffe2da 100644
--- a/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/EntityPersistentFieldStrategyTest.java
+++ b/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/EntityPersistentFieldStrategyTest.java
@@ -14,8 +14,6 @@
package org.apache.tapestry5.hibernate.web.internal;
-import org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy;
-import org.apache.tapestry5.hibernate.web.internal.SessionRestorable;
import org.apache.tapestry5.test.TapestryTestCase;
import org.hibernate.HibernateException;
import org.hibernate.Session;
diff --git a/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/HibernateEntityValueEncoderTest.java b/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/HibernateEntityValueEncoderTest.java
index 52f48974e..19954fc31 100644
--- a/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/HibernateEntityValueEncoderTest.java
+++ b/tapestry-hibernate/src/test/java/org/apache/tapestry5/hibernate/web/internal/HibernateEntityValueEncoderTest.java
@@ -16,7 +16,6 @@ package org.apache.tapestry5.hibernate.web.internal;
import org.apache.tapestry5.commons.services.PropertyAccess;
import org.apache.tapestry5.commons.services.TypeCoercer;
-import org.apache.tapestry5.hibernate.web.internal.HibernateEntityValueEncoder;
import org.apache.tapestry5.ioc.Registry;
import org.apache.tapestry5.ioc.test.IOCTestCase;
import org.hibernate.Session;
@@ -109,7 +108,7 @@ public class HibernateEntityValueEncoderTest extends IOCTestCase
{
assertMessageContains(
ex,
- "Exception converting 'xyz' to instance of java.lang.Long (id type for entity org.apache.tapestry5.internal.hibernate.SampleEntity)");
+ "Exception converting 'xyz' to instance of java.lang.Long (id type for entity org.apache.tapestry5.hibernate.web.internal.SampleEntity)");
}
assertNull(encoder.toValue(""));
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/pages/CachedForm.java b/tapestry-hibernate/src/test/java/org/example/app0/pages/CachedForm.java
index 1ea0b68c1..20c769a94 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/pages/CachedForm.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/pages/CachedForm.java
@@ -16,6 +16,7 @@ package org.example.app0.pages;
import org.apache.tapestry5.annotations.Cached;
import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.hibernate.HibernateSessionManager;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.example.app0.entities.User;
@@ -37,7 +38,7 @@ public class CachedForm
private int index;
@Inject
- private Session session;
+ private HibernateSessionManager sessionManager;
@Inject
private UserDAO userDAO;
@@ -48,20 +49,18 @@ public class CachedForm
User user = new User();
user.setFirstName(name);
- session.save(user);
+ sessionManager.getSession().save(user);
}
@SuppressWarnings("unchecked")
@Cached
public List<User> getUsers()
{
- return session.createQuery("from User").list();
+ return sessionManager.getSession().createQuery("from User").list();
}
void onActionFromSetup()
{
userDAO.deleteAll();
}
-
-
}
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/pages/EncodeEntities.java b/tapestry-hibernate/src/test/java/org/example/app0/pages/EncodeEntities.java
index d9ffcbf1d..e4f0a6cec 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/pages/EncodeEntities.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/pages/EncodeEntities.java
@@ -14,18 +14,18 @@
package org.example.app0.pages;
+import java.util.List;
+
import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.hibernate.HibernateSessionManager;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.example.app0.entities.User;
-import org.hibernate.Session;
-
-import java.util.List;
public class EncodeEntities
{
@Inject
- private Session session;
+ private HibernateSessionManager sessionManager;
@SuppressWarnings("unused")
@Property
@@ -37,14 +37,15 @@ public class EncodeEntities
User user = new User();
user.setFirstName("name");
- session.save(user);
+ sessionManager.getSession().save(user);
}
@SuppressWarnings("unchecked")
User onPassivate()
{
// Use ordering so that we get the most recently inserted users first.
- List<User> users = session.createQuery("from User order by id desc").list();
+ List<User> users = sessionManager.getSession().createQuery("from User order by id desc")
+ .list();
if (users.isEmpty())
return null;
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/pages/GridDemo.java b/tapestry-hibernate/src/test/java/org/example/app0/pages/GridDemo.java
index a1b361b0e..b9b211a6b 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/pages/GridDemo.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/pages/GridDemo.java
@@ -15,24 +15,24 @@
package org.example.app0.pages;
import org.apache.tapestry5.grid.GridDataSource;
+import org.apache.tapestry5.hibernate.HibernateSessionManager;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.hibernate.web.HibernateGridDataSource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.example.app0.entities.User;
import org.example.app0.services.UserDAO;
-import org.hibernate.Session;
public class GridDemo
{
@Inject
- private Session session;
+ private HibernateSessionManager sessionManager;
@Inject
private UserDAO userDAO;
public GridDataSource getSource()
{
- return new HibernateGridDataSource(session, User.class);
+ return new HibernateGridDataSource(sessionManager.getSession(), User.class);
}
@CommitAfter
@@ -51,7 +51,7 @@ public class GridDemo
user.setEncodedPassword("####");
user.setEmail("joe" + suffix + "@null.com");
- session.persist(user);
+ sessionManager.getSession().persist(user);
}
}
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/pages/PersistEntity.java b/tapestry-hibernate/src/test/java/org/example/app0/pages/PersistEntity.java
index 484f66683..883515713 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/pages/PersistEntity.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/pages/PersistEntity.java
@@ -33,9 +33,6 @@ public class PersistEntity
@Inject
private UserDAO userDAO;
- @Inject
- private Session session;
-
@Inject
private HibernateSessionManager manager;
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/pages/SSOEntity.java b/tapestry-hibernate/src/test/java/org/example/app0/pages/SSOEntity.java
index 5e6fe8348..a0fd2885e 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/pages/SSOEntity.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/pages/SSOEntity.java
@@ -23,7 +23,7 @@ import org.example.app0.services.UserDAO;
import java.util.List;
-public class SSOEntity
+public class SSOEntity
{
@SessionState
@Property
@@ -31,10 +31,10 @@ public class SSOEntity
@Inject
private UserDAO userDAO;
-
+
@Inject
private Request request;
-
+
void onPersistEntity()
{
User user = new User();
@@ -44,7 +44,7 @@ public class SSOEntity
this.user = user;
}
-
+
void onSetToNull()
{
user = null;
@@ -55,17 +55,14 @@ public class SSOEntity
List<User> users = userDAO.findAll();
userDAO.delete(users.toArray(new User[0]));
- System.err.println("DELETED");
}
-
+
public String getPersistedEntityClassName()
{
- Session session = request.getSession(true);
-
- Object value = session.getAttribute("sso:"+User.class.getName());
-
- System.err.println("getPersistedEntityClassName(): "+value);
-
- return value.getClass().getName();
+ Session session = request.getSession(true);
+
+ Object value = session.getAttribute("sso:" + User.class.getName());
+
+ return value.getClass().getName();
}
}
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/services/UserDAOImpl.java b/tapestry-hibernate/src/test/java/org/example/app0/services/UserDAOImpl.java
index a0f0f3703..7a4bb1c7e 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/services/UserDAOImpl.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/services/UserDAOImpl.java
@@ -14,6 +14,7 @@
package org.example.app0.services;
+import org.apache.tapestry5.hibernate.HibernateSessionManager;
import org.example.app0.entities.User;
import org.hibernate.Session;
@@ -21,30 +22,31 @@ import java.util.List;
public class UserDAOImpl implements UserDAO
{
- private final Session session;
+ private final HibernateSessionManager sessionManager;
- public UserDAOImpl(Session session)
+ public UserDAOImpl(HibernateSessionManager sessionManager)
{
- this.session = session;
+ this.sessionManager = sessionManager;
}
@Override
public void add(User user)
{
- session.save(user);
+ sessionManager.getSession().save(user);
}
@Override
@SuppressWarnings({ "unchecked" })
public List<User> findAll()
{
- return (List<User>) session.createQuery("from User").list();
+ return (List<User>) sessionManager.getSession().createQuery("from User").list();
}
@Override
public void delete(User... users)
{
- for (User user : users) session.delete(user);
+ for (User user : users)
+ sessionManager.getSession().delete(user);
}
@Override
@@ -52,7 +54,7 @@ public class UserDAOImpl implements UserDAO
{
for (User u : findAll())
{
- session.delete(u);
+ sessionManager.getSession().delete(u);
}
}
}
diff --git a/tapestry-hibernate/src/test/conf/testng.xml b/tapestry-hibernate/src/test/resources/testng.xml
similarity index 87%
rename from tapestry-hibernate/src/test/conf/testng.xml
rename to tapestry-hibernate/src/test/resources/testng.xml
index ae459a0ca..58f4ffac1 100644
--- a/tapestry-hibernate/src/test/conf/testng.xml
+++ b/tapestry-hibernate/src/test/resources/testng.xml
@@ -19,12 +19,12 @@
<parameter name="tapestry.integration-webapp" value="src/test/webapp"/>
<test name="Tapestry Hibernate Internal APIs">
<packages>
- <package name="org.apache.tapestry5.internal.hibernate"/>
+ <package name="org.apache.tapestry5.hibernate.web.internal"/>
</packages>
</test>
<test name="Tapestry Hibernate Integration Tests">
<packages>
- <package name="org.apache.tapestry5.hibernate.integration"/>
+ <package name="org.apache.tapestry5.hibernate.web.integration"/>
</packages>
</test>
</suite>
diff --git a/tapestry-http/build.gradle b/tapestry-http/build.gradle
index 96e4ed9bf..b91bb13d6 100644
--- a/tapestry-http/build.gradle
+++ b/tapestry-http/build.gradle
@@ -1,32 +1,34 @@
-import org.gradle.plugins.ide.idea.model.*
+plugins {
+ id 'tapestry.testng-convention'
+}
+
import org.apache.tools.ant.filters.ReplaceTokens
-import t5build.*
-description = "Tapestry classes that handle HTTP requests"
+description = 'Tapestry classes that handle HTTP requests'
dependencies {
implementation project(':tapestry-ioc')
implementation project(':tapestry-json')
implementation project(':beanmodel')
- provided project(":tapestry-test")
- provided project(":tapestry-test-constants")
-
- provided "jakarta.servlet:jakarta.servlet-api:${versions.servletapi}"
+ provided libs.jakarta.servlet.api
- implementation "commons-codec:commons-codec:1.10"
- implementation "commons-io:commons-io:${versions.commonsIo}"
+ implementation libs.commons.codec
+ implementation libs.commons.io
- testRuntimeOnly "org.hsqldb:hsqldb:${versions.hsqldb}"
+ testImplementation project(':tapestry-test')
+ testImplementation project(':tapestry-test-constants')
- testRuntimeOnly 'com.google.inject:guice:3.0'
+ testRuntimeOnly("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
+ testRuntimeOnly libs.guice
+ testRuntimeOnly libs.slf4j.simple
}
// Not sure why this is necessary:
compileTestGroovy.dependsOn compileTestJava
jar {
- from("src/main/filtered-resources") {
+ from('src/main/filtered-resources') {
filter(ReplaceTokens, tokens: [version: project.parent.version])
}
}
diff --git a/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHandlerHelperImplTest.java b/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHandlerHelperImplTest.java
index 865bb13ab..3bd02f2ea 100644
--- a/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHandlerHelperImplTest.java
+++ b/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHandlerHelperImplTest.java
@@ -7,16 +7,16 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import org.apache.tapestry5.http.services.CorsHandlerHelper;
+import org.easymock.EasyMock;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import org.apache.tapestry5.http.services.CorsHandlerHelper;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.testng.annotations.Test;
-
/**
* Test suite for {@link CorsHandlerHelperImpl}.
*/
@@ -32,6 +32,7 @@ public class CorsHandlerHelperImplTest {
// Scenario 1: explicit origins
CorsHandlerHelper helper = create(String.join(" , ", allowedOrigins));
+
HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
for (String origin : allowedOrigins)
@@ -41,14 +42,14 @@ public class CorsHandlerHelperImplTest {
EasyMock.reset(request);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(origin);
EasyMock.replay(request);
- Assert.assertEquals("Allowed origin", origin, helper.getAllowedOrigin(request).get());
+ Assert.assertEquals(origin, helper.getAllowedOrigin(request).get(), "Allowed origin");
EasyMock.verify(request);
// Non-allowed origins
EasyMock.reset(request);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(origin + "baaaa");
EasyMock.replay(request);
- Assert.assertFalse("Non-allowed origins", helper.getAllowedOrigin(request).isPresent());
+ Assert.assertFalse(helper.getAllowedOrigin(request).isPresent(), "Non-allowed origins");
EasyMock.verify(request);
}
@@ -62,7 +63,8 @@ public class CorsHandlerHelperImplTest {
EasyMock.reset(request);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(origin);
EasyMock.replay(request);
- Assert.assertEquals("All origins should be accepted", CorsHandlerHelper.ORIGIN_WILDCARD, helper.getAllowedOrigin(request).get());
+ Assert.assertEquals(CorsHandlerHelper.ORIGIN_WILDCARD,
+ helper.getAllowedOrigin(request).get(), "All origins should be accepted");
EasyMock.verify(request);
}
@@ -78,7 +80,7 @@ public class CorsHandlerHelperImplTest {
HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(request.getMethod()).andReturn("PUT");
EasyMock.replay(request);
- Assert.assertFalse("Not OPTIONS", helper.isPreflight(request));
+ Assert.assertFalse(helper.isPreflight(request), "Not OPTIONS");
EasyMock.verify(request);
// Scenario 2: no Origin
@@ -86,7 +88,7 @@ public class CorsHandlerHelperImplTest {
EasyMock.expect(request.getMethod()).andReturn(CorsHandlerHelper.OPTIONS_METHOD);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(null);
EasyMock.replay(request);
- Assert.assertFalse("No Origin", helper.isPreflight(request));
+ Assert.assertFalse(helper.isPreflight(request), "No Origin");
EasyMock.verify(request);
// Scenario 3: accepted origin
@@ -94,7 +96,7 @@ public class CorsHandlerHelperImplTest {
EasyMock.expect(request.getMethod()).andReturn(CorsHandlerHelper.OPTIONS_METHOD);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(origin);
EasyMock.replay(request);
- Assert.assertTrue("Preflight indeed", helper.isPreflight(request));
+ Assert.assertTrue(helper.isPreflight(request), "Preflight indeed");
EasyMock.verify(request);
// Scenario 4: non-accepted origin
@@ -102,7 +104,7 @@ public class CorsHandlerHelperImplTest {
EasyMock.expect(request.getMethod()).andReturn(CorsHandlerHelper.OPTIONS_METHOD);
EasyMock.expect(request.getHeader(CorsHandlerHelper.ORIGIN_HEADER)).andReturn(origin + "baaah");
EasyMock.replay(request);
- Assert.assertFalse("Non-accepted origin", helper.isPreflight(request));
+ Assert.assertFalse(helper.isPreflight(request), "Non-accepted origin");
EasyMock.verify(request);
}
@@ -173,8 +175,8 @@ public class CorsHandlerHelperImplTest {
helper = create(CorsHandlerHelper.ORIGIN_WILDCARD, false);
helper.configureCredentials(response);
- Assert.assertNull("Header shouldn't be set",
- response.getHeader(CorsHandlerHelper.ALLOW_CREDENTIALS_HEADER));
+ Assert.assertNull(response.getHeader(CorsHandlerHelper.ALLOW_CREDENTIALS_HEADER),
+ "Header shouldn't be set");
}
@@ -214,8 +216,10 @@ public class CorsHandlerHelperImplTest {
EasyMock.replay(request);
helper.configureAllowedHeaders(response, request);
EasyMock.verify(request);
- Assert.assertEquals(requestHeaders, response.getHeader(CorsHandlerHelper.ALLOW_HEADERS_HEADER));
- Assert.assertEquals(CorsHandlerHelper.REQUEST_HEADERS_HEADER, response.getHeader(CorsHandlerHelper.VARY_HEADER));
+ Assert.assertEquals(response.getHeader(CorsHandlerHelper.ALLOW_HEADERS_HEADER),
+ requestHeaders);
+ Assert.assertEquals(response.getHeader(CorsHandlerHelper.VARY_HEADER),
+ CorsHandlerHelper.REQUEST_HEADERS_HEADER);
// Scenario 3: configuration empty, request's Access-Control-Request-Headers also empty
response = new TestableHttpServletResponse();
@@ -225,7 +229,8 @@ public class CorsHandlerHelperImplTest {
helper.configureAllowedHeaders(response, request);
EasyMock.verify(request);
Assert.assertNull(response.getHeader(CorsHandlerHelper.ALLOW_HEADERS_HEADER));
- Assert.assertEquals(CorsHandlerHelper.REQUEST_HEADERS_HEADER, response.getHeader(CorsHandlerHelper.VARY_HEADER));
+ Assert.assertEquals(response.getHeader(CorsHandlerHelper.VARY_HEADER),
+ CorsHandlerHelper.REQUEST_HEADERS_HEADER);
}
@@ -243,8 +248,8 @@ public class CorsHandlerHelperImplTest {
helper = new CorsHandlerHelperImpl("", false, "", "", "", "");
helper.configureExposeHeaders(response);
- Assert.assertNull("Header shouldn't be set",
- response.getHeader(CorsHandlerHelper.EXPOSE_HEADERS_HEADER));
+ Assert.assertNull(response.getHeader(CorsHandlerHelper.EXPOSE_HEADERS_HEADER),
+ "Header shouldn't be set");
}
@@ -262,8 +267,8 @@ public class CorsHandlerHelperImplTest {
helper = new CorsHandlerHelperImpl("", false, "", "", "", "");
helper.configureExposeHeaders(response);
- Assert.assertNull("Header shouldn't be set",
- response.getHeader(CorsHandlerHelper.MAX_AGE_HEADER));
+ Assert.assertNull(response.getHeader(CorsHandlerHelper.MAX_AGE_HEADER),
+ "Header shouldn't be set");
}
diff --git a/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHttpServletRequestFilterTest.java b/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHttpServletRequestFilterTest.java
index 45f319c62..e7fe39d22 100644
--- a/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHttpServletRequestFilterTest.java
+++ b/tapestry-http/src/test/java/org/apache/tapestry5/http/internal/services/CorsHttpServletRequestFilterTest.java
@@ -3,17 +3,17 @@ package org.apache.tapestry5.http.internal.services;
import java.io.IOException;
import java.util.Arrays;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
import org.apache.tapestry5.http.CorsHandlerResult;
import org.apache.tapestry5.http.services.CorsHandler;
import org.apache.tapestry5.http.services.CorsHttpServletRequestFilter;
import org.apache.tapestry5.http.services.HttpServletRequestHandler;
import org.easymock.EasyMock;
-import org.junit.Assert;
+import org.testng.Assert;
import org.testng.annotations.Test;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
/**
* Test suite for {@link CorsHttpServletRequestFilter}.
*/
diff --git a/tapestry-http/src/test/java/org/apache/tapestry5/http/test/TapestryHttpIntegrationTests.java b/tapestry-http/src/test/java/org/apache/tapestry5/http/test/TapestryHttpIntegrationTests.java
index 40fca07e9..633f3ea48 100644
--- a/tapestry-http/src/test/java/org/apache/tapestry5/http/test/TapestryHttpIntegrationTests.java
+++ b/tapestry-http/src/test/java/org/apache/tapestry5/http/test/TapestryHttpIntegrationTests.java
@@ -25,9 +25,9 @@ public class TapestryHttpIntegrationTests extends SeleniumTestCase {
public void testSimpleDispatcher() throws Exception
{
open("/hello");
- assertEquals("Return to base URL", getText("//a"));
+ assertEquals(getText("//a"), "Return to base URL");
clickAndWait("//a");
- assertEquals("Hello!", getText("//body/a"));
+ assertEquals(getText("//body/a"), "Hello!");
}
}
diff --git a/tapestry-http/src/test/java/org/apache/tapestry5/http/test/services/AppModule.java b/tapestry-http/src/test/java/org/apache/tapestry5/http/test/services/AppModule.java
index f7eab0d06..f3c8e7e5c 100644
--- a/tapestry-http/src/test/java/org/apache/tapestry5/http/test/services/AppModule.java
+++ b/tapestry-http/src/test/java/org/apache/tapestry5/http/test/services/AppModule.java
@@ -3,6 +3,8 @@ package org.apache.tapestry5.http.test.services;
import org.apache.tapestry5.commons.MappedConfiguration;
import org.apache.tapestry5.commons.OrderedConfiguration;
import org.apache.tapestry5.http.TapestryHttpSymbolConstants;
+import org.apache.tapestry5.http.internal.TapestryHttpInternalConstants;
+import org.apache.tapestry5.http.services.CompressionAnalyzer;
import org.apache.tapestry5.http.services.Dispatcher;
import org.apache.tapestry5.http.services.HttpServletRequestFilter;
import org.apache.tapestry5.http.services.RequestFilter;
@@ -30,6 +32,12 @@ public class AppModule {
public static void contributeApplicationDefaults(MappedConfiguration<String, Object> configuration)
{
configuration.add(TapestryHttpSymbolConstants.GZIP_COMPRESSION_ENABLED, true);
+ configuration.add(TapestryHttpSymbolConstants.PRODUCTION_MODE, true);
+ }
+
+ public static CompressionAnalyzer buildCompressionAnalyzer()
+ {
+ return str -> true;
}
}
diff --git a/tapestry-internal-test/build.gradle b/tapestry-internal-test/build.gradle
index 9caa72c9b..4213b6d2d 100644
--- a/tapestry-internal-test/build.gradle
+++ b/tapestry-internal-test/build.gradle
@@ -1,5 +1,5 @@
-description = "Internal utilties used to assist with testing; not intended for outside use"
+description = 'Internal utilties used to assist with testing; not intended for outside use'
dependencies {
- implementation project(":tapestry-core")
-}
\ No newline at end of file
+ implementation project(':tapestry-core')
+}
diff --git a/tapestry-ioc-jcache/build.gradle b/tapestry-ioc-jcache/build.gradle
index 878cbab07..07cc1df77 100644
--- a/tapestry-ioc-jcache/build.gradle
+++ b/tapestry-ioc-jcache/build.gradle
@@ -1,35 +1,26 @@
-import org.gradle.plugins.ide.idea.model.*
-import t5build.*
-
-description = "JCache (JSR 107) integration for Tapestry-IoC"
+plugins {
+ id 'tapestry.junit4-legacy-convention'
+}
-//apply plugin: JavaPlugin
+description = 'JCache (JSR 107) integration for Tapestry-IoC'
-project.ext.libraryVersions = [
- jcache: '1.0.0',
+ext.moduleLibs = [
+ javaxCacheApi: 'javax.cache:cache-api:1.0.0',
+ javaxCacheTests: 'javax.cache:cache-tests:1.0.0',
+ javaxCacheDomain: 'javax.cache:test-domain:1.0.0',
+ cacheAnnotations: 'org.jsr107.ri:cache-annotations-ri-common:1.0.0',
+ infinispanJcache: 'org.infinispan:infinispan-jcache:9.4.24.Final',
]
dependencies {
- /*compile "org.apache.tapestry:tapestry-ioc:${tapestryVersion()}"*/
- provided project(":tapestry-ioc")
- implementation "javax.cache:cache-api:${libraryVersions.jcache}"
- implementation "org.jsr107.ri:cache-annotations-ri-common:${libraryVersions.jcache}"
- testImplementation "javax.cache:cache-tests:${libraryVersions.jcache}"
- testImplementation "javax.cache:test-domain:${libraryVersions.jcache}"
- testRuntimeOnly "org.infinispan:infinispan-jcache:7.0.0.Alpha4" /* Just to be able to run the tests */
-}
+ provided project(":tapestry-ioc")
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jcache.module.JCacheModule'
- }
-}
-
-test {
- useJUnit()
+ implementation moduleLibs.javaxCacheApi
+ implementation moduleLibs.cacheAnnotations
- // those tests do not work with JDK 6 (java.lang.UnsupportedClassVersionError)
- exclude '**/InterceptionUsingDefaultCacheNameTest.class',
- '**/InterceptionCacheNameOnEachMethodTest.class',
- '**/InterceptionUsingCacheConfigTest.class'
+ testImplementation(moduleLibs.javaxCacheTests)
+ testImplementation moduleLibs.javaxCacheDomain
+ testRuntimeOnly moduleLibs.infinispanJcache /* Just to be able to run the tests */
}
+
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jcache.module.JCacheModule'
diff --git a/tapestry-ioc-junit/build.gradle b/tapestry-ioc-junit/build.gradle
index 39a81a2ca..117e20ba3 100644
--- a/tapestry-ioc-junit/build.gradle
+++ b/tapestry-ioc-junit/build.gradle
@@ -1,10 +1,13 @@
-description = "Utilities for junit testing a tapestry-ioc application"
+plugins {
+ id 'tapestry.junit5-convention'
+}
+
+description = 'Utilities for junit testing a tapestry-ioc application'
dependencies {
implementation project(':tapestry-ioc')
- implementation 'junit:junit:4.11'
-}
-test {
- useJUnit()
+ // We also need these in implementation
+ implementation platform(libs.junit.bom)
+ implementation libs.junit.jupiter.api
}
diff --git a/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunner.java b/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunner.java
deleted file mode 100644
index d12741978..000000000
--- a/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunner.java
+++ /dev/null
@@ -1,150 +0,0 @@
-// 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.
-
-package org.apache.tapestry5.ioc.junit;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.def.ModuleDef;
-import org.junit.runner.Description;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunListener;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runner.notification.StoppedByUserException;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.InitializationError;
-import org.junit.runners.model.Statement;
-
-/**
- *
- * A JUnit4ClassRunner to help with Tapestry IOC integration tests. The test
- * runner requires a registry configuration to be defined in a {@link Registry}
- * annotation. A {@link RegistryShutdownType} can be specified to configure the
- * lifecycle of the test registry and it's services
- *
- *
- *
- * {@link org.apache.tapestry5.ioc.junit.ModuleDef}s can be added to the
- * {@link org.apache.tapestry5.ioc.Registry} by annotating a factory method(s)
- * with {@link ModuleDef}. These {@link ModuleDef} factory methods must be
- * <ul>
- * <li>public</li>
- * <li>static</li>
- * <li>take zero arguments</li>
- * <li>return a subclass of {@link org.apache.tapestry5.ioc.junit.ModuleDef}</li>
- * </ul>
- *
- *
- *
- * Any services defined in the registry can be {@link Inject}ed into the test
- * class to be used during testing.
- *
- */
-public class TapestryIOCJUnit4ClassRunner extends BlockJUnit4ClassRunner {
- private final TestRegistryManager registryManager;
-
- public TapestryIOCJUnit4ClassRunner(Class<?> type) throws InitializationError {
- super(type);
- this.registryManager = new TestRegistryManager(type);
- }
-
- @Override
- public void run(RunNotifier notifier) {
- RunNotifier wrapper = new RegistryManagerRunNotifier(registryManager, notifier);
- super.run(wrapper);
- }
-
- @Override
- protected Statement withAfterClasses(Statement statement) {
- final Statement superStatement = super.withAfterClasses(statement);
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- superStatement.evaluate();
- registryManager.afterTestClass();
- }
- };
- }
-
- @Override
- protected Object createTest() throws Exception {
- org.apache.tapestry5.ioc.Registry registry = registryManager.getOrCreateRegistry();
- return registry.autobuild(getTestClass().getJavaClass());
- }
-
- public static class RegistryManagerRunNotifier extends RunNotifier {
- private final RunNotifier delegate;
- private final TestRegistryManager registryManager;
-
- public RegistryManagerRunNotifier(TestRegistryManager registryManager, RunNotifier delegate) {
- super();
- this.delegate = delegate;
- this.registryManager = registryManager;
- }
-
- @Override
- public void addListener(RunListener listener) {
- delegate.addListener(listener);
- }
-
- @Override
- public void removeListener(RunListener listener) {
- delegate.removeListener(listener);
- }
-
- @Override
- public void fireTestRunStarted(Description description) {
- delegate.fireTestRunStarted(description);
- }
-
- @Override
- public void fireTestRunFinished(Result result) {
- delegate.fireTestRunFinished(result);
- }
-
- @Override
- public void fireTestStarted(Description description) throws StoppedByUserException {
- delegate.fireTestStarted(description);
- }
-
- @Override
- public void fireTestFailure(Failure failure) {
- delegate.fireTestFailure(failure);
- }
-
- @Override
- public void fireTestAssumptionFailed(Failure failure) {
- delegate.fireTestAssumptionFailed(failure);
- }
-
- @Override
- public void fireTestIgnored(Description description) {
- delegate.fireTestIgnored(description);
- }
-
- @Override
- public void fireTestFinished(Description description) {
- registryManager.afterTestMethod();
- delegate.fireTestFinished(description);
- }
-
- @Override
- public void pleaseStop() {
- delegate.pleaseStop();
- }
-
- @Override
- public void addFirstListener(RunListener listener) {
- delegate.addFirstListener(listener);
- }
- }
-}
\ No newline at end of file
diff --git a/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnitExtension.java b/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnitExtension.java
new file mode 100644
index 000000000..f6e75087d
--- /dev/null
+++ b/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnitExtension.java
@@ -0,0 +1,108 @@
+// Copyright 2025 The Apache Software 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.
+
+package org.apache.tapestry5.ioc.junit;
+
+import java.lang.reflect.Field;
+
+import org.apache.tapestry5.ioc.Registry;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.TestInstanceFactory;
+import org.junit.jupiter.api.extension.TestInstanceFactoryContext;
+import org.junit.jupiter.api.extension.TestInstantiationException;
+
+public class TapestryIOCJUnitExtension implements BeforeAllCallback, AfterAllCallback,
+ BeforeEachCallback, AfterEachCallback, TestInstanceFactory
+{
+
+ private TestRegistryManager registryManager;
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception
+ {
+ Class<?> testClass = context.getRequiredTestClass();
+ registryManager = new TestRegistryManager(testClass);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception
+ {
+ if (registryManager != null)
+ {
+ registryManager.afterTestClass();
+ }
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception
+ {
+ // No-op: lifecycle handled by createTestInstance
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception
+ {
+ if (registryManager != null)
+ {
+ registryManager.afterTestMethod();
+ }
+ }
+
+ @Override
+ public Object createTestInstance(TestInstanceFactoryContext factoryContext,
+ ExtensionContext extensionContext) throws TestInstantiationException
+ {
+ if (registryManager == null)
+ {
+ registryManager = new TestRegistryManager(factoryContext.getTestClass());
+ }
+ try
+ {
+ Registry registry = registryManager.getOrCreateRegistry();
+ Object testInstance = registry.autobuild(factoryContext.getTestClass());
+ injectFields(testInstance, registry);
+ return testInstance;
+ }
+ catch (Exception e)
+ {
+ throw new TestInstantiationException("", e);
+ }
+ }
+
+ private void injectFields(Object instance, Registry registry)
+ {
+ Class<?> clazz = instance.getClass();
+ for (Field field : clazz.getDeclaredFields())
+ {
+ if (field.isAnnotationPresent(Inject.class))
+ {
+ Object service = registry.getObject(field.getType(), null);
+ field.setAccessible(true);
+ try
+ {
+ field.set(instance, service);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Failed to inject field: " + field, e);
+ }
+ }
+ }
+ }
+}
diff --git a/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TestRegistryManager.java b/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TestRegistryManager.java
index fd8ac454f..d74b61519 100644
--- a/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TestRegistryManager.java
+++ b/tapestry-ioc-junit/src/main/java/org/apache/tapestry5/ioc/junit/TestRegistryManager.java
@@ -22,110 +22,130 @@ import java.util.Collections;
import java.util.List;
import org.apache.tapestry5.ioc.RegistryBuilder;
-import org.junit.runners.model.InitializationError;
/**
- * Helper class used by the {@link TapestryIOCJUnit4ClassRunner} to manage the test registry
+ * Helper class used by the {@link TapestryIOCJUnitExtension} to manage the test registry
*/
-public class TestRegistryManager {
- private final Registry annotation;
- private final List<Method> moduleDefFactories;
-
- private org.apache.tapestry5.ioc.Registry registry;
-
- public TestRegistryManager(Class<?> type) throws InitializationError {
- super();
-
- Registry annotation = type.getAnnotation(Registry.class);
- if (annotation == null) {
- throw new InitializationError(type.getName() + " does not specify a @Registry");
- }
-
- this.annotation = annotation;
- this.moduleDefFactories = findModuleDefFactories(type);
- }
-
- protected List<Method> findModuleDefFactories(Class<?> type) throws InitializationError {
- List<Method> factoryMethods = new ArrayList<Method>();
- for (Method method : type.getMethods()) {
- if (method.getAnnotation(ModuleDef.class) != null) {
- validateModuleDefMethod(method);
- factoryMethods.add(method);
- }
- }
- return factoryMethods.isEmpty() ? Collections.<Method> emptyList() : factoryMethods;
- }
-
- protected void validateModuleDefMethod(Method method) throws InitializationError {
- int modifiers = method.getModifiers();
- if (method.getParameterTypes().length != 0
- || !Modifier.isStatic(modifiers)
- || !Modifier.isPublic(modifiers)) {
-
- throw new InitializationError(
- String.format("@ModuleDef method %s must be public static and accept no arguments",
- method.getName()));
- }
- if (!org.apache.tapestry5.ioc.def.ModuleDef.class.isAssignableFrom(method.getReturnType())) {
- throw new InitializationError(
- String.format("@ModuleDef method %s return type %s is not valid",
- method.getName(), method.getReturnType().getName()));
- }
- }
-
- /**
- * Get the existing registry or create one if required.
- * @return The test Registry
- * @throws Exception
- */
- public org.apache.tapestry5.ioc.Registry getOrCreateRegistry() throws Exception {
- if (registry == null) {
- RegistryBuilder builder = new RegistryBuilder();
- if (annotation.modules() != null) {
- builder.add(annotation.modules());
- }
- for (Method moduleDefFactory : moduleDefFactories) {
- try {
- org.apache.tapestry5.ioc.def.ModuleDef moduleDef =
- (org.apache.tapestry5.ioc.def.ModuleDef) moduleDefFactory.invoke(null);
-
- builder.add(moduleDef);
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Exception) {
- throw (Exception) e.getTargetException();
- }
- throw e;
- }
- }
- registry = builder.build();
- registry.performRegistryStartup();
- }
- return registry;
- }
-
- /**
- * Notify that the current test method has completed
- */
- public void afterTestMethod() {
- if (annotation.shutdown() == RegistryShutdownType.AFTER_METHOD) {
- shutdownRegistry();
- }
- }
-
- /**
- * Notify that the current test class has completed
- */
- public void afterTestClass() {
- if (annotation.shutdown() == RegistryShutdownType.AFTER_CLASS) {
- shutdownRegistry();
- }
- }
-
- protected void shutdownRegistry() {
- try {
- registry.shutdown();
- } finally {
- registry = null;
- }
- }
+public class TestRegistryManager
+{
+ private final Registry annotation;
+ private final List<Method> moduleDefFactories;
+
+ private org.apache.tapestry5.ioc.Registry registry;
+
+ public TestRegistryManager(Class<?> type) throws RuntimeException
+ {
+ super();
+
+ Registry annotation = type.getAnnotation(Registry.class);
+ if (annotation == null)
+ { throw new RuntimeException(type.getName() + " does not specify a @Registry"); }
+
+ this.annotation = annotation;
+ this.moduleDefFactories = findModuleDefFactories(type);
+ }
+
+ protected List<Method> findModuleDefFactories(Class<?> type) throws RuntimeException
+ {
+ List<Method> factoryMethods = new ArrayList<Method>();
+ for (Method method : type.getMethods())
+ {
+ if (method.getAnnotation(ModuleDef.class) != null)
+ {
+ validateModuleDefMethod(method);
+ factoryMethods.add(method);
+ }
+ }
+ return factoryMethods.isEmpty() ? Collections.<Method> emptyList() : factoryMethods;
+ }
+
+ protected void validateModuleDefMethod(Method method) throws RuntimeException
+ {
+ int modifiers = method.getModifiers();
+ if (method.getParameterTypes().length != 0 || !Modifier.isStatic(modifiers)
+ || !Modifier.isPublic(modifiers))
+ {
+
+ throw new RuntimeException(String.format(
+ "@ModuleDef method %s must be public static and accept no arguments",
+ method.getName()));
+ }
+ if (!org.apache.tapestry5.ioc.def.ModuleDef.class.isAssignableFrom(method.getReturnType()))
+ {
+ throw new RuntimeException(
+ String.format("@ModuleDef method %s return type %s is not valid",
+ method.getName(), method.getReturnType().getName()));
+ }
+ }
+
+ /**
+ * Get the existing registry or create one if required.
+ *
+ * @return The test Registry
+ * @throws Exception
+ */
+ public org.apache.tapestry5.ioc.Registry getOrCreateRegistry() throws Exception
+ {
+ if (registry == null)
+ {
+ RegistryBuilder builder = new RegistryBuilder();
+ if (annotation.modules() != null)
+ {
+ builder.add(annotation.modules());
+ }
+ for (Method moduleDefFactory : moduleDefFactories)
+ {
+ try
+ {
+ org.apache.tapestry5.ioc.def.ModuleDef moduleDef = (org.apache.tapestry5.ioc.def.ModuleDef) moduleDefFactory
+ .invoke(null);
+
+ builder.add(moduleDef);
+ }
+ catch (InvocationTargetException e)
+ {
+ if (e.getTargetException() instanceof Exception)
+ { throw (Exception) e.getTargetException(); }
+ throw e;
+ }
+ }
+ registry = builder.build();
+ registry.performRegistryStartup();
+ }
+ return registry;
+ }
+
+ /**
+ * Notify that the current test method has completed
+ */
+ public void afterTestMethod()
+ {
+ if (annotation.shutdown() == RegistryShutdownType.AFTER_METHOD)
+ {
+ shutdownRegistry();
+ }
+ }
+
+ /**
+ * Notify that the current test class has completed
+ */
+ public void afterTestClass()
+ {
+ if (annotation.shutdown() == RegistryShutdownType.AFTER_CLASS)
+ {
+ shutdownRegistry();
+ }
+ }
+
+ protected void shutdownRegistry()
+ {
+ try
+ {
+ registry.shutdown();
+ }
+ finally
+ {
+ registry = null;
+ }
+ }
}
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterClassTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterClassTest.java
deleted file mode 100644
index 67be2ef61..000000000
--- a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterClassTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 The Apache Software 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.
-
-package org.apache.tapestry5.ioc.junit;
-
-import static org.apache.tapestry5.ioc.junit.RegistryShutdownType.AFTER_CLASS;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.runners.MethodSorters.NAME_ASCENDING;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.junit.Registry;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunner;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunnerAfterClassTest.AfterClassTestModule;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(TapestryIOCJUnit4ClassRunner.class)
-@Registry(modules=AfterClassTestModule.class, shutdown=AFTER_CLASS)
-@FixMethodOrder(NAME_ASCENDING) // guarantees test ordering
-public class TapestryIOCJUnit4ClassRunnerAfterClassTest {
- public static class AfterClassTestModule {
- public List<String> buildList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- return list;
- }
- }
-
- @Inject
- private List<String> list;
-
- @Test
- public void testInjectA() {
- assertArrayEquals(new Object[] { "foo" }, list.toArray());
- list.add("bar");
- }
-
- @Test
- public void testInjectB() {
- assertArrayEquals(new Object[] { "foo", "bar" }, list.toArray());
- list.add("baz");
- }
-
- @Test
- public void testInjectC() {
- assertArrayEquals(new Object[] { "foo", "bar", "baz" }, list.toArray());
- }
-}
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterMethodTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterMethodTest.java
deleted file mode 100644
index acbaa8189..000000000
--- a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerAfterMethodTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 The Apache Software 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.
-
-package org.apache.tapestry5.ioc.junit;
-
-import static org.apache.tapestry5.ioc.junit.RegistryShutdownType.AFTER_METHOD;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.runners.MethodSorters.NAME_ASCENDING;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.junit.Registry;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunner;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunnerAfterMethodTest.AfterMethodTestModule;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(TapestryIOCJUnit4ClassRunner.class)
-@Registry(modules=AfterMethodTestModule.class, shutdown=AFTER_METHOD)
-@FixMethodOrder(NAME_ASCENDING) // guarantees test ordering
-public class TapestryIOCJUnit4ClassRunnerAfterMethodTest {
- public static class AfterMethodTestModule {
- public List<String> buildList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- return list;
- }
- }
-
- @Inject
- private List<String> list;
-
- @Test
- public void testInjectA() {
- assertArrayEquals(new Object[] { "foo" }, list.toArray());
-
- list.add("bar");
- }
-
- @Test
- public void testInjectB() {
- assertArrayEquals(new Object[] { "foo" }, list.toArray());
-
- list.add("baz");
- }
-
- @Test
- public void testInjectC() {
- assertArrayEquals(new Object[] { "foo" }, list.toArray());
- }
-}
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerModuleDefTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerModuleDefTest.java
deleted file mode 100644
index 3915584c8..000000000
--- a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit4ClassRunnerModuleDefTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 The Apache Software 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.
-
-package org.apache.tapestry5.ioc.junit;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.junit.ModuleDef;
-import org.apache.tapestry5.ioc.junit.Registry;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunner;
-import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit4ClassRunnerModuleDefTest.ModuleDefTestModule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(TapestryIOCJUnit4ClassRunner.class)
-@Registry(modules=ModuleDefTestModule.class)
-public class TapestryIOCJUnit4ClassRunnerModuleDefTest {
- @ModuleDef
- public static MapModuleDef createModuleDef1() {
- Map<String,Object> map = new HashMap<String, Object>();
- map.put("a", new Date(111));
- map.put("b", 222L);
-
- return new MapModuleDef(map);
- }
-
- @ModuleDef
- public static org.apache.tapestry5.ioc.def.ModuleDef createModuleDef2() {
- Map<String,Object> map = new HashMap<String, Object>();
- map.put("c", 333);
-
- return new MapModuleDef(map);
- }
-
- public static class ModuleDefTestModule {
- public String buildD() {
- return "444";
- }
- }
-
- @Inject private Date a;
- @Inject private Long b;
- @Inject private Integer c;
- @Inject private String d;
-
- @Test
- public void testModuleDefInject() {
- assertEquals(new Date(111), a);
- assertEquals(new Long(222L), b);
- assertEquals(new Integer(333), c);
- assertEquals("444", d);
- }
-}
\ No newline at end of file
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterClassTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterClassTest.java
new file mode 100644
index 000000000..40a894e11
--- /dev/null
+++ b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterClassTest.java
@@ -0,0 +1,74 @@
+// Copyright 2006–2025 The Apache Software 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.
+
+package org.apache.tapestry5.ioc.junit;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.junit.TapestryIOCJUnit5AfterClassTest.AfterClassTestModule;
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(TapestryIOCJUnitExtension.class)
+@Registry(modules = AfterClassTestModule.class, shutdown = RegistryShutdownType.AFTER_CLASS)
+@TestMethodOrder(OrderAnnotation.class)
+public class TapestryIOCJUnit5AfterClassTest
+{
+
+ public static class AfterClassTestModule
+ {
+ public List<String> buildList()
+ {
+ List<String> list = new ArrayList<>();
+ list.add("foo");
+ return list;
+ }
+ }
+
+ @Inject
+ private List<String> list;
+
+ @Test
+ @Order(1)
+ public void testInjectA()
+ {
+ assertArrayEquals(new Object[]
+ { "foo" }, list.toArray());
+ list.add("bar");
+ }
+
+ @Test
+ @Order(2)
+ public void testInjectB()
+ {
+ assertArrayEquals(new Object[]
+ { "foo", "bar" }, list.toArray());
+ list.add("baz");
+ }
+
+ @Test
+ @Order(3)
+ public void testInjectC()
+ {
+ assertArrayEquals(new Object[]
+ { "foo", "bar", "baz" }, list.toArray());
+ }
+}
\ No newline at end of file
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterMethodTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterMethodTest.java
new file mode 100644
index 000000000..c41dab760
--- /dev/null
+++ b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5AfterMethodTest.java
@@ -0,0 +1,69 @@
+// Copyright 2006–2025 The Apache Software 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.
+
+package org.apache.tapestry5.ioc.junit;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(TapestryIOCJUnitExtension.class)
+@Registry(modules = TapestryIOCJUnit5AfterMethodTest.AfterMethodTestModule.class, shutdown = RegistryShutdownType.AFTER_METHOD)
+@TestMethodOrder(MethodOrderer.MethodName.class)
+public class TapestryIOCJUnit5AfterMethodTest
+{
+
+ public static class AfterMethodTestModule
+ {
+ public List<String> buildList()
+ {
+ List<String> list = new ArrayList<>();
+ list.add("foo");
+ return list;
+ }
+ }
+
+ @Inject
+ private List<String> list;
+
+ @Test
+ void testInjectA()
+ {
+ assertArrayEquals(new Object[]
+ { "foo" }, list.toArray());
+ list.add("bar");
+ }
+
+ @Test
+ void testInjectB()
+ {
+ assertArrayEquals(new Object[]
+ { "foo" }, list.toArray());
+ list.add("baz");
+ }
+
+ @Test
+ void testInjectC()
+ {
+ assertArrayEquals(new Object[]
+ { "foo" }, list.toArray());
+ }
+}
diff --git a/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5ModuleDefTest.java b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5ModuleDefTest.java
new file mode 100644
index 000000000..dabbb69bf
--- /dev/null
+++ b/tapestry-ioc-junit/src/test/java/org/apache/tapestry5/ioc/junit/TapestryIOCJUnit5ModuleDefTest.java
@@ -0,0 +1,74 @@
+// Copyright 2006–2025 The Apache Software 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.
+
+package org.apache.tapestry5.ioc.junit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(TapestryIOCJUnitExtension.class)
+@Registry(modules = TapestryIOCJUnit5ModuleDefTest.ModuleDefTestModule.class)
+public class TapestryIOCJUnit5ModuleDefTest
+{
+
+ @ModuleDef
+ public static org.apache.tapestry5.ioc.def.ModuleDef createModuleDef1()
+ {
+ Map<String, Object> map = new HashMap<>();
+ map.put("a", new Date(111));
+ map.put("b", 222L);
+ return new MapModuleDef(map);
+ }
+
+ @ModuleDef
+ public static org.apache.tapestry5.ioc.def.ModuleDef createModuleDef2()
+ {
+ Map<String, Object> map = new HashMap<>();
+ map.put("c", 333);
+ return new MapModuleDef(map);
+ }
+
+ public static class ModuleDefTestModule
+ {
+ public String buildD()
+ {
+ return "444";
+ }
+ }
+
+ @Inject
+ private Date a;
+ @Inject
+ private Long b;
+ @Inject
+ private Integer c;
+ @Inject
+ private String d;
+
+ @Test
+ void testModuleDefInject()
+ {
+ assertEquals(new Date(111), a);
+ assertEquals(Long.valueOf(222L), b);
+ assertEquals(Integer.valueOf(333), c);
+ assertEquals("444", d);
+ }
+}
diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
index 5a89ce604..9fb52df35 100644
--- a/tapestry-ioc/build.gradle
+++ b/tapestry-ioc/build.gradle
@@ -1,33 +1,28 @@
-description = "A code-centric, high-performance, simple Inversion of Control container"
+plugins {
+ id 'tapestry.junit5-spock-convention'
+}
+description = 'A code-centric, high-performance, simple Inversion of Control container'
dependencies {
api project(':tapestry-func')
- api project(':tapestry5-annotations')
- api project(":plastic")
- api project(":beanmodel")
+ api project(':commons')
+ implementation project(":beanmodel")
provided project(':tapestry-test')
// For now, keep these compile dependencies synchronized with the binaries dependencies
// of the top-level build:
- api "jakarta.inject:jakarta.inject-api:${versions.injectApi}"
- api "jakarta.annotation:jakarta.annotation-api:${versions.annotationApi}"
+ api libs.jakarta.inject.api
+ api libs.jakarta.annotation.api
- api "org.slf4j:slf4j-api:${versions.slf4j}"
+ testImplementation libs.commons.lang3
+ testImplementation libs.hibernate.core
+ testRuntimeOnly("${libs.hsqldb.get().module.group}:${libs.hsqldb.get().module.name}:${libs.hsqldb.get().version}:jdk8")
- testImplementation "commons-lang:commons-lang:2.6"
- testImplementation "org.apache.commons:commons-lang3:${versions.commonsLang}"
- testImplementation "org.hibernate:hibernate-core:5.2.10.Final"
- testRuntimeOnly "org.hsqldb:hsqldb:${versions.hsqldb}"
-
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-
- provided "org.testng:testng:${versions.testng}", { transitive = false }
}
test {
- useJUnitPlatform()
// Override the master build.gradle
systemProperties.remove("tapestry.service-reloading-enabled")
-}
\ No newline at end of file
+}
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
index 5b6a5ff19..a235396ce 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java
@@ -295,7 +295,12 @@ public abstract class AbstractResource extends LockSupport implements Resource
String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2);
- URL directoryResource = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/");
+ if (!resourceInJar.endsWith("/"))
+ {
+ resourceInJar += "/";
+ }
+ URL directoryResource = Thread.currentThread().getContextClassLoader()
+ .getResource(resourceInJar);
boolean isDirectory = directoryResource != null && "jar".equals(directoryResource.getProtocol());
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/AdviseByMarkerModule2.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/AdviseByMarkerModule2.java
index f080e1f83..5c48fa149 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/AdviseByMarkerModule2.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/AdviseByMarkerModule2.java
@@ -22,8 +22,7 @@ import org.apache.tapestry5.ioc.test.Greeter;
import org.apache.tapestry5.ioc.test.RedMarker;
import org.apache.tapestry5.plastic.MethodAdvice;
import org.apache.tapestry5.plastic.MethodInvocation;
-import org.testng.Assert;
-
+import org.spockframework.util.Assert;
public class AdviseByMarkerModule2
{
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/DecorateByMarkerModule2.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/DecorateByMarkerModule2.java
index 481179474..6296de58b 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/DecorateByMarkerModule2.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/DecorateByMarkerModule2.java
@@ -24,7 +24,7 @@ import org.apache.tapestry5.ioc.test.Greeter;
import org.apache.tapestry5.ioc.test.RedMarker;
import org.apache.tapestry5.plastic.MethodAdvice;
import org.apache.tapestry5.plastic.MethodInvocation;
-import org.testng.Assert;
+import org.spockframework.util.Assert;
public class DecorateByMarkerModule2
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceBuilderMethodFixture.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceBuilderMethodFixture.java
index e4f9945f6..77021b73d 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceBuilderMethodFixture.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceBuilderMethodFixture.java
@@ -14,17 +14,21 @@
package org.apache.tapestry5.ioc.test.internal;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
import org.apache.tapestry5.ioc.ServiceResources;
import org.apache.tapestry5.ioc.annotations.InjectService;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.annotations.Value;
import org.slf4j.Logger;
-import org.testng.Assert;
+import org.spockframework.util.Assert;
import jakarta.inject.Named;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
/**
* Used by {@link ioc.specs.ServiceBuilderMethodInvokerSpec}.
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceDecoratorFixture.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceDecoratorFixture.java
index 79bee8b5b..6512395bb 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceDecoratorFixture.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/test/internal/ServiceDecoratorFixture.java
@@ -1,6 +1,7 @@
package org.apache.tapestry5.ioc.test.internal;
-import org.testng.Assert;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import org.spockframework.util.Assert;
/**
* Used by {@link org.apache.tapestry5.ioc.test.internal.services.ServiceDecoratorImplSpec}.
@@ -15,15 +16,15 @@ public class ServiceDecoratorFixture extends Assert
public <T> T decoratorReturnsInterceptor(Class<T> serviceInterface, T delegate)
{
- assertSame(serviceInterface, FieService.class);
- assertSame(delegate, expectedDelegate);
+ assertSame(FieService.class, serviceInterface);
+ assertSame(expectedDelegate, delegate);
return serviceInterface.cast(interceptorToReturn);
}
public Object decoratorUntyped(Object delegate)
{
- assertSame(delegate, expectedDelegate);
+ assertSame(expectedDelegate, delegate);
return interceptorToReturn;
}
diff --git a/tapestry-javadoc/build.gradle b/tapestry-javadoc/build.gradle
index d72b91a73..3142737a5 100644
--- a/tapestry-javadoc/build.gradle
+++ b/tapestry-javadoc/build.gradle
@@ -1,32 +1,35 @@
+plugins {
+ id 'tapestry.junit5-convention'
+}
+
description = "JavaDoc Plugin for Tapestry that generates component reference documentation for component classes"
dependencies {
- implementation project(':tapestry-core')
- implementation "commons-lang:commons-lang:2.6"
-
- if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
- implementation files(getTools())
- }
-
-}
+ implementation project(':tapestry-core')
-/** Returns the tools.jar/classes.jar of the Java runtime. */
-File getTools() {
+ implementation libs.commons.lang3
+ implementation libs.commons.text
- def dir = isMacOSX_1_6() ? "classes" : "lib"
-
- def jar = isMacOSX_1_6() ? "classes" : "tools.jar"
-
- def jreRelpath = "../${dir}/${jar}"
- def jdkRelpath = "$dir/${jar}"
-
- def javaHome = System.properties['java.home']
+ testImplementation platform(libs.spock.bom)
+ testImplementation libs.spock.core
+}
- return new File(javaHome, jdkRelpath).exists() ? new File(javaHome, jdkRelpath) : new File(javaHome, jreRelpath)
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(11)
+ }
}
-boolean isMacOSX_1_6() {
- System.properties['os.name'].toLowerCase().contains('mac os') &&
- System.properties['java.version'].startsWith("1.6.")
+tasks.withType(JavaCompile).configureEach {
+ // Override Java 8 compatibility inherited from root
+ sourceCompatibility = '11'
+ targetCompatibility = '11'
+
+ // Only apply --add-modules if target is not 1.8
+ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
+ options.compilerArgs += [
+ '--add-modules',
+ 'jdk.compiler'
+ ]
+ }
}
-
\ No newline at end of file
diff --git a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ClassDescription.java b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ClassDescription.java
index 2b959b1bb..1af159767 100644
--- a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ClassDescription.java
+++ b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ClassDescription.java
@@ -14,12 +14,23 @@
package org.apache.tapestry5.javadoc;
-import com.sun.source.doctree.DocCommentTree;
-import com.sun.source.doctree.DocTree;
-import com.sun.source.doctree.SinceTree;
-import com.sun.source.util.SimpleDocTreeVisitor;
-import jdk.javadoc.doclet.DocletEnvironment;
-import org.apache.commons.lang.StringUtils;
+import java.util.List;
+import java.util.Map;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.SimpleAnnotationValueVisitor9;
+import javax.lang.model.util.SimpleTypeVisitor9;
+
+import org.apache.commons.lang3.StringUtils;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Events;
@@ -27,14 +38,12 @@ import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.commons.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import javax.lang.model.element.*;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.SimpleAnnotationValueVisitor9;
-import javax.lang.model.util.SimpleTypeVisitor9;
-import java.util.List;
-import java.util.Map;
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.SinceTree;
+import com.sun.source.util.SimpleDocTreeVisitor;
+
+import jdk.javadoc.doclet.DocletEnvironment;
public class ClassDescription
{
diff --git a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ParameterDescription.java b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ParameterDescription.java
index d9f87c176..f97e66e7b 100644
--- a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ParameterDescription.java
+++ b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/ParameterDescription.java
@@ -14,18 +14,20 @@
package org.apache.tapestry5.javadoc;
-import com.sun.source.doctree.*;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.commons.util.CollectionFactory;
-
-import javax.lang.model.element.VariableElement;
import java.io.IOException;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.lang.model.element.VariableElement;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.apache.tapestry5.commons.util.CollectionFactory;
+
+import com.sun.source.doctree.*;
+
public class ParameterDescription
{
public final VariableElement field;
@@ -103,18 +105,19 @@ public class ParameterDescription
String label = seeTag.getLabel().toString();
if (StringUtils.isNotEmpty(label))
{
- builder.append(StringEscapeUtils.escapeHtml(label));
+ builder.append(StringEscapeUtils.escapeHtml4(label));
continue;
}
if (seeTag.getReference() != null)
- builder.append(StringEscapeUtils.escapeHtml(seeTag.getReference().getSignature()));
+ builder.append(
+ StringEscapeUtils.escapeHtml4(seeTag.getReference().getSignature()));
}
else if (tag.getKind() == DocTree.Kind.CODE)
{
LiteralTree codeTag = (LiteralTree) tag;
builder.append("<code>");
- builder.append(StringEscapeUtils.escapeHtml(codeTag.getBody().getBody()));
+ builder.append(StringEscapeUtils.escapeHtml4(codeTag.getBody().getBody()));
builder.append("</code>");
}
}
@@ -135,7 +138,7 @@ public class ParameterDescription
boolean match = m.find(index);
if (match){
if (index != m.start()){
- sb.append(StringEscapeUtils.escapeHtml(string.substring(index, m.start())));
+ sb.append(StringEscapeUtils.escapeHtml4(string.substring(index, m.start())));
}
String tagName = m.group(1);
if (tagName!= null){
@@ -147,7 +150,7 @@ public class ParameterDescription
}
index = m.end();
}else{
- sb.append(StringEscapeUtils.escapeHtml(string.substring(index)));
+ sb.append(StringEscapeUtils.escapeHtml4(string.substring(index)));
break;
}
}
diff --git a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/TapestryDocTaglet.java b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/TapestryDocTaglet.java
index 2229af4f8..336e0c2d1 100644
--- a/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/TapestryDocTaglet.java
+++ b/tapestry-javadoc/src/main/java/org/apache/tapestry5/javadoc/TapestryDocTaglet.java
@@ -14,18 +14,6 @@
package org.apache.tapestry5.javadoc;
-import com.sun.source.doctree.DocTree;
-import jdk.javadoc.doclet.Doclet;
-import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.doclet.Taglet;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.commons.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
@@ -34,6 +22,21 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.tapestry5.commons.util.CollectionFactory;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+
+import com.sun.source.doctree.DocTree;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Taglet;
+
/**
* An inline tag allowed inside a type; it produces Tapestry component reference and other information.
*/
diff --git a/tapestry-jmx/build.gradle b/tapestry-jmx/build.gradle
index ef371e800..fa69921ca 100644
--- a/tapestry-jmx/build.gradle
+++ b/tapestry-jmx/build.gradle
@@ -1,18 +1,13 @@
-description = "Allows easy exposure of Tapestry Services as JMX MBeans"
+plugins {
+ id 'tapestry.testng-convention'
+}
-dependencies {
- implementation project(':tapestry-core')
+description = 'Allows easy exposure of Tapestry Services as JMX MBeans'
- testImplementation project(':tapestry-test')
- }
+dependencies {
+ implementation project(':tapestry-core')
-test {
- systemProperties "tapestry.service-reloading-enabled": "false"
+ testImplementation project(':tapestry-test')
}
-
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jmx.modules.JmxModule'
- }
-}
\ No newline at end of file
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jmx.modules.JmxModule'
diff --git a/tapestry-jmx/src/test/conf/testng.xml b/tapestry-jmx/src/test/conf/testng.xml
deleted file mode 100644
index 50881830f..000000000
--- a/tapestry-jmx/src/test/conf/testng.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-
-<suite name="Tapestry JMX" parallel="false" thread-count="10" annotations="1.5" verbose="2">
-
- <test name="Tapestry JMX Integration Tests">
- <parameter name="tapestry.web-app-folder" value="src/test/webapp"/>
-
- <packages>
- <package name="org.apache.tapestry5.jmx.integration"/>
- </packages>
- </test>
-</suite>
diff --git a/tapestry-jmx/src/test/resources/testng.xml b/tapestry-jmx/src/test/resources/testng.xml
new file mode 100644
index 000000000..6a21a0615
--- /dev/null
+++ b/tapestry-jmx/src/test/resources/testng.xml
@@ -0,0 +1,17 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+
+<suite
+ name="Tapestry JMX"
+ annotations="1.5"
+ verbose="2">
+
+ <test name="Tapestry JMX Integration Tests" enabled="true">
+ <parameter
+ name="tapestry.web-app-folder"
+ value="src/test/webapp" />
+
+ <packages>
+ <package name="org.apache.tapestry5.jmx.integration" />
+ </packages>
+ </test>
+</suite>
diff --git a/tapestry-jpa/build.gradle b/tapestry-jpa/build.gradle
index 93235c583..ba7e471a2 100644
--- a/tapestry-jpa/build.gradle
+++ b/tapestry-jpa/build.gradle
@@ -1,38 +1,33 @@
-description = "Provides support for simple CRUD applications built on top of Tapestry and JPA"
+plugins {
+ id 'tapestry.testng-convention'
+}
-dependencies {
- implementation project(':tapestry-core')
- api 'jakarta.persistence:jakarta.persistence-api:3.0.0'
- implementation 'jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.1'
+description = 'Provides support for simple CRUD applications built on top of Tapestry and JPA'
- testImplementation 'org.slf4j:slf4j-simple:1.7.25'
- testImplementation 'org.slf4j:slf4j-simple:2.0.5'
- testImplementation project(':tapestry-test')
- testImplementation 'org.eclipse.persistence:eclipselink:3.0.4'
+ext.moduleLibs = [
+ jakartaCdiApi: 'jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.1',
+ eclipselink: 'org.eclipse.persistence:eclipselink:3.0.4',
+ dbcp: 'org.apache.tomcat:dbcp:6.0.32',
+ h2: 'com.h2database:h2:1.3.175'
+]
- testRuntimeOnly "org.apache.tomcat:dbcp:6.0.32"
- testRuntimeOnly 'com.h2database:h2:1.3.175'
-
-}
-
-repositories {
- maven {
- name "EclipseLink"
- url "https://download.eclipse.org/rt/eclipselink/maven.repo/"
- }
-}
+dependencies {
+ implementation project(':tapestry-core')
-test {
- systemProperties "tapestry.service-reloading-enabled": "false"
-}
+ api libs.jakarta.persistence.api
+ implementation moduleLibs.jakartaCdiApi
+ testImplementation project(':tapestry-test')
+ testImplementation moduleLibs.eclipselink
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jpa.modules.JpaModule'
- }
+ testRuntimeOnly moduleLibs.dbcp
+ testRuntimeOnly moduleLibs.h2
+
+ testImplementation libs.testng
}
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.jpa.modules.JpaModule'
+
task runTestApp1(type:JavaExec) {
description 'Start app1 integration test app, useful when debugging failing integration tests'
main = 'org.apache.tapestry5.test.JettyRunner'
@@ -73,4 +68,4 @@ task runTestApp6(type:JavaExec) {
main = 'org.apache.tapestry5.test.JettyRunner'
args "-d", "src/test/app6", "-p", "8080"
classpath += project.sourceSets.test.runtimeClasspath
-}
\ No newline at end of file
+}
diff --git a/tapestry-jpa/src/test/conf/testng.xml b/tapestry-jpa/src/test/resources/testng.xml
similarity index 100%
rename from tapestry-jpa/src/test/conf/testng.xml
rename to tapestry-jpa/src/test/resources/testng.xml
diff --git a/tapestry-json/build.gradle b/tapestry-json/build.gradle
index dba943356..a937b3dd0 100644
--- a/tapestry-json/build.gradle
+++ b/tapestry-json/build.gradle
@@ -1,17 +1,15 @@
-description = "Repackaged, improved (and tested) version of code originally from https://github.com/tdunning/open-json"
+plugins {
+ id 'tapestry.junit5-convention'
+}
+
+description = 'Repackaged, improved (and tested) version of code originally from https://github.com/tdunning/open-json'
dependencies {
+
implementation project(':tapestry5-annotations')
implementation project(':commons')
- testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
-}
-test {
- useJUnit()
+ testImplementation project(":tapestry-func")
}
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.json.modules.JSONModule'
- }
-}
\ No newline at end of file
+jar.manifest.attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.json.modules.JSONModule'
diff --git a/tapestry-json/src/test/conf/testng.xml b/tapestry-json/src/test/conf/testng.xml
deleted file mode 100644
index ab3857602..000000000
--- a/tapestry-json/src/test/conf/testng.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Tapestry JSON" annotations="1.5" verbose="2">
- <test name="Unit Tests" enabled="true">
- <packages>
- <package name="org.apache.tapestry5.json"/>
- </packages>
- </test>
-</suite>
diff --git a/tapestry-json/src/test/groovy/json/specs/CoercionsSpec.groovy b/tapestry-json/src/test/groovy/json/specs/CoercionsSpec.groovy
deleted file mode 100644
index d7c1d1494..000000000
--- a/tapestry-json/src/test/groovy/json/specs/CoercionsSpec.groovy
+++ /dev/null
@@ -1,29 +0,0 @@
-package json.specs
-
-import org.apache.tapestry5.internal.json.StringToJSONArray
-import org.apache.tapestry5.internal.json.StringToJSONObject
-import org.apache.tapestry5.json.JSONArray
-import org.apache.tapestry5.json.JSONObject
-import spock.lang.Specification
-
-class CoercionsSpec extends Specification {
-
- def "string to JSONObject"() {
- def json = /{foo:"bar"}/
- def expected = new JSONObject(json)
-
- expect:
-
- new StringToJSONObject().coerce(json) == expected
- }
-
- void "string to JSONArray"() {
-
- def json = /[1, 2, 'three']/
- def expected = new JSONArray(json)
-
- expect:
-
- new StringToJSONArray().coerce(json) == expected
- }
-}
diff --git a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy b/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
deleted file mode 100644
index 52419cc7e..000000000
--- a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy
+++ /dev/null
@@ -1,639 +0,0 @@
-package json.specs
-
-import org.apache.tapestry5.json.JSONArray
-import org.apache.tapestry5.json.JSONLiteral
-import org.apache.tapestry5.json.JSONObject
-import org.apache.tapestry5.json.exceptions.JSONArrayIndexOutOfBoundsException
-import org.apache.tapestry5.json.exceptions.JSONInvalidTypeException
-import org.apache.tapestry5.json.exceptions.JSONSyntaxException
-import org.apache.tapestry5.json.exceptions.JSONTypeMismatchException
-
-import spock.lang.Specification
-
-class JSONArraySpec extends Specification {
-
- def "can create a JSONArray by parsing a JSON string"() {
- when:
-
- def array = new JSONArray(/[ 'foo', 'bar', "baz" ]/)
-
- then:
-
- array.size() == 3
- array.get(0) == "foo"
- array.get(1) == "bar"
- array.get(2) == "baz"
- }
-
- def "create a JSONArray from varags"() {
- when:
-
- def array = new JSONArray("fred", "barney", "wilma")
-
- then:
-
- array.size() == 3
-
- array.toCompactString() == /["fred","barney","wilma"]/
- }
-
- def "array must start with a bracket"() {
- when:
-
- new JSONArray("1, 2, 3]")
-
- then:
-
- JSONSyntaxException e = thrown()
-
- e.message == "A JSONArray text must start with '[' (actual: '1') at character 1 of 1, 2, 3]"
- }
-
- def "parse an empty array"() {
- when:
-
- def array = new JSONArray("[]")
-
- then:
-
- array.isEmpty()
- }
-
- def "isEmpty() is false if array is non-empty"() {
- when:
-
- def array = new JSONArray("[1]")
-
- then:
-
- array.isEmpty() == false
- }
-
- def "isEmpty() == zero length == zero size"() {
- when:
-
- def array = new JSONArray("[]")
-
- then:
-
- array.isEmpty()
- array.length() == 0
- array.size() == 0
- }
-
- def "an empty element in the parse is a null"() {
- when:
-
- def array = new JSONArray("[1,,3]")
-
- then:
-
- array.size() == 3
- array.getInt(0) == 1
- array.isNull(1)
- array.getInt(2) == 3
- }
-
- def "a comma at the end of the list is ignored"() {
- when:
-
- def array = new JSONArray("[1,2,]")
-
- then:
-
- array.size() == 2
- array.get(0) == 1
- array.get(1) == 2
- }
-
- def "getBoolean() when not a boolean at index is an exception"() {
- def array = new JSONArray("[123]")
-
- when:
-
- array.getBoolean(0)
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == "JSONArray[0] is not a BOOLEAN. Actual: java.lang.Integer"
- }
-
- def "handling of boolean values passed into constructor"() {
- when:
-
- def array = new JSONArray(true, false, "True", "False")
-
- then:
-
- array.getBoolean(0) == true
- array.getBoolean(1) == false
-
- array.getBoolean(2) == true
- array.getBoolean(3) == false
- }
-
- def "getDouble() when not a double at index is an exception"() {
- def array = new JSONArray(true)
-
- when:
-
- array.getDouble(0)
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == "JSONArray[0] is not a NUMBER. Actual: java.lang.Boolean"
- }
-
- def "getDouble() works with numbers and parseable strings"() {
- def array = new JSONArray(400l, "95.5")
-
- expect:
-
- array.getDouble(0) == 400d
- array.getDouble(1) == 95.5d
- }
-
- def "getLong() works with numbers and parseable strings"() {
- def array = new JSONArray(400l, "95.5")
-
- expect:
-
- array.getLong(0) == 400l
- array.getLong(1) == 95l
- }
-
- def "getJSONArray() when not an array at index is exception"() {
- def array = new JSONArray("fred", "barney")
-
- when:
-
- array.getJSONArray(1)
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == "JSONArray[1] is not a ARRAY. Actual: java.lang.String"
- }
-
- def "get a nested array"() {
- def nested = new JSONArray()
- def outer = new JSONArray(nested)
-
- expect:
-
- outer.getJSONArray(0).is(nested)
- }
-
- def "getJSONObject() when not a JSONObject at index is an exception"() {
- def array = new JSONArray("fred", "barney", "wilma")
-
- when:
-
- array.getJSONObject(1)
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == "JSONArray[1] is not a OBJECT. Actual: java.lang.String"
- }
-
- def "may not put at a negative index"() {
- def array = new JSONArray()
-
- when:
-
- array.put(-2, "fred")
-
- then:
-
- JSONArrayIndexOutOfBoundsException e = thrown()
-
- e.index == -2
- }
-
- def "put() overrides existing value in array"() {
- def array = new JSONArray("fred", "barney", "wilma")
-
- when:
-
- array.put 2, "betty"
-
- then:
-
- array.get(2) == "betty"
- }
-
- def "put() with index past end pads array with nulls"() {
- def array = new JSONArray("fred", "barney", "wilma")
-
- when:
-
- array.put 4, "bambam"
-
- then:
-
- array.isNull(3)
-
- array.toCompactString() == /["fred","barney","wilma",null,"bambam"]/
- }
-
- def "array equality"() {
- when:
-
- def array1 = new JSONArray(1, 2, 3)
- def array2 = new JSONArray(1, 2, 3)
-
- then:
-
- array1 == array1
- !array1.equals(null)
- array1 != this
- array1 == array2
-
- when:
-
- array2.put 9, "stuff"
-
- then:
-
- array1 != array2
- }
-
- def "array hashCode"() {
- when:
-
- def array1 = new JSONArray(1, 2, 3)
- def array2 = new JSONArray(1, 2, 3)
-
- then:
-
- array1.hashCode() == array2.hashCode()
-
- when:
-
- array2.put 9, "stuff"
-
- then:
-
- array1.hashCode() != array2.hashCode()
- }
-
- def "pretty print"() {
- def array = new JSONArray("fred", "barney")
-
- expect:
-
- array.toString() == '''[
- "fred",
- "barney"
-]'''
- }
-
- def "JSONArray is Iterable"() {
- def array = new JSONArray(1, 2, false)
-
- when:
-
- def i = array.iterator()
-
- then:
-
- i.next() == 1
- i.next() == 2
- i.next() == false
-
- !i.hasNext()
- }
-
- def "remove an element by index"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- array.remove(1)
-
- then:
-
- array.size() == 2
- array.toCompactString() == /["one","three"]/
- }
-
- def "remove an element by value"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.remove("one")
-
- then:
-
- result == true
- array.size() == 2
- array.toCompactString() == /["two","three"]/
- }
-
- def "remove an element by value - not found"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.remove("four")
-
- then:
-
- result == false
- array.size() == 3
- array.toCompactString() == /["one","two","three"]/
- }
-
- def "remove all elements by collection"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.removeAll(["one", "three"])
-
- then:
-
- result == true
- array.size() == 1
- array.toCompactString() == /["two"]/
- }
-
- def "remove all elements by collection - partial"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.removeAll(["one", "four"])
-
- then:
-
- result == true
- array.size() == 2
- array.toCompactString() == /["two","three"]/
- }
-
- def "remove all elements by collection - none found"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.removeAll(["four", "five"])
-
- then:
-
- result == false
- array.size() == 3
- array.toCompactString() == /["one","two","three"]/
- }
-
- def "retain all elements by collection - all"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.retainAll(["one", "two", "three"])
-
- then:
-
- result == false
- array.size() == 3
- array.toCompactString() == /["one","two","three"]/
- }
-
- def "retain all elements by collection - partial"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.retainAll(["one", "three"])
-
- then:
-
- result == true
- array.size() == 2
- array.toCompactString() == /["one","three"]/
- }
-
- def "retain all elements by collection - none"() {
- def array = new JSONArray("one", "two", "three")
-
- when:
-
- def result = array.retainAll(["four", "five"])
-
- then:
-
- result == true
- array.isEmpty()
- array.toCompactString() == /[]/
- }
-
- def "putAll() adds new objects to existing array"() {
- def array = new JSONArray(100, 200)
-
- when:
-
- array.putAll([300, 400, 500])
-
- then:
-
- array.toCompactString() == /[100,200,300,400,500]/
- }
-
- def "putAll() with null does not modify the array"() {
- def array = new JSONArray(100, 200)
-
- when:
-
- array.putAll(null)
-
- then:
-
- array.toCompactString() == /[100,200]/
- }
-
-
- def "addAll() adds new objects to existing array"() {
- def array = new JSONArray(100, 200)
-
- when:
-
- array.addAll([300, 400, 500])
-
- then:
-
- array.toCompactString() == /[100,200,300,400,500]/
- }
-
-
- def "addAll() returns true if changed"() {
- def array = new JSONArray(100, 200)
-
- when:
-
- def result = array.addAll([300, 400, 500])
-
- then:
-
- result == true
- }
-
- def "addAll() returns false if not changed"() {
- def array = new JSONArray(100, 200)
-
- when:
-
- def result = array.addAll((Collection)null)
-
- then:
-
- result == false
- }
-
- def "list returned by toList() is unmodifiable"() {
- def array = new JSONArray(100, 200)
- def list = array.toList()
-
- when:
-
- list.clear()
-
- then:
-
- thrown(UnsupportedOperationException)
- }
-
- def "list from toList() is live"() {
- def array = new JSONArray(100, 200)
- when:
-
- def list = array.toList()
-
- then:
-
- list == [100, 200]
-
- when:
-
- array.remove(0)
-
- then:
-
- list == [200]
- }
-
- def "can initialize JSONObject from an Iterable"() {
- when:
-
- def list = JSONArray.from([1, 2, 3])
-
- then:
-
- list.toString(true) == "[1,2,3]"
- }
-
- def "put() should throw an IllegalArgumentException when receiving null"() {
-
- def array = new JSONArray()
-
- when:
-
- array.put(null)
-
- then:
-
- thrown IllegalArgumentException
- }
-
- def "new JSONArray() should throw an IllegalArgumentException when receiving null"() {
-
- when:
-
- new JSONArray(1, null, 3)
-
- then:
-
- thrown IllegalArgumentException
- }
-
- def "only specific object types may be added - no exception"() {
- def array = new JSONArray()
-
- when:
-
- array.put(value)
-
- then:
-
- noExceptionThrown()
-
- where:
- value << [
- true,
- 3,
- 3.5,
- "*VALUE*",
- new JSONLiteral("*LITERAL*"),
- new JSONObject(),
- new JSONArray()
- ]
- }
-
- def "only specific object types may be added - exception"() {
- def array = new JSONArray()
-
- when:
-
- array.put(value)
-
- then:
-
- JSONInvalidTypeException e = thrown()
-
- where:
- value << [
- new java.util.Date(),
- [],
- [:]
- ]
- }
-
- def "array index out of bounds must throw informative exception"() {
- def array = new JSONArray(1, 2, 3)
-
- when:
-
- array.get(array.size())
-
- then:
-
- JSONArrayIndexOutOfBoundsException e = thrown()
- e.index == 3
- }
-
- def "non-finite / NaN Double not allowed in constructor"() {
-
- when:
-
- new JSONArray(value)
-
- then:
-
- RuntimeException e = thrown()
-
- where:
- value << [
- Double.POSITIVE_INFINITY,
- Double.NEGATIVE_INFINITY,
- Double.NaN
- ]
- }
-}
diff --git a/tapestry-json/src/test/groovy/json/specs/JSONCollectorsSpec.groovy b/tapestry-json/src/test/groovy/json/specs/JSONCollectorsSpec.groovy
deleted file mode 100644
index a8c452312..000000000
--- a/tapestry-json/src/test/groovy/json/specs/JSONCollectorsSpec.groovy
+++ /dev/null
@@ -1,101 +0,0 @@
-package json.specs
-
-import org.apache.tapestry5.json.JSONCollectors
-import org.apache.tapestry5.json.exceptions.JSONInvalidTypeException
-
-import java.util.stream.Stream
-
-import spock.lang.Specification
-
-class JSONCollectorsSpec extends Specification {
-
- def "collect stream to array"() {
-
- given:
-
- def stringValue = "a string value"
- def longValue = 3L
-
- def stream = Stream.of(stringValue, longValue)
-
- when:
-
- def collected = stream.collect(JSONCollectors.toArray());
-
- then:
-
- collected.size() == 2
- collected.get(0) == stringValue
- collected.get(1) == longValue
- }
-
- def "collect stream to array invalid type"() {
-
- given:
-
- def stringValue = "a string value"
- def longValue = 3L
- def invalidValue = new java.util.Date()
-
- def stream = Stream.of(stringValue, longValue, invalidValue)
-
- when:
-
- def collected = stream.collect(JSONCollectors.toArray());
-
- then:
-
- JSONInvalidTypeException e = thrown()
- }
-
- def "collect stream to map"() {
-
- given:
-
- def first = new Tuple("first key", "a string value")
- def second = new Tuple("second key", 3L)
-
- def stream = Stream.of(first, second)
-
- when:
-
- def collected = stream.collect(JSONCollectors.toMap({ t -> t.get(0) }, { t -> t.get(1) }));
-
- then:
-
- collected.size() == 2
- collected.get(first.get(0)) == first.get(1)
- collected.get(second.get(0)) == second.get(1)
- }
-
- def "collect stream to map invalid type"() {
-
- given:
-
- def first = new Tuple("first key", "a string value")
- def second = new Tuple("second key", 3L)
- def third = new Tuple("invalid type", new java.util.Date())
-
- def stream = Stream.of(first, second, third)
-
- when:
-
- def collected = stream.collect(JSONCollectors.toMap({ t -> t.get(0) }, { t -> t.get(1) }));
-
- then:
-
- JSONInvalidTypeException e = thrown()
- }
-
- def "collect stream to map duplicate key"() {
-
- when:
-
- def collected = Stream.of("first", "second", "first").collect(JSONCollectors.toMap({ v -> v }, { v -> v }))
-
- then:
-
- IllegalStateException e = thrown()
- }
-
-}
diff --git a/tapestry-json/src/test/groovy/json/specs/JSONObjectSpec.groovy b/tapestry-json/src/test/groovy/json/specs/JSONObjectSpec.groovy
deleted file mode 100644
index 4d07bc605..000000000
--- a/tapestry-json/src/test/groovy/json/specs/JSONObjectSpec.groovy
+++ /dev/null
@@ -1,989 +0,0 @@
-package json.specs
-
-import org.apache.tapestry5.json.JSONArray
-import org.apache.tapestry5.json.JSONLiteral
-import org.apache.tapestry5.json.JSONObject
-import org.apache.tapestry5.json.JSONString
-import org.apache.tapestry5.json.exceptions.JSONInvalidTypeException
-import org.apache.tapestry5.json.exceptions.JSONSyntaxException
-import org.apache.tapestry5.json.exceptions.JSONTypeMismatchException
-import org.apache.tapestry5.json.exceptions.JSONValueNotFoundException
-
-import spock.lang.Issue
-import spock.lang.Specification
-import spock.lang.Unroll
-
-class JSONObjectSpec extends Specification {
-
- def "copy an existing JSONObject"() {
- def master = new JSONObject("fred", "flintstone", "barney", "rubble")
-
- when:
-
- def emptyCopy = new JSONObject(master)
-
- then:
-
- emptyCopy.keys().empty
-
- when:
-
- def limitedCopy = new JSONObject(master, "fred")
-
- then:
-
- limitedCopy.keys().size() == 1
- limitedCopy.get("fred") == "flintstone"
-
- when:
-
- def fullCopy = new JSONObject(master, "fred", "barney")
-
- then:
-
- fullCopy.toCompactString() == /{"fred":"flintstone","barney":"rubble"}/
- }
-
- def "copy all properties of JSONObject"() {
- def master = new JSONObject("fred", "flintstone", "barney", "rubble")
-
- when:
-
- def fullCopy = master.copy()
-
- then:
-
- master == fullCopy
-
- // And they are independent:
-
- when:
-
- master.put("wilma", "flintstone")
-
- then:
-
- master != fullCopy
- }
-
- def "unknown keys when copying a JSONObject are ignored"() {
- def master = new JSONObject("fred", "flintstone", "barney", "rubble")
-
- when:
-
- def copy = new JSONObject(master, "fred", "wilma")
-
- then:
-
- copy.keys().size() == 1
- copy.get("fred") == "flintstone"
- }
-
- def "get with unknown key is an exception"() {
- def master = new JSONObject("fred", "flintstone")
-
- when:
-
- master.get "barney"
-
- then:
-
- JSONValueNotFoundException e = thrown()
-
- e.message == /JSONObject["barney"] is not found. Required: ANY/
- }
-
- def "getOrDefault returns defaultValue if not found"() {
- def master = new JSONObject("fred", "flintstone")
-
- when:
-
- def result = master.getOrDefault "barney", "gumble"
-
- then:
-
- result == "gumble"
- }
-
- def "getOrDefault returns value if found"() {
- def master = new JSONObject("fred", "flintstone")
-
- when:
-
- def result = master.getOrDefault "fred", "other"
-
- then:
-
- result == "flintstone"
- }
-
- @Unroll
- def "ensure that stored value #typeName #value is #expectedTypeName #expected"() {
-
- when:
-
- def object = new JSONObject().put("key", value)
-
- then:
-
- object."get${expectedTypeName.capitalize()}"("key") == expected
-
- where:
-
- value | expected | expectedType
- "true" | true | boolean
- "TRUE" | true | boolean
- "false" | false | boolean
- "FALSE" | false | boolean
- Boolean.TRUE | true | boolean
- Boolean.FALSE | false | boolean
- 3.5d | 3.5d | double
- 1000l | 1000d | double
- "-101.7" | -101.7d | double
- "3" | 3 | int
- 97l | 97 | int
- "-8.76" | -8 | int
- 92d | 92l | long
- "-200" | -200l | long
- 123 | "123" | String
-
- typeName = value.class.simpleName
- expectedTypeName = expectedType.simpleName
- }
-
- @Unroll
- def "conversion of double #input to string should be '#expected'"() {
- expect:
-
- JSONObject.doubleToString(input) == expected
-
- where:
-
- input | expected
- 3d | "3"
- -22.5d | "-22.5"
- 0d | "0"
- Double.NaN | "null"
- Double.NEGATIVE_INFINITY | "null"
- Double.POSITIVE_INFINITY | "null"
- }
-
- def "exception when getBoolean() on a value that is not a boolean"() {
-
- def object = new JSONObject().put("akey", 37)
-
- when:
-
- object.getBoolean "akey"
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == /JSONObject["akey"] is not a BOOLEAN. Actual: java.lang.Integer/
- }
-
- def "accumulate simple values"() {
- def object = new JSONObject()
-
- def key = "acckey"
-
- when:
-
- object.accumulate key, "alpha"
-
- then: "first value added is just stored"
-
- object.toCompactString() == /{"acckey":"alpha"}/
-
- when: "subsequent values added are accumulated in a JSONArray"
-
- object.accumulate key, "beta"
- object.accumulate key, "gamma"
-
- then:
-
- object.toCompactString() == /{"acckey":["alpha","beta","gamma"]}/
-
- object.getJSONArray(key).length() == 3
- }
-
- def "accumulate when the stored value is already an array just appends the value"() {
- def object = new JSONObject()
-
- when:
-
- object.accumulate "key", new JSONArray("fred", "barney")
-
- then:
-
- object.toCompactString() == /{"key":["fred","barney"]}/
-
- when:
-
- object.accumulate "key", "wilma"
-
- then:
-
- object.toCompactString() == /{"key":["fred","barney","wilma"]}/
- }
-
- def "can create a JSONObject from a JSON string"() {
- when:
-
- def object = new JSONObject(/ { fred: "flintstone", caveman: true, friends: ["barney"] }/)
-
- then:
-
- object.get("fred") == "flintstone"
- object.getBoolean("caveman") == true
-
- def friends = object.getJSONArray "friends"
-
- friends.length() == 1
- friends.get(0) == "barney"
- }
-
- def "append to an unknown key creates a JSONArray for the value"() {
- def object = new JSONObject()
-
- when:
-
- object.append "friends", "barney"
-
- then:
-
- object.toCompactString() == /{"friends":["barney"]}/
- }
-
- def "append to an existing key containing a JSONArray appends to the array"() {
- def object = new JSONObject(/{friends: ["barney"] }/)
-
- when:
-
- object.append "friends", "zaphod"
-
- then:
-
- object.toCompactString() == /{"friends":["barney","zaphod"]}/
- }
-
- def "appending to a key whose value is not aArray is an exception"() {
- def object = new JSONObject(/{friends: 0 }/)
-
- when:
-
- object.append "friends", "zaphod"
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == /JSONObject["friends"] is not a ARRAY. Actual: java.lang.Integer/
- }
-
- def "getDouble() with a non-numeric value is an exception"() {
- def object = new JSONObject(/{notdouble: true}/)
-
- when:
-
- object.getDouble "notdouble"
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == /JSONObject["notdouble"] is not a NUMBER. Actual: java.lang.Boolean/
- }
-
- def "getDouble() with a string that can not be parsed as a number is an exception"() {
- def object = new JSONObject(/{notdouble: "this is a fact"}/)
-
- when:
-
- object.getDouble "notdouble"
-
- then:
-
- JSONTypeMismatchException e = thrown()
-
- e.message == /JSONObject["notdouble"] is not a NUMBER. Actual: java.lang.String/
- }
-
- def "has() will identify which keys have values and which do not"() {
- def object = new JSONObject(/{fred: 'flintstone'}/)
-
- expect:
-
- object.has("fred")
- !object.has("barney")
- }
-
- def "getJSONArray() for a value that is not aArray is an exception"() {
- def object = new JSONObject(/{notarray: 22.7}/)
-
- when:
-
- object.getJSONArray "notarray"
-
- then:
-
- RuntimeException e = thrown()
-
- e.message == /JSONObject["notarray"] is not a ARRAY. Actual: java.lang.Double/
- }
-
- def "length() of a JSONObject is the number of keys"() {
- when:
-
- def object = new JSONObject()
-
- then:
-
- object.length() == 0
-
- when:
-
- object.put "fred", "flintstone"
-
- then:
-
- object.length() == 1
-
- when:
-
- object.accumulate "fred", "murray"
-
- then:
-
- object.length() == 1
-
- when:
-
- object.put "barney", "rubble"
-
- then:
-
- object.length() == 2
- }
-
- def "names() returns the keys as a JSONArray"() {
- def object = new JSONObject(/ {fred: 'flintstone', barney: 'rubble' }/)
-
- when:
-
- def names = object.names()
-
- then:
-
- names instanceof JSONArray
- names.length() == 2
-
- new ArrayList(names.toList()).sort() == ["barney", "fred"]
- }
-
- def "names() with no properties returns null"() {
-
- when:
-
- def object = new JSONObject()
-
- then:
-
- object.names() == null
- }
-
- def "the null literal is the NULL object"() {
- when:
-
- def object = new JSONObject(/{nullkey: null}/)
-
- then:
-
- object.get("nullkey") is JSONObject.NULL
- object.isNull("nullkey")
- }
-
- def "the NULL object is output as null literal"() {
- when:
-
- def object = new JSONObject().put("nullkey", JSONObject.NULL)
-
- then:
-
- object.isNull("nullkey")
- object.toCompactString() == /{"nullkey":null}/
- }
-
- def "the NULL object matches Java's null"() {
- expect:
-
- JSONObject.NULL.equals(null)
- }
-
- @Unroll
- def "#desc invalid input is an exception"() {
- when:
-
- new JSONObject(input)
-
- then:
-
- JSONSyntaxException e = thrown()
-
- e.message.trim().startsWith expected
-
- where:
-
- input | expected | desc
- "{ " | "A JSONObject text must end with '}' at character 3" | "unmatched open brace"
- "fred" | /A JSONObject text must start with '{' (actual: 'f') at character 1 of/ | "missing open brace"
- /{ "akey" }/ | /Expected a ':' after a key at character 10 of/ | "missing value after key"
- /{ "fred" : 1 "barney" }/ | /Expected a ',' or '}' at character 14 of/ | "missing property separator"
- /{ "list" : [1, 2/ | /Expected a ',' or ']' at character 16 of/ | "missing seperator or closing bracket"
- '''/* unclosed''' | /Unclosed comment at character 11 of/ | "unclosed C-style comment"
- /{ "fred \n}/ | /Unterminated string at character 11 of/ | "unterminated string at line end"
- /{ fred: ,}/ | /Missing value at character 8 of / | "missing value after key"
- }
-
- def "can use ':' or '=>' as key seperator, and ';' as property separator"() {
- def object = new JSONObject(/{ "fred" = 1; "barney" => 2}/)
-
- expect:
-
- object.getInt("fred") == 1
- object.getInt("barney") == 2
- }
-
- @Unroll
- def "conversion of #typeName #value to string is #expected"() {
- expect:
-
- JSONObject.numberToString(value) == expected
-
- where:
-
- value | expected
- new BigDecimal("100.0000000") | "100"
-
- typeName = value.class.simpleName
- }
-
- @Unroll
- def "quote(): #desc"() {
- expect:
-
- JSONObject.quote(value) == expected
-
- where:
-
- value | expected | desc
- null | /""/ | "null is empty string"
- "" | /""/ | "empty string is empty string"
- '''"/\b\t\n\f\r\u2001/a</''' | '''"\\"/\\b\\t\\n\\f\\r\\u2001/a<\\/"''' | "special characters"
- }
-
- def "non-finite numbers are not allowed"() {
- def object = new JSONObject()
-
- when:
-
- object.put "nonfinite", value
-
- then:
-
- RuntimeException e = thrown()
-
- e.message == /JSON does not allow non-finite numbers./
-
- where:
-
- value << [
- Double.NaN,
- Double.NEGATIVE_INFINITY,
- Double.POSITIVE_INFINITY,
- Float.NaN,
- Float.NEGATIVE_INFINITY,
- Float.POSITIVE_INFINITY
- ]
- }
-
- def "parse an empty object is empty"() {
- when:
-
- def object = new JSONObject(/{}/)
-
- then:
-
- object.length() == 0
- }
-
- def "put a Java null is a remove"() {
- def object = new JSONObject(/{fred:'flintstone', barney:'rubble'}/)
-
- when:
-
- object.put("fred", null)
-
- then:
-
- object.toCompactString() == /{"barney":"rubble"}/
- }
-
- def "only specific object types may be added - no exception"() {
- def object = new JSONObject(/{}/)
-
- when:
-
- object.put("key", value)
-
- then:
-
- noExceptionThrown()
-
- where:
- value << [
- null,
- true,
- 3,
- 3.5,
- "*VALUE*",
- new JSONLiteral("*LITERAL*"),
- new JSONObject(),
- new JSONArray()
- ]
- }
-
- def "only specific object types may be added - exception"() {
- def object = new JSONObject(/{}/)
-
- when:
-
- object.put("key", value)
-
- then:
-
- JSONInvalidTypeException e = thrown()
-
- where:
- value << [
- new java.util.Date(),
- [],
- [:]
- ]
- }
-
- def "JSONString can output anything it wants"() {
- def string = { "*VALUE*" } as JSONString
-
- def object = new JSONObject()
-
- when:
-
- object.put("key", string)
-
- then:
-
- object.toCompactString() == /{"key":*VALUE*}/
- }
-
- def "equals() implementation"() {
- def json = /{ "key" : 99 }/
-
- when:
-
- def obj1 = new JSONObject(json)
- def obj2 = new JSONObject(json)
-
- then:
-
- obj1 == obj2
- obj2 == obj1
-
- obj1.equals(null) == false
- obj1 != json
-
- when:
-
- obj2.put("screw", "the pooch")
-
- then:
-
- obj1 != obj2
- }
-
- def "hashCode() implementation"() {
- def json = /{ "key" : 99 }/
-
- when:
-
- def obj1 = new JSONObject(json)
- def obj2 = new JSONObject(json)
-
- then:
-
- obj1.hashCode() == obj2.hashCode()
-
- when:
-
- obj2.put("screw", "the pooch")
-
- then:
-
- obj1.hashCode() != obj2.hashCode()
- }
-
- def "escaped characters in the JSON are parsed correctly"() {
- when:
-
- def object = new JSONObject("{ \"key\" : \"\\\"/\\b\\t\\n\\f\\r\\u2001/a<\\/\\x20\" }")
-
- then:
-
- object.get("key") == '''"/\b\t\n\f\r\u2001/a</ '''
- }
-
- def "parse a nested object"() {
- def object = new JSONObject(/ { key: { name: "inner" }}/)
-
- expect:
-
- object.getJSONObject("key").getString("name") == "inner"
- }
-
- def "parse boolean literals"() {
- def object = new JSONObject(/{ t: true, f: false }/)
-
- expect:
-
- object.getBoolean("t") == true
- object.getBoolean("f") == false
- }
-
... 2933 lines suppressed ...