Skip to content

Commit 6be2ec9

Browse files
committed
Initial commit
0 parents  commit 6be2ec9

File tree

73 files changed

+7788
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+7788
-0
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*.{yml,xml}]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Set up JDK/Maven
12+
uses: actions/setup-java@v3
13+
with:
14+
distribution: 'zulu'
15+
java-version: 11
16+
- name: Build and verify all modules
17+
run: >-
18+
mvn
19+
--batch-mode
20+
--activate-profiles=checkstyle,spotbugs,coverage
21+
"-DrepoBaseUrl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
22+
verify

.github/workflows/release.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: 'Release version number'
8+
required: true
9+
developmentVersion:
10+
description: 'Next development (snapshot) version number'
11+
required: true
12+
13+
jobs:
14+
release:
15+
name: Create release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out from SCM
19+
uses: actions/checkout@v3
20+
- name: Import GPG key
21+
uses: crazy-max/ghaction-import-gpg@v5
22+
with:
23+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
24+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
25+
- name: Set up JDK/Maven
26+
uses: actions/setup-java@v3
27+
with:
28+
distribution: 'zulu'
29+
java-version: 11
30+
- name: Configure Maven settings
31+
uses: whelk-io/maven-settings-xml-action@v21
32+
with:
33+
servers: >-
34+
[{
35+
"id": "ossrh",
36+
"username": "${{ github.actor }}",
37+
"password": "${{ secrets.OSS_PASSWORD }}"
38+
}]
39+
- name: Configure git
40+
run: |
41+
git config --global committer.email "[email protected]"
42+
git config --global committer.name "GitHub Actions"
43+
git config --global author.email "${{ github.actor }}@users.noreply.github.com"
44+
git config --global author.name "${{ github.actor }}"
45+
- name: Prepare release
46+
id: prepare_release
47+
run: >-
48+
mvn
49+
--batch-mode
50+
"-DpreparationGoals=clean compile"
51+
"-DreleaseVersion=${{ github.event.inputs.releaseVersion }}"
52+
"-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}"
53+
"-Dtag=v${{ github.event.inputs.releaseVersion }}"
54+
"-Dusername=${{ github.actor }}"
55+
"-Dpassword=${{ secrets.GITHUB_TOKEN }}"
56+
"-DrepoBaseUrl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
57+
release:prepare
58+
- name: Perform release
59+
id: perform_release
60+
run: >-
61+
mvn
62+
--batch-mode
63+
"-Dgoals=deploy"
64+
"-DreleaseProfiles=release,-examples"
65+
"-Darguments=-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -DrepoBaseUrl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
66+
"-Dusername=${{ github.actor }}"
67+
"-Dpassword=${{ secrets.GITHUB_TOKEN }}"
68+
"-DrepoBaseUrl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
69+
release:perform
70+
# Maven Release Plugin 3.0.0-M1 would automatically remove the tag, but unfortunately
71+
# it's unusable due to this bug: https://issues.apache.org/jira/browse/MRELEASE-1038
72+
# Hence, for the time being, we have to delete the tag ourselves.
73+
- name: 'In case of failure: Rollback'
74+
id: rollback
75+
if: failure()
76+
run: >-
77+
git tag -d "v${{ github.event.inputs.releaseVersion }}" && git push origin ":refs/tags/v${{ github.event.inputs.releaseVersion }}"
78+
;
79+
mvn
80+
--batch-mode
81+
"-Dusername=${{ github.actor }}"
82+
"-Dpassword=${{ secrets.GITHUB_TOKEN }}"
83+
"-DrepoBaseUrl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
84+
release:rollback
85+
- name: Create GitHub release
86+
id: create_github_release
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
tag_name: v${{ github.event.inputs.releaseVersion }}
90+
name: assertj-mail-${{ github.event.inputs.releaseVersion }}
91+
body: |-
92+
Release ${{ github.event.inputs.releaseVersion }} of assertj-mail
93+
94+
[Change log](${{ github.server_url }}/${{ github.repository }}/blob/main/CHANGES.md)
95+
files: |
96+
./target/checkout/assertj-mail/target/assertj-mail-${{ github.event.inputs.releaseVersion }}.jar
97+
./target/checkout/assertj-mail/target/assertj-mail-${{ github.event.inputs.releaseVersion }}-javadoc.jar
98+
./target/checkout/assertj-mail-jakarta/target/assertj-mail-jakarta-${{ github.event.inputs.releaseVersion }}.jar
99+
./target/checkout/assertj-mail-jakarta/target/assertj-mail-jakarta-${{ github.event.inputs.releaseVersion }}-javadoc.jar

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.classpath
2+
.project
3+
.settings
4+
.idea/
5+
*.iml
6+
7+
target/

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AssertJ Mail Changes
2+
3+
## Version 1.0.0 (12 March 2023)
4+
5+
Initial release

