Skip to content

Commit 9c1e9f9

Browse files
authored
feat: Migrate java-test-helpers to java-core. (#90)
1 parent 650dfbe commit 9c1e9f9

File tree

101 files changed

+9731
-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.

101 files changed

+9731
-0
lines changed

.github/workflows/manual-publish-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
options:
99
- lib/shared/common
1010
- lib/shared/internal
11+
- lib/shared/test-helpers
1112
- lib/sdk/server
1213
- lib/java-server-sdk-otel
1314
- lib/java-server-sdk-redis-store

.github/workflows/manual-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
options:
1010
- lib/shared/common
1111
- lib/shared/internal
12+
- lib/shared/test-helpers
1213
- lib/sdk/server
1314
- lib/java-server-sdk-otel
1415
- lib/java-server-sdk-redis-store

.github/workflows/release-please.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
outputs:
1313
package-sdk-common-released: ${{ steps.release.outputs['lib/shared/common--release_created'] }}
1414
package-sdk-internal-released: ${{ steps.release.outputs['lib/shared/internal--release_created'] }}
15+
package-test-helpers-released: ${{ steps.release.outputs['lib/shared/test-helpers--release_created'] }}
1516
package-server-sdk-released: ${{ steps.release.outputs['lib/sdk/server--release_created'] }}
1617
package-server-sdk-otel-released: ${{ steps.release.outputs['lib/java-server-sdk-otel--release_created'] }}
1718
package-server-sdk-redis-store-released: ${{ steps.release.outputs['lib/java-server-sdk-redis-store--release_created'] }}
@@ -188,3 +189,36 @@ jobs:
188189
sonatype_password: ${{ env.SONATYPE_PASSWORD }}
189190
aws_role: ${{ vars.AWS_ROLE_ARN }}
190191
token: ${{ secrets.GITHUB_TOKEN }}
192+
193+
release-test-helpers:
194+
runs-on: ubuntu-latest
195+
needs: release-please
196+
permissions:
197+
id-token: write
198+
contents: write
199+
pull-requests: write
200+
if: ${{ needs.release-please.outputs.package-test-helpers-released == 'true'}}
201+
steps:
202+
- uses: actions/checkout@v4
203+
204+
- uses: launchdarkly/gh-actions/actions/[email protected]
205+
name: Get secrets
206+
with:
207+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
208+
ssm_parameter_pairs: '/production/common/releasing/sonatype/central/username = SONATYPE_USER_NAME,
209+
/production/common/releasing/sonatype/central/password = SONATYPE_PASSWORD,
210+
/production/common/releasing/java/keyId = SIGNING_KEY_ID'
211+
s3_path_pairs: 'launchdarkly-releaser/java/code-signing-keyring.gpg = code-signing-keyring.gpg'
212+
213+
- uses: ./.github/actions/full-release
214+
with:
215+
workspace_path: lib/shared/test-helpers
216+
dry_run: false
217+
prerelease: false
218+
code_signing_keyring: ${{ github.workspace }}/code-signing-keyring.gpg
219+
signing_key_id: ${{ env.SIGNING_KEY_ID }}
220+
signing_key_passphrase: ''
221+
sonatype_username: ${{ env.SONATYPE_USER_NAME }}
222+
sonatype_password: ${{ env.SONATYPE_PASSWORD }}
223+
aws_role: ${{ vars.AWS_ROLE_ARN }}
224+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-helpers.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: test-helpers
2+
3+
on:
4+
push:
5+
branches: [main, 'feat/**']
6+
paths-ignore:
7+
- '**.md' #Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [main, 'feat/**']
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build-test-helpers:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
java-version: [8, 11, 17, 19]
20+
os: [ubuntu-latest]
21+
include:
22+
- java-version: 11
23+
os: windows-latest
24+
- java-version: 17
25+
os: windows-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- name: Shared CI Steps
30+
uses: ./.github/actions/ci
31+
with:
32+
workspace_path: 'lib/shared/test-helpers'
33+
java_version: ${{ matrix.java-version }}

.release-please-manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"lib/java-server-sdk-redis-store": "3.0.1",
44
"lib/shared/common": "2.1.2",
55
"lib/shared/internal": "1.5.1",
6+
"lib/shared/test-helpers": "2.0.2",
67
"lib/sdk/server": "7.10.2"
78
}

