diff --git a/.dependabot/config.yml b/.dependabot/config.yml deleted file mode 100644 index 16be16a270..0000000000 --- a/.dependabot/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: 1 - -update_configs: - - package_manager: "java:gradle" - directory: "/" - update_schedule: "daily" - # Redundant - default repository branch by default - target_branch: "release/3.x" diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index dcb6481825..b9b8948882 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,8 +6,8 @@ **If looking for support** -* Search / Ask question on [stackoverflow](http://stackoverflow.com/questions/tagged/mockito) -* Go to the [mockito mailing-list](http://groups.google.com/group/mockito) (moderated) +* Search / Ask question on [stackoverflow](https://stackoverflow.com/questions/tagged/mockito) +* Go to the [mockito mailing-list](https://groups.google.com/group/mockito) (moderated) * Issues should always have a [Short, Self Contained, Correct (Compilable), Example](http://sscce.org) (same as any question on stackoverflow.com) # Contributing to Mockito @@ -46,7 +46,7 @@ Things we pay attention in a PR : * On pull requests, please document the change, what it brings, what is the benefit. * **Clean commit history** in the topic branch in your fork of the repository, even during review. That means that commits are _rebased_ and _squashed_ if necessary, so that each commit clearly changes one things and there are no extraneous fix-ups. - For that matter it's possible to commit [_semantic_ changes](http://lemike-de.tumblr.com/post/79041908218/semantic-commits). _Tests are an asset, so is history_. + For that matter it's possible to commit [_semantic_ changes](https://lemike-de.tumblr.com/post/79041908218/semantic-commits). _Tests are an asset, so is history_. _Example gratia_: @@ -80,7 +80,7 @@ But first of all, make sure that : * Line ending character is unix-style **`LF`** * New line is added at end of file: `IntelliJ setting > Editor > General > Ensure line feed at file end on save` -For most editors, this should be automatically enforced by [EditorConfig](http://editorconfig.org/). +For most editors, this should be automatically enforced by [EditorConfig](https://editorconfig.org/). Check if your editor has a built-in plugin or if you need to download one. IntelliJ has a built-in plugin, for Eclipse you need to download [this plugin](https://github.com/ncjones/editorconfig-eclipse#readme). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 467f81e489..058a562f95 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,7 +4,7 @@ > > If this is about mockito usage, the better way is to reach out to > -> - stackoverflow : http://stackoverflow.com/questions/tagged/mockito +> - stackoverflow : https://stackoverflow.com/questions/tagged/mockito > - the mailing-list : https://groups.google.com/forum/#!forum/mockito / mockito@googlegroups.com > (Note mailing-list is moderated to avoid spam) > diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..1ef0730a67 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5813dfbc77..8eca81f58c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: run: ./gradlew bintrayUpload githubRelease --scan env: MAVEN_CENTRAL_RELEASE: ${{contains(toJSON(github.event.commits.*.message), '[ci maven-central-release]')}} - GH_WRITE_TOKEN: ${{secrets.GH_WRITE_TOKEN}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} BINTRAY_API_KEY: ${{secrets.BINTRAY_API_KEY}} NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}} NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}} diff --git a/README.md b/README.md index 6774bc92bd..69cd1d4450 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + Mockito @@ -27,16 +27,16 @@ The maintainers of org.mockito:mockito-core and thousands of other packages are ## Development -Mockito [continuously delivers](https://github.com/mockito/mockito/wiki/Continuous-Delivery-Overview) improvements using Shipkit library (http://shipkit.org). See the [latest release notes](https://github.com/mockito/mockito/blob/release/3.x/doc/release-notes/official.md) and [latest documentation](http://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html). Docs in javadoc.io are available 24h after release. Read also about [semantic versioning in Mockito](https://github.com/mockito/mockito/wiki/Semantic-Versioning). **Note: not every version is published to Maven Central.** +Mockito [continuously delivers](https://github.com/mockito/mockito/wiki/Continuous-Delivery-Overview) improvements using Shipkit library (http://shipkit.org). See the [latest release notes](https://github.com/mockito/mockito/blob/release/3.x/doc/release-notes/official.md) and [latest documentation](https://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html). Docs in javadoc.io are available 24h after release. Read also about [semantic versioning in Mockito](https://github.com/mockito/mockito/wiki/Semantic-Versioning). **Note: not every version is published to Maven Central.** Older 1.x and 2.x releases are available in -[Central Repository](http://search.maven.org/#artifactdetails|org.mockito|mockito-core|1.10.19|jar) +[Central Repository](https://search.maven.org/artifact/org.mockito/mockito-core/1.10.19/jar) , [Bintray](https://bintray.com/mockito/maven/mockito/1.10.19/view) -and [javadoc.io](http://javadoc.io/doc/org.mockito/mockito-core/1.10.19/org/mockito/Mockito.html) (documentation). +and [javadoc.io](https://javadoc.io/doc/org.mockito/mockito-core/1.10.19/org/mockito/Mockito.html) (documentation). ## More information -All you want to know about Mockito is hosted at [The Mockito Site](http://site.mockito.org) which is [Open Source](https://github.com/mockito/mockito.github.io) and likes [pull requests](https://github.com/mockito/mockito.github.io/pulls), too. +All you want to know about Mockito is hosted at [The Mockito Site](https://site.mockito.org) which is [Open Source](https://github.com/mockito/mockito.github.io) and likes [pull requests](https://github.com/mockito/mockito.github.io/pulls), too. Want to contribute? Take a look at the [Contributing Guide](https://github.com/mockito/mockito/blob/release/3.x/.github/CONTRIBUTING.md). @@ -44,8 +44,8 @@ Enjoy Mockito! ## Need help? -* Search / Ask question on [stackoverflow](http://stackoverflow.com/questions/tagged/mockito) -* Go to the [mockito mailing-list](http://groups.google.com/group/mockito) (moderated) +* Search / Ask question on [stackoverflow](https://stackoverflow.com/questions/tagged/mockito) +* Go to the [mockito mailing-list](https://groups.google.com/group/mockito) (moderated) * Open a ticket in GitHub [issue tracker](https://github.com/mockito/mockito/issues) ## How to develop Mockito? @@ -67,7 +67,7 @@ Mockito [implements Continuous Delivery model](https://github.com/mockito/mockit Every change on the main branch (for example merging a pull request) triggers a release build on CI. The build publishes new version if specific criteria are met: all tests green, no 'ci skip release' used in commit message, see the build log for more information. Every new version is published to ["mockito/maven" Bintray repository](https://bintray.com/mockito/maven). -New versions that Mockito team deems "notable" are additionally published to [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mockito%22) and [JCenter](https://bintray.com/bintray/jcenter). +New versions that Mockito team deems "notable" are additionally published to [Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mockito%22) and [JCenter](https://bintray.com/bintray/jcenter). We used to publish every version to Maven Central but we changed this strategy based on feedback from the community ([#911](https://github.com/mockito/mockito/issues/911)). * Q: What's new in Mockito release model? diff --git a/build.gradle b/build.gradle index 64b4fe7581..c53b0554d9 100644 --- a/build.gradle +++ b/build.gradle @@ -7,22 +7,22 @@ buildscript { dependencies { classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0' - classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.2.1' + classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0' //Using buildscript.classpath so that we can resolve plugins from maven local, during local testing - classpath "org.shipkit:shipkit-auto-version:0.0.+" - classpath "org.shipkit:shipkit-changelog:0.0.+" + classpath "org.shipkit:shipkit-auto-version:0.+" + classpath "org.shipkit:shipkit-changelog:0.+" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+" - classpath 'com.google.googlejavaformat:google-java-format:1.8' + classpath 'com.google.googlejavaformat:google-java-format:1.9' } } plugins { - id "com.diffplug.gradle.spotless" version "3.24.3" + id "com.diffplug.gradle.spotless" version "4.5.1" id 'eclipse' - id 'com.github.ben-manes.versions' version '0.28.0' - id 'biz.aQute.bnd.builder' version '5.1.0' + id 'com.github.ben-manes.versions' version '0.36.0' + id 'biz.aQute.bnd.builder' version '5.2.0' id 'ru.vyarus.animalsniffer' version '1.5.2' } diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 7c62a4d000..79808ad5ab 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -4,17 +4,17 @@ ext { def versions = [:] -versions.bytebuddy = '1.10.18' -versions.junitJupiter = '5.4.2' +versions.bytebuddy = '1.10.19' +versions.junitJupiter = '5.7.0' versions.errorprone = '2.4.0' -libraries.junit4 = 'junit:junit:4.12' +libraries.junit4 = 'junit:junit:4.13.1' libraries.junitJupiterApi = "org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}" -libraries.junitPlatformLauncher = 'org.junit.platform:junit-platform-launcher:1.1.0' +libraries.junitPlatformLauncher = 'org.junit.platform:junit-platform-launcher:1.7.0' libraries.junitJupiterEngine = "org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}" -libraries.assertj = 'org.assertj:assertj-core:3.16.1' -libraries.hamcrest = 'org.hamcrest:hamcrest-core:1.3' -libraries.opentest4j = 'org.opentest4j:opentest4j:1.1.1' +libraries.assertj = 'org.assertj:assertj-core:3.18.1' +libraries.hamcrest = 'org.hamcrest:hamcrest-core:2.2' +libraries.opentest4j = 'org.opentest4j:opentest4j:1.2.0' libraries.bytebuddy = "net.bytebuddy:byte-buddy:${versions.bytebuddy}" libraries.bytebuddyagent = "net.bytebuddy:byte-buddy-agent:${versions.bytebuddy}" @@ -23,7 +23,7 @@ libraries.bytebuddyandroid = "net.bytebuddy:byte-buddy-android:${versions.bytebu libraries.errorprone = "com.google.errorprone:error_prone_core:${versions.errorprone}" libraries.errorproneTestApi = "com.google.errorprone:error_prone_test_helpers:${versions.errorprone}" -libraries.autoservice = "com.google.auto.service:auto-service:1.0-rc5" +libraries.autoservice = "com.google.auto.service:auto-service:1.0-rc7" // objenesis 3.x fails on android instrumentation test compile. https://github.com/mockito/mockito/issues/2007 libraries.objenesis2 = 'org.objenesis:objenesis:2.6' @@ -31,14 +31,14 @@ libraries.objenesis3 = 'org.objenesis:objenesis:3.1' libraries.asm = 'org.ow2.asm:asm:7.0' -libraries.osgi = 'org.osgi:osgi.core:7.0.0' -libraries.equinox = 'org.eclipse.platform:org.eclipse.osgi:3.15.0' -libraries.bndGradle = 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.1' +libraries.osgi = 'org.osgi:osgi.core:8.0.0' +libraries.equinox = 'org.eclipse.platform:org.eclipse.osgi:3.16.100' +libraries.bndGradle = 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.2.0' -def kotlinVersion = '1.3.72' +def kotlinVersion = '1.4.21-2' libraries.kotlin = [ version: kotlinVersion, stdlib: "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}", - coroutines: 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7', + coroutines: 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2-native-mt', ] diff --git a/gradle/java-publication.gradle b/gradle/java-publication.gradle index e7e03d444c..9fa7d62a5c 100644 --- a/gradle/java-publication.gradle +++ b/gradle/java-publication.gradle @@ -25,6 +25,10 @@ artifacts { archives javadocJar } +tasks.withType(GenerateModuleMetadata) { + enabled = false +} + //Gradle Maven publishing plugin configuration (https://docs.gradle.org/current/userguide/publishing_maven.html) apply plugin: "maven-publish" publishing { diff --git a/gradle/mockito-core/javadoc.gradle b/gradle/mockito-core/javadoc.gradle index 0ed36bb960..3171895693 100644 --- a/gradle/mockito-core/javadoc.gradle +++ b/gradle/mockito-core/javadoc.gradle @@ -41,8 +41,7 @@ javadoc { options.noNavBar = false options.noTree = false options.links = ['https://docs.oracle.com/javase/6/docs/api/', - 'http://junit.org/junit4/javadoc/4.12/', - 'http://hamcrest.org/JavaHamcrest/javadoc/1.3/'] + 'http://junit.org/junit4/javadoc/4.12/'] options.header("""Mockito ${project.version} API""") options.footer("""Mockito ${project.version} API""") options.bottom(""" diff --git a/gradle/mockito-core/osgi.gradle b/gradle/mockito-core/osgi.gradle index 2fa0b78354..0c6f395e8b 100644 --- a/gradle/mockito-core/osgi.gradle +++ b/gradle/mockito-core/osgi.gradle @@ -1,12 +1,3 @@ -import java.nio.file.attribute.FileTime -import java.util.jar.Attributes -import java.util.jar.JarEntry -import java.util.jar.JarFile -import java.util.jar.JarOutputStream -import java.util.jar.Manifest - -import static java.util.Calendar.FEBRUARY - apply plugin: 'biz.aQute.bnd.builder' jar { @@ -14,9 +5,9 @@ jar { bnd( 'Bundle-Name': 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.', 'Bundle-SymbolicName': 'org.mockito.mockito-core', - 'Bundle-Version': project.version.replace('-', '.'), + 'Bundle-Version': "\${version_cleanup;${project.version}}", '-versionpolicy': '[${version;==;${@}},${version;+;${@}})', - 'Export-Package': "!org.mockito.internal.*,org.mockito.*;version=${version}", + 'Export-Package': "org.mockito.internal.*;status=INTERNAL;mandatory:=status;version=${version},org.mockito.*;version=${version}", 'Import-Package': [ 'net.bytebuddy.*;version="[1.6.0,2.0)"', 'junit.*;resolution:=optional', @@ -27,89 +18,7 @@ jar { 'org.mockito.*' ].join(','), '-removeheaders': 'Private-Package', - 'Automatic-Module-Name': 'org.mockito' + 'Automatic-Module-Name': 'org.mockito', + '-noextraheaders': 'true' ) } - -jar.doLast { - JarFile originalJar = new JarFile(jar.archivePath) - - new RemoveOsgiLastModifiedHeader(originalJar) - .transform() - .renameTo jar.archivePath -} - - -/* - * The OSGi plugin in Gradle 5.3 has a known issue (https://github.com/gradle/gradle/issues/6187) where it embeds - * a Manifest entry "Bnd-LastModified" (set to the last modified time of the build directory) even if you ask it not to - * using `-noextraheaders` or `-removeheaders`. - * - * It cannot be pinned or removed, and is a source of non-determinism in the build. - * - * This class addresses the problem by rewriting the JAR and removing that entry from the Manifest. A side-effect of this - * is having to set `lastModifiedTime` for each entry to a fixed value, else this would also introduce non-determinism. - * - * The fixed value is the same as the default value for Gradle's fixed timestamps, and the rationale behind it is detailed - * in https://github.com/gradle/gradle/blob/58538513a3bff3b7015718976fe1304e23f40694/subprojects/core/src/main/java/org/gradle/api/internal/file/archive/ZipCopyAction.java#L42-L57 - */ - -class RemoveOsgiLastModifiedHeader { - private final long CONSTANT_TIME_FOR_ZIP_ENTRIES = new GregorianCalendar(1980, FEBRUARY, 1, 0, 0, 0).timeInMillis - - private final JarFile artifact - - RemoveOsgiLastModifiedHeader(JarFile artifact) { - this.artifact = artifact - } - - File transform() { - File temp = File.createTempFile("temp",".jar") - - temp.withOutputStream { os -> - JarOutputStream stream = new JarOutputStream(os) - - this.artifact - .entries() - // Keep META-INF folder at the beginning to avoid https://github.com/mockito/mockito/issues/2108 - .sort { (it.name.startsWith("META-INF") ? "A/" + it.name : "B/" + it.name) } - .each { JarEntry entry -> - - stream.putNextEntry(newJarEntry(entry)) - - if (entry.name == "META-INF/MANIFEST.MF") { - newManifest(entry).write(stream) - } else { - stream << this.artifact.getInputStream(entry) - } - - stream.closeEntry() - } - - stream.finish() - } - - temp - } - - Manifest newManifest(JarEntry entry) { - Manifest manifest = new Manifest() - - manifest.read(this.artifact.getInputStream(entry)) - - manifest - .getMainAttributes() - .remove(new Attributes.Name("Bnd-LastModified")) - - manifest - } - - JarEntry newJarEntry(JarEntry original) { - JarEntry newEntry = new JarEntry(original.name) - - newEntry.setLastModifiedTime(FileTime.fromMillis(CONSTANT_TIME_FOR_ZIP_ENTRIES)) - - newEntry - } - -} diff --git a/gradle/shipkit.gradle b/gradle/shipkit.gradle index 2a430fe6f8..7957191ac8 100644 --- a/gradle/shipkit.gradle +++ b/gradle/shipkit.gradle @@ -3,8 +3,8 @@ apply plugin: "org.shipkit.shipkit-changelog" apply plugin: "org.shipkit.shipkit-gh-release" tasks.named("generateChangelog") { - previousRevision = "v" + project.ext.'shipkit-auto-version.previous-version' - readOnlyToken = "a0a4c0f41c200f7c653323014d6a72a127764e17" + previousRevision = project.ext.'shipkit-auto-version.previous-tag' + githubToken = System.getenv("GITHUB_TOKEN") repository = "mockito/mockito" } @@ -13,7 +13,8 @@ tasks.named("githubRelease") { dependsOn genTask repository = genTask.repository changelog = genTask.outputFile - writeToken = System.getenv("GH_WRITE_TOKEN") + newTagRevision = System.getenv("GITHUB_SHA") + githubToken = System.getenv("GITHUB_TOKEN") } /** @@ -40,4 +41,4 @@ static boolean shouldReleaseToCentral(project) { project.tasks.bintrayPublish.doLast { logger.lifecycle(message) } } return centralRelease -} \ No newline at end of file +} diff --git a/src/main/java/org/mockito/BDDMockito.java b/src/main/java/org/mockito/BDDMockito.java index c4861ba4a9..1f249b4595 100644 --- a/src/main/java/org/mockito/BDDMockito.java +++ b/src/main/java/org/mockito/BDDMockito.java @@ -13,7 +13,7 @@ * Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your test methods. * This is exactly how we write our tests and we warmly encourage you to do so! *

