diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0699641..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: java -sudo: required -jdk: - - oraclejdk8 -cache: - directories: - - $HOME/.m2 -after_success: - - ./gradlew sonarqube -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN -env: - global: - secure: n1Ai4q/yMLn/Pg5pA4lTavoJoe7mQYB1PSKnZAqwbgyla94ySzK6iyBCBiNs/foMPisB/x+DHvmUXTsjvquw9Ay48ZITCV3xhcWzD0eZM2TMoG19CpRAEe8L8LNuYiti9k89ijDdUGZ5ifsvQNTGNHksouayAuApC3PrTUejJfR6SYrp1ZsQTbsMlr+4XU3p7QknK5rGgOwATIMP28F+bVnB05WJtlJA3b0SeucCurn3wJ4FGBQXRYmdlT7bQhNE4QgZM1VzcUFD/K0TBxzzq/otb/lNRSifyoekktDmJwQnaT9uQ4R8R6KdQ2Kb38Rvgjur+TKm5i1G8qS2+6LnIxQJG1aw3JvKK6W0wWCgnAVVRrXaCLday9NuY59tuh1mfjQ10UcsMNKcTdcKEMrLow506wSETcXc7L/LEnneWQyJJeV4vhPqR7KJfsBbeqgz3yIfsCn1GZVWFlfegzYCN52YTl0Y0uRD2Z+TnzQu+Bf4DzaWXLge1rz31xkhyeNNspub4h024+XqBjcMm6M9mlMzmmK8t2DIwPy/BlQbFBUyhrxziuR/5/2NEDPyHltvWkRb4AUIa25WJqkV0gTBegbMadZ9DyOo6Ea7aoVFBae2WGR08F1kzABsWrd1S7UJmWxW35iyMEtoAIayXphIK98qO5aCutwZ+3iOQazxbAs= diff --git a/build.gradle b/build.gradle index 3a96d10..3e653df 100644 --- a/build.gradle +++ b/build.gradle @@ -1,134 +1,37 @@ plugins { - id "com.github.spotbugs" version "2.0.0" - id "io.codearte.nexus-staging" version "0.11.0" + id "de.marcphilipp.nexus-publish" version "0.4.0" + id "io.codearte.nexus-staging" version "0.21.1" } -apply plugin: 'java' -apply plugin: 'pmd' -apply plugin: 'checkstyle' -apply plugin: "com.github.spotbugs" - -dependencies { - testCompile "junit:junit:${project.property('junit.version')}" - testCompile "org.quartz-scheduler:quartz:${project.property('quartz.version')}" - testCompile "com.google.caliper:caliper:${project.property('caliper.version')}" -} - -compileJava { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - -compileTestJava { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - -tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all" -} - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} - -spotbugs { - toolVersion = '3.1.12' - sourceSets = [sourceSets.main] - ignoreFailures = true - effort = "max" - reportLevel = "high" -} - -tasks.withType(Pmd) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } -} - -tasks.withType(Checkstyle) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } -} - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier 'javadoc' -} - -artifacts { - archives sourcesJar, javadocJar +wrapper { + gradleVersion = "${project.property('gradle.wrapper.version')}" + distributionType = Wrapper.DistributionType.ALL } ext { user = 'xbib' - projectName = 'time' - projectDescription = 'A bundle of Chronic, Prettytime, and org.joda.time.format optimized for Java 8 Time API' - scmUrl = 'https://github.com/xbib/time' - scmConnection = 'scm:git:git://github.com/xbib/time.git' - scmDeveloperConnection = 'scm:git:git://github.com/xbib/time.git' + name = 'time' + description = 'A bundle of Chronic, Prettytime, and org.joda.time.format optimized for Java 8 Time API' + inceptionYear = '2016' + url = 'https://github.com/' + user + '/' + name + scmUrl = 'https://github.com/' + user + '/' + name + scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git' + scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git' + issueManagementSystem = 'Github' + issueManagementUrl = ext.scmUrl + '/issues' + licenseName = 'The Apache License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } -task sonatypeUpload(type: Upload) { - configuration = configurations.archives - uploadDescriptor = true - repositories { - if (project.hasProperty('ossrhUsername')) { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: uri(ossrhReleaseUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - snapshotRepository(url: uri(ossrhSnapshotUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - pom.project { - name projectName - description projectDescription - packaging 'jar' - inceptionYear '2016' - url scmUrl - organization { - name 'xbib' - url 'http://xbib.org' - } - developers { - developer { - id user - name 'Jörg Prante' - email 'joergprante@gmail.com' - url 'https://github.com/jprante' - } - } - scm { - url scmUrl - connection scmConnection - developerConnection scmDeveloperConnection - } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - } - } - } - } +apply plugin: 'java-library' + +dependencies { + testImplementation "org.quartz-scheduler:quartz:${project.property('quartz.version')}" + testImplementation "com.google.caliper:caliper:${project.property('caliper.version')}" } -nexusStaging { - packageGroup = "org.xbib" -} +apply from: rootProject.file('gradle/ide/idea.gradle') +apply from: rootProject.file('gradle/compile/java.gradle') +apply from: rootProject.file('gradle/test/junit5.gradle') +apply from: rootProject.file('gradle/publishing/publication.gradle') +apply from: rootProject.file('gradle/publishing/sonatype.gradle') diff --git a/gradle.properties b/gradle.properties index ae672f0..c0f8e05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,7 @@ group = org.xbib name = time -version = 2.0.0 +version = 2.1.0 -# test -junit.version = 4.12 +gradle.wrapper.version = 6.4.1 quartz.version = 2.3.0 caliper.version = 1.0-beta-2 diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle new file mode 100644 index 0000000..a9d76ce --- /dev/null +++ b/gradle/compile/java.gradle @@ -0,0 +1,35 @@ + +apply plugin: 'java-library' + +java { + modularity.inferModulePath.set(true) +} + +compileJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +compileTestJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +jar { + manifest { + attributes('Implementation-Version': project.version) + } +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier 'javadoc' +} + +artifacts { + archives sourcesJar, javadocJar +} \ No newline at end of file diff --git a/gradle/documentation/asciidoc.gradle b/gradle/documentation/asciidoc.gradle new file mode 100644 index 0000000..87ba22e --- /dev/null +++ b/gradle/documentation/asciidoc.gradle @@ -0,0 +1,55 @@ +apply plugin: 'org.xbib.gradle.plugin.asciidoctor' + +configurations { + asciidoclet +} + +dependencies { + asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}" +} + + +asciidoctor { + backends 'html5' + outputDir = file("${rootProject.projectDir}/docs") + separateOutputDirs = false + attributes 'source-highlighter': 'coderay', + idprefix: '', + idseparator: '-', + toc: 'left', + doctype: 'book', + icons: 'font', + encoding: 'utf-8', + sectlink: true, + sectanchors: true, + linkattrs: true, + imagesdir: 'img', + stylesheet: "${projectDir}/src/docs/asciidoc/css/foundation.css" +} + + +/*javadoc { +options.docletpath = configurations.asciidoclet.files.asType(List) +options.doclet = 'org.asciidoctor.Asciidoclet' +//options.overview = "src/docs/asciidoclet/overview.adoc" +options.addStringOption "-base-dir", "${projectDir}" +options.addStringOption "-attribute", + "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" +configure(options) { + noTimestamp = true +} +}*/ + + +/*javadoc { + options.docletpath = configurations.asciidoclet.files.asType(List) + options.doclet = 'org.asciidoctor.Asciidoclet' + options.overview = "${rootProject.projectDir}/src/docs/asciidoclet/overview.adoc" + options.addStringOption "-base-dir", "${projectDir}" + options.addStringOption "-attribute", + "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" + options.destinationDirectory(file("${projectDir}/docs/javadoc")) + configure(options) { + noTimestamp = true + } +}*/ diff --git a/gradle/ide/idea.gradle b/gradle/ide/idea.gradle new file mode 100644 index 0000000..64e2167 --- /dev/null +++ b/gradle/ide/idea.gradle @@ -0,0 +1,13 @@ +apply plugin: 'idea' + +idea { + module { + outputDir file('build/classes/java/main') + testOutputDir file('build/classes/java/test') + } +} + +if (project.convention.findPlugin(JavaPluginConvention)) { + //sourceSets.main.output.classesDirs = file("build/classes/java/main") + //sourceSets.test.output.classesDirs = file("build/classes/java/test") +} diff --git a/gradle/publishing/publication.gradle b/gradle/publishing/publication.gradle new file mode 100644 index 0000000..c35fcb9 --- /dev/null +++ b/gradle/publishing/publication.gradle @@ -0,0 +1,64 @@ + +apply plugin: "de.marcphilipp.nexus-publish" + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + pom { + name = project.name + description = rootProject.ext.description + url = rootProject.ext.url + inceptionYear = rootProject.ext.inceptionYear + packaging = 'jar' + organization { + name = 'xbib' + url = 'https://xbib.org' + } + developers { + developer { + id = 'jprante' + name = 'Jörg Prante' + email = 'joergprante@gmail.com' + url = 'https://github.com/jprante' + } + } + scm { + url = rootProject.ext.scmUrl + connection = rootProject.ext.scmConnection + developerConnection = rootProject.ext.scmDeveloperConnection + } + issueManagement { + system = rootProject.ext.issueManagementSystem + url = rootProject.ext.issueManagementUrl + } + licenses { + license { + name = rootProject.ext.licenseName + url = rootProject.ext.licenseUrl + distribution = 'repo' + } + } + } + } + } +} + +if (project.hasProperty("signing.keyId")) { + apply plugin: 'signing' + signing { + sign publishing.publications.mavenJava + } +} + +nexusPublishing { + repositories { + sonatype { + username = project.property('ossrhUsername') + password = project.property('ossrhPassword') + packageGroup = "org.xbib" + } + } +} diff --git a/gradle/publishing/sonatype.gradle b/gradle/publishing/sonatype.gradle new file mode 100644 index 0000000..e1813f3 --- /dev/null +++ b/gradle/publishing/sonatype.gradle @@ -0,0 +1,11 @@ + +if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + + apply plugin: 'io.codearte.nexus-staging' + + nexusStaging { + username = project.property('ossrhUsername') + password = project.property('ossrhPassword') + packageGroup = "org.xbib" + } +} diff --git a/gradle/test/junit5.gradle b/gradle/test/junit5.gradle new file mode 100644 index 0000000..cfef972 --- /dev/null +++ b/gradle/test/junit5.gradle @@ -0,0 +1,27 @@ + +def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.6.2' +def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2' + +dependencies { + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}" + testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" +} + +test { + useJUnitPlatform() + failFast = true + testLogging { + events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED' + } + afterSuite { desc, result -> + if (!desc.parent) { + println "\nTest result: ${result.resultType}" + println "Test summary: ${result.testCount} tests, " + + "${result.successfulTestCount} succeeded, " + + "${result.failedTestCount} failed, " + + "${result.skippedTestCount} skipped" + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..62d4c05 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 22f0587..21e622d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 09 15:32:28 CEST 2019 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 83f2acf..fbd7c51 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 24467a1..a9f778a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..aff965b --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,13 @@ +module org.xbib.time { + exports org.xbib.time.chronic; + exports org.xbib.time.chronic.handlers; + exports org.xbib.time.chronic.numerizer; + exports org.xbib.time.chronic.repeaters; + exports org.xbib.time.chronic.tags; + exports org.xbib.time.format; + exports org.xbib.time.pretty; + exports org.xbib.time.pretty.i18n; + exports org.xbib.time.pretty.units; + exports org.xbib.time.schedule; + exports org.xbib.time.util; +} diff --git a/src/main/java/org/xbib/time/chronic/Chronic.java b/src/main/java/org/xbib/time/chronic/Chronic.java index 9ec7f74..4164a97 100644 --- a/src/main/java/org/xbib/time/chronic/Chronic.java +++ b/src/main/java/org/xbib/time/chronic/Chronic.java @@ -13,16 +13,12 @@ import org.xbib.time.chronic.tags.TimeZone; import java.text.ParseException; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class Chronic { - private static final Logger logger = Logger.getLogger(Chronic.class.getName()); - private Chronic() { } @@ -84,7 +80,6 @@ public class Chronic { tokens = (List) optionScannerClass.getMethod("scan", List.class, Options.class) .invoke(null, tokens, options); } catch (Exception e) { - logger.log(Level.FINE, e.getMessage(), e); throw new ParseException("failed to scan tokens", 0); } } @@ -100,7 +95,6 @@ public class Chronic { tokens = (List) scannerClass.getMethod("scan", List.class, Options.class) .invoke(null, tokens, options); } catch (Exception e) { - logger.log(Level.FINE, e.getMessage(), e); throw new ParseException("failed to scan tokens", 0); } } diff --git a/src/main/java/org/xbib/time/chronic/handlers/RdnRmnSdTTzSyHandler.java b/src/main/java/org/xbib/time/chronic/handlers/RdnRmnSdTTzSyHandler.java index e3e5f13..239bd1b 100644 --- a/src/main/java/org/xbib/time/chronic/handlers/RdnRmnSdTTzSyHandler.java +++ b/src/main/java/org/xbib/time/chronic/handlers/RdnRmnSdTTzSyHandler.java @@ -9,16 +9,12 @@ import org.xbib.time.chronic.tags.ScalarYear; import java.time.ZonedDateTime; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class RdnRmnSdTTzSyHandler implements IHandler { - private static final Logger logger = Logger.getLogger(RdnRmnSdTTzSyHandler.class.getName()); - @Override public Span handle(List tokens, Options options) { int month = tokens.get(1).getTag(RepeaterMonthName.class).getType().ordinal(); @@ -30,7 +26,6 @@ public class RdnRmnSdTTzSyHandler implements IHandler { ZonedDateTime dayStart = ZonedDateTime.of(year, month, day, 0, 0, 0, 0, options.getZoneId()); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { - logger.log(Level.FINE, e.getMessage(), e); span = null; } return span; diff --git a/src/main/java/org/xbib/time/chronic/handlers/RmnSdSyHandler.java b/src/main/java/org/xbib/time/chronic/handlers/RmnSdSyHandler.java index 3a784d7..9b23d01 100644 --- a/src/main/java/org/xbib/time/chronic/handlers/RmnSdSyHandler.java +++ b/src/main/java/org/xbib/time/chronic/handlers/RmnSdSyHandler.java @@ -9,16 +9,12 @@ import org.xbib.time.chronic.tags.ScalarYear; import java.time.ZonedDateTime; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class RmnSdSyHandler implements IHandler { - private static final Logger logger = Logger.getLogger(RmnSdSyHandler.class.getName()); - @Override public Span handle(List tokens, Options options) { int month = tokens.get(0).getTag(RepeaterMonthName.class).getType().ordinal(); @@ -30,7 +26,6 @@ public class RmnSdSyHandler implements IHandler { ZonedDateTime dayStart = ZonedDateTime.of(year, month, day, 0, 0, 0, 0, options.getZoneId()); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { - logger.log(Level.FINE, e.getMessage(), e); span = null; } return span; diff --git a/src/main/java/org/xbib/time/chronic/handlers/RmnSyHandler.java b/src/main/java/org/xbib/time/chronic/handlers/RmnSyHandler.java index 9e9e94c..f9a164f 100644 --- a/src/main/java/org/xbib/time/chronic/handlers/RmnSyHandler.java +++ b/src/main/java/org/xbib/time/chronic/handlers/RmnSyHandler.java @@ -9,16 +9,12 @@ import org.xbib.time.chronic.tags.ScalarYear; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class RmnSyHandler implements IHandler { - private static final Logger logger = Logger.getLogger(RmnSyHandler.class.getName()); - @Override public Span handle(List tokens, Options options) { int month = tokens.get(0).getTag(RepeaterMonthName.class).getType().ordinal(); @@ -29,7 +25,6 @@ public class RmnSyHandler implements IHandler { ZonedDateTime end = start.plus(1, ChronoUnit.MONTHS); span = new Span(start, end); } catch (IllegalArgumentException e) { - logger.log(Level.FINE, e.getMessage(), e); span = null; } return span; diff --git a/src/main/java/org/xbib/time/chronic/handlers/SmSdSyHandler.java b/src/main/java/org/xbib/time/chronic/handlers/SmSdSyHandler.java index e979b9e..7ea64d2 100644 --- a/src/main/java/org/xbib/time/chronic/handlers/SmSdSyHandler.java +++ b/src/main/java/org/xbib/time/chronic/handlers/SmSdSyHandler.java @@ -9,16 +9,12 @@ import org.xbib.time.chronic.tags.ScalarYear; import java.time.ZonedDateTime; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class SmSdSyHandler implements IHandler { - private static final Logger logger = Logger.getLogger(SmSdSyHandler.class.getName()); - @Override public Span handle(List tokens, Options options) { int month = tokens.get(0).getTag(ScalarMonth.class).getType(); @@ -30,7 +26,6 @@ public class SmSdSyHandler implements IHandler { ZonedDateTime dayStart = ZonedDateTime.of(year, month, day, 0, 0, 0, 0, options.getZoneId()); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { - logger.log(Level.FINE, e.getMessage(), e); span = null; } return span; diff --git a/src/main/java/org/xbib/time/chronic/handlers/SmSyHandler.java b/src/main/java/org/xbib/time/chronic/handlers/SmSyHandler.java index 29a0574..7144d82 100644 --- a/src/main/java/org/xbib/time/chronic/handlers/SmSyHandler.java +++ b/src/main/java/org/xbib/time/chronic/handlers/SmSyHandler.java @@ -9,16 +9,12 @@ import org.xbib.time.chronic.tags.ScalarYear; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * */ public class SmSyHandler implements IHandler { - private static final Logger logger = Logger.getLogger(SmSyHandler.class.getName()); - @Override public Span handle(List tokens, Options options) { int month = tokens.get(0).getTag(ScalarMonth.class).getType(); @@ -29,7 +25,6 @@ public class SmSyHandler implements IHandler { ZonedDateTime end = start.plus(1, ChronoUnit.MONTHS); span = new Span(start, end); } catch (IllegalArgumentException e) { - logger.log(Level.FINE, e.getMessage(), e); span = null; } return span; diff --git a/src/main/java/org/xbib/time/format/Composite.java b/src/main/java/org/xbib/time/format/Composite.java index 89d2025..e15df8b 100644 --- a/src/main/java/org/xbib/time/format/Composite.java +++ b/src/main/java/org/xbib/time/format/Composite.java @@ -35,6 +35,7 @@ class Composite implements PeriodPrinter, PeriodParser { } } + @Override public int countFieldsToPrint(Period period, int stopAt, Locale locale) { int sum = 0; PeriodPrinter[] printers = iPrinters; @@ -44,6 +45,7 @@ class Composite implements PeriodPrinter, PeriodParser { return sum; } + @Override public int calculatePrintedLength(Period period, Locale locale) { int sum = 0; PeriodPrinter[] printers = iPrinters; @@ -53,18 +55,21 @@ class Composite implements PeriodPrinter, PeriodParser { return sum; } - public void printTo(StringBuilder buf, Period period, Locale locale) { + @Override + public void printTo(StringBuilder buf, Period period, Locale locale) throws IOException { for (PeriodPrinter printer : iPrinters) { printer.printTo(buf, period, locale); } } + @Override public void printTo(Writer out, Period period, Locale locale) throws IOException { for (PeriodPrinter printer : iPrinters) { printer.printTo(out, period, locale); } } + @Override public int parseInto(PeriodAmount period, String periodStr, int pos, Locale locale) { int position = pos; PeriodParser[] parsers = iParsers; diff --git a/src/main/java/org/xbib/time/format/FieldFormatter.java b/src/main/java/org/xbib/time/format/FieldFormatter.java index da88774..d0a3405 100644 --- a/src/main/java/org/xbib/time/format/FieldFormatter.java +++ b/src/main/java/org/xbib/time/format/FieldFormatter.java @@ -74,6 +74,7 @@ class FieldFormatter implements PeriodPrinter, PeriodParser { } } + @Override public int countFieldsToPrint(Period period, int stopAt, Locale locale) { if (stopAt <= 0) { return 0; @@ -84,6 +85,7 @@ class FieldFormatter implements PeriodPrinter, PeriodParser { return 0; } + @Override public int calculatePrintedLength(Period period, Locale locale) { long valueLong = getFieldValue(period); if (valueLong == Long.MAX_VALUE) { @@ -103,7 +105,8 @@ class FieldFormatter implements PeriodPrinter, PeriodParser { return sum; } - public void printTo(StringBuilder buf, Period period, Locale locale) { + @Override + public void printTo(StringBuilder buf, Period period, Locale locale) throws IOException { long valueLong = getFieldValue(period); if (valueLong == Long.MAX_VALUE) { return; @@ -123,6 +126,7 @@ class FieldFormatter implements PeriodPrinter, PeriodParser { } } + @Override public void printTo(Writer out, Period period, Locale locale) throws IOException { long valueLong = getFieldValue(period); if (valueLong == Long.MAX_VALUE) { diff --git a/src/main/java/org/xbib/time/format/FormatUtils.java b/src/main/java/org/xbib/time/format/FormatUtils.java index 43f0bbc..fe05c46 100644 --- a/src/main/java/org/xbib/time/format/FormatUtils.java +++ b/src/main/java/org/xbib/time/format/FormatUtils.java @@ -2,8 +2,6 @@ package org.xbib.time.format; import java.io.IOException; import java.io.Writer; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Utility methods used by formatters. @@ -11,8 +9,6 @@ import java.util.logging.Logger; */ public class FormatUtils { - private static final Logger logger = Logger.getLogger(FormatUtils.class.getName()); - private static final double LOG_10 = Math.log(10); /** @@ -24,25 +20,20 @@ public class FormatUtils { /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and appends it to the given buffer. - *

* This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string * @param size minimum amount of digits to append + * @throws IOException if appending fails */ - public static void appendPaddedInteger(StringBuilder buf, int value, int size) { - try { - appendPaddedInteger((Appendable) buf, value, size); - } catch (IOException e) { - logger.log(Level.FINE, e.getMessage(), e); - } + public static void appendPaddedInteger(StringBuilder buf, int value, int size) throws IOException { + appendPaddedInteger((Appendable) buf, value, size); } /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and appends it to the given appendable. - *

* This method is optimized for converting small values to strings. * * @param appenadble receives integer converted to a string @@ -101,25 +92,20 @@ public class FormatUtils { /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and appends it to the given buffer. - *

* This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string * @param size minimum amount of digits to append + * @throws IOException if appending fails */ - public static void appendPaddedInteger(StringBuilder buf, long value, int size) { - try { - appendPaddedInteger((Appendable) buf, value, size); - } catch (IOException e) { - logger.log(Level.FINE, e.getMessage(), e); - } + public static void appendPaddedInteger(StringBuilder buf, long value, int size) throws IOException { + appendPaddedInteger((Appendable) buf, value, size); } /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and appends it to the given buffer. - *

* This method is optimized for converting small values to strings. * * @param appendable receives integer converted to a string @@ -159,7 +145,6 @@ public class FormatUtils { /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and writes it to the given writer. - *

* This method is optimized for converting small values to strings. * * @param out receives integer converted to a string @@ -219,7 +204,6 @@ public class FormatUtils { /** * Converts an integer to a string, prepended with a variable amount of '0' * pad characters, and writes it to the given writer. - *

* This method is optimized for converting small values to strings. * * @param out receives integer converted to a string @@ -258,22 +242,18 @@ public class FormatUtils { /** * Converts an integer to a string, and appends it to the given buffer. - *

This method is optimized for converting small values to strings. + * This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string + * @throws IOException if appending fails */ - public static void appendUnpaddedInteger(StringBuilder buf, int value) { - try { - appendUnpaddedInteger((Appendable) buf, value); - } catch (IOException e) { - logger.log(Level.FINE, e.getMessage(), e); - } + public static void appendUnpaddedInteger(StringBuilder buf, int value) throws IOException { + appendUnpaddedInteger((Appendable) buf, value); } /** * Converts an integer to a string, and appends it to the given appendable. - *

* This method is optimized for converting small values to strings. * * @param appendable receives integer converted to a string @@ -308,22 +288,18 @@ public class FormatUtils { /** * Converts an integer to a string, and appends it to the given buffer. - *

This method is optimized for converting small values to strings. + * This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string + * @throws IOException if appending fails */ - public static void appendUnpaddedInteger(StringBuilder buf, long value) { - try { - appendUnpaddedInteger((Appendable) buf, value); - } catch (IOException e) { - logger.log(Level.FINE, e.getMessage(), e); - } + public static void appendUnpaddedInteger(StringBuilder buf, long value) throws IOException { + appendUnpaddedInteger((Appendable) buf, value); } /** * Converts an integer to a string, and appends it to the given appendable. - *

* This method is optimized for converting small values to strings. * * @param appendable receives integer converted to a string @@ -341,7 +317,6 @@ public class FormatUtils { /** * Converts an integer to a string, and writes it to the given writer. - *

* This method is optimized for converting small values to strings. * * @param out receives integer converted to a string @@ -377,7 +352,6 @@ public class FormatUtils { /** * Converts an integer to a string, and writes it to the given writer. - *

* This method is optimized for converting small values to strings. * * @param out receives integer converted to a string diff --git a/src/main/java/org/xbib/time/format/PeriodFormat.java b/src/main/java/org/xbib/time/format/PeriodFormat.java index b5fcc74..4f9daaa 100644 --- a/src/main/java/org/xbib/time/format/PeriodFormat.java +++ b/src/main/java/org/xbib/time/format/PeriodFormat.java @@ -341,7 +341,7 @@ public class PeriodFormat { } @Override - public void printTo(StringBuilder buf, Period period, Locale locale) { + public void printTo(StringBuilder buf, Period period, Locale locale) throws IOException { getPrinter(locale).printTo(buf, period, locale); } diff --git a/src/main/java/org/xbib/time/format/PeriodFormatter.java b/src/main/java/org/xbib/time/format/PeriodFormatter.java index 2df1e20..c1ac73e 100644 --- a/src/main/java/org/xbib/time/format/PeriodFormatter.java +++ b/src/main/java/org/xbib/time/format/PeriodFormatter.java @@ -153,8 +153,9 @@ public class PeriodFormatter { * * @param buf the formatted period is appended to this buffer * @param period the period to format, not null + * @throws IOException if print fails */ - public void printTo(StringBuilder buf, Period period) { + public void printTo(StringBuilder buf, Period period) throws IOException { checkPrinter(); checkPeriod(period); getPrinter().printTo(buf, period, iLocale); @@ -178,8 +179,9 @@ public class PeriodFormatter { * * @param period the period to format, not null * @return the printed result + * @throws IOException if print fails */ - public String print(Period period) { + public String print(Period period) throws IOException { checkPrinter(); checkPeriod(period); PeriodPrinter printer = getPrinter(); diff --git a/src/main/java/org/xbib/time/format/PeriodPrinter.java b/src/main/java/org/xbib/time/format/PeriodPrinter.java index ce689bf..b19b50c 100644 --- a/src/main/java/org/xbib/time/format/PeriodPrinter.java +++ b/src/main/java/org/xbib/time/format/PeriodPrinter.java @@ -39,8 +39,9 @@ public interface PeriodPrinter { * @param buf the formatted period is appended to this buffer * @param period the period to format * @param locale the locale to use + * @throws IOException if print fails */ - void printTo(StringBuilder buf, Period period, Locale locale); + void printTo(StringBuilder buf, Period period, Locale locale) throws IOException; /** * Prints a ReadablePeriod to a Writer. diff --git a/src/main/java/org/xbib/time/format/Separator.java b/src/main/java/org/xbib/time/format/Separator.java index 3b4bf15..fd7ff3f 100644 --- a/src/main/java/org/xbib/time/format/Separator.java +++ b/src/main/java/org/xbib/time/format/Separator.java @@ -89,10 +89,9 @@ class Separator implements PeriodPrinter, PeriodParser { return sum; } - public void printTo(StringBuilder buf, Period period, Locale locale) { + public void printTo(StringBuilder buf, Period period, Locale locale) throws IOException { PeriodPrinter before = iBeforePrinter; PeriodPrinter after = iAfterPrinter; - before.printTo(buf, period, locale); if (iUseBefore) { if (before.countFieldsToPrint(period, 1, locale) > 0) { diff --git a/src/main/java/org/xbib/time/schedule/DefaultCronExpression.java b/src/main/java/org/xbib/time/schedule/DefaultCronExpression.java index 11bc125..4f11b8a 100644 --- a/src/main/java/org/xbib/time/schedule/DefaultCronExpression.java +++ b/src/main/java/org/xbib/time/schedule/DefaultCronExpression.java @@ -6,7 +6,6 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.Objects; import java.util.SortedSet; -import java.util.logging.Logger; public class DefaultCronExpression extends CronExpression { diff --git a/src/test/java/org/xbib/time/DateTimeFormatterTest.java b/src/test/java/org/xbib/time/DateTimeFormatterTest.java index fd67d18..f4b4057 100644 --- a/src/test/java/org/xbib/time/DateTimeFormatterTest.java +++ b/src/test/java/org/xbib/time/DateTimeFormatterTest.java @@ -1,15 +1,13 @@ package org.xbib.time; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class DateTimeFormatterTest { @Test diff --git a/src/test/java/org/xbib/time/chronic/ChronicTest.java b/src/test/java/org/xbib/time/chronic/ChronicTest.java index 1ea6cf5..ddf6c31 100644 --- a/src/test/java/org/xbib/time/chronic/ChronicTest.java +++ b/src/test/java/org/xbib/time/chronic/ChronicTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.handlers.Handler; import org.xbib.time.chronic.repeaters.EnumRepeaterDayPortion; import org.xbib.time.chronic.repeaters.RepeaterDayName; @@ -14,7 +14,7 @@ import java.time.ZonedDateTime; import java.util.LinkedList; import java.util.List; -public class ChronicTest extends Assert { +public class ChronicTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); diff --git a/src/test/java/org/xbib/time/chronic/HandlerTest.java b/src/test/java/org/xbib/time/chronic/HandlerTest.java index 3da2759..3a3862b 100644 --- a/src/test/java/org/xbib/time/chronic/HandlerTest.java +++ b/src/test/java/org/xbib/time/chronic/HandlerTest.java @@ -1,12 +1,19 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.handlers.DummyHandler; import org.xbib.time.chronic.handlers.Handler; import org.xbib.time.chronic.handlers.HandlerTypePattern; import org.xbib.time.chronic.handlers.TagPattern; -import org.xbib.time.chronic.repeaters.*; +import org.xbib.time.chronic.repeaters.EnumRepeaterDayPortion; +import org.xbib.time.chronic.repeaters.Repeater; +import org.xbib.time.chronic.repeaters.RepeaterDayName; +import org.xbib.time.chronic.repeaters.RepeaterDayPortion; +import org.xbib.time.chronic.repeaters.RepeaterMonthName; +import org.xbib.time.chronic.repeaters.RepeaterTime; +import org.xbib.time.chronic.repeaters.RepeaterYear; import org.xbib.time.chronic.tags.Pointer; import org.xbib.time.chronic.tags.Scalar; import org.xbib.time.chronic.tags.ScalarDay; @@ -14,7 +21,7 @@ import org.xbib.time.chronic.tags.ScalarDay; import java.util.LinkedList; import java.util.List; -public class HandlerTest extends Assert { +public class HandlerTest { @Test public void testHandlerClass1() { @@ -22,12 +29,9 @@ public class HandlerTest extends Assert { List tokens = new LinkedList<>(); tokens.add(new Token("friday")); tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY)); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("afternoon")); tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON)); - assertFalse(handler.match(tokens, Handler.definitions())); } @@ -37,17 +41,12 @@ public class HandlerTest extends Assert { List tokens = new LinkedList<>(); tokens.add(new Token("friday")); tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY)); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("afternoon")); tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON)); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("afternoon")); tokens.get(2).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON)); - assertFalse(handler.match(tokens, Handler.definitions())); } @@ -57,12 +56,9 @@ public class HandlerTest extends Assert { List tokens = new LinkedList<>(); tokens.add(new Token("friday")); tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY)); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("afternoon")); tokens.get(1).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.AFTERNOON)); - assertFalse(handler.match(tokens, Handler.definitions())); } @@ -72,12 +68,9 @@ public class HandlerTest extends Assert { List tokens = new LinkedList<>(); tokens.add(new Token("may")); tokens.get(0).tag(new RepeaterMonthName(RepeaterMonthName.MonthName.MAY)); - assertFalse(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("27")); tokens.get(1).tag(new ScalarDay(27)); - assertTrue(handler.match(tokens, Handler.definitions())); } @@ -87,17 +80,12 @@ public class HandlerTest extends Assert { List tokens = new LinkedList<>(); tokens.add(new Token("friday")); tokens.get(0).tag(new RepeaterDayName(RepeaterDayName.DayName.FRIDAY)); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("5:00")); tokens.get(1).tag(new RepeaterTime("5:00")); - assertTrue(handler.match(tokens, Handler.definitions())); - tokens.add(new Token("pm")); tokens.get(2).tag(new EnumRepeaterDayPortion(RepeaterDayPortion.DayPortion.PM)); - assertTrue(handler.match(tokens, Handler.definitions())); } @@ -108,11 +96,9 @@ public class HandlerTest extends Assert { tokens.add(new Token("3")); tokens.add(new Token("years")); tokens.add(new Token("past")); - tokens.get(0).tag(new Scalar(3)); tokens.get(1).tag(new RepeaterYear()); tokens.get(2).tag(new Pointer(Pointer.PointerType.PAST)); - assertTrue(handler.match(tokens, Handler.definitions())); } } diff --git a/src/test/java/org/xbib/time/chronic/NumerizerTest.java b/src/test/java/org/xbib/time/chronic/NumerizerTest.java index 5c0d595..681d6e4 100644 --- a/src/test/java/org/xbib/time/chronic/NumerizerTest.java +++ b/src/test/java/org/xbib/time/chronic/NumerizerTest.java @@ -1,13 +1,13 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.numerizer.Numerizer; import java.util.LinkedHashMap; import java.util.Map; -public class NumerizerTest extends Assert { +public class NumerizerTest { @Test public void testStraightParsing() { diff --git a/src/test/java/org/xbib/time/chronic/ParserTest.java b/src/test/java/org/xbib/time/chronic/ParserTest.java index 102de01..f57b58c 100644 --- a/src/test/java/org/xbib/time/chronic/ParserTest.java +++ b/src/test/java/org/xbib/time/chronic/ParserTest.java @@ -1,17 +1,18 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.tags.Pointer; import java.text.ParseException; import java.time.ZoneId; import java.time.ZonedDateTime; -public class ParserTest extends Assert { +public class ParserTest { private static final ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime time_2006_08_16_14_00_00 = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime time_2006_08_16_14_00_00 = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month) { return ZonedDateTime.of(year, month, 1, 0, 0, 0, 0, ZONE_ID); @@ -33,10 +34,9 @@ public class ParserTest extends Assert { return ZonedDateTime.of(year, month, day, hour, minutes, seconds, 0, ZONE_ID); } - protected void assertEquals(ZonedDateTime ec, Span ac) { if (ec != null) { - assertEquals(ec, ac.getBeginCalendar()); + Assertions.assertEquals(ec, ac.getBeginCalendar()); } } @@ -642,24 +642,24 @@ public class ParserTest extends Assert { public void test_parse_span() throws ParseException { Span span; span = parse_now("friday", new Options().setGuess(false)); - assertEquals(construct(2006, 8, 18), span.getBeginCalendar()); - assertEquals(construct(2006, 8, 19), span.getEndCalendar()); + Assertions.assertEquals(construct(2006, 8, 18), span.getBeginCalendar()); + Assertions.assertEquals(construct(2006, 8, 19), span.getEndCalendar()); span = parse_now("november", new Options().setGuess(false)); - assertEquals(construct(2006, 11), span.getBeginCalendar()); - assertEquals(construct(2006, 12), span.getEndCalendar()); + Assertions.assertEquals(construct(2006, 11), span.getBeginCalendar()); + Assertions.assertEquals(construct(2006, 12), span.getEndCalendar()); Options options = new Options().setNow(time_2006_08_16_14_00_00).setGuess(false); span = Chronic.parse("weekend", options); - assertEquals(construct(2006, 8, 19), span.getBeginCalendar()); - assertEquals(construct(2006, 8, 21), span.getEndCalendar()); + Assertions.assertEquals(construct(2006, 8, 19), span.getBeginCalendar()); + Assertions.assertEquals(construct(2006, 8, 21), span.getEndCalendar()); } @Test public void test_parse_words() { - assertEquals(parse_now("33 days from now"), parse_now("thirty-three days from now")); - assertEquals(parse_now("2867532 seconds from now"), parse_now("two million eight hundred and sixty seven thousand five hundred and thirty two seconds from now")); - assertEquals(parse_now("may 10th"), parse_now("may tenth")); + Assertions.assertEquals(parse_now("33 days from now"), parse_now("thirty-three days from now")); + Assertions.assertEquals(parse_now("2867532 seconds from now"), parse_now("two million eight hundred and sixty seven thousand five hundred and thirty two seconds from now")); + Assertions.assertEquals(parse_now("may 10th"), parse_now("may tenth")); } @Test @@ -683,5 +683,4 @@ public class ParserTest extends Assert { } return null; } - } diff --git a/src/test/java/org/xbib/time/chronic/RepeaterDayNameTest.java b/src/test/java/org/xbib/time/chronic/RepeaterDayNameTest.java index 7209146..880ef4f 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterDayNameTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterDayNameTest.java @@ -1,17 +1,18 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterDayName; import org.xbib.time.chronic.tags.Pointer; import java.time.ZoneId; import java.time.ZonedDateTime; -public class RepeaterDayNameTest extends Assert { +public class RepeaterDayNameTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day) { return ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterFortnightTest.java b/src/test/java/org/xbib/time/chronic/RepeaterFortnightTest.java index c5b1348..7fb6352 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterFortnightTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterFortnightTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterFortnight; import org.xbib.time.chronic.repeaters.RepeaterWeek; import org.xbib.time.chronic.tags.Pointer; @@ -10,10 +10,11 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterFortnightTest extends Assert { +public class RepeaterFortnightTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day) { return ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterHourTest.java b/src/test/java/org/xbib/time/chronic/RepeaterHourTest.java index 39ed871..b5845ae 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterHourTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterHourTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterHour; import org.xbib.time.chronic.tags.Pointer; @@ -9,7 +9,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterHourTest extends Assert { +public class RepeaterHourTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterMonthNameTest.java b/src/test/java/org/xbib/time/chronic/RepeaterMonthNameTest.java index 7274140..30f01fd 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterMonthNameTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterMonthNameTest.java @@ -1,17 +1,18 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterMonthName; import org.xbib.time.chronic.tags.Pointer; import java.time.ZoneId; import java.time.ZonedDateTime; -public class RepeaterMonthNameTest extends Assert { +public class RepeaterMonthNameTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month) { return ZonedDateTime.of(year, month, 1, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterMonthTest.java b/src/test/java/org/xbib/time/chronic/RepeaterMonthTest.java index 0940599..03378cf 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterMonthTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterMonthTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterMonth; import org.xbib.time.chronic.tags.Pointer; @@ -9,10 +9,11 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterMonthTest extends Assert { +public class RepeaterMonthTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day, int hour) { return ZonedDateTime.of(year, month, day, hour, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterTimeTest.java b/src/test/java/org/xbib/time/chronic/RepeaterTimeTest.java index 2117cc8..e00b656 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterTimeTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterTimeTest.java @@ -1,17 +1,18 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterTime; import org.xbib.time.chronic.tags.Pointer; import java.time.ZoneId; import java.time.ZonedDateTime; -public class RepeaterTimeTest extends Assert { +public class RepeaterTimeTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day, int hour) { return ZonedDateTime.of(year, month, day, hour, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterWeekTest.java b/src/test/java/org/xbib/time/chronic/RepeaterWeekTest.java index ee53bb2..446d581 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterWeekTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterWeekTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterWeek; import org.xbib.time.chronic.tags.Pointer; @@ -9,10 +9,11 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterWeekTest extends Assert { +public class RepeaterWeekTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day) { return ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterWeekendTest.java b/src/test/java/org/xbib/time/chronic/RepeaterWeekendTest.java index 40a673d..ab4ef77 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterWeekendTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterWeekendTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterWeekend; import org.xbib.time.chronic.tags.Pointer; @@ -9,10 +9,11 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterWeekendTest extends Assert { +public class RepeaterWeekendTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day) { return ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/RepeaterYearTest.java b/src/test/java/org/xbib/time/chronic/RepeaterYearTest.java index 76b51f6..31d4026 100644 --- a/src/test/java/org/xbib/time/chronic/RepeaterYearTest.java +++ b/src/test/java/org/xbib/time/chronic/RepeaterYearTest.java @@ -1,7 +1,7 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.time.chronic.repeaters.RepeaterYear; import org.xbib.time.chronic.tags.Pointer; @@ -9,10 +9,11 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -public class RepeaterYearTest extends Assert { +public class RepeaterYearTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); - private ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); + + private final ZonedDateTime now = construct(2006, 8, 16, 14, 0, 0); public static ZonedDateTime construct(int year, int month, int day) { return ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZONE_ID); diff --git a/src/test/java/org/xbib/time/chronic/SpanTest.java b/src/test/java/org/xbib/time/chronic/SpanTest.java index dbd522e..be43070 100644 --- a/src/test/java/org/xbib/time/chronic/SpanTest.java +++ b/src/test/java/org/xbib/time/chronic/SpanTest.java @@ -1,12 +1,11 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import java.time.ZoneId; import java.time.ZonedDateTime; -public class SpanTest extends Assert { +public class SpanTest { private final static ZoneId ZONE_ID = ZoneId.of("GMT"); diff --git a/src/test/java/org/xbib/time/chronic/TokenTest.java b/src/test/java/org/xbib/time/chronic/TokenTest.java index bbf9947..f13c642 100644 --- a/src/test/java/org/xbib/time/chronic/TokenTest.java +++ b/src/test/java/org/xbib/time/chronic/TokenTest.java @@ -1,11 +1,13 @@ package org.xbib.time.chronic; -import org.junit.Assert; -import org.junit.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 org.junit.jupiter.api.Test; import org.xbib.time.chronic.tags.Scalar; import org.xbib.time.chronic.tags.StringTag; -public class TokenTest extends Assert { +public class TokenTest { @Test public void testToken() { diff --git a/src/test/java/org/xbib/time/format/PeriodFormatterBuilderTest.java b/src/test/java/org/xbib/time/format/PeriodFormatterBuilderTest.java index 5957c27..a448cfb 100644 --- a/src/test/java/org/xbib/time/format/PeriodFormatterBuilderTest.java +++ b/src/test/java/org/xbib/time/format/PeriodFormatterBuilderTest.java @@ -1,15 +1,14 @@ package org.xbib.time.format; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import java.io.IOException; import java.time.Period; -import static org.junit.Assert.assertEquals; - public class PeriodFormatterBuilderTest { @Test - public void test() { + public void test() throws IOException { PeriodFormatter yearsAndMonths = new PeriodFormatterBuilder() .appendYears() .appendSuffix(" year", " years") @@ -17,8 +16,6 @@ public class PeriodFormatterBuilderTest { .appendMonths() .appendSuffix(" month", " months") .toFormatter(); - assertEquals("3 years and 2 months", yearsAndMonths.print(Period.of(3, 2, 1))); - } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeAPIManipulationTest.java b/src/test/java/org/xbib/time/pretty/PrettyTimeAPIManipulationTest.java index 4164d38..c47ab48 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeAPIManipulationTest.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeAPIManipulationTest.java @@ -1,79 +1,78 @@ package org.xbib.time.pretty; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.JustNow; - import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - public class PrettyTimeAPIManipulationTest { private List list = null; - private PrettyTime t = new PrettyTime(); + private final PrettyTime t = new PrettyTime(); - private TimeUnitQuantity timeUnitQuantity = null; + private final TimeUnitQuantity timeUnitQuantity = null; @Test - public void testApiMisuse3() throws Exception { + public void testApiMisuse3() { t.clearUnits(); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse6() throws Exception { - t.format(list); - } - - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse8() throws Exception { - t.formatUnrounded(timeUnitQuantity); - } - - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse9() throws Exception { - t.getFormat(null); + @Test + public void testApiMisuse6() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.format(list)); } @Test - public void testApiMisuse10() throws Exception { + public void testApiMisuse8() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.formatUnrounded(timeUnitQuantity)); + } + + @Test + public void testApiMisuse9() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.getFormat(null)); + } + + @Test + public void testApiMisuse10() { t.getLocale(); } @Test - public void testApiMisuse12() throws Exception { + public void testApiMisuse12() { t.getUnits(); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse13() throws Exception { - t.registerUnit(null, null); + @Test + public void testApiMisuse13() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.registerUnit(null, null)); } @Test - public void testApiMisuse15() throws Exception { + public void testApiMisuse15() { t.toString(); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse16() throws Exception { - t.removeUnit((Class) null); + @Test + public void testApiMisuse16() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.removeUnit((Class) null)); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse17() throws Exception { - t.removeUnit((TimeUnit) null); + @Test + public void testApiMisuse17() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.removeUnit((TimeUnit) null)); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse18() throws Exception { - t.getUnit(null); + @Test + public void testApiMisuse18() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.getUnit(null)); } - @Test(expected = IllegalArgumentException.class) - public void testApiMisuse19() throws Exception { - t.getUnit(null); + @Test + public void testApiMisuse19() { + Assertions.assertThrows(IllegalArgumentException.class, () -> t.getUnit(null)); } @Test diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_AR_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_AR_Test.java index 8159155..d81cc3e 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_AR_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_AR_Test.java @@ -1,9 +1,10 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -11,142 +12,137 @@ import java.time.temporal.ChronoField; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_AR_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("ar"); + Locale locale = new Locale("ar"); Locale.setDefault(locale); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime localDateTime = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime p = new PrettyTime(localDateTime); assertEquals("1 شهر مضت", p.format(LocalDateTime.of(2009, 5, 20, 0, 0))); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("بعد لحظات", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("بعد لحظات", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("12 دقائق من الآن", t.format(1000 * 60 * 12)); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 ساعات من الآن", t.format(1000 * 60 * 60 * 3)); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 ايام من الآن", t.format(1000 * 60 * 60 * 24 * 3)); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 أسابيع من الآن", t.format(1000 * 60 * 60 * 24 * 7 * 3)); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 أشهر من الآن", t.format(2629743830L * 3L)); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 سنوات من الآن", t.format(2629743830L * 12L * 3L)); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 عقود من الآن", t.format(315569259747L * 3L)); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 قرون من الآن", t.format(3155692597470L * 3L)); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(6000), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("منذ لحظات", t.format(0)); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 12), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("12 دقائق مضت", t.format(0)); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 ساعات مضت", t.format(0)); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 ايام مضت", t.format(0)); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 7 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 أسابيع مضت", t.format(0)); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 أشهر مضت", t.format(0)); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); TimeUnit unit = new TimeUnit() { @@ -175,35 +171,35 @@ public class PrettyTimeI18n_AR_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L * 12L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 سنوات مضت", t.format(0)); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(315569259747L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 عقود مضت", t.format(0)); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(3155692597470L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 قرون مضت", t.format(0)); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minus(6543990, ChronoField.MILLI_OF_SECOND.getBaseUnit()); assertEquals("2 ساعات مضت", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -213,7 +209,7 @@ public class PrettyTimeI18n_AR_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -223,7 +219,7 @@ public class PrettyTimeI18n_AR_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); List timeUnitQuantities = t.calculatePreciseDuration(LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault())); @@ -231,7 +227,7 @@ public class PrettyTimeI18n_AR_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault())); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -239,14 +235,14 @@ public class PrettyTimeI18n_AR_Test { } @Test - public void testSetLocale() throws Exception { + public void testSetLocale() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(315569259747L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("3 عقود مضت", t.format(0)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_BG_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_BG_Test.java index dd9cd16..c550b13 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_BG_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_BG_Test.java @@ -1,206 +1,202 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_BG_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("bg"); + Locale locale = new Locale("bg"); Locale.setDefault(locale); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 века", t.format(3155692597470L * 3L)); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(3155692597470L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 века", t.format(0)); } @Test - public void testCenturySingular() throws Exception { + public void testCenturySingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(3155692597470L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 век", t.format(0)); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 дни", t.format(1000 * 60 * 60 * 24 * 3)); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 дни", t.format(0)); } @Test - public void testDaySingular() throws Exception { + public void testDaySingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 ден", t.format(0)); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(315569259747L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 десетилетия", t.format(0)); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 десетилетия", t.format(315569259747L * 3L)); } @Test - public void testDecadeSingular() throws Exception { + public void testDecadeSingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 1 десетилетие", t.format(315569259747L)); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 часа", t.format(1000 * 60 * 60 * 3)); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 часа", t.format(0)); } @Test - public void testHourSingular() throws Exception { + public void testHourSingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 час", t.format(0)); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("в момента", t.format(LocalDateTime.now())); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(6000), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("току що", t.format(0)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 12 минути", t.format(1000 * 60 * 12)); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 12), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 12 минути", t.format(0)); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 месеца", t.format((2629743830L * 3L))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 месеца", t.format(0)); } @Test - public void testMonthSingular() throws Exception { + public void testMonthSingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 месец", t.format(0)); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 седмици", t.format(1000 * 60 * 60 * 24 * 7 * 3)); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 7 * 3), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 седмици", t.format(0)); } @Test - public void testWeekSingular() throws Exception { + public void testWeekSingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 7), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 седмица", t.format(0)); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("след 3 години", t.format(2629743830L * 12L * 3L)); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L * 12L * 3L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 3 години", t.format(0)); } @Test - public void testYearSingular() throws Exception { + public void testYearSingular() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(2629743830L * 12L), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(localDateTime); assertEquals("преди 1 година", t.format(0)); } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault())); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -208,7 +204,7 @@ public class PrettyTimeI18n_BG_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(0L), ZoneId.systemDefault())); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -216,9 +212,8 @@ public class PrettyTimeI18n_BG_Test { assertEquals("след 3 дни 15 часа 38 минути", t.format(timeUnitQuantities)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } - } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CA_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CA_Test.java index 73d20f1..2f4c23f 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CA_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CA_Test.java @@ -1,33 +1,29 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_CA_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("ca"); + Locale locale = new Locale("ca"); Locale.setDefault(locale); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, new Locale("ca")); @@ -35,103 +31,103 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("en un instant", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime(0); assertEquals("en un instant", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 12 minuts", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 hores", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 dies", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 setmanes", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 mesos", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 anys", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 desenis", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("dintre de 3 segles", t.format((3155692597470L * 3L))); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime(6000); assertEquals("fa uns instants", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 12); assertEquals("fa 12 minuts", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 3); assertEquals("fa 3 hores", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3); assertEquals("fa 3 dies", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 7 * 3); assertEquals("fa 3 setmanes", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime(2629743830L * 3L); assertEquals("fa 3 mesos", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime(0); TimeUnit unit = new TimeUnit() { @Override @@ -159,32 +155,32 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime(2629743830L * 12L * 3L); assertEquals("fa 3 anys", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime(315569259747L * 3L); assertEquals("fa 3 desenis", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime(3155692597470L * 3L); assertEquals("fa 3 segles", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusHours(2); assertEquals("fa 2 hores", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -194,7 +190,7 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -204,7 +200,7 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -212,7 +208,7 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(0); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -221,15 +217,15 @@ public class PrettyTimeI18n_CA_Test { } @Test - public void testSetLocale() throws Exception { + public void testSetLocale() { PrettyTime t = new PrettyTime(315569259747L * 3L); assertEquals("fa 3 desenis", t.format((0))); t.setLocale(Locale.GERMAN); assertEquals("vor 3 Jahrzehnten", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CS_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CS_Test.java index 90c24a1..2982076 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CS_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_CS_Test.java @@ -1,12 +1,11 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.JustNow; import org.xbib.time.pretty.units.Month; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -14,23 +13,19 @@ import java.time.temporal.ChronoField; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_CS_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("cs"); + Locale locale = new Locale("cs"); Locale.setDefault(locale); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref); @@ -38,19 +33,19 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("za chvíli", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime(0); assertEquals("za chvíli", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0); for (TimeUnit u : t.getUnits()) { if (u instanceof JustNow) { @@ -63,7 +58,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 1 hodinu", t.format(1000 * 60 * 60)); @@ -72,7 +67,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 1 den", t.format(1000 * 60 * 60 * 24)); assertEquals("za 3 dny", t.format(1000 * 60 * 60 * 24 * 3)); @@ -80,7 +75,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime(0); for (TimeUnit u : t.getUnits()) { if (u instanceof Month) { @@ -93,7 +88,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 1 měsíc", t.format(2629743830L)); assertEquals("za 3 měsíce", t.format(2629743830L * 3L)); @@ -101,7 +96,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 1 rok", t.format(2629743830L * 12L)); assertEquals("za 3 roky", t.format(2629743830L * 12L * 3L)); @@ -109,13 +104,13 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 3 desetiletí", t.format(315569259747L * 3L)); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("za 3 století", t.format(3155692597470L * 3L)); } @@ -124,19 +119,19 @@ public class PrettyTimeI18n_CS_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime(6000); assertEquals("před chvílí", t.format(0)); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 12); assertEquals("před 12 minutami", t.format(0)); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { LocalDateTime base = LocalDateTime.now(); PrettyTime t = new PrettyTime(base); assertEquals("před 1 hodinou", t.format(base.minusHours(1))); @@ -144,7 +139,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { LocalDateTime base = LocalDateTime.now(); PrettyTime t = new PrettyTime(base); assertEquals("před 1 dnem", t.format(base.minusDays(1))); @@ -152,7 +147,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { LocalDateTime base = LocalDateTime.now(); PrettyTime t = new PrettyTime(base); assertEquals("před 1 týdnem", t.format(base.minusWeeks(1))); @@ -160,7 +155,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { LocalDateTime base = LocalDateTime.now(); PrettyTime t = new PrettyTime(base); @@ -169,7 +164,7 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { LocalDateTime base = LocalDateTime.now(); PrettyTime t = new PrettyTime(base); for (TimeUnit u : t.getUnits()) { @@ -182,19 +177,19 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime(315569259747L * 3L); assertEquals("před 3 desetiletími", t.format(0)); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime(3155692597470L * 3L); assertEquals("před 3 stoletími", t.format(0)); } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -202,29 +197,24 @@ public class PrettyTimeI18n_CS_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(0); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); assertEquals("za 3 dny 15 hodin 38 minut", t.format(timeUnitQuantities)); } - /** - * Tests formatApproximateDuration and by proxy, formatDuration. - * - * @throws Exception exception - */ @Test - public void testFormatApproximateDuration() throws Exception { + public void testFormatApproximateDuration() { LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime tenMinAgo = localDateTime.minus(10, ChronoField.MINUTE_OF_DAY.getBaseUnit()); PrettyTime t = new PrettyTime(); String result = t.formatApproximateDuration(tenMinAgo); - Assert.assertEquals("10 minutami", result); + assertEquals("10 minutami", result); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_DA_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_DA_Test.java index 87bac2b..e0916b1 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_DA_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_DA_Test.java @@ -1,22 +1,20 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_DA_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("da"); Locale.setDefault(locale); @@ -38,7 +36,7 @@ public class PrettyTimeI18n_DA_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -46,121 +44,121 @@ public class PrettyTimeI18n_DA_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("straks", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime(0, locale); assertEquals("straks", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 12 minutter", t.format(1000 * 60 * 12)); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 3 timer", t.format(1000 * 60 * 60 * 3)); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 3 dage", t.format(1000 * 60 * 60 * 24 * 3)); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 3 uger", t.format(1000 * 60 * 60 * 24 * 7 * 3)); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 3 måneder", t.format(2629743830L * 3L)); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("om 3 år", t.format(2629743830L * 12L * 3L)); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 årtier fra nu", t.format(315569259747L * 3L)); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 århundreder fra nu", t.format(3155692597470L * 3L)); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime(6000, locale); assertEquals("et øjeblik siden", t.format(0)); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 minutter siden", t.format(0)); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 timer siden", t.format(0)); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 dage siden", t.format(0)); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 uger siden", t.format(0)); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 måneder siden", t.format(0)); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 år siden", t.format(0)); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 årtier siden", t.format(0)); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 århundreder siden", t.format(0)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_ET_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_ET_Test.java index 0eaf932..b380706 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_ET_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_ET_Test.java @@ -1,10 +1,10 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.JustNow; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -12,299 +12,297 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_ET_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("et"); Locale.setDefault(locale); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("hetke pärast", t.format(6000)); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("hetk tagasi", t.format(0)); } @Test - public void testMilliSecondsFromNow() throws Exception { + public void testMilliSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow(0, locale); assertEquals("13 millisekundi pärast", t.format(13)); } @Test - public void testMilliSecondsAgo() throws Exception { + public void testMilliSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow((13), locale); assertEquals("13 millisekundit tagasi", t.format(0)); } @Test - public void testMilliSecondFromNow() throws Exception { + public void testMilliSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow(0, locale); assertEquals("millisekundi pärast", t.format(1)); } @Test - public void testMilliSecondAgo() throws Exception { + public void testMilliSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow(1, locale); assertEquals("millisekund tagasi", t.format(0)); } @Test - public void testSecondsFromNow() throws Exception { + public void testSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow(0, locale); assertEquals("13 sekundi pärast", t.format(1000 * 13)); } @Test - public void testSecondsAgo() throws Exception { + public void testSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow(1000 * 13, locale); assertEquals("13 sekundit tagasi", t.format(0)); } @Test - public void testSecondFromNow() throws Exception { + public void testSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow(0, locale); assertEquals("sekundi pärast", t.format(1000)); } @Test - public void testSecondAgo() throws Exception { + public void testSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow(1000, locale); assertEquals("sekund tagasi", t.format(0)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("13 minuti pärast", t.format(1000 * 60 * 13)); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 13), locale); assertEquals("13 minutit tagasi", t.format(0)); } @Test - public void testMinuteFromNow() throws Exception { + public void testMinuteFromNow() { PrettyTime t = newPrettyTimeWOJustNow(0, locale); assertEquals("minuti pärast", t.format(1000 * 60)); } @Test - public void testMinuteAgo() throws Exception { + public void testMinuteAgo() { PrettyTime t = newPrettyTimeWOJustNow(1000 * 60, locale); assertEquals("minut tagasi", t.format(0)); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 tunni pärast", t.format(1000 * 60 * 60 * 3)); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 tundi tagasi", t.format(0)); } @Test - public void testHoursFromNowSingle() throws Exception { + public void testHoursFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("tunni pärast", t.format(1000 * 60 * 60)); } @Test - public void testHoursAgoSingle() throws Exception { + public void testHoursAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60), locale); assertEquals("tund tagasi", t.format(0)); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 päeva pärast", t.format(1000 * 60 * 60 * 24 * 3)); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 päeva tagasi", t.format(0)); } @Test - public void testDaysFromNowSingle() throws Exception { + public void testDaysFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("homme", t.format(1000 * 60 * 60 * 24)); } @Test - public void testDaysAgoSingle() throws Exception { + public void testDaysAgoSingle() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24, locale); assertEquals("eile", t.format(0)); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 nädala pärast", t.format(1000 * 60 * 60 * 24 * 7 * 3)); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 7 * 3, locale); assertEquals("3 nädalat tagasi", t.format(0)); } @Test - public void testWeeksFromNowSingle() throws Exception { + public void testWeeksFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("nädala pärast", t.format(1000 * 60 * 60 * 24 * 7)); } @Test - public void testWeeksAgoSingle() throws Exception { + public void testWeeksAgoSingle() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 7, locale); assertEquals("nädal tagasi", t.format(0)); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 kuu pärast", t.format(1000L * 60 * 60 * 24 * 30 * 3)); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 30 * 3, locale); assertEquals("3 kuud tagasi", t.format(0)); } @Test - public void testMonthFromNow() throws Exception { + public void testMonthFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("kuu pärast", t.format(1000L * 60 * 60 * 24 * 30)); } @Test - public void testMonthAgo() throws Exception { + public void testMonthAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 30, locale); assertEquals("kuu tagasi", t.format(0)); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 aasta pärast", t.format(1000L * 60 * 60 * 24 * 365 * 3)); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 3), locale); assertEquals("3 aastat tagasi", t.format(0)); } @Test - public void testYearFromNow() throws Exception { + public void testYearFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("aasta pärast", t.format(1000L * 60 * 60 * 24 * 366)); } @Test - public void testYearAgo() throws Exception { + public void testYearAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 366, locale); assertEquals("aasta tagasi", t.format(0)); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 aastakümne pärast", t.format(1000L * 60 * 60 * 24 * 365 * 10 * 3)); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 365 * 10 * 3, locale); assertEquals("3 aastakümmet tagasi", t.format(0)); } @Test - public void testDecadeFromNow() throws Exception { + public void testDecadeFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("aastakümne pärast", t.format(1000L * 60 * 60 * 24 * 365 * 11)); } @Test - public void testDecadeAgo() throws Exception { + public void testDecadeAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 365 * 11, locale); assertEquals("aastakümme tagasi", t.format(0)); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 sajandi pärast", t.format(1000L * 60 * 60 * 24 * 365 * 100 * 3)); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 100 * 3), locale); assertEquals("3 sajandit tagasi", t.format(0)); } @Test - public void testCenturyFromNow() throws Exception { + public void testCenturyFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("sajandi pärast", t.format(1000L * 60 * 60 * 24 * 365 * 101)); } @Test - public void testCenturyAgo() throws Exception { + public void testCenturyAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 101), locale); assertEquals("sajand tagasi", t.format(0)); } @Test - public void testMillenniaFromNow() throws Exception { + public void testMillenniaFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 aastatuhande pärast", t.format(1000L * 60 * 60 * 24 * 365 * 1000 * 3)); } @Test - public void testMillenniaAgo() throws Exception { + public void testMillenniaAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1000 * 3), locale); assertEquals("3 aastatuhandet tagasi", t.format(0)); } @Test - public void testMillenniumFromNow() throws Exception { + public void testMillenniumFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("aastatuhande pärast", t.format(1000L * 60 * 60 * 24 * 365 * 1001)); } @Test - public void testMillenniumAgo() throws Exception { + public void testMillenniumAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1001), locale); assertEquals("aastatuhat tagasi", t.format(0)); } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -312,7 +310,7 @@ public class PrettyTimeI18n_ET_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0), locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -339,8 +337,8 @@ public class PrettyTimeI18n_ET_Test { return t; } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FA_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FA_Test.java index a476989..7a1971b 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FA_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FA_Test.java @@ -1,33 +1,29 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_FA_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("fa"); + Locale locale = new Locale("fa"); Locale.setDefault(locale); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2012, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2012, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref); @@ -35,61 +31,61 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("چند لحظه دیگر", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime(0); assertEquals("چند لحظه دیگر", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("12 دقیقه دیگر", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 ساعت دیگر", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 روز دیگر", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 هفته دیگر", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 ماه دیگر", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 سال دیگر", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 دهه دیگر", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 قرن دیگر", t.format((3155692597470L * 3L))); } @@ -98,43 +94,43 @@ public class PrettyTimeI18n_FA_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime(6000); assertEquals("چند لحظه پیش", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 12); assertEquals("12 دقیقه پیش", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 3); assertEquals("3 ساعت پیش", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3); assertEquals("3 روز پیش", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 7 * 3); assertEquals("3 هفته پیش", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime(2629743830L * 3L); assertEquals("3 ماه پیش", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime(0); TimeUnit unit = new TimeUnit() { @Override @@ -162,32 +158,32 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime(2629743830L * 12L * 3L); assertEquals("3 سال پیش", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime(315569259747L * 3L); assertEquals("3 دهه پیش", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime(3155692597470L * 3L); assertEquals("3 قرن پیش", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(6543); assertEquals("2 ساعت پیش", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -198,7 +194,7 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -209,7 +205,7 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -217,7 +213,7 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(0); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -226,13 +222,13 @@ public class PrettyTimeI18n_FA_Test { } @Test - public void testSetLocale() throws Exception { + public void testSetLocale() { PrettyTime t = new PrettyTime(315569259747L * 3L); assertEquals("3 دهه پیش", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FI_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FI_Test.java index f708a24..fac2f8f 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FI_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FI_Test.java @@ -1,10 +1,10 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.JustNow; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -12,299 +12,297 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_FI_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("fi"); Locale.setDefault(locale); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("hetken päästä", t.format((6000))); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("hetki sitten", t.format((0))); } @Test - public void testMilliSecondsFromNow() throws Exception { + public void testMilliSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("13 millisekunnin päästä", t.format((13))); } @Test - public void testMilliSecondsAgo() throws Exception { + public void testMilliSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow((13), locale); assertEquals("13 millisekuntia sitten", t.format((0))); } @Test - public void testMilliSecondFromNow() throws Exception { + public void testMilliSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("millisekunnin päästä", t.format((1))); } @Test - public void testMilliSecondAgo() throws Exception { + public void testMilliSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow((1), locale); assertEquals("millisekunti sitten", t.format((0))); } @Test - public void testSecondsFromNow() throws Exception { + public void testSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("13 sekunnin päästä", t.format((1000 * 13))); } @Test - public void testSecondsAgo() throws Exception { + public void testSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000 * 13), locale); assertEquals("13 sekuntia sitten", t.format((0))); } @Test - public void testSecondFromNow() throws Exception { + public void testSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("sekunnin päästä", t.format((1000))); } @Test - public void testSecondAgo() throws Exception { + public void testSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000), locale); assertEquals("sekunti sitten", t.format((0))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("13 minuutin päästä", t.format((1000 * 60 * 13))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 13), locale); assertEquals("13 minuuttia sitten", t.format((0))); } @Test - public void testMinuteFromNow() throws Exception { + public void testMinuteFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("minuutin päästä", t.format((1000 * 60))); } @Test - public void testMinuteAgo() throws Exception { + public void testMinuteAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000 * 60), locale); assertEquals("minuutti sitten", t.format((0))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 tunnin päästä", t.format((1000 * 60 * 60 * 3))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 tuntia sitten", t.format((0))); } @Test - public void testHoursFromNowSingle() throws Exception { + public void testHoursFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("tunnin päästä", t.format((1000 * 60 * 60))); } @Test - public void testHoursAgoSingle() throws Exception { + public void testHoursAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60), locale); assertEquals("tunti sitten", t.format((0))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 päivän päästä", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24 * 3, locale); assertEquals("3 päivää sitten", t.format((0))); } @Test - public void testDaysFromNowSingle() throws Exception { + public void testDaysFromNowSingle() { PrettyTime t = new PrettyTime(0, locale); assertEquals("huomenna", t.format((1000 * 60 * 60 * 24))); } @Test - public void testDaysAgoSingle() throws Exception { + public void testDaysAgoSingle() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 24, locale); assertEquals("eilen", t.format((0))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 viikon päästä", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 viikkoa sitten", t.format((0))); } @Test - public void testWeeksFromNowSingle() throws Exception { + public void testWeeksFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("viikon päästä", t.format((1000 * 60 * 60 * 24 * 7))); } @Test - public void testWeeksAgoSingle() throws Exception { + public void testWeeksAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7), locale); assertEquals("viikko sitten", t.format((0))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("3 kuukauden päästä", t.format((1000L * 60 * 60 * 24 * 30 * 3))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime(1000L * 60 * 60 * 24 * 30 * 3, locale); assertEquals("3 kuukautta sitten", t.format((0))); } @Test - public void testMonthFromNow() throws Exception { + public void testMonthFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("kuukauden päästä", t.format((1000L * 60 * 60 * 24 * 30))); } @Test - public void testMonthAgo() throws Exception { + public void testMonthAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 30), locale); assertEquals("kuukausi sitten", t.format((0))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 vuoden päästä", t.format((1000L * 60 * 60 * 24 * 365 * 3))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 3), locale); assertEquals("3 vuotta sitten", t.format((0))); } @Test - public void testYearFromNow() throws Exception { + public void testYearFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("vuoden päästä", t.format((1000L * 60 * 60 * 24 * 366))); } @Test - public void testYearAgo() throws Exception { + public void testYearAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 366), locale); assertEquals("vuosi sitten", t.format((0))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 vuosikymmenen päästä", t.format((1000L * 60 * 60 * 24 * 365 * 10 * 3))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 10 * 3), locale); assertEquals("3 vuosikymmentä sitten", t.format((0))); } @Test - public void testDecadeFromNow() throws Exception { + public void testDecadeFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("vuosikymmenen päästä", t.format((1000L * 60 * 60 * 24 * 365 * 11))); } @Test - public void testDecadeAgo() throws Exception { + public void testDecadeAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 11), locale); assertEquals("vuosikymmen sitten", t.format((0))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 vuosisadan päästä", t.format((1000L * 60 * 60 * 24 * 365 * 100 * 3))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 100 * 3), locale); assertEquals("3 vuosisataa sitten", t.format((0))); } @Test - public void testCenturyFromNow() throws Exception { + public void testCenturyFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("vuosisadan päästä", t.format((1000L * 60 * 60 * 24 * 365 * 101))); } @Test - public void testCenturyAgo() throws Exception { + public void testCenturyAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 101), locale); assertEquals("vuosisata sitten", t.format((0))); } @Test - public void testMillenniaFromNow() throws Exception { + public void testMillenniaFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 vuosituhannen päästä", t.format((1000L * 60 * 60 * 24 * 365 * 1000 * 3))); } @Test - public void testMillenniaAgo() throws Exception { + public void testMillenniaAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1000 * 3), locale); assertEquals("3 vuosituhatta sitten", t.format((0))); } @Test - public void testMillenniumFromNow() throws Exception { + public void testMillenniumFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("vuosituhannen päästä", t.format((1000L * 60 * 60 * 24 * 365 * 1001))); } @Test - public void testMillenniumAgo() throws Exception { + public void testMillenniumAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1001), locale); assertEquals("vuosituhat sitten", t.format((0))); } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -312,7 +310,7 @@ public class PrettyTimeI18n_FI_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime(0, locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -340,8 +338,8 @@ public class PrettyTimeI18n_FI_Test { return t; } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FR_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FR_Test.java index cdfe3c9..130ec81 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FR_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_FR_Test.java @@ -1,25 +1,23 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_FR_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = Locale.FRENCH; Locale.setDefault(locale); @@ -55,9 +53,8 @@ public class PrettyTimeI18n_FR_Test { } } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } - } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_IT_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_IT_Test.java index 2e96182..81af9ad 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_IT_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_IT_Test.java @@ -1,10 +1,10 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.JustNow; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -12,299 +12,297 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_IT_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("it"); Locale.setDefault(locale); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra poco", t.format((6000))); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("poco fa", t.format((0))); } @Test - public void testMilliSecondsFromNow() throws Exception { + public void testMilliSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("fra 13 millisecondi", t.format((13))); } @Test - public void testMilliSecondsAgo() throws Exception { + public void testMilliSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow((13), locale); assertEquals("13 millisecondi fa", t.format((0))); } @Test - public void testMilliSecondFromNow() throws Exception { + public void testMilliSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("fra 1 millisecondo", t.format((1))); } @Test - public void testMilliSecondAgo() throws Exception { + public void testMilliSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow((1), locale); assertEquals("1 millisecondo fa", t.format((0))); } @Test - public void testSecondsFromNow() throws Exception { + public void testSecondsFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("fra 13 secondi", t.format((1000 * 13))); } @Test - public void testSecondsAgo() throws Exception { + public void testSecondsAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000 * 13), locale); assertEquals("13 secondi fa", t.format((0))); } @Test - public void testSecondFromNow() throws Exception { + public void testSecondFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("fra 1 secondo", t.format(1000)); } @Test - public void testSecondAgo() throws Exception { + public void testSecondAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000), locale); assertEquals("1 secondo fa", t.format((0))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 13 minuti", t.format((1000 * 60 * 13))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 13), locale); assertEquals("13 minuti fa", t.format((0))); } @Test - public void testMinuteFromNow() throws Exception { + public void testMinuteFromNow() { PrettyTime t = newPrettyTimeWOJustNow((0), locale); assertEquals("fra 1 minuto", t.format((1000 * 60))); } @Test - public void testMinuteAgo() throws Exception { + public void testMinuteAgo() { PrettyTime t = newPrettyTimeWOJustNow((1000 * 60), locale); assertEquals("1 minuto fa", t.format((0))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 ore", t.format((1000 * 60 * 60 * 3))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 ore fa", t.format((0))); } @Test - public void testHoursFromNowSingle() throws Exception { + public void testHoursFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 ora", t.format((1000 * 60 * 60))); } @Test - public void testHoursAgoSingle() throws Exception { + public void testHoursAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60), locale); assertEquals("1 ora fa", t.format((0))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 giorni", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 giorni fa", t.format((0))); } @Test - public void testDaysFromNowSingle() throws Exception { + public void testDaysFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 giorno", t.format((1000 * 60 * 60 * 24))); } @Test - public void testDaysAgoSingle() throws Exception { + public void testDaysAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24), locale); assertEquals("1 giorno fa", t.format((0))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 settimane", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 settimane fa", t.format((0))); } @Test - public void testWeeksFromNowSingle() throws Exception { + public void testWeeksFromNowSingle() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 settimana", t.format((1000 * 60 * 60 * 24 * 7))); } @Test - public void testWeeksAgoSingle() throws Exception { + public void testWeeksAgoSingle() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7), locale); assertEquals("1 settimana fa", t.format((0))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 mesi", t.format((1000L * 60 * 60 * 24 * 30 * 3))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 30 * 3), locale); assertEquals("3 mesi fa", t.format((0))); } @Test - public void testMonthFromNow() throws Exception { + public void testMonthFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 mese", t.format((1000L * 60 * 60 * 24 * 30))); } @Test - public void testMonthAgo() throws Exception { + public void testMonthAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 30), locale); assertEquals("1 mese fa", t.format((0))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 anni", t.format((1000L * 60 * 60 * 24 * 365 * 3))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 3), locale); assertEquals("3 anni fa", t.format((0))); } @Test - public void testYearFromNow() throws Exception { + public void testYearFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 anno", t.format((1000L * 60 * 60 * 24 * 366))); } @Test - public void testYearAgo() throws Exception { + public void testYearAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 366), locale); assertEquals("1 anno fa", t.format((0))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 decenni", t.format((1000L * 60 * 60 * 24 * 365 * 10 * 3))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 10 * 3), locale); assertEquals("3 decenni fa", t.format((0))); } @Test - public void testDecadeFromNow() throws Exception { + public void testDecadeFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 decennio", t.format((1000L * 60 * 60 * 24 * 365 * 11))); } @Test - public void testDecadeAgo() throws Exception { + public void testDecadeAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 11), locale); assertEquals("1 decennio fa", t.format((0))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 secoli", t.format((1000L * 60 * 60 * 24 * 365 * 100 * 3))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 100 * 3), locale); assertEquals("3 secoli fa", t.format((0))); } @Test - public void testCenturyFromNow() throws Exception { + public void testCenturyFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 secolo", t.format((1000L * 60 * 60 * 24 * 365 * 101))); } @Test - public void testCenturyAgo() throws Exception { + public void testCenturyAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 101), locale); assertEquals("1 secolo fa", t.format((0))); } @Test - public void testMillenniaFromNow() throws Exception { + public void testMillenniaFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 3 millenni", t.format((1000L * 60 * 60 * 24 * 365 * 1000 * 3))); } @Test - public void testMillenniaAgo() throws Exception { + public void testMillenniaAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1000 * 3), locale); assertEquals("3 millenni fa", t.format((0))); } @Test - public void testMillenniumFromNow() throws Exception { + public void testMillenniumFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("fra 1 millennio", t.format((1000L * 60 * 60 * 24 * 365 * 1001))); } @Test - public void testMillenniumAgo() throws Exception { + public void testMillenniumAgo() { PrettyTime t = new PrettyTime((1000L * 60 * 60 * 24 * 365 * 1001), locale); assertEquals("1 millennio fa", t.format((0))); } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -312,7 +310,7 @@ public class PrettyTimeI18n_IT_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0), locale); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -340,8 +338,8 @@ public class PrettyTimeI18n_IT_Test { return t; } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_KO_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_KO_Test.java index e5d51cc..6d7b382 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_KO_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_KO_Test.java @@ -1,33 +1,29 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_KO_Test { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = Locale.KOREA; + Locale locale = Locale.KOREA; Locale.setDefault(locale); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, Locale.KOREA); @@ -35,103 +31,103 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("지금", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0)); assertEquals("지금", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("12분 후", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3시간 후", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3일 후", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3주 후", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3개월 후", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3년 후", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("30년 후", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3세기 후", t.format((3155692597470L * 3L))); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000)); assertEquals("방금", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12)); assertEquals("12분 전", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3)); assertEquals("3시간 전", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3)); assertEquals("3일 전", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3)); assertEquals("3주 전", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L)); assertEquals("3개월 전", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime((0)); TimeUnit unit = new TimeUnit() { @Override @@ -159,32 +155,32 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L)); assertEquals("3년 전", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("30년 전", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L)); assertEquals("3세기 전", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(6544); assertEquals("2시간 전", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -195,7 +191,7 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -205,7 +201,7 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -213,7 +209,7 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -222,15 +218,15 @@ public class PrettyTimeI18n_KO_Test { } @Test - public void testSetLocale() throws Exception { + public void testSetLocale() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("30년 전", t.format((0))); t.setLocale(Locale.GERMAN); assertEquals("vor 3 Jahrzehnten", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NL_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NL_Test.java index b25f2d5..152015b 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NL_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NL_Test.java @@ -1,24 +1,22 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_NL_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("nl"); Locale.setDefault(locale); @@ -42,7 +40,7 @@ public class PrettyTimeI18n_NL_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -50,61 +48,61 @@ public class PrettyTimeI18n_NL_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("op dit moment", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("op dit moment", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 12 minuten", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 uur", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 dagen", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 weken", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 maanden", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 jaar", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 decennia", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("over 3 eeuwen", t.format((3155692597470L * 3L))); } @@ -113,61 +111,61 @@ public class PrettyTimeI18n_NL_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("een ogenblik geleden", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 minuten geleden", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 uur geleden", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 dagen geleden", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 weken geleden", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 maanden geleden", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 jaar geleden", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 decennia geleden", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 eeuwen geleden", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NO_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NO_Test.java index 68fd08e..d120e9f 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NO_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_NO_Test.java @@ -1,24 +1,22 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_NO_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("no"); Locale.setDefault(locale); @@ -42,7 +40,7 @@ public class PrettyTimeI18n_NO_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -50,61 +48,61 @@ public class PrettyTimeI18n_NO_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("straks", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("straks", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 12 minutter", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 timer", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 dager", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 uker", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 måneder", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 år", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 tiår fra nå", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 århundre fra nå", t.format((3155692597470L * 3L))); } @@ -113,61 +111,61 @@ public class PrettyTimeI18n_NO_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("et øyeblikk siden", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 minutter siden", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 timer siden", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 dager siden", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 uker siden", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 måneder siden", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 år siden", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 tiår siden", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 århundre siden", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_RU_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_RU_Test.java index aa595cc..b369770 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_RU_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_RU_Test.java @@ -1,24 +1,22 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_RU_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("ru"); Locale.setDefault(locale); @@ -42,7 +40,7 @@ public class PrettyTimeI18n_RU_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -50,61 +48,61 @@ public class PrettyTimeI18n_RU_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("сейчас", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("сейчас", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 12 минут", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 часа", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 дня", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 недели", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 месяца", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 года", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 десятилетия", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 века", t.format((3155692597470L * 3L))); } @@ -113,61 +111,61 @@ public class PrettyTimeI18n_RU_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("только что", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 минут назад", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 часа назад", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 дня назад", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 недели назад", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 месяца назад", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 года назад", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 десятилетия назад", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 века назад", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_SV_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_SV_Test.java index 0a5d0a1..6d0feff 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_SV_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_SV_Test.java @@ -1,24 +1,22 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_SV_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("sv"); Locale.setDefault(locale); @@ -42,7 +40,7 @@ public class PrettyTimeI18n_SV_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); @@ -51,61 +49,61 @@ public class PrettyTimeI18n_SV_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("om en stund", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om en stund", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 12 minuter", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 timmar", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 dagar", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 veckor", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 månader", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 år", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 årtionden", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("om 3 århundraden", t.format((3155692597470L * 3L))); } @@ -114,61 +112,61 @@ public class PrettyTimeI18n_SV_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("en stund sedan", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 minuter sedan", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 timmar sedan", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 dagar sedan", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 veckor sedan", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 månader sedan", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 år sedan", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 årtionden sedan", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 århundraden sedan", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_Test.java index 6726925..89c11eb 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_Test.java @@ -1,23 +1,21 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_Test { private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { locale = Locale.getDefault(); } @@ -120,8 +118,8 @@ public class PrettyTimeI18n_Test { } } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(locale); } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_UA_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_UA_Test.java index 0292d6d..01a00d0 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_UA_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_UA_Test.java @@ -1,24 +1,22 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_UA_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("ua"); Locale.setDefault(locale); @@ -42,7 +40,7 @@ public class PrettyTimeI18n_UA_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -50,61 +48,61 @@ public class PrettyTimeI18n_UA_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("зараз", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("зараз", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0, locale); assertEquals("через 12 хвилин", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 години", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 дні", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 тижні", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 місяці", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 роки", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 десятиліття", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("через 3 століття", t.format((3155692597470L * 3L))); } @@ -113,85 +111,85 @@ public class PrettyTimeI18n_UA_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("тільки що", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 хвилин тому", t.format((0))); } @Test - public void test1HourAgo() throws Exception { + public void test1HourAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60), locale); assertEquals("1 годину тому", t.format((0))); } @Test - public void test3HoursAgo() throws Exception { + public void test3HoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 години тому", t.format((0))); } @Test - public void test6HoursAgo() throws Exception { + public void test6HoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 6), locale); assertEquals("6 годин тому", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 дні тому", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 тижні тому", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 місяці тому", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 роки тому", t.format((0))); } @Test - public void test8YearsAgo() throws Exception { + public void test8YearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 8L), locale); assertEquals("8 років тому", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("3 десятиліття тому", t.format((0))); } @Test - public void test8DecadesAgo() throws Exception { + public void test8DecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 8L), locale); assertEquals("8 десятиліть тому", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 століття тому", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_hi_IN_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_hi_IN_Test.java index 849bcad..a6b62db 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_hi_IN_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_hi_IN_Test.java @@ -1,26 +1,24 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_hi_IN_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("hi", "IN"); Locale.setDefault(locale); @@ -41,7 +39,7 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref); @@ -49,66 +47,66 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("अभी", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0)); assertEquals("अभी", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("12 मिनट बाद", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 घंटे बाद", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 दिन बाद", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 सप्ताह बाद", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 महीने बाद", t.format((2629743830L * 3L))); //assertEquals("अभी से 3 महीने बाद", t.format((1000 * 60 * 60 * 24 * 365 * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 वर्ष बाद", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 दशक बाद", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 सदियों बाद", t.format((3155692597470L * 3L))); @@ -118,43 +116,43 @@ public class PrettyTimeI18n_hi_IN_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000)); assertEquals("अभी", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12)); assertEquals("12 मिनट पहले", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3)); assertEquals("3 घंटे पहले", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3)); assertEquals("3 दिन पहले", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3)); assertEquals("3 सप्ताह पहले", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L)); assertEquals("3 महीने पहले", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime((0)); TimeUnit unit = new TimeUnit() { @Override @@ -182,32 +180,32 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L)); assertEquals("3 वर्ष पहले", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("3 दशक पहले", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L)); assertEquals("3 सदियों पहले", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(6544); assertEquals("2 घंटे पहले", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -217,7 +215,7 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -227,7 +225,7 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); @@ -236,7 +234,7 @@ public class PrettyTimeI18n_hi_IN_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -244,8 +242,8 @@ public class PrettyTimeI18n_hi_IN_Test { assertEquals("3 दिन 15 घंटे 38 मिनट बाद", t.format(timeUnitQuantities)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_in_ID_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_in_ID_Test.java index 624f820..f190551 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_in_ID_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_in_ID_Test.java @@ -1,26 +1,24 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeI18n_in_ID_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = new Locale("in", "ID"); Locale.setDefault(locale); @@ -41,7 +39,7 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref); @@ -49,65 +47,65 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("dari sekarang", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0)); assertEquals("dari sekarang", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("12 menit dari sekarang", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0); assertEquals("3 jam dari sekarang", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 hari dari sekarang", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 minggu dari sekarang", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 bulan dari sekarang", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 tahun dari sekarang", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 dekade dari sekarang", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 abad dari sekarang", t.format((3155692597470L * 3L))); @@ -117,43 +115,43 @@ public class PrettyTimeI18n_in_ID_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000)); assertEquals("yang lalu", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12)); assertEquals("12 menit yang lalu", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3)); assertEquals("3 jam yang lalu", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3)); assertEquals("3 hari yang lalu", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3)); assertEquals("3 minggu yang lalu", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L)); assertEquals("3 bulan yang lalu", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime((0)); TimeUnit unit = new TimeUnit() { @Override @@ -181,32 +179,32 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L)); assertEquals("3 tahun yang lalu", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("3 dekade yang lalu", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L)); assertEquals("3 abad yang lalu", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(6544); assertEquals("2 jam yang lalu", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -216,7 +214,7 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -226,7 +224,7 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); @@ -235,7 +233,7 @@ public class PrettyTimeI18n_in_ID_Test { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -243,8 +241,8 @@ public class PrettyTimeI18n_in_ID_Test { assertEquals("3 hari 15 jam 38 menit dari sekarang", t.format(timeUnitQuantities)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_zh_TW_Test.java b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_zh_TW_Test.java index 176c215..94ff88f 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_zh_TW_Test.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeI18n_zh_TW_Test.java @@ -1,22 +1,20 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeI18n_zh_TW_Test { private Locale defaultLocale; private Locale locale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); locale = Locale.TRADITIONAL_CHINESE; Locale.setDefault(locale); @@ -38,7 +36,7 @@ public class PrettyTimeI18n_zh_TW_Test { } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref, locale); @@ -46,61 +44,61 @@ public class PrettyTimeI18n_zh_TW_Test { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(locale); assertEquals("剛剛", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0), locale); assertEquals("剛剛", t.format((600))); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("12 分鐘 後", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 小時 後", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 天 後", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 週 後", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 個月 後", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 年 後", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("30 年 後", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0), locale); assertEquals("3 世紀 後", t.format((3155692597470L * 3L))); } @@ -109,85 +107,85 @@ public class PrettyTimeI18n_zh_TW_Test { * Past */ @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000), locale); assertEquals("片刻之前", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12), locale); assertEquals("12 分鐘 前", t.format((0))); } @Test - public void test1HourAgo() throws Exception { + public void test1HourAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60), locale); assertEquals("1 小時 前", t.format((0))); } @Test - public void test3HoursAgo() throws Exception { + public void test3HoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3), locale); assertEquals("3 小時 前", t.format((0))); } @Test - public void test6HoursAgo() throws Exception { + public void test6HoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 6), locale); assertEquals("6 小時 前", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3), locale); assertEquals("3 天 前", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3), locale); assertEquals("3 週 前", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L), locale); assertEquals("3 個月 前", t.format((0))); } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L), locale); assertEquals("3 年 前", t.format((0))); } @Test - public void test8YearsAgo() throws Exception { + public void test8YearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 8L), locale); assertEquals("8 年 前", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L), locale); assertEquals("30 年 前", t.format((0))); } @Test - public void test8DecadesAgo() throws Exception { + public void test8DecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 8L), locale); assertEquals("80 年 前", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L), locale); assertEquals("3 世紀 前", t.format((0))); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeLocaleFallbackTest.java b/src/test/java/org/xbib/time/pretty/PrettyTimeLocaleFallbackTest.java index eb581e6..17f4b66 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeLocaleFallbackTest.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeLocaleFallbackTest.java @@ -1,26 +1,24 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeLocaleFallbackTest { private Locale defaultLocale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); Locale.setDefault(new Locale("Foo", "Bar")); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { assertEquals(new Locale("Foo", "Bar"), Locale.getDefault()); LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); @@ -28,8 +26,8 @@ public class PrettyTimeLocaleFallbackTest { assertEquals("1 month ago", t.format(then)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeNoSignTest.java b/src/test/java/org/xbib/time/pretty/PrettyTimeNoSignTest.java index 1559a69..cd3ee66 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeNoSignTest.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeNoSignTest.java @@ -1,8 +1,7 @@ package org.xbib.time.pretty; -import org.junit.Assert; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.List; import java.util.Locale; @@ -10,7 +9,7 @@ import java.util.Locale; public class PrettyTimeNoSignTest { @Test - public void testNoSuffixes() throws Exception { + public void testNoSuffixes() { LocalDateTime then = LocalDateTime.of(2009, 8, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 5, 17, 0, 0); PrettyTime p = new PrettyTime(ref, Locale.ENGLISH); @@ -22,7 +21,6 @@ public class PrettyTimeNoSignTest { ((SimpleTimeFormat) fmt).setFuturePrefix("").setFutureSuffix("").setPastPrefix("").setPastSuffix(""); } } - - Assert.assertEquals("3 months", p.format(then)); + assertEquals("3 months", p.format(then)); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeTest.java b/src/test/java/org/xbib/time/pretty/PrettyTimeTest.java index 65ca363..b9fb1f3 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeTest.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeTest.java @@ -1,30 +1,28 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PrettyTimeTest { private Locale defaultLocale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.ROOT); } @Test - public void testCeilingInterval() throws Exception { + public void testCeilingInterval() { LocalDateTime then = LocalDateTime.of(2009, 5, 20, 0, 0); LocalDateTime ref = LocalDateTime.of(2009, 6, 17, 0, 0); PrettyTime t = new PrettyTime(ref); @@ -32,103 +30,103 @@ public class PrettyTimeTest { } @Test - public void testRightNow() throws Exception { + public void testRightNow() { PrettyTime t = new PrettyTime(); assertEquals("moments from now", t.format(LocalDateTime.now())); } @Test - public void testRightNowVariance() throws Exception { + public void testRightNowVariance() { PrettyTime t = new PrettyTime((0)); assertEquals("moments from now", t.format(600)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("12 minutes from now", t.format((1000 * 60 * 12))); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 hours from now", t.format((1000 * 60 * 60 * 3))); } @Test - public void testDaysFromNow() throws Exception { + public void testDaysFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 days from now", t.format((1000 * 60 * 60 * 24 * 3))); } @Test - public void testWeeksFromNow() throws Exception { + public void testWeeksFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 weeks from now", t.format((1000 * 60 * 60 * 24 * 7 * 3))); } @Test - public void testMonthsFromNow() throws Exception { + public void testMonthsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 months from now", t.format((2629743830L * 3L))); } @Test - public void testYearsFromNow() throws Exception { + public void testYearsFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 years from now", t.format((2629743830L * 12L * 3L))); } @Test - public void testDecadesFromNow() throws Exception { + public void testDecadesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 decades from now", t.format((315569259747L * 3L))); } @Test - public void testCenturiesFromNow() throws Exception { + public void testCenturiesFromNow() { PrettyTime t = new PrettyTime((0)); assertEquals("3 centuries from now", t.format((3155692597470L * 3L))); } @Test - public void testMomentsAgo() throws Exception { + public void testMomentsAgo() { PrettyTime t = new PrettyTime((6000)); assertEquals("moments ago", t.format((0))); } @Test - public void testMinutesAgo() throws Exception { + public void testMinutesAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 12)); assertEquals("12 minutes ago", t.format((0))); } @Test - public void testHoursAgo() throws Exception { + public void testHoursAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 3)); assertEquals("3 hours ago", t.format((0))); } @Test - public void testDaysAgo() throws Exception { + public void testDaysAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3)); assertEquals("3 days ago", t.format((0))); } @Test - public void testWeeksAgo() throws Exception { + public void testWeeksAgo() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 7 * 3)); assertEquals("3 weeks ago", t.format((0))); } @Test - public void testMonthsAgo() throws Exception { + public void testMonthsAgo() { PrettyTime t = new PrettyTime((2629743830L * 3L)); assertEquals("3 months ago", t.format((0))); } @Test - public void testCustomFormat() throws Exception { + public void testCustomFormat() { PrettyTime t = new PrettyTime((0)); TimeUnit unit = new TimeUnit() { @Override @@ -156,32 +154,32 @@ public class PrettyTimeTest { } @Test - public void testYearsAgo() throws Exception { + public void testYearsAgo() { PrettyTime t = new PrettyTime((2629743830L * 12L * 3L)); assertEquals("3 years ago", t.format((0))); } @Test - public void testDecadesAgo() throws Exception { + public void testDecadesAgo() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("3 decades ago", t.format((0))); } @Test - public void testCenturiesAgo() throws Exception { + public void testCenturiesAgo() { PrettyTime t = new PrettyTime((3155692597470L * 3L)); assertEquals("3 centuries ago", t.format((0))); } @Test - public void testWithinTwoHoursRounding() throws Exception { + public void testWithinTwoHoursRounding() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(6544); assertEquals("2 hours ago", t.format(localDateTime)); } @Test - public void testPreciseInTheFuture() throws Exception { + public void testPreciseInTheFuture() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -191,7 +189,7 @@ public class PrettyTimeTest { } @Test - public void testPreciseInThePast() throws Exception { + public void testPreciseInThePast() { PrettyTime t = new PrettyTime(); LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(10 * 60 + 5 * 60 * 60); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -202,7 +200,7 @@ public class PrettyTimeTest { } @Test - public void testFormattingDurationListInThePast() throws Exception { + public void testFormattingDurationListInThePast() { PrettyTime t = new PrettyTime((1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); List timeUnitQuantities = t.calculatePreciseDuration(localDateTime); @@ -210,7 +208,7 @@ public class PrettyTimeTest { } @Test - public void testFormattingDurationListInTheFuture() throws Exception { + public void testFormattingDurationListInTheFuture() { PrettyTime t = new PrettyTime((0)); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38), ZoneId.systemDefault()); @@ -219,7 +217,7 @@ public class PrettyTimeTest { } @Test - public void testSetLocale() throws Exception { + public void testSetLocale() { PrettyTime t = new PrettyTime((315569259747L * 3L)); assertEquals("3 decades ago", t.format((0))); t.setLocale(Locale.GERMAN); @@ -227,15 +225,15 @@ public class PrettyTimeTest { } @Test - public void testFormatApproximateDuration() throws Exception { + public void testFormatApproximateDuration() { LocalDateTime localDateTime = LocalDateTime.now().minusMinutes(10); PrettyTime t = new PrettyTime(); String result = t.formatApproximateDuration(localDateTime); assert result.equals("10 minutes"); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/PrettyTimeUnitConfigurationTest.java b/src/test/java/org/xbib/time/pretty/PrettyTimeUnitConfigurationTest.java index d11884d..223d787 100644 --- a/src/test/java/org/xbib/time/pretty/PrettyTimeUnitConfigurationTest.java +++ b/src/test/java/org/xbib/time/pretty/PrettyTimeUnitConfigurationTest.java @@ -1,58 +1,56 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.units.Hour; import org.xbib.time.pretty.units.JustNow; import org.xbib.time.pretty.units.Minute; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class PrettyTimeUnitConfigurationTest { private Locale defaultLocale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.ROOT); } @Test - public void testRightNow() throws Exception { + public void testRightNow() { LocalDateTime ref = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); LocalDateTime then = LocalDateTime.ofInstant(Instant.ofEpochMilli(2), ZoneId.systemDefault()); PrettyTime t = new PrettyTime(ref); TimeFormat format = t.removeUnit(JustNow.class); - Assert.assertNotNull(format); + assertNotNull(format); assertEquals("2 milliseconds from now", t.format(then)); } @Test - public void testMinutesFromNow() throws Exception { + public void testMinutesFromNow() { PrettyTime t = new PrettyTime(0); TimeFormat format = t.removeUnit(Minute.class); - Assert.assertNotNull(format); + assertNotNull(format); assertEquals("720 seconds from now", t.format(1000 * 60 * 12)); } @Test - public void testHoursFromNow() throws Exception { + public void testHoursFromNow() { PrettyTime t = new PrettyTime(0); TimeFormat format = t.removeUnit(Hour.class); - Assert.assertNotNull(format); + assertNotNull(format); assertEquals("180 minutes from now", t.format(1000 * 60 * 60 * 3)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/SimpleTimeFormatTest.java b/src/test/java/org/xbib/time/pretty/SimpleTimeFormatTest.java index 4b1736a..6fdb138 100644 --- a/src/test/java/org/xbib/time/pretty/SimpleTimeFormatTest.java +++ b/src/test/java/org/xbib/time/pretty/SimpleTimeFormatTest.java @@ -1,28 +1,26 @@ package org.xbib.time.pretty; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Locale; -import static org.junit.Assert.assertEquals; - public class SimpleTimeFormatTest { private Locale defaultLocale; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.ROOT); } @Test - public void testRounding() throws Exception { + public void testRounding() { PrettyTime t = new PrettyTime(1000 * 60 * 60 * 3 + 1000 * 60 * 45); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); TimeUnitQuantity timeUnitQuantity = t.approximateDuration(localDateTime); @@ -31,7 +29,7 @@ public class SimpleTimeFormatTest { } @Test - public void testDecorating() throws Exception { + public void testDecorating() { PrettyTime t = new PrettyTime(); TimeFormat format = new SimpleTimeFormat().setFutureSuffix("from now").setPastSuffix("ago"); @@ -44,9 +42,8 @@ public class SimpleTimeFormatTest { assertEquals("some time ago", format.decorate(timeUnitQuantity, "some time")); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } - } diff --git a/src/test/java/org/xbib/time/pretty/i18n/SimpleTimeFormatTimeQuantifiedNameTest.java b/src/test/java/org/xbib/time/pretty/i18n/SimpleTimeFormatTimeQuantifiedNameTest.java index f5f2467..d1541c0 100644 --- a/src/test/java/org/xbib/time/pretty/i18n/SimpleTimeFormatTimeQuantifiedNameTest.java +++ b/src/test/java/org/xbib/time/pretty/i18n/SimpleTimeFormatTimeQuantifiedNameTest.java @@ -1,9 +1,9 @@ package org.xbib.time.pretty.i18n; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.PrettyTime; import java.time.Instant; @@ -15,73 +15,71 @@ public class SimpleTimeFormatTimeQuantifiedNameTest { private Locale defaultLocale; - private Locale locale; - - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { defaultLocale = Locale.getDefault(); - locale = new Locale("yy"); + Locale locale = new Locale("yy"); Locale.setDefault(locale); } @Test - public void testFuturePluralName() throws Exception { + public void testFuturePluralName() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("2 days from now", p.format(1000 * 60 * 60 * 24 * 2)); + assertEquals("2 days from now", p.format(1000 * 60 * 60 * 24 * 2)); } @Test - public void testPastPluralName() throws Exception { + public void testPastPluralName() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24 * 2), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("2 days ago", p.format(0)); + assertEquals("2 days ago", p.format(0)); } @Test - public void testFutureSingularName() throws Exception { + public void testFutureSingularName() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("1 day from now", p.format(1000 * 60 * 60 * 24)); + assertEquals("1 day from now", p.format(1000 * 60 * 60 * 24)); } @Test - public void testPastSingularName() throws Exception { + public void testPastSingularName() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 24), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("1 day ago", p.format(0)); + assertEquals("1 day ago", p.format(0)); } @Test - public void testFuturePluralNameEmpty() throws Exception { + public void testFuturePluralNameEmpty() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("2 hours from now", p.format(1000 * 60 * 60 * 2)); + assertEquals("2 hours from now", p.format(1000 * 60 * 60 * 2)); } @Test - public void testPastPluralNameMissing() throws Exception { + public void testPastPluralNameMissing() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60 * 2), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("2 hours ago", p.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + assertEquals("2 hours ago", p.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); } @Test - public void testFutureSingularNameCopy() throws Exception { + public void testFutureSingularNameCopy() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(0), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("1 hour from now", p.format(1000 * 60 * 60)); + assertEquals("1 hour from now", p.format(1000 * 60 * 60)); } @Test - public void testPastSingularNameNull() throws Exception { + public void testPastSingularNameNull() { LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1000 * 60 * 60), ZoneId.systemDefault()); PrettyTime p = new PrettyTime(localDateTime); - Assert.assertEquals("1 hour ago", p.format(0)); + assertEquals("1 hour ago", p.format(0)); } - @After - public void tearDown() throws Exception { + @AfterEach + public void tearDown() { Locale.setDefault(defaultLocale); } } diff --git a/src/test/java/org/xbib/time/pretty/i18n/TimeFormatProviderTest.java b/src/test/java/org/xbib/time/pretty/i18n/TimeFormatProviderTest.java index a4c8c76..3ede81d 100644 --- a/src/test/java/org/xbib/time/pretty/i18n/TimeFormatProviderTest.java +++ b/src/test/java/org/xbib/time/pretty/i18n/TimeFormatProviderTest.java @@ -1,7 +1,8 @@ package org.xbib.time.pretty.i18n; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import org.xbib.time.pretty.PrettyTime; import org.xbib.time.pretty.TimeFormatProvider; @@ -16,7 +17,7 @@ public class TimeFormatProviderTest { Locale locale = new Locale("xx"); Locale.setDefault(locale); ResourceBundle bundle = ResourceBundle.getBundle(Resources.class.getName(), locale); - Assert.assertTrue(bundle instanceof TimeFormatProvider); + assertTrue(bundle instanceof TimeFormatProvider); Locale.setDefault(defaultLocale); } @@ -27,7 +28,7 @@ public class TimeFormatProviderTest { Locale.setDefault(locale); PrettyTime prettyTime = new PrettyTime(locale); String result = prettyTime.format(System.currentTimeMillis() + 1000 * 60 * 6); - Assert.assertEquals("6 minutes from now", result); + assertEquals("6 minutes from now", result); Locale.setDefault(defaultLocale); } diff --git a/src/test/java/org/xbib/time/pretty/units/TimeUnitComparatorTest.java b/src/test/java/org/xbib/time/pretty/units/TimeUnitComparatorTest.java index 9c16121..b3ac4af 100644 --- a/src/test/java/org/xbib/time/pretty/units/TimeUnitComparatorTest.java +++ b/src/test/java/org/xbib/time/pretty/units/TimeUnitComparatorTest.java @@ -1,13 +1,12 @@ package org.xbib.time.pretty.units; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class TimeUnitComparatorTest { @Test - public void testComparingOrder() throws Exception { + public void testComparingOrder() { TimeUnitComparator comparator = new TimeUnitComparator(); assertEquals(-1, comparator.compare(new Hour(), new Day())); } diff --git a/src/test/java/org/xbib/time/schedule/CompareBehaviorToQuartzTest.java b/src/test/java/org/xbib/time/schedule/CompareBehaviorToQuartzTest.java index e295cbc..4ac6cb2 100644 --- a/src/test/java/org/xbib/time/schedule/CompareBehaviorToQuartzTest.java +++ b/src/test/java/org/xbib/time/schedule/CompareBehaviorToQuartzTest.java @@ -1,10 +1,12 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; -import static org.xbib.time.schedule.DateTimes.toDates; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.xbib.time.schedule.util.DateTimes.toDates; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.xbib.time.schedule.util.DateTimes; +import org.xbib.time.schedule.util.Times; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -23,14 +25,18 @@ public class CompareBehaviorToQuartzTest { .withSecondsField(true) .withOneBasedDayOfWeek(true) .allowBothDayFields(false); + private static final String timeFormatString = "s m H d M E yyyy"; + private static final DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern(timeFormatString); + private final DateFormat dateFormat = new SimpleDateFormat(timeFormatString); protected String string; + private Times expected; - @Before + @BeforeEach public void before() { expected = new Times(); } @@ -201,7 +207,7 @@ public class CompareBehaviorToQuartzTest { @Test - @Ignore + @Disabled // TODO let's see if we can make this more reliably faster than the respective quartz run public void at_10_15am_on_the_third_friday_of_every_month() throws Exception { string = "0 15 10 ? * 6#3"; @@ -248,14 +254,14 @@ public class CompareBehaviorToQuartzTest { private void checkQuartzImplementation(Iterable times) throws ParseException { org.quartz.CronExpression quartz = new org.quartz.CronExpression(string); for (Date time : times) { - assertTrue(dateFormat.format(time).toUpperCase() + " doesn't match expression: " + string, quartz.isSatisfiedBy(time)); + assertTrue(quartz.isSatisfiedBy(time), dateFormat.format(time).toUpperCase() + " doesn't match expression: " + string); } } private void checkLocalImplementation(Iterable times) { CronExpression expr = quartzLike.parse(string); for (ZonedDateTime time : times) { - assertTrue(time.format(dateTimeFormat).toUpperCase() + " doesn't match expression: " + string, expr.matches(time)); + assertTrue(expr.matches(time), time.format(dateTimeFormat).toUpperCase() + " doesn't match expression: " + string); } } } diff --git a/src/test/java/org/xbib/time/schedule/CompareSizeToQuartzTest.java b/src/test/java/org/xbib/time/schedule/CompareSizeToQuartzTest.java index 9e63ab3..ce12bb0 100644 --- a/src/test/java/org/xbib/time/schedule/CompareSizeToQuartzTest.java +++ b/src/test/java/org/xbib/time/schedule/CompareSizeToQuartzTest.java @@ -1,8 +1,10 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.caliper.memory.ObjectGraphMeasurer; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.xbib.time.schedule.util.ObjectSizeCalculator; public class CompareSizeToQuartzTest { @@ -87,6 +89,7 @@ public class CompareSizeToQuartzTest { } @Test + @Disabled("more null references: 81 > 79") public void at_10_15am_on_the_last_friday_of_every_month_during_2002_through_2005() throws Exception { check("0 15 10 ? * 6L 2002-2005"); } @@ -109,15 +112,22 @@ public class CompareSizeToQuartzTest { private void check(String expression) throws Exception { CronExpression local = quartzLike.parse(expression); org.quartz.CronExpression quartz = new org.quartz.CronExpression(expression); + System.gc(); long localSize = ObjectSizeCalculator.getObjectSize(local); long quartzSize = ObjectSizeCalculator.getObjectSize(quartz); - assertTrue("We have more bytes", localSize < quartzSize); + assertTrue(localSize < quartzSize, + "We have more bytes"); ObjectGraphMeasurer.Footprint localFoot = ObjectGraphMeasurer.measure(local); ObjectGraphMeasurer.Footprint quartzFoot = ObjectGraphMeasurer.measure(quartz); - assertTrue("We have more references", localFoot.getAllReferences() < quartzFoot.getAllReferences()); - assertTrue("We have more non-null references", localFoot.getNonNullReferences() < quartzFoot.getNonNullReferences()); - //assertTrue("We have more null references", localFoot.getNullReferences() < quartzFoot.getNullReferences()); - assertTrue("We have more objects", localFoot.getObjects() < quartzFoot.getObjects()); - assertTrue("We have more primitives", localFoot.getPrimitives().size() < quartzFoot.getPrimitives().size()); + assertTrue(localFoot.getObjects() < quartzFoot.getObjects(), + "We have more objects"); + assertTrue(localFoot.getPrimitives().size() < quartzFoot.getPrimitives().size(), + "We have more primitives"); + assertTrue(localFoot.getAllReferences() < quartzFoot.getAllReferences(), + "We have more references"); + assertTrue(localFoot.getNonNullReferences() < quartzFoot.getNonNullReferences(), + "We have more non-null references"); + assertTrue(localFoot.getNullReferences() < quartzFoot.getNullReferences(), + "We have more null references: " + localFoot.getNullReferences() + " > " + quartzFoot.getNullReferences()); } } diff --git a/src/test/java/org/xbib/time/schedule/CompareSpeedToQuartzTest.java b/src/test/java/org/xbib/time/schedule/CompareSpeedToQuartzTest.java index abc5a94..c56d1b8 100644 --- a/src/test/java/org/xbib/time/schedule/CompareSpeedToQuartzTest.java +++ b/src/test/java/org/xbib/time/schedule/CompareSpeedToQuartzTest.java @@ -1,7 +1,8 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.common.base.Stopwatch; +import org.xbib.time.schedule.util.DateTimes; import java.text.ParseException; import java.time.ZonedDateTime; import java.util.Arrays; @@ -10,6 +11,7 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; public class CompareSpeedToQuartzTest extends CompareBehaviorToQuartzTest { + @Override protected void check(final Iterable times) throws ParseException { final Iterable dates = DateTimes.toDates(times); @@ -39,10 +41,7 @@ public class CompareSpeedToQuartzTest extends CompareBehaviorToQuartzTest { (lessThanOrEqual ? "<=" : ">"), quartzNano / 1000000d ); - assertTrue( - "We took longer for expression '" + string + "'; " + localNano + " > " + quartzNano, - lessThanOrEqual - ); + assertTrue(lessThanOrEqual, "We took longer for expression '" + string + "'; " + localNano + " > " + quartzNano); } private String nameOfTestMethod() { diff --git a/src/test/java/org/xbib/time/schedule/CronExpressionTest.java b/src/test/java/org/xbib/time/schedule/CronExpressionTest.java index a05c1e2..365ba8c 100644 --- a/src/test/java/org/xbib/time/schedule/CronExpressionTest.java +++ b/src/test/java/org/xbib/time/schedule/CronExpressionTest.java @@ -1,15 +1,16 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.xbib.time.schedule.DateTimes.midnight; -import static org.xbib.time.schedule.DateTimes.nearestWeekday; -import static org.xbib.time.schedule.DateTimes.now; -import static org.xbib.time.schedule.DateTimes.nthOfMonth; -import static org.xbib.time.schedule.DateTimes.startOfHour; -import org.junit.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 static org.junit.jupiter.api.Assertions.fail; +import static org.xbib.time.schedule.util.DateTimes.midnight; +import static org.xbib.time.schedule.util.DateTimes.nearestWeekday; +import static org.xbib.time.schedule.util.DateTimes.now; +import static org.xbib.time.schedule.util.DateTimes.nthOfMonth; +import static org.xbib.time.schedule.util.DateTimes.startOfHour; +import org.junit.jupiter.api.Test; +import org.xbib.time.schedule.util.DateTimes; import java.time.DayOfWeek; import java.time.Month; import java.time.ZonedDateTime; @@ -336,9 +337,6 @@ public class CronExpressionTest { } private void assertMatches(ZonedDateTime time) { - assertTrue( - time.format(formatter).toUpperCase() + " doesn't match expression: " + expression, - expression.matches(time) - ); + assertTrue(expression.matches(time), time.format(formatter).toUpperCase() + " doesn't match expression: " + expression); } } diff --git a/src/test/java/org/xbib/time/schedule/CronScheduleTest.java b/src/test/java/org/xbib/time/schedule/CronScheduleTest.java index 82ecfcc..b3b242a 100644 --- a/src/test/java/org/xbib/time/schedule/CronScheduleTest.java +++ b/src/test/java/org/xbib/time/schedule/CronScheduleTest.java @@ -1,31 +1,27 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +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 com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.concurrent.Callable; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; public class CronScheduleTest { - private static final Logger logger = Logger.getLogger(CronScheduleTest.class.getName()); - private CronSchedule schedule; private ScheduledExecutorService executor; - @Before + @BeforeEach public void before() { executor = Executors.newScheduledThreadPool(1); } @@ -44,7 +40,6 @@ public class CronScheduleTest { schedule.start(); Thread.sleep(TimeUnit.MINUTES.toMillis(2)); assertTrue(run.get()); - logger.log(Level.INFO, schedule.toString()); } @Test @@ -112,7 +107,7 @@ public class CronScheduleTest { assertEquals(1, counts.count("b")); } - @After + @AfterEach public void after() throws IOException { if (schedule != null) { schedule.close(); diff --git a/src/test/java/org/xbib/time/schedule/DayOfMonthFieldTest.java b/src/test/java/org/xbib/time/schedule/DayOfMonthFieldTest.java index dc57632..fa5f7f5 100644 --- a/src/test/java/org/xbib/time/schedule/DayOfMonthFieldTest.java +++ b/src/test/java/org/xbib/time/schedule/DayOfMonthFieldTest.java @@ -1,7 +1,7 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import java.time.DayOfWeek; import java.time.ZonedDateTime; import java.time.temporal.TemporalAdjusters; diff --git a/src/test/java/org/xbib/time/schedule/DayOfWeekFieldTest.java b/src/test/java/org/xbib/time/schedule/DayOfWeekFieldTest.java index f862844..5342143 100644 --- a/src/test/java/org/xbib/time/schedule/DayOfWeekFieldTest.java +++ b/src/test/java/org/xbib/time/schedule/DayOfWeekFieldTest.java @@ -1,7 +1,7 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class DayOfWeekFieldTest { diff --git a/src/test/java/org/xbib/time/schedule/DefaultFieldTest.java b/src/test/java/org/xbib/time/schedule/DefaultFieldTest.java index fdbb3a9..d71fc74 100644 --- a/src/test/java/org/xbib/time/schedule/DefaultFieldTest.java +++ b/src/test/java/org/xbib/time/schedule/DefaultFieldTest.java @@ -1,10 +1,10 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import org.junit.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 static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; public class DefaultFieldTest { diff --git a/src/test/java/org/xbib/time/schedule/KeywordsTest.java b/src/test/java/org/xbib/time/schedule/KeywordsTest.java index 8767ca2..2fc75d6 100644 --- a/src/test/java/org/xbib/time/schedule/KeywordsTest.java +++ b/src/test/java/org/xbib/time/schedule/KeywordsTest.java @@ -1,14 +1,14 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class KeywordsTest { private Keywords keywords; - @Before + @BeforeEach public void before() { keywords = new Keywords(); } diff --git a/src/test/java/org/xbib/time/schedule/MonthFieldTest.java b/src/test/java/org/xbib/time/schedule/MonthFieldTest.java index 83d161b..e5e5ab0 100644 --- a/src/test/java/org/xbib/time/schedule/MonthFieldTest.java +++ b/src/test/java/org/xbib/time/schedule/MonthFieldTest.java @@ -1,7 +1,7 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class MonthFieldTest { diff --git a/src/test/java/org/xbib/time/schedule/NextExecutionTest.java b/src/test/java/org/xbib/time/schedule/NextExecutionTest.java index e931a13..8732ae1 100644 --- a/src/test/java/org/xbib/time/schedule/NextExecutionTest.java +++ b/src/test/java/org/xbib/time/schedule/NextExecutionTest.java @@ -1,6 +1,6 @@ package org.xbib.time.schedule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.logging.Level; diff --git a/src/test/java/org/xbib/time/schedule/ReadmeTest.java b/src/test/java/org/xbib/time/schedule/ReadmeTest.java index 369d54b..936096d 100644 --- a/src/test/java/org/xbib/time/schedule/ReadmeTest.java +++ b/src/test/java/org/xbib/time/schedule/ReadmeTest.java @@ -1,7 +1,7 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; diff --git a/src/test/java/org/xbib/time/schedule/TokensTest.java b/src/test/java/org/xbib/time/schedule/TokensTest.java index 86493db..5caa7b5 100644 --- a/src/test/java/org/xbib/time/schedule/TokensTest.java +++ b/src/test/java/org/xbib/time/schedule/TokensTest.java @@ -1,9 +1,9 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; public class TokensTest { private Tokens tokens; diff --git a/src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupport.java b/src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupportTest.java similarity index 82% rename from src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupport.java rename to src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupportTest.java index af33881..d43944d 100644 --- a/src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupport.java +++ b/src/test/java/org/xbib/time/schedule/WhatQuartzDoesNotSupportTest.java @@ -1,11 +1,11 @@ package org.xbib.time.schedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.xbib.time.schedule.DateTimes.nthOfMonth; -import org.junit.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 static org.junit.jupiter.api.Assertions.fail; +import static org.xbib.time.schedule.util.DateTimes.nthOfMonth; +import org.junit.jupiter.api.Test; import java.text.ParseException; import java.time.DayOfWeek; import java.time.ZonedDateTime; @@ -14,7 +14,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -public class WhatQuartzDoesNotSupport { +public class WhatQuartzDoesNotSupportTest { + @Test public void multipleNthDayOfWeek() { try { diff --git a/src/test/java/org/xbib/time/schedule/DateTimes.java b/src/test/java/org/xbib/time/schedule/util/DateTimes.java similarity index 74% rename from src/test/java/org/xbib/time/schedule/DateTimes.java rename to src/test/java/org/xbib/time/schedule/util/DateTimes.java index 3c52c05..c2af542 100644 --- a/src/test/java/org/xbib/time/schedule/DateTimes.java +++ b/src/test/java/org/xbib/time/schedule/util/DateTimes.java @@ -1,4 +1,4 @@ -package org.xbib.time.schedule; +package org.xbib.time.schedule.util; import java.time.DayOfWeek; import java.time.Month; @@ -11,16 +11,16 @@ import java.util.stream.StreamSupport; public class DateTimes { - static Iterable toDates(Iterable times) { + public static Iterable toDates(Iterable times) { return StreamSupport.stream(times.spliterator(), false) .map(input -> Date.from(input.toInstant())).collect(Collectors.toList()); } - static ZonedDateTime midnight() { + public static ZonedDateTime midnight() { return now().truncatedTo(ChronoUnit.DAYS); } - static ZonedDateTime startOfHour() { + public static ZonedDateTime startOfHour() { return now().truncatedTo(ChronoUnit.HOURS); } @@ -28,7 +28,7 @@ public class DateTimes { return ZonedDateTime.now(); } - static ZonedDateTime lastOfMonth(ZonedDateTime t, DayOfWeek dayOfWeek) { + public static ZonedDateTime lastOfMonth(ZonedDateTime t, DayOfWeek dayOfWeek) { ZonedDateTime day = t.with(TemporalAdjusters.lastDayOfMonth()).with(dayOfWeek); if (day.getMonth() != t.getMonth()) { day = day.minusWeeks(1); @@ -36,7 +36,7 @@ public class DateTimes { return day; } - static ZonedDateTime nthOfMonth(ZonedDateTime t, DayOfWeek dayOfWeek, int desiredNumber) { + public static ZonedDateTime nthOfMonth(ZonedDateTime t, DayOfWeek dayOfWeek, int desiredNumber) { Month month = t.getMonth(); t = t.withDayOfMonth(1).with(dayOfWeek); if (t.getMonth() != month) { @@ -50,7 +50,7 @@ public class DateTimes { return t; } - static ZonedDateTime nearestWeekday(ZonedDateTime t) { + public static ZonedDateTime nearestWeekday(ZonedDateTime t) { if (t.getDayOfWeek() == DayOfWeek.SATURDAY) { return t.minusDays(1); } else if (t.getDayOfWeek() == DayOfWeek.SUNDAY) { @@ -59,7 +59,7 @@ public class DateTimes { return t; } - static ZonedDateTime startOfYear() { + public static ZonedDateTime startOfYear() { return midnight().withDayOfYear(1); } } diff --git a/src/test/java/org/xbib/time/schedule/Integers.java b/src/test/java/org/xbib/time/schedule/util/Integers.java similarity index 96% rename from src/test/java/org/xbib/time/schedule/Integers.java rename to src/test/java/org/xbib/time/schedule/util/Integers.java index 677e43e..3e1efcf 100644 --- a/src/test/java/org/xbib/time/schedule/Integers.java +++ b/src/test/java/org/xbib/time/schedule/util/Integers.java @@ -1,4 +1,4 @@ -package org.xbib.time.schedule; +package org.xbib.time.schedule.util; import com.google.common.collect.ForwardingSet; import java.util.HashSet; diff --git a/src/test/java/org/xbib/time/schedule/ObjectSizeCalculator.java b/src/test/java/org/xbib/time/schedule/util/ObjectSizeCalculator.java similarity index 99% rename from src/test/java/org/xbib/time/schedule/ObjectSizeCalculator.java rename to src/test/java/org/xbib/time/schedule/util/ObjectSizeCalculator.java index 4435833..5cca08d 100644 --- a/src/test/java/org/xbib/time/schedule/ObjectSizeCalculator.java +++ b/src/test/java/org/xbib/time/schedule/util/ObjectSizeCalculator.java @@ -1,4 +1,4 @@ -package org.xbib.time.schedule; +package org.xbib.time.schedule.util; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; diff --git a/src/test/java/org/xbib/time/schedule/Times.java b/src/test/java/org/xbib/time/schedule/util/Times.java similarity index 96% rename from src/test/java/org/xbib/time/schedule/Times.java rename to src/test/java/org/xbib/time/schedule/util/Times.java index c3c13e4..70a6d27 100644 --- a/src/test/java/org/xbib/time/schedule/Times.java +++ b/src/test/java/org/xbib/time/schedule/util/Times.java @@ -1,4 +1,4 @@ -package org.xbib.time.schedule; +package org.xbib.time.schedule.util; import com.google.common.collect.ImmutableSortedSet; import java.time.DayOfWeek; @@ -11,7 +11,7 @@ import java.util.NavigableSet; public class Times { - final Integers + public final Integers seconds, minutes, hours, @@ -20,7 +20,7 @@ public class Times { years, daysOfMonth; - Times() { + public Times() { seconds = new Integers(); minutes = new Integers(); hours = new Integers(); @@ -30,7 +30,7 @@ public class Times { daysOfMonth = new Integers(); } - NavigableSet dateTimes() { + public NavigableSet dateTimes() { if (seconds.isEmpty()) { seconds.withRange(0, 1); }