lib/shared/test-helpers/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Eclipse project files
2+
.classpath
3+
.project
4+
.settings
5+
6+
# Intellij project files
7+
*.iml
8+
*.ipr
9+
*.iws
10+
.idea/
11+
12+
#Gradle
13+
.gradletasknamecache
14+
.gradle/
15+
build/
16+
bin/
17+
out/
18+
classes/
19+
buildSrc/build
20+
buildSrc/.gradle
21+
22+
# Test code that gets temporarily copied by our Android CI build
23+
src/androidTest/java/com/launchdarkly/sdk/**/*.java
24+
!src/androidTest/java/com/launchdarkly/sdk/BaseTest.java
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Change log
2+
3+
All notable changes to the project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4+
5+
## [2.0.2] - 2023-06-27
6+
### Changed:
7+
- Bumping Guava version to incorporate CVE fixes.
8+
9+
## [2.0.1] - 2022-12-18
10+
(This release replaces the broken 2.0.0 release, which was accidentally duplicated from 1.3.0.)
11+
12+
This release improves compatibility of the library with Android code by removing usage of Java 8 APIs that are not supported in Android. It also revises the embedded HTTP mechanism to use a fork of `nanohttpd` rather than the heavier-weight Jetty.
13+
14+
### Changed:
15+
- All methods that took a `java.time.Duration` now take `long, TimeUnit` instead.
16+
- The `HttpServer` class is now based on a fork of the lightweight `nanohttpd` (https://github.com/launchdarkly-labs/nanohttpd) library. This should work correctly in any server-side Java environment; it has not been validated in Android, but the previous Jetty implementation did not work in Android anyway.
17+
18+
## [2.0.0] - 2022-11-17
19+
This release improves compatibility of the library with Android code by removing usage of Java 8 APIs that are not supported in Android. It also revises the embedded HTTP mechanism to use a fork of `nanohttpd` rather than the heavier-weight Jetty.
20+
21+
### Changed:
22+
- All methods that took a `java.time.Duration` now take `long, TimeUnit` instead.
23+
- The `HttpServer` class is now based on a fork of the lightweight `nanohttpd` (https://github.com/launchdarkly-labs/nanohttpd) library. This should work correctly in any server-side Java environment; it has not been validated in Android, but the previous Jetty implementation did not work in Android anyway.
24+
25+
## [1.3.0] - 2022-08-29
26+
### Added:
27+
- `com.launchdarkly.testhelpers.tcptest`: this package is analogous to `httptest` but much simpler, providing a basic TCP listener that can be configured with behaviors like "close connections without sending a response" or "forward the connection to another port".
28+
- `com.launchdarkly.testhelpers.httptest.SpecialHttpConfigurations`: test helpers to validate several standard kinds of HTTP client configurations.
29+
30+
## [1.2.0] - 2022-07-08
31+
### Added:
32+
- `TypeBehavior.singletonValueFactory` is a new method that can be used with `TypeBehavior.checkEqualsAndHashCode` to allow testing of types that have interned/singleton values.
33+
34+
## [1.1.1] - 2022-06-17
35+
### Fixed:
36+
- Fixed Hamcrest dependency to use `hamcrest-library` rather than `hamcrest-all`, because JUnit (which is commonly used in any unit test code that would also use Hamcrest) has a transitive dependency on `hamcrest-library` and using both would result in duplication on the classpath.
37+
38+
## [1.1.0] - 2021-07-21
39+
### Added:
40+
- `Assertions`, `ConcurrentHelpers`, `JsonAssertions`, `TempDir`, `TempFile`, `TypeBehavior`.
41+
42+
## [1.0.0] - 2021-06-25
43+
Initial release.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing to this project
2+
3+
## Submitting bug reports and feature requests
4+
5+
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/java-core/issues) in the GitHub repository. Bug reports and feature requests specific to this project should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.
6+
7+
## Submitting pull requests
8+
9+
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
10+
11+
## Build instructions
12+
13+
### Prerequisites
14+
15+
The project builds with [Gradle](https://gradle.org/) and should be built against Java 8.
16+
17+
### Building
18+
19+
To build the project without running any tests:
20+
```
21+
./gradlew jar
22+
```
23+
24+
If you wish to clean your working directory between builds, you can clean it by running:
25+
```
26+
./gradlew clean
27+
```
28+
29+
If you wish to use your generated artifact by another Maven/Gradle project, you will likely want to publish the artifact to your local Maven repository so that your other project can access it.
30+
```
31+
./gradlew publishToMavenLocal
32+
```
33+
34+
### Testing
35+
36+
To build the project and run all unit tests:
37+
```
38+
./gradlew test
39+
```

lib/shared/test-helpers/LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2021 Catamorphic, Co.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

lib/shared/test-helpers/NOTICE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
java-test-helpers
2+
Copyright 2021 Catamorphic, Co.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
================================================================================
17+
18+
This project bundles the following dependencies under the BSD 3-Clause License.
19+
See bundled license files for details.
20+
21+
- NanoHttpd (core module)
22+
https://github.com/NanoHttpd/nanohttpd
23+
Copyright (c) 2012-2013 by Paul S. Hawke, 2001, 2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
24+
Files: com.launchdarkly.testhelpers.httptest.nanohttpd.*

0 commit comments

Comments
 (0)