- * Start learning about BDD here: http://en.wikipedia.org/wiki/Behavior_Driven_Development + * Start learning about BDD here: https://en.wikipedia.org/wiki/Behavior-driven_development *

* The problem is that current stubbing api with canonical role of when word does not integrate nicely with //given //when //then comments. * It's because stubbing belongs to given component of the test and not to the when component of the test. diff --git a/src/main/java/org/mockito/CheckReturnValue.java b/src/main/java/org/mockito/CheckReturnValue.java index 7bc3b257bf..935b3207f6 100644 --- a/src/main/java/org/mockito/CheckReturnValue.java +++ b/src/main/java/org/mockito/CheckReturnValue.java @@ -17,7 +17,7 @@ * This annotation is public, because we have to use it in multiple packages. * * @see Findbugs source code - * @see ErrorProne check + * @see ErrorProne check * @since 2.11.4 */ @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PACKAGE, ElementType.TYPE}) diff --git a/src/main/java/org/mockito/Mock.java b/src/main/java/org/mockito/Mock.java index cb5bfba157..8b8132000e 100644 --- a/src/main/java/org/mockito/Mock.java +++ b/src/main/java/org/mockito/Mock.java @@ -32,7 +32,7 @@ * @Mock private ArticleCalculator calculator; * @Mock(name = "database") private ArticleDatabase dbMock; * @Mock(answer = RETURNS_MOCKS) private UserProvider userProvider; - * @Mock(extraInterfaces = {Queue.class, Observer.class}) private articleMonitor; + * @Mock(extraInterfaces = {Queue.class, Observer.class}) private ArticleMonitor articleMonitor; * @Mock(stubOnly = true) private Logger logger; * * private ArticleManager manager; diff --git a/src/main/java/org/mockito/Mockito.java b/src/main/java/org/mockito/Mockito.java index 64df8b8db7..e14af0c654 100644 --- a/src/main/java/org/mockito/Mockito.java +++ b/src/main/java/org/mockito/Mockito.java @@ -38,7 +38,7 @@ * The Mockito library enables mock creation, verification and stubbing. * *

