Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
options:
- lib/shared/common
- lib/shared/internal
- lib/shared/test-helpers
- lib/sdk/server
- lib/java-server-sdk-otel
- lib/java-server-sdk-redis-store
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
options:
- lib/shared/common
- lib/shared/internal
- lib/shared/test-helpers
- lib/sdk/server
- lib/java-server-sdk-otel
- lib/java-server-sdk-redis-store
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
outputs:
package-sdk-common-released: ${{ steps.release.outputs['lib/shared/common--release_created'] }}
package-sdk-internal-released: ${{ steps.release.outputs['lib/shared/internal--release_created'] }}
package-test-helpers-released: ${{ steps.release.outputs['lib/shared/test-helpers--release_created'] }}
package-server-sdk-released: ${{ steps.release.outputs['lib/sdk/server--release_created'] }}
package-server-sdk-otel-released: ${{ steps.release.outputs['lib/java-server-sdk-otel--release_created'] }}
package-server-sdk-redis-store-released: ${{ steps.release.outputs['lib/java-server-sdk-redis-store--release_created'] }}
Expand Down Expand Up @@ -188,3 +189,36 @@ jobs:
sonatype_password: ${{ env.SONATYPE_PASSWORD }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}

release-test-helpers:
runs-on: ubuntu-latest
needs: release-please
permissions:
id-token: write
contents: write
pull-requests: write
if: ${{ needs.release-please.outputs.package-test-helpers-released == 'true'}}
steps:
- uses: actions/checkout@v4

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.1.0
name: Get secrets
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/sonatype/central/username = SONATYPE_USER_NAME,
/production/common/releasing/sonatype/central/password = SONATYPE_PASSWORD,
/production/common/releasing/java/keyId = SIGNING_KEY_ID'
s3_path_pairs: 'launchdarkly-releaser/java/code-signing-keyring.gpg = code-signing-keyring.gpg'

- uses: ./.github/actions/full-release
with:
workspace_path: lib/shared/test-helpers
dry_run: false
prerelease: false
code_signing_keyring: ${{ github.workspace }}/code-signing-keyring.gpg
signing_key_id: ${{ env.SIGNING_KEY_ID }}
signing_key_passphrase: ''
sonatype_username: ${{ env.SONATYPE_USER_NAME }}
sonatype_password: ${{ env.SONATYPE_PASSWORD }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/test-helpers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test-helpers

on:
push:
branches: [main, 'feat/**']
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [main, 'feat/**']
paths-ignore:
- '**.md'

jobs:
build-test-helpers:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
java-version: [8, 11, 17, 19]
os: [ubuntu-latest]
include:
- java-version: 11
os: windows-latest
- java-version: 17
os: windows-latest
steps:
- uses: actions/checkout@v3

- name: Shared CI Steps
uses: ./.github/actions/ci
with:
workspace_path: 'lib/shared/test-helpers'
java_version: ${{ matrix.java-version }}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"lib/java-server-sdk-redis-store": "3.0.1",
"lib/shared/common": "2.1.2",
"lib/shared/internal": "1.5.1",
"lib/shared/test-helpers": "2.0.2",
"lib/sdk/server": "7.10.2"
}
24 changes: 24 additions & 0 deletions lib/shared/test-helpers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Eclipse project files
.classpath
.project
.settings

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

#Gradle
.gradletasknamecache
.gradle/
build/
bin/
out/
classes/
buildSrc/build
buildSrc/.gradle

# Test code that gets temporarily copied by our Android CI build
src/androidTest/java/com/launchdarkly/sdk/**/*.java
!src/androidTest/java/com/launchdarkly/sdk/BaseTest.java
43 changes: 43 additions & 0 deletions lib/shared/test-helpers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Change log

All notable changes to the project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [2.0.2] - 2023-06-27
### Changed:
- Bumping Guava version to incorporate CVE fixes.

## [2.0.1] - 2022-12-18
(This release replaces the broken 2.0.0 release, which was accidentally duplicated from 1.3.0.)

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.

### Changed:
- All methods that took a `java.time.Duration` now take `long, TimeUnit` instead.
- 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.

## [2.0.0] - 2022-11-17
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.

### Changed:
- All methods that took a `java.time.Duration` now take `long, TimeUnit` instead.
- 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.