DEVELOPMENT.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Requirements
2+
3+
* JDK 11 or newer (e.g. [OpenJDK](https://openjdk.org/))
4+
* [Apache Maven](https://maven.apache.org/) 3.3.9 or newer
5+
6+
# Code Style
7+
8+
This project adheres to [Google Java Style](https://google.github.io/styleguide/javaguide.html) and uses
9+
[Checkstyle](https://checkstyle.org/) for validating code style.
10+
11+
Run `mvn --activate-profiles=checkstyle verify` to execute Checkstyle.
12+
13+
Use [google_checks.xml](https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml)
14+
for configuring your IDE's inspection and formatting settings.
15+
16+
# Static Code Analysis
17+
18+
This project uses [SpotBugs](https://spotbugs.github.io/) for static code analysis.
19+
20+
Run `mvn --activate-profiles=spotbugs verify` to execute SpotBugs.
21+
22+
# Testing
23+
24+
Run `mvn --activate-profiles=coverage verify` to execute all tests and to assert code coverage requirements are met.
25+
26+
# Building
27+
28+
Run `mvn --activate-profiles=checkstyle,spotbugs,coverage verify` to build all modules, execute all tests
29+
and run all checks.
30+
31+
Run `mvn --activate-profiles=-examples install` to install the main artifacts into the local repository.
32+
33+
# Code Generation
34+
35+
The code for the assertj-mail-jakarta and assert-mail-examples-jakarta modules is “generated” from their non-Jakarta
36+
counterparts by copying source files and substituting “jakarta.mail” for “javax.mail”.

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Dirk Weinhardt
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
[![Build Status](https://img.shields.io/github/actions/workflow/status/devopsix/assertj-mail/build.yml)](https://github.com/devopsix/assertj-mail/actions?query=workflow%3ABuild)
2+
[![Maven Central](https://img.shields.io/maven-central/v/org.devopsix/assertj-mail.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.devopsix%22%20AND%20a:%assertj-mail%22)
3+
[![License](https://img.shields.io/github/license/devopsix/assertj-mail)](LICENSE.txt)
4+
5+
# AssertJ Mail
6+
7+
AssertJ Mail is an extension library for the [AssertJ][] assertion library.
8+
It provides assertions for types from the `javax.mail` and `jakarta.mail` packages.
9+
10+
The [hamcrest-mail][] sister project provides a set of Hamcrest matchers with similar features.
11+
12+
## Usage
13+
To use AssertJ Mail in a Maven project add a dependency on `org.devopsix:assertj-mail` (for Java EE 8 / javax.mail) or
14+
`org.devopsix:assertj-mail-jakarta` (for Jakarta EE 9+ / jakarta.mail) to the pom.xml file.
15+
16+
```xml
17+
<!-- Maven coordinates for Java EE 8 / javax.mail -->
18+
<dependency>
19+
<groupId>org.devopsix</groupId>
20+
<artifactId>assertj-mail</artifactId>
21+
<version>1.0.0</version>
22+
<scope>test</scope>
23+
</dependency>
24+
<!-- Maven coordinates for Jakarta EE 9+ / jakarta.mail -->
25+
<dependency>
26+
<groupId>org.devopsix</groupId>
27+
<artifactId>assertj-mail-jakarta</artifactId>
28+
<version>1.0.0</version>
29+
<scope>test</scope>
30+
</dependency>
31+
```
32+
33+
The assertions are available as static methods on the `MailAssertions` class.
34+
35+
Here are a few examples:
36+
37+
```java
38+
Message message;
39+
MailAssertions.assertThat(message).from()
40+
.singleElement(as(MailAssertions.INTERNET_ADDRESS))
41+
.address().isEqualTo("[email protected]");
42+
43+
MailAssertions.assertThat(message).to()
44+
.singleElement(Assertions.as(MailAssertions.INTERNET_ADDRESS))
45+
.address().isEqualTo("[email protected]");
46+
47+
MailAssertions.assertThat(message).subject().isEqualTo("Foo");
48+
49+
MailAssertions.assertThat(message).headerValue("Message-ID").isEqualTo("Foo");
50+
51+
MailAssertions.assertThat(message).dateHeaderValue("Resent-Date").isEqualToIgnoringNanos(date);
52+
```
53+
54+
More example can be found in the [examples](examples/) directory (for Java EE 8 / javax.mail) and in the
55+
[examples-jakarta](examples-jakarta/) directory (for Jakarta EE 9+ / jakarta.mail).
56+
57+
## Assertions
58+
59+
* `MessageAssert.headerValue(String name)` - An assertion for a message's header (String value)
60+
* `MessageAssert.headerValues(String name)` - An assertion for a message's header (multiple Strings values)
61+
* `MessageAssert.dateHeaderValue(String name)` - An assertion for a message's header (date value)
62+
* `MessageAssert.dateHeaderValues(String name)` - An assertion for a message's header (multiple date values)
63+
* `MessageAssert.textContent()` - An assertion for a message's text content
64+
* `MessageAssert.binaryContent()` - An assertion for a message's binary content
65+
* `MessageAssert.isMultipart()` - Asserts that a message has multipart content
66+
* `MessageAssert.multipartContent()` - An assertion for a message's multipart content
67+
* `MessageAssert.multipartContents()` - An assertion for a message's multipart contents (recursive)
68+
* `MessageAssert.date()` - An assertion for a message's “Date” header
69+
* `MessageAssert.from()` - An assertion for a message's “From” header
70+
* `MessageAssert.sender()` - An assertion for a message's “Sender” header
71+
* `MessageAssert.replyTo()` - An assertion for a message's “Reply-To” header
72+
* `MessageAssert.to()` - An assertion for a message's “To” header
73+
* `MessageAssert.cc()` - An assertion for a message's “Cc” header
74+
* `MessageAssert.bcc()` - An assertion for a message's “Bcc” header
75+
* `MessageAssert.subject()` - An assertion for a message's “Subject” header
76+
* `PartAssert.dkimSignature(Map<String, String> publicKeys)` - An assertion for the part's DKIM signature
77+
* `PartAssert.headerValue(String name)` - An assertion for a part's header (String value)
78+
* `PartAssert.headerValues(String name)` - An assertion for a part's header (multiple Strings values)
79+
* `PartAssert.dateHeaderValue(String name)` - An assertion a part's header (date value)
80+
* `PartAssert.dateHeaderValues(String name)` - An assertion for a part's header (multiple date values)
81+
* `PartAssert.textContent()` - An assertion for a part's text content
82+
* `PartAssert.binaryContent()` - An assertion for a part's binary content
83+
* `PartAssert.isMultipart()` - Asserts that a part has multipart content
84+
* `PartAssert.multipartContent()` - An assertion for a part's multipart content
85+
* `PartAssert.multipartContents()` - An assertion for a part's multipart contents (recursive)
86+
* `DkimSignatureAssert.isValid()` - Asserts that a DKIM signature is valid
87+
* `DkimSignatureAssert.records()` - An assertion for the signature records of a [DKIM][] signature
88+
* `MultipartAssert.contentType()` - An assertion for a multipart's content type
89+
* `MultipartAssert.parts()` - An assertion for a multipart's actual parts
90+
* `InternetAddressAssert.address()` - An assertion for an address' address part
91+
* `InternetAddressAssert.personal()` - An assertion for an address' name part
92+
93+
[AssertJ]: https://github.com/assertj/assertj
94+
[DKIM]: https://tools.ietf.org/html/rfc4871
95+
[hamcrest-mail]: https://github.com/devopsix/hamcrest-mail

0 commit comments

Comments
 (0)