- * This javadoc content is also available on the http://mockito.org web page. + * This javadoc content is also available on the https://site.mockito.org/ web page. * All documentation is kept in javadocs because it guarantees consistency between what's on the web and what's in the source code. * It allows access to documentation straight from the IDE even if you work offline. * It motivates Mockito developers to keep documentation up-to-date with the code that they write, @@ -104,7 +104,7 @@ *

0. Migrating to Mockito 2

* * In order to continue improving Mockito and further improve the unit testing experience, we want you to upgrade to 2.1.0! - * Mockito follows semantic versioning and contains breaking changes only on major version upgrades. + * Mockito follows semantic versioning and contains breaking changes only on major version upgrades. * In the lifecycle of a library, breaking changes are necessary * to roll out a set of brand new features that alter the existing behavior or even change the API. * For a comprehensive guide on the new release including incompatible changes, @@ -767,7 +767,7 @@ * https://github.com/mockito/mockito/wiki/FAQ *

* In case of questions you may also post to mockito mailing list: - * http://groups.google.com/group/mockito + * https://groups.google.com/group/mockito *

* Next, you should know that Mockito validates if you use it correctly all the time. * However, there's a gotcha so please read the javadoc for {@link Mockito#validateMockitoUsage()} @@ -780,7 +780,7 @@ * Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your test methods. * This is exactly how we write our tests and we warmly encourage you to do so! *