## [1.3.0] - 2022-08-29
### Added:
- `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".
- `com.launchdarkly.testhelpers.httptest.SpecialHttpConfigurations`: test helpers to validate several standard kinds of HTTP client configurations.

## [1.2.0] - 2022-07-08
### Added:
- `TypeBehavior.singletonValueFactory` is a new method that can be used with `TypeBehavior.checkEqualsAndHashCode` to allow testing of types that have interned/singleton values.

## [1.1.1] - 2022-06-17
### Fixed:
- 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.

## [1.1.0] - 2021-07-21
### Added:
- `Assertions`, `ConcurrentHelpers`, `JsonAssertions`, `TempDir`, `TempFile`, `TypeBehavior`.

## [1.0.0] - 2021-06-25
Initial release.
39 changes: 39 additions & 0 deletions lib/shared/test-helpers/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing to this project

## Submitting bug reports and feature requests

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.

## Submitting pull requests

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.

## Build instructions

### Prerequisites

The project builds with [Gradle](https://gradle.org/) and should be built against Java 8.

### Building

To build the project without running any tests:
```
./gradlew jar
```

If you wish to clean your working directory between builds, you can clean it by running:
```
./gradlew clean
```

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.
```
./gradlew publishToMavenLocal
```

### Testing

To build the project and run all unit tests:
```
./gradlew test
```
13 changes: 13 additions & 0 deletions lib/shared/test-helpers/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2021 Catamorphic, Co.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
24 changes: 24 additions & 0 deletions lib/shared/test-helpers/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
java-test-helpers
Copyright 2021 Catamorphic, Co.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

================================================================================

This project bundles the following dependencies under the BSD 3-Clause License.
See bundled license files for details.

- NanoHttpd (core module)
https://github.com/NanoHttpd/nanohttpd
Copyright (c) 2012-2013 by Paul S. Hawke, 2001, 2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
Files: com.launchdarkly.testhelpers.httptest.nanohttpd.*
28 changes: 28 additions & 0 deletions lib/shared/test-helpers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# LaunchDarkly Java Test Helpers

[![Quality control](https://github.com/launchdarkly/java-test-helpers/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/java-test-helpers/actions/workflows/ci.yml)
[![Javadocs](http://javadoc.io/badge/com.launchdarkly/java-test-helpers.svg)](http://javadoc.io/doc/com.launchdarkly/java-test-helpers)

## Overview

This project centralizes some test support code that is used by LaunchDarkly's Java and Android SDKs and related components, which may be useful in other Java projects.

See [API documentation](http://javadoc.io/doc/com.launchdarkly/java-test-helpers) for full details.

## Contributing

We encourage pull requests and other contributions from the community. See [Contributing](CONTRIBUTING.md).

## About LaunchDarkly

* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
* Explore LaunchDarkly
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
115 changes: 115 additions & 0 deletions lib/shared/test-helpers/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import java.time.Duration
import org.gradle.external.javadoc.CoreJavadocOptions

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
}

plugins { // see Dependencies.kt in buildSrc
Libs.javaBuiltInGradlePlugins.forEach { id(it) }
Libs.javaExtGradlePlugins.forEach { (n, v) -> id(n) version v }
}

repositories {
mavenLocal()
// Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots:
maven { url = uri("https://oss.sonatype.org/content/groups/public/") }
mavenCentral()
}

configurations.all {
// check for updates every build for dependencies with: 'changing: true'
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}

base {
group = ProjectValues.groupId
archivesBaseName = ProjectValues.artifactId
version = version
}

java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies { // see Dependencies.kt in buildSrc
Libs.implementation.forEach { implementation(it) }
Libs.javaTestImplementation.forEach { testImplementation(it) }
}

checkstyle {
toolVersion = "9.3"
configFile = file("${project.rootDir}/checkstyle.xml")
}

tasks.checkstyleMain {
// Exclude embedded nanohttpd code from checkstyle
exclude("com/launchdarkly/testhelpers/httptest/nanohttpd/**")
}

tasks.jar {
manifest {
attributes(mapOf("Implementation-Version" to project.version))
}
// Include NOTICE file in binary distribution
from(".") {
include("NOTICE")
into("META-INF")
}
// Include nanohttpd license in binary distribution per BSD 3-Clause requirements
from("src/main/java/com/launchdarkly/testhelpers/httptest/nanohttpd") {
include("LICENSE.md")
into("META-INF/licenses/nanohttpd")
}
}

tasks.javadoc {
// Force the Javadoc build to fail if there are any Javadoc warnings.
(options as CoreJavadocOptions).addStringOption("Xwerror")

// Exclude embedded nanohttpd code from Javadoc generation
exclude("com/launchdarkly/testhelpers/httptest/nanohttpd/**")
}

helpers.Test.configureTask(tasks.compileTestJava, tasks.test, configurations["testRuntimeClasspath"])

helpers.Jacoco.configureTasks(
tasks.jacocoTestReport,
tasks.jacocoTestCoverageVerification
)

helpers.Idea.configure(idea)

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])

helpers.Pom.standardPom(pom) // see Pom.kt in buildSrc
}
}
repositories {
mavenLocal()
}
}

nexusPublishing {
clientTimeout.set(Duration.ofMinutes(2)) // we've seen extremely long delays in creating repositories
repositories {
sonatype{
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}

signing {
setRequired({ findProperty("skipSigning") != "true" })
sign(publishing.publications["mavenJava"])
}
Loading
Loading