- * Start learning about BDD here: http://en.wikipedia.org/wiki/Behavior_Driven_Development + * Start learning about BDD here: https://en.wikipedia.org/wiki/Behavior-driven_development *

* The problem is that current stubbing api with canonical role of when word does not integrate nicely with //given //when //then comments. * It's because stubbing belongs to given component of the test and not to the when component of the test. @@ -823,7 +823,7 @@ * List serializableMock = mock(List.class, withSettings().serializable()); * *

- * The mock can be serialized assuming all the normal + * The mock can be serialized assuming all the normal * serialization requirements are met by the class. *

* Making a real object spy serializable is a bit more effort as the spy(...) method does not have an overloaded version @@ -1357,7 +1357,7 @@ * *

  • This mock maker has been designed around Java Agent runtime attachment ; this require a compatible JVM, * that is part of the JDK (or Java 9 VM). When running on a non-JDK VM prior to Java 9, it is however possible to - * manually add the Byte Buddy Java agent jar using the -javaagent + * manually add the Byte Buddy Java agent jar using the -javaagent * parameter upon starting the JVM. *
  • * @@ -1506,7 +1506,7 @@ *

    45. New JUnit Jupiter (JUnit5+) extension

    * * For integration with JUnit Jupiter (JUnit5+), use the `org.mockito:mockito-junit-jupiter` artifact. - * For more information about the usage of the integration, see the JavaDoc of MockitoExtension. + * For more information about the usage of the integration, see the JavaDoc of MockitoExtension. * *

    46. * New Mockito.lenient() and MockSettings.lenient() methods (Since 2.20.0)

    @@ -1582,7 +1582,7 @@ * * * Due to the defined scope of the mocked construction, object construction returns to its original behavior once the scope is - * released. To define mock behavior and to verify static method invocations, use the MockedConstruction that is returned. + * released. To define mock behavior and to verify method invocations, use the MockedConstruction that is returned. *

    */ @SuppressWarnings("unchecked") @@ -3189,7 +3189,7 @@ public static VerificationAfterDelay after(long millis) { /** * First of all, in case of any trouble, I encourage you to read the Mockito FAQ: https://github.com/mockito/mockito/wiki/FAQ *

    - * In case of questions you may also post to mockito mailing list: http://groups.google.com/group/mockito + * In case of questions you may also post to mockito mailing list: https://groups.google.com/group/mockito *

    * validateMockitoUsage() explicitly validates the framework state to detect invalid use of Mockito. * However, this feature is optional because Mockito validates the usage all the time... but there is a gotcha so read on. diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineByteBuddyMockMaker.java b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineByteBuddyMockMaker.java index 96477f4776..9c0aa9362f 100644 --- a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineByteBuddyMockMaker.java +++ b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineByteBuddyMockMaker.java @@ -95,7 +95,7 @@ * Note that inline mocks require a Java agent to be attached. Mockito will attempt an attachment of a Java agent upon * loading the mock maker for creating inline mocks. Such runtime attachment is only possible when using a JVM that * is part of a JDK or when using a Java 9 VM. When running on a non-JDK VM prior to Java 9, it is however possible to - * manually add the Byte Buddy Java agent jar using the -javaagent + * manually add the Byte Buddy Java agent jar using the -javaagent * parameter upon starting the JVM. Furthermore, the inlining mock maker requires the VM to support class retransformation * (also known as HotSwap). All major VM distributions such as HotSpot (OpenJDK), J9 (IBM/Websphere) or Zing (Azul) * support this feature. diff --git a/src/main/java/org/mockito/internal/util/Platform.java b/src/main/java/org/mockito/internal/util/Platform.java index 200fc511d6..946e4ff3be 100644 --- a/src/main/java/org/mockito/internal/util/Platform.java +++ b/src/main/java/org/mockito/internal/util/Platform.java @@ -61,7 +61,7 @@ public static String describe() { "", "The regular Byte Buddy mock makers cannot generate code on an Android VM!", "To resolve this, please use the 'mockito-android' dependency for your application:", - "http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22", + "https://search.maven.org/artifact/org.mockito/mockito-android", "", description); } diff --git a/src/main/java/org/mockito/internal/util/reflection/GenericMetadataSupport.java b/src/main/java/org/mockito/internal/util/reflection/GenericMetadataSupport.java index 17265c883a..ae54e6aebe 100644 --- a/src/main/java/org/mockito/internal/util/reflection/GenericMetadataSupport.java +++ b/src/main/java/org/mockito/internal/util/reflection/GenericMetadataSupport.java @@ -197,7 +197,7 @@ private BoundedType boundsOf(TypeVariable typeParameter) { */ private BoundedType boundsOf(WildcardType wildCard) { /* - * According to JLS(http://docs.oracle.com/javase/specs/jls/se5.0/html/typesValues.html#4.5.1): + * According to JLS(https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.5.1): * - Lower and upper can't coexist: (for instance, this is not allowed: * & super MyInterface>) * - Multiple concrete type bounds are not supported (for instance, this is not allowed: @@ -594,9 +594,9 @@ public Class rawType() { * Type representing bounds of a type * * @see TypeVarBoundedType - * @see http://docs.oracle.com/javase/specs/jls/se5.0/html/typesValues.html#4.4 + * @see https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4 * @see WildCardBoundedType - * @see http://docs.oracle.com/javase/specs/jls/se5.0/html/typesValues.html#4.5.1 + * @see https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.5.1 */ public interface BoundedType extends Type { Type firstBound(); @@ -622,7 +622,7 @@ public interface BoundedType extends Type { * *

    * - * @see http://docs.oracle.com/javase/specs/jls/se5.0/html/typesValues.html#4.4 + * @see https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4 */ public static class TypeVarBoundedType implements BoundedType { private final TypeVariable typeVariable; @@ -689,7 +689,7 @@ public TypeVariable typeVariable() { *

    The JLS says that lower bound and upper bound are mutually exclusive, and that multiple bounds * are not allowed. * - * @see http://docs.oracle.com/javase/specs/jls/se5.0/html/typesValues.html#4.4 + * @see https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4 */ public static class WildCardBoundedType implements BoundedType { private final WildcardType wildcard; diff --git a/src/main/java/org/mockito/junit/MockitoJUnitRunner.java b/src/main/java/org/mockito/junit/MockitoJUnitRunner.java index 3d2e8675e5..6951868e68 100644 --- a/src/main/java/org/mockito/junit/MockitoJUnitRunner.java +++ b/src/main/java/org/mockito/junit/MockitoJUnitRunner.java @@ -46,7 +46,7 @@ * It drives cleaner tests and improves debugging experience. * The only reason this feature is not turned on by default * is because it would have been an incompatible change - * and Mockito strictly follows semantic versioning. + * and Mockito strictly follows semantic versioning. * * * Runner is completely optional - there are other ways you can get @Mock working, for example by writing a base class. diff --git a/src/main/java/org/mockito/junit/MockitoRule.java b/src/main/java/org/mockito/junit/MockitoRule.java index 276d7ce7e9..a45314ecc9 100644 --- a/src/main/java/org/mockito/junit/MockitoRule.java +++ b/src/main/java/org/mockito/junit/MockitoRule.java @@ -46,7 +46,7 @@ * It drives cleaner tests and improves debugging experience. * The only reason this feature is not turned on by default * is because it would have been an incompatible change - * and Mockito strictly follows semantic versioning. + * and Mockito strictly follows semantic versioning. * * * Example use: diff --git a/src/test/java/org/mockito/internal/matchers/apachecommons/EqualsBuilderTest.java b/src/test/java/org/mockito/internal/matchers/apachecommons/EqualsBuilderTest.java index 5e2bd696bb..53f34109ba 100644 --- a/src/test/java/org/mockito/internal/matchers/apachecommons/EqualsBuilderTest.java +++ b/src/test/java/org/mockito/internal/matchers/apachecommons/EqualsBuilderTest.java @@ -1064,7 +1064,7 @@ public void testUnrelatedClasses() { } /** - * Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=33067 + * Test from https://issues.apache.org/jira/browse/LANG-42 */ @Test public void testNpeForNullElement() { @@ -1072,7 +1072,7 @@ public void testNpeForNullElement() { Object[] x2 = new Object[] {new Integer(1), new Integer(2), new Integer(3)}; // causes an NPE in 2.0 according to: - // http://issues.apache.org/bugzilla/show_bug.cgi?id=33067 + // https://issues.apache.org/jira/browse/LANG-42 new EqualsBuilder().append(x1, x2); } diff --git a/src/test/java/org/mockito/internal/util/PlatformTest.java b/src/test/java/org/mockito/internal/util/PlatformTest.java index eef773dd64..b72c71d398 100644 --- a/src/test/java/org/mockito/internal/util/PlatformTest.java +++ b/src/test/java/org/mockito/internal/util/PlatformTest.java @@ -68,13 +68,13 @@ public void should_warn_for_jvm() throws Exception { public void should_parse_open_jdk_string_and_report_wether_below_or_nut_update_45() { // Given // Sources : - // - http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html - // - http://www.oracle.com/technetwork/java/javase/jdk7-naming-418744.html - // - http://www.oracle.com/technetwork/java/javase/jdk8-naming-2157130.html + // - https://www.oracle.com/java/technologies/javase/versioning-naming.html + // - https://www.oracle.com/java/technologies/javase/jdk7-naming.html + // - https://www.oracle.com/java/technologies/javase/jdk8-naming.html // - - // http://stackoverflow.com/questions/35844985/how-do-we-get-sr-and-fp-of-ibm-jre-using-java + // https://stackoverflow.com/questions/35844985/how-do-we-get-sr-and-fp-of-ibm-jre-using-java // - - // http://www.ibm.com/support/knowledgecenter/SSYKE2_6.0.0/com.ibm.java.doc.user.win32.60/user/java_version_check.html + // https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.80.doc/user/build_number.html Map versions = new HashMap() { { @@ -103,7 +103,7 @@ public void should_parse_open_jdk9_string() { // Given // Sources : - // - http://openjdk.java.net/jeps/223 (Java 9) + // - https://openjdk.java.net/jeps/223 (Java 9) // // System Property Existing Proposed // ------------------------------- ------------ -------- diff --git a/subprojects/inline/src/test/java/org/mockitoinline/StaticMockTest.java b/subprojects/inline/src/test/java/org/mockitoinline/StaticMockTest.java index 2dde8d4a9b..4516583b96 100644 --- a/subprojects/inline/src/test/java/org/mockitoinline/StaticMockTest.java +++ b/subprojects/inline/src/test/java/org/mockitoinline/StaticMockTest.java @@ -166,10 +166,27 @@ public void testStaticMockMustBeExclusiveInScopeWithinThread() { } } + @Test + public void testStaticMockVoid() { + try (MockedStatic dummy = Mockito.mockStatic(Dummy.class)) { + Dummy.fooVoid("bar"); + assertNull(Dummy.var1); + dummy.verify(()->Dummy.fooVoid("bar")); + } + Dummy.fooVoid("bar"); + assertEquals("bar", Dummy.var1); + } + static class Dummy { + static String var1 = null; + static String foo() { return "foo"; } + + static void fooVoid(String var2) { + var1 = var2; + } } } diff --git a/subprojects/junit-jupiter/junit-jupiter.gradle b/subprojects/junit-jupiter/junit-jupiter.gradle index 7cfc0b7de1..6e24b6a861 100644 --- a/subprojects/junit-jupiter/junit-jupiter.gradle +++ b/subprojects/junit-jupiter/junit-jupiter.gradle @@ -1,6 +1,11 @@ +import aQute.bnd.gradle.BundleTaskConvention +import aQute.bnd.gradle.FileSetRepositoryConvention +import aQute.bnd.gradle.Resolve + description = "Mockito JUnit 5 support" apply from: "$rootDir/gradle/java-library.gradle" +apply plugin: 'biz.aQute.bnd.builder' dependencies { compile project.rootProject @@ -13,3 +18,43 @@ dependencies { tasks.withType(Test) { useJUnitPlatform() } + +jar { + classpath = project.configurations.runtimeClasspath + bnd( + 'Bundle-Name': 'Mockito Extension Library for JUnit 5.', + 'Bundle-SymbolicName': 'org.mockito.junit-jupiter', + 'Bundle-Version': "\${version_cleanup;${project.version}}", + '-versionpolicy': '[${version;==;${@}},${version;+;${@}})', + 'Export-Package': "org.mockito.junit.jupiter.*;version=${version}", + '-removeheaders': 'Private-Package', + 'Automatic-Module-Name': 'org.mockito.junit.jupiter', + '-noextraheaders': 'true', + '-export-apiguardian': 'org.mockito.internal.*' + ) +} + +def osgiPropertiesFile = file("$buildDir/verifyOSGiProperties.bndrun") + +// Bnd's Resolve task uses a properties file for its configuration. This +// task writes out the properties necessary for it to verify the OSGi +// metadata. +tasks.register('osgiProperties', WriteProperties) { + outputFile = osgiPropertiesFile + property('-standalone', true) + property('-runee', "JavaSE-${targetCompatibility}") + property('-runrequires', 'osgi.identity;filter:="(osgi.identity=org.mockito.junit-jupiter)"') +} + +// Bnd's Resolve task is what verifies that a jar can be used in OSGi and +// that its metadata is valid. If the metadata is invalid this task will +// fail. +tasks.register('verifyOSGi', Resolve) { + dependsOn(osgiProperties) + setBndrun(osgiPropertiesFile) + reportOptional = false +} + +tasks.check { + dependsOn(verifyOSGi) +} diff --git a/subprojects/junit-jupiter/src/test/java/org/mockitousage/JunitJupiterTest.java b/subprojects/junit-jupiter/src/test/java/org/mockitousage/JunitJupiterTest.java index df9fce5e88..31abe2e610 100644 --- a/subprojects/junit-jupiter/src/test/java/org/mockitousage/JunitJupiterTest.java +++ b/subprojects/junit-jupiter/src/test/java/org/mockitousage/JunitJupiterTest.java @@ -80,7 +80,7 @@ void rootMockCreated() { @Nested @ExtendWith(MockitoExtension.class) // ^^ duplicate registration should be ignored by JUnit - // see http://junit.org/junit5/docs/current/user-guide/#extensions-registration-inherita + // see https://junit.org/junit5/docs/current/user-guide/#extensions-registration-inheritance class DuplicateExtensionOnNestedTest { @Mock diff --git a/version.properties b/version.properties index 68dab810c7..84772019f6 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ # Used by Shipkit Auto Version Gradle plugin: https://github.com/shipkit/shipkit-auto-version -version=3.6.* \ No newline at end of file +version=3.7.*