diff --git a/CHANGELOG b/CHANGELOG index 6b3aa0ad..b682730a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,3 +5,19 @@ See the changelog report for further details: http://m2.modularity.net.au/projects/ical4j-vcard/changelog.html + + ------------------------------------------------------------------------ + + Tests migrated from JUnit 4 to JUnit 5 Jupiter. The vintage engine bridge + has been removed; all Java tests now use org.junit.jupiter.api and + org.junit.jupiter.params exclusively. + + BREAKING (test sources only): the abstract base classes + net.fortuna.ical4j.vcard.PropertyTest + net.fortuna.ical4j.vcard.ParameterTest + no longer have a constructor or fields. Subclasses must now provide + `public static Stream parameters()` instead of the previous + JUnit 4 `@Parameters` Collection + constructor injection. + Test classes are not published in the main jar so external impact is + unlikely; downstream consumers depending on these test bases need the + same migration. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2e906360..ca767c5d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,10 @@ [versions] -ical4j = "4.2.1" +ical4j = "4.2.4" commons-io = "2.21.0" groovy = "3.0.25" log4j = "2.25.2" spock = "2.4-M7-groovy-3.0" -junitVintage = "5.14.1" - +junit = "5.14.1" [libraries] ical4j = { module = "org.mnode.ical4j:ical4j", version.ref = "ical4j" } @@ -20,5 +19,5 @@ log4j-slf4j2 = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version. spock-bom = { module = "org.spockframework:spock-bom", version.ref = "spock"} spock-core = { module = "org.spockframework:spock-core", version.ref = "spock"} -junit-jupiter = { group = "org.junit.jupiter", name="junit-jupiter", version.ref = "junitVintage"} +junit-jupiter = { group = "org.junit.jupiter", name="junit-jupiter", version.ref = "junit"} junit-platform = { module = "org.junit.platform:junit-platform-launcher" } diff --git a/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/.openspec.yaml b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/.openspec.yaml new file mode 100644 index 00000000..68948146 --- /dev/null +++ b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-05-24 diff --git a/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/design.md b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/design.md new file mode 100644 index 00000000..fd1de6c0 --- /dev/null +++ b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/design.md @@ -0,0 +1,83 @@ +## Context + +The Gradle test task uses `useJUnitPlatform()`. The test runtime classpath currently contains: +- `org.junit.jupiter:junit-jupiter:5.14.1` (declared in `libs.versions.toml` under the misleading version key `junitVintage`) +- `org.junit.platform:junit-platform-launcher` (declared as `testRuntimeOnly`) +- `junit:junit:4.13.2` (transitive via `org.codehaus.groovy:groovy-test`, which is why the JUnit 4 tests compile) +- `org.spockframework:spock-core` (runs Groovy specs) + +What is **not** on the classpath: `org.junit.vintage:junit-vintage-engine`. The JUnit Platform launcher only discovers tests via registered engines, so every class annotated with `org.junit.Test` (~67 files) is silently skipped at the discovery phase. The Groovy/Spock specs are unaffected and stay healthy throughout this change. + +Two parameterized base classes carry the bulk of the property/parameter coverage: +- `net.fortuna.ical4j.vcard.PropertyTest` — extended by 41 subclasses under `property/`. +- `net.fortuna.ical4j.vcard.ParameterTest` — extended by 6 subclasses under `parameter/`. + +In the JUnit 4 model, each subclass overrides a `static Collection parameters()` annotated with `@Parameters`, and the inherited `@Test` methods consume the parameter set via constructor injection. JUnit 5 has no class-level parameterized runner, so this inheritance shape needs to change. + +## Goals / Non-Goals + +**Goals:** +- All Java test classes use only `org.junit.jupiter.api` and `org.junit.jupiter.params` APIs. +- Tests previously hidden by missing vintage engine are visible in CI reports as either passing, failing, or explicitly disabled. +- A single test framework remains in active use (Jupiter); vintage engine is removed once unused. +- The parameterized base-class pattern is preserved but simplified — base classes hold the test methods, subclasses provide data only. +- The misleading `junitVintage` version key is renamed to `junit`. + +**Non-Goals:** +- Migrating or restructuring Groovy/Spock specs. +- Adding new test coverage. Tests that surface as failing under the vintage bridge are triaged (fix the test or the underlying code) but no new scenarios are written as part of this change. +- Bumping the JUnit Jupiter or other framework versions. +- Removing the transitive `junit:junit:4.13.2` brought in by Groovy. It is harmless once nothing imports it. + +## Decisions + +### Decision 1: Bridge with vintage engine before migrating + +**Decision:** Add `org.junit.vintage:junit-vintage-engine` as `testRuntimeOnly` first, triage the failures it surfaces, then migrate file-by-file, then drop vintage. + +**Rationale:** The current state is undetected silent skips. The fastest path to "we know what's actually broken" is registering the engine that runs those tests. Skipping this step means migrating ~67 files blind — every Jupiter rewrite would simultaneously be the first execution of that test in months, mixing two failure modes (migration bugs vs. pre-existing failures). + +**Alternatives considered:** +- *Big-bang rewrite without vintage*: One large PR rewrites all tests. Rejected — large diff, high review cost, conflates "broken before" with "broken by migration." +- *Permanently keep vintage*: Smallest patch. Rejected — leaves the codebase with two test frameworks indefinitely and contradicts the stated goal of a single modern stack. + +### Decision 2: Reshape the parameterized base classes + +**Decision:** `PropertyTest` and `ParameterTest` become abstract classes containing `@ParameterizedTest` + `@MethodSource("parameters")` methods that accept arguments directly. Each subclass overrides `static Stream parameters()` to supply data. No constructor state, no `@RunWith`. + +**Rationale:** Jupiter resolves `@MethodSource` by name at the test class being executed, including methods inherited from `static` providers defined in subclasses. This keeps the "one place to add a property test, one method to supply data" ergonomics of the current design while removing the JUnit 4 runner machinery and the awkward constructor-stored fields. + +**Alternatives considered:** +- *Flatten each subclass*: Inline test methods into every subclass. Rejected — would multiply ~7 methods × 47 subclasses (~330 method copies). The base-class pattern earned its keep here. +- *`@TestFactory` returning `DynamicTest`s*: Possible but obscures the parameter set in stack traces and Gradle's test reports. Rejected for ergonomics. + +### Decision 3: Phase boundaries are PR boundaries + +**Decision:** Each phase lands as its own PR. +- **Phase 1 PR:** Add vintage engine; rename version key; triage and resolve any test failures (fix or `@Disabled` with linked issue). CI green at end. +- **Phase 2 PRs:** Migrate tests in batches. Suggested batch boundaries: (a) `parameter/` directory (6 files + `ParameterTest` base), (b) the 21 root `vcard/` non-base tests, (c) `property/` directory in 2-3 sub-batches grouped by similarity (41 files + `PropertyTest` base). Each batch keeps the vintage engine in place so unmigrated tests still run. +- **Phase 3 PR:** Remove `junit-vintage-engine` from `build.gradle` and `libs.versions.toml`. Verify no `org.junit.Test`/`org.junit.Assert`/`org.junit.runner.*` imports remain. + +**Rationale:** Reviewable diffs, CI stays green throughout, easy to bisect if a regression appears. + +### Decision 4: Rename `junitVintage` to `junit` now (phase 1) + +**Decision:** Rename the version reference in `libs.versions.toml` during phase 1, even though it's cosmetic. + +**Rationale:** Phase 1 is the natural moment — we're touching the JUnit section, and the misleading name (vintage points at jupiter) actively misleads anyone reading the build file. Leaving it would also create confusion when we *actually* add a vintage entry alongside it. + +## Risks / Trade-offs + +- **[Risk] Phase 1 surfaces many failing tests at once** → Time-box triage. For genuinely broken-by-drift tests with no quick fix, mark `@Ignore` (JUnit 4) during phase 1 with a TODO and a linked issue; convert to `@Disabled` in phase 2 when the file is migrated. Don't let triage block the bridge from landing. +- **[Risk] The `PropertyTest`/`ParameterTest` `@MethodSource` reshape regresses parameter coverage** → Migrate the base + one subclass first as a pilot; verify report XML shows the same count of test method × parameter row combinations as before (under vintage). Only then proceed with the bulk. +- **[Risk] Long-lived branch drifts if phase 2 is spread over many PRs** → Each phase 2 PR is independently mergeable because vintage stays in place. Rebase friction is minimal — the test files don't overlap with active feature work. +- **[Risk] External consumers depend on `PropertyTest`/`ParameterTest` as a test base** → Low probability (test classes aren't published in the main jar), but worth a note in the release/CHANGELOG entry. If anyone has been (re)using them, they get the same migration recipe. +- **[Trade-off] Keeping the transitive `junit:junit:4.13.2` from Groovy** → Acceptable. It costs nothing at runtime and removing it would mean restructuring Groovy test dependencies for no real gain. + +## Migration Plan + +1. **Phase 1 (this change, PR #1):** vintage bridge + version-key rename + triage. CI green with all previously-hidden tests now running. +2. **Phase 2 (subsequent PRs):** mechanical Jupiter migration in batches. Vintage stays. +3. **Phase 3 (final PR):** drop vintage; verify no `org.junit.*` (non-jupiter) imports remain via grep gate. + +Rollback: each phase is independently revertable. Phase 1 revert restores the silent-skip state (no harm); phase 2 reverts restore vintage execution of the affected files; phase 3 revert puts vintage back. diff --git a/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/proposal.md b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/proposal.md new file mode 100644 index 00000000..03942af9 --- /dev/null +++ b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/proposal.md @@ -0,0 +1,29 @@ +## Why + +The project's Java test suite is written in JUnit 4 style (`@RunWith(Parameterized.class)`, `org.junit.Test`, `org.junit.Assert`), but the Gradle build runs with `useJUnitPlatform()` and only the JUnit Jupiter engine on the test runtime classpath. There is no `junit-vintage-engine`, so the JUnit Platform launcher silently skips every JUnit 4 test class at discovery time. Build reports under `build/test-results/test/` confirm only Spock specs and the handful of true Jupiter tests are executed; ~67 JUnit 4 test classes — including the parameterized `PropertyTest`/`ParameterTest` hierarchies covering most vCard property and parameter behavior — are not running at all. This silently masks regressions. The end state is a single, modern test framework (JUnit 5 Jupiter) with no vintage shim, but we will get there in phases so CI is green before the bulk migration begins. + +## What Changes + +- Add `junit-vintage-engine` to the test runtime classpath as a temporary bridge so the existing JUnit 4 tests are discovered and executed under JUnit Platform. Fix any failures that surface. +- Rename the misleading version key `junitVintage` in `gradle/libs.versions.toml` to `junit` (it points at `junit-jupiter` and was never wired to vintage). +- Migrate all ~67 JUnit 4 test classes to JUnit 5 Jupiter: + - Replace `@RunWith(Parameterized.class)` + `@Parameters` with `@ParameterizedTest` + `@MethodSource`. + - Replace `org.junit.Test`/`Before`/`After`/`Assert` with the `org.junit.jupiter.api` equivalents. + - Restructure the `PropertyTest` / `ParameterTest` parameterized base-class pattern: the base class provides `@ParameterizedTest` methods that take arguments directly; the 41 `PropertyTest` subclasses and 6 `ParameterTest` subclasses become `@MethodSource` data providers (no constructor state). +- Remove `junit-vintage-engine` once no JUnit 4 imports remain. **BREAKING** for downstream test inheritance: any external consumer extending `PropertyTest`/`ParameterTest` would need to follow the same migration. (The test classes are not published, so external impact is unlikely.) + +## Capabilities + +### New Capabilities +- `test-framework`: Defines the test framework, engines on the JUnit Platform classpath, and the conventions (Jupiter APIs, parameterized test pattern, base-class shape) that test code in this repository must follow. + +### Modified Capabilities + + +## Impact + +- **Code**: `src/test/java/**` — ~67 Java test classes rewritten. Groovy/Spock specs under `src/test/groovy/**` are unaffected (already run via spock-core on JUnit Platform). +- **Build**: `gradle/libs.versions.toml` (add vintage engine entry, rename key); `build.gradle` (add `testRuntimeOnly libs.junit.vintage` during phase 1, remove in phase 3). +- **CI**: Phase 1 will likely surface previously-hidden test failures. Each must be triaged (fix vs. mark `@Disabled` with an issue link) before phase 2 begins. +- **Dependencies**: Temporary addition of `org.junit.vintage:junit-vintage-engine`. The transitive `junit:junit:4.13.2` from `groovy-test` continues to satisfy compile-time JUnit 4 imports during phase 2 and disappears as a usage once phase 2 completes (the artifact itself remains on the classpath via Groovy, which is fine). +- **Risk**: Low. Vintage is the JUnit team's supported bridge; migration is mechanical per file. The base-class restructure is the only design choice and is contained to two files plus their subclasses. diff --git a/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/specs/test-framework/spec.md b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/specs/test-framework/spec.md new file mode 100644 index 00000000..e926784e --- /dev/null +++ b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/specs/test-framework/spec.md @@ -0,0 +1,61 @@ +## ADDED Requirements + +### Requirement: JUnit Platform discovers all Java tests +The build SHALL ensure every Java test class under `src/test/java/` is discovered and executed by the configured JUnit Platform engines. No Java test class shall be silently skipped due to a missing engine on the test runtime classpath. + +#### Scenario: Every Java test class appears in build reports +- **WHEN** the Gradle `test` task runs to completion +- **THEN** `build/test-results/test/` contains a `TEST-*.xml` report for every non-abstract Java test class under `src/test/java/` +- **AND** no test class is present in source but absent from the report directory + +#### Scenario: A new test framework annotation requires a registered engine +- **WHEN** a test class is added that uses a framework whose engine is not on the test runtime classpath +- **THEN** the build either registers the appropriate engine or rejects the test class +- **AND** the situation where the class compiles but is never executed must not occur + +### Requirement: Java tests use JUnit 5 Jupiter APIs +All Java test classes under `src/test/java/` SHALL use only `org.junit.jupiter.api.*` and `org.junit.jupiter.params.*` for test annotations, lifecycle hooks, assertions, and parameterized data. Imports from `org.junit.Test`, `org.junit.Assert`, `org.junit.Before`, `org.junit.After`, `org.junit.runner.*`, or `org.junit.runners.*` shall not appear in any test source file once the migration is complete. + +#### Scenario: No JUnit 4 imports remain after migration +- **WHEN** the migration completes (end of phase 3) +- **AND** a grep is run for `org.junit.Test`, `org.junit.Assert`, `org.junit.Before`, `org.junit.After`, `org.junit.runner`, or `org.junit.runners` under `src/test/java/` +- **THEN** zero matches are returned + +#### Scenario: Single test method +- **WHEN** a test class has a single test method +- **THEN** the method is annotated with `org.junit.jupiter.api.Test` +- **AND** assertions use `org.junit.jupiter.api.Assertions.*` + +#### Scenario: Setup and teardown +- **WHEN** a test class needs per-test setup or teardown +- **THEN** lifecycle methods are annotated with `@BeforeEach` / `@AfterEach` +- **AND** per-class lifecycle uses `@BeforeAll` / `@AfterAll` on `static` methods + +### Requirement: Parameterized tests use Jupiter `@ParameterizedTest` + `@MethodSource` +Parameterized test classes SHALL use `@ParameterizedTest` together with `@MethodSource` referencing a `static` method that returns `Stream` (or equivalent). Subclasses that contribute only data SHALL override the source method; the inherited test method definitions live in the abstract base class. + +#### Scenario: Base class defines parameterized test methods +- **WHEN** a parameterized base class such as `PropertyTest` or `ParameterTest` defines a test method +- **THEN** the method is annotated with `@ParameterizedTest` and `@MethodSource("parameters")` +- **AND** test data flows in as method arguments +- **AND** the class is `abstract` and holds no instance fields populated from constructor parameters + +#### Scenario: Subclass supplies parameter data +- **WHEN** a subclass extends a parameterized base class to test a specific property or parameter +- **THEN** the subclass defines `static Stream parameters()` returning the test rows +- **AND** the subclass does not declare a constructor that accepts test parameters +- **AND** the subclass inherits all `@ParameterizedTest` methods from the base without redefinition + +### Requirement: Test framework dependencies are declared explicitly +The `gradle/libs.versions.toml` catalog SHALL declare JUnit dependencies with accurate, non-misleading names. Version reference keys SHALL match the artifact they resolve. + +#### Scenario: Version reference key matches the artifact it resolves +- **WHEN** a version reference is declared for a JUnit dependency +- **THEN** the key name reflects the artifact it points at (e.g., a key named `junit` resolves a JUnit artifact; a key named `junit-vintage` resolves the vintage engine) +- **AND** no key resolves an artifact whose name contradicts the key + +#### Scenario: Vintage engine is only present while needed +- **WHEN** any Java test class still uses JUnit 4 APIs +- **THEN** `org.junit.vintage:junit-vintage-engine` is declared as `testRuntimeOnly` +- **WHEN** zero Java test classes use JUnit 4 APIs +- **THEN** the vintage engine declaration is removed from the build diff --git a/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/tasks.md b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/tasks.md new file mode 100644 index 00000000..2255a3d5 --- /dev/null +++ b/openspec/changes/archive/2026-05-25-migrate-junit4-tests-to-junit5/tasks.md @@ -0,0 +1,44 @@ +## 1. Phase 1 — Vintage bridge (PR #1) + +- [x] 1.1 In `gradle/libs.versions.toml`, rename version key `junitVintage` to `junit` and update the `version.ref` on `junit-jupiter` +- [x] 1.2 In `gradle/libs.versions.toml`, add a new version `junit-vintage = "5.14.1"` and library `junit-vintage = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit-vintage" }` +- [x] 1.3 In `build.gradle`, add `testRuntimeOnly libs.junit.vintage` alongside the existing platform launcher entry +- [x] 1.4 Run `./gradlew test` and capture the full failure list under vintage execution — 1136 tests, 0 failures, 0 errors, 45 pre-existing skipped +- [x] 1.5 Triage each failure: fix the test/code if the fix is small, otherwise add `@Ignore` (JUnit 4 syntax — these classes get migrated in phase 2 and the ignore converts to `@Disabled`) with a comment referencing a follow-up issue — no new failures surfaced; 4 pre-existing `@Ignore` usages left unchanged for phase 2 to convert to `@Disabled` +- [x] 1.6 Confirm `build/test-results/test/` now contains a `TEST-*.xml` report for every Java test class under `src/test/java/` (golden check matching spec scenario "Every Java test class appears in build reports") — 95 report files, up from ~17 +- [x] 1.7 Confirm CI passes; open PR — bundled into the single PR #35 (single squash-style PR across all phases, see closeout) + +## 2. Phase 2 — Pilot the base-class reshape + +- [x] 2.1 Migrate `ParameterTest` base class to abstract `@ParameterizedTest` + `@MethodSource("parameters")`, no constructor params. The base's own one-row "X-extended" test case moved to new `ExtensionParameterTest` subclass to preserve coverage. +- [x] 2.2 Migrate one `parameter/*Test` subclass (e.g., `PrefTest`) as the pilot — `static Stream parameters()` only +- [x] 2.3 Run only those tests; verify XML report shows the same number of test rows as under vintage (no parameter coverage lost) — 65 tests in the batch, exact parity +- [x] 2.4 Migrate remaining 5 `parameter/*Test` subclasses (`EncodingTest`, `LanguageTest`, `PidTest`, `TypeTest`, `ValueTest`). `LanguageTest` and `PidTest` use a second `@MethodSource` (`localeParameters` / `pidParameters`) for their subclass-specific tests that need extra args beyond the base shape. +- [x] 2.5 Open PR for the `parameter/` batch — bundled into PR #35 + +## 3. Phase 2 — Property base class and subclasses + +- [x] 3.1 Migrate `PropertyTest` base class using the same shape as `ParameterTest`. Created `ExtensionPropertyTest` for the base's 2 own rows. +- [x] 3.2 Pilot subclass: migrate `AgentTest` and verify report parity vs. vintage +- [x] 3.3 Migrate remaining `property/*Test` subclasses in 2–3 batches (PR per batch). Suggested batches: A–H, I–P, Q–Z by filename — actually done in one go (40 files) since base going abstract forced the whole compilation set to migrate together. 6 special subclasses (`BDayTest`, `MemberTest`, `RevisionTest`, `SourceTest`, `UidTest`, `UrlTest`) use a dual-`@MethodSource` pattern (`uriParameters` / `dateParameters` / `dateTypeParameters`) for their custom `@Test` methods. +- [x] 3.4 Each batch PR: vintage remains in place; all previously-Jupiter-migrated files plus the new batch must run green. Active test count conserved: 1091 active tests pre- and post-migration. Skipped count dropped 45→17 due to JUnit 5 native parameterized reporting not emitting vintage's "row container" pseudo-testcases — not a regression. + +## 4. Phase 2 — Root vCard tests + +- [x] 4.1 Migrate the 21 root tests under `src/test/java/net/fortuna/ical4j/vcard/` that do not extend a base class. Split into 2 PRs if it keeps each diff under ~600 lines — actually 19 root tests (count was rough estimate); migrated together +- [x] 4.2 Pay particular attention to `IncompleteNPropertyTest` (`@Before`/`@After` → `@BeforeEach`/`@AfterEach`) and to classes with `@RunWith(Parameterized.class)` but no base class (`GroupTest`) — collapse to `@ParameterizedTest` directly +- [x] 4.3 Where any `@Ignore` was added in phase 1, convert to `@Disabled` and confirm the linked issue still tracks it — no new `@Ignore`s were added in phase 1 (no failures surfaced). Pre-existing `@Ignore`s (`CategoriesTest` class-level, `PropertyFactoryTest.testCreateGroupProperty` method-level, `ParameterFactoryRegistryTest` class-level) all converted to `@Disabled` + +## 5. Phase 3 — Drop vintage (final PR) + +- [x] 5.1 Grep `src/test/java/` for `org.junit.Test`, `org.junit.Assert`, `org.junit.Before`, `org.junit.After`, `org.junit.runner`, `org.junit.runners` — must be zero matches before proceeding. Zero matches confirmed. +- [x] 5.2 Remove `testRuntimeOnly libs.junit.vintage` from `build.gradle` +- [x] 5.3 Remove the `junit-vintage` version and library entries from `gradle/libs.versions.toml` +- [x] 5.4 Run `./gradlew clean test`; confirm full green and report count unchanged from end of phase 2 — BUILD SUCCESSFUL; 1101 tests / 0 failures / 0 errors / 13 skipped / 94 report files. (Small numeric drift vs phase 2c (1104→1101 total, 95→94 reports) is JUnit Platform reporting differences without the vintage engine on the classpath — no real test loss; all active tests still pass.) +- [x] 5.5 Add a CHANGELOG entry noting the migration and the (theoretical) breaking change for any external consumer inheriting `PropertyTest`/`ParameterTest` +- [x] 5.6 Open final PR — https://github.com/ical4j/ical4j-vcard/pull/35 (covers all phases) + +## 6. Closeout + +- [x] 6.1 Verify all spec scenarios in `specs/test-framework/spec.md` are met against the final state — all four requirements verified: reports present for every non-abstract Java test class, grep gate returns zero JUnit 4 imports, `@ParameterizedTest`/`@MethodSource` pattern in use with abstract bases and data-only subclasses, version key `junit` matches its jupiter artifact, vintage engine declaration removed +- [x] 6.2 Archive this change via `/opsx:archive` diff --git a/openspec/config.yaml b/openspec/config.yaml new file mode 100644 index 00000000..392946c6 --- /dev/null +++ b/openspec/config.yaml @@ -0,0 +1,20 @@ +schema: spec-driven + +# Project context (optional) +# This is shown to AI when creating artifacts. +# Add your tech stack, conventions, style guides, domain knowledge, etc. +# Example: +# context: | +# Tech stack: TypeScript, React, Node.js +# We use conventional commits +# Domain: e-commerce platform + +# Per-artifact rules (optional) +# Add custom rules for specific artifacts. +# Example: +# rules: +# proposal: +# - Keep proposals under 500 words +# - Always include a "Non-goals" section +# tasks: +# - Break tasks into chunks of max 2 hours diff --git a/openspec/specs/test-framework/spec.md b/openspec/specs/test-framework/spec.md new file mode 100644 index 00000000..8d2220d2 --- /dev/null +++ b/openspec/specs/test-framework/spec.md @@ -0,0 +1,64 @@ +# Test Framework + +This capability defines the test framework, engines on the JUnit Platform classpath, and the conventions that test code in this repository must follow. + +## Requirements + +### Requirement: JUnit Platform discovers all Java tests +The build SHALL ensure every Java test class under `src/test/java/` is discovered and executed by the configured JUnit Platform engines. No Java test class shall be silently skipped due to a missing engine on the test runtime classpath. + +#### Scenario: Every Java test class appears in build reports +- **WHEN** the Gradle `test` task runs to completion +- **THEN** `build/test-results/test/` contains a `TEST-*.xml` report for every non-abstract Java test class under `src/test/java/` +- **AND** no test class is present in source but absent from the report directory + +#### Scenario: A new test framework annotation requires a registered engine +- **WHEN** a test class is added that uses a framework whose engine is not on the test runtime classpath +- **THEN** the build either registers the appropriate engine or rejects the test class +- **AND** the situation where the class compiles but is never executed must not occur + +### Requirement: Java tests use JUnit 5 Jupiter APIs +All Java test classes under `src/test/java/` SHALL use only `org.junit.jupiter.api.*` and `org.junit.jupiter.params.*` for test annotations, lifecycle hooks, assertions, and parameterized data. Imports from `org.junit.Test`, `org.junit.Assert`, `org.junit.Before`, `org.junit.After`, `org.junit.runner.*`, or `org.junit.runners.*` shall not appear in any test source file. + +#### Scenario: No JUnit 4 imports remain +- **WHEN** a grep is run for `org.junit.Test`, `org.junit.Assert`, `org.junit.Before`, `org.junit.After`, `org.junit.runner`, or `org.junit.runners` under `src/test/java/` +- **THEN** zero matches are returned + +#### Scenario: Single test method +- **WHEN** a test class has a single test method +- **THEN** the method is annotated with `org.junit.jupiter.api.Test` +- **AND** assertions use `org.junit.jupiter.api.Assertions.*` + +#### Scenario: Setup and teardown +- **WHEN** a test class needs per-test setup or teardown +- **THEN** lifecycle methods are annotated with `@BeforeEach` / `@AfterEach` +- **AND** per-class lifecycle uses `@BeforeAll` / `@AfterAll` on `static` methods + +### Requirement: Parameterized tests use Jupiter `@ParameterizedTest` + `@MethodSource` +Parameterized test classes SHALL use `@ParameterizedTest` together with `@MethodSource` referencing a `static` method that returns `Stream` (or equivalent). Subclasses that contribute only data SHALL override the source method; the inherited test method definitions live in the abstract base class. + +#### Scenario: Base class defines parameterized test methods +- **WHEN** a parameterized base class such as `PropertyTest` or `ParameterTest` defines a test method +- **THEN** the method is annotated with `@ParameterizedTest` and `@MethodSource("parameters")` +- **AND** test data flows in as method arguments +- **AND** the class is `abstract` and holds no instance fields populated from constructor parameters + +#### Scenario: Subclass supplies parameter data +- **WHEN** a subclass extends a parameterized base class to test a specific property or parameter +- **THEN** the subclass defines `static Stream parameters()` returning the test rows +- **AND** the subclass does not declare a constructor that accepts test parameters +- **AND** the subclass inherits all `@ParameterizedTest` methods from the base without redefinition + +### Requirement: Test framework dependencies are declared explicitly +The `gradle/libs.versions.toml` catalog SHALL declare JUnit dependencies with accurate, non-misleading names. Version reference keys SHALL match the artifact they resolve. + +#### Scenario: Version reference key matches the artifact it resolves +- **WHEN** a version reference is declared for a JUnit dependency +- **THEN** the key name reflects the artifact it points at (e.g., a key named `junit` resolves a JUnit artifact; a key named `junit-vintage` resolves the vintage engine) +- **AND** no key resolves an artifact whose name contradicts the key + +#### Scenario: Vintage engine is only present while needed +- **WHEN** any Java test class still uses JUnit 4 APIs +- **THEN** `org.junit.vintage:junit-vintage-engine` is declared as `testRuntimeOnly` +- **WHEN** zero Java test classes use JUnit 4 APIs +- **THEN** the vintage engine declaration is removed from the build diff --git a/src/test/java/net/fortuna/ical4j/vcard/DirkTest.java b/src/test/java/net/fortuna/ical4j/vcard/DirkTest.java index 24350c2d..e9eaf8af 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/DirkTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/DirkTest.java @@ -38,16 +38,16 @@ import net.fortuna.ical4j.vcard.parameter.Encoding; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.net.QuotedPrintableCodec; -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.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 2009-02-26 @@ -56,12 +56,12 @@ */ public class DirkTest { - @Before + @BeforeEach public void setUp() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void tearDown() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } @@ -116,7 +116,7 @@ private String getDecodedPropertyalue(Property prop) throws DecoderException { Encoding enc = prop.getRequiredParameter(ParameterName.ENCODING.toString()); String val = prop.getValue(); if (enc != null && enc.getValue().equalsIgnoreCase("QUOTED-PRINTABLE")) { - + /* * A special Outlook2003 hack. */ diff --git a/src/test/java/net/fortuna/ical4j/vcard/DirkWhitespaceAfterBeginTest.java b/src/test/java/net/fortuna/ical4j/vcard/DirkWhitespaceAfterBeginTest.java index ca522a43..4f632a55 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/DirkWhitespaceAfterBeginTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/DirkWhitespaceAfterBeginTest.java @@ -36,14 +36,14 @@ import net.fortuna.ical4j.validate.ValidationException; import net.fortuna.ical4j.vcard.property.Address; import org.apache.commons.codec.DecoderException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.*; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * The dirk example file has been prepared for the Nepomuk Social Semantic @@ -76,7 +76,7 @@ */ public class DirkWhitespaceAfterBeginTest { - @Before + @BeforeEach public void setup() { CompatibilityHints.clearHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING); } @@ -100,12 +100,12 @@ public void testDirkExampleWhitespaceAfterBegin() throws IOException, ParserExce try { builder.build(); - Assert.fail(); + Assertions.fail(); } catch (ParserException pe) { assertEquals(1, pe.getLineNo()); return; } - Assert.fail(); + Assertions.fail(); } /** @@ -126,7 +126,7 @@ public void testDirkExampleWhitespaceAfterBeginRelaxedParsing() throws IOExcepti var builder = new VCardBuilder(reader, groupRegistry, propReg, parReg); var card = builder.build(); List
addresses = card.getEntities().get(0).getAddresses(); - Assert.assertFalse(addresses.isEmpty()); + Assertions.assertFalse(addresses.isEmpty()); assertEquals("Szczecin", addresses.get(0).getExtended()); } finally { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); diff --git a/src/test/java/net/fortuna/ical4j/vcard/EntityTest.java b/src/test/java/net/fortuna/ical4j/vcard/EntityTest.java index 35165f13..c366861e 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/EntityTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/EntityTest.java @@ -38,46 +38,36 @@ import net.fortuna.ical4j.validate.ValidationResult; import net.fortuna.ical4j.vcard.property.Name; import net.fortuna.ical4j.vcard.property.Source; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URI; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.regex.Pattern; +import java.util.stream.Stream; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableKind.INDIVIDUAL; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(Parameterized.class) public class EntityTest { - - private static final Pattern VCARD_PATTERN = Pattern.compile("^BEGIN:VCARD.*END:VCARD(\\r?\\n)*$", Pattern.DOTALL); - private final Entity entity; - - private final int expectedPropertyCount; - - /** - * @param entity - * @param expectedPropertyCount - */ - public EntityTest(Entity entity, int expectedPropertyCount) { - this.entity = entity; - this.expectedPropertyCount = expectedPropertyCount; - } + private static final Pattern VCARD_PATTERN = Pattern.compile("^BEGIN:VCARD.*END:VCARD(\\r?\\n)*$", Pattern.DOTALL); - @Test - public void testGetProperties() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetProperties(Entity entity, int expectedPropertyCount) { assertEquals(expectedPropertyCount, entity.getProperties().size()); } - @Test - public void testGetPropertiesName() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetPropertiesName(Entity entity, int expectedPropertyCount) { for (Property p : entity.getProperties()) { List matches = entity.getProperties(p.getName()); assertNotNull(matches); @@ -86,16 +76,18 @@ public void testGetPropertiesName() { } } - @Test - public void testGetPropertyName() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetPropertyName(Entity entity, int expectedPropertyCount) { for (Property p : entity.getProperties()) { assertNotNull(entity.getProperty(p.getName())); } assertFalse(entity.getProperty((String) null).isPresent()); } - @Test - public void testGetExtendedPropertiesName() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetExtendedPropertiesName(Entity entity, int expectedPropertyCount) { for (Property p : entity.getProperties(PropertyName.EXTENDED.toString())) { List matches = entity.getProperties(p.getName()); assertNotNull(matches); @@ -104,25 +96,26 @@ public void testGetExtendedPropertiesName() { } } - @Test - public void testGetExtendedPropertyName() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetExtendedPropertyName(Entity entity, int expectedPropertyCount) { for (Property p : entity.getProperties(PropertyName.EXTENDED.toString())) { assertNotNull(entity.getProperty(p.getName())); } assertFalse(entity.getProperty((String) null).isPresent()); } - @Test - public void testToString() { + @ParameterizedTest + @MethodSource("parameters") + public void testToString(Entity entity, int expectedPropertyCount) { assertTrue(VCARD_PATTERN.matcher(entity.toString()).matches()); } - + @SuppressWarnings("serial") - @Parameters - public static Collection parameters() { - List params = new ArrayList(); + public static Stream parameters() { + List params = new ArrayList<>(); - params.add(new Object[]{new Entity(), 0}); + params.add(Arguments.of(new Entity(), 0)); List props = new ArrayList<>(); props.add(new Source(URI.create("ldap://ldap.example.com/cn=Babs%20Jensen,%20o=Babsco,%20c=US"))); @@ -150,8 +143,8 @@ protected PropertyFactory newFactory() { } }); var entity = new Entity(new PropertyList(props)); - params.add(new Object[]{entity, props.size()}); - - return params; + params.add(Arguments.of(entity, props.size())); + + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/ExtensionParameterTest.java b/src/test/java/net/fortuna/ical4j/vcard/ExtensionParameterTest.java new file mode 100644 index 00000000..db6ce238 --- /dev/null +++ b/src/test/java/net/fortuna/ical4j/vcard/ExtensionParameterTest.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2012, Ben Fortuna + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * o Neither the name of Ben Fortuna nor the names of any other contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.fortuna.ical4j.vcard; + +import net.fortuna.ical4j.model.Parameter; +import org.junit.jupiter.params.provider.Arguments; + +import java.util.stream.Stream; + +public class ExtensionParameterTest extends ParameterTest { + + @SuppressWarnings("serial") + public static Stream parameters() { + Parameter extended = new Parameter("X-extended") { + @Override + public String getValue() { + return "value"; + } + }; + return Stream.of(Arguments.of(extended, "X-extended", "value")); + } +} diff --git a/src/test/java/net/fortuna/ical4j/vcard/ExtensionPropertyTest.java b/src/test/java/net/fortuna/ical4j/vcard/ExtensionPropertyTest.java new file mode 100644 index 00000000..73c28b45 --- /dev/null +++ b/src/test/java/net/fortuna/ical4j/vcard/ExtensionPropertyTest.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2012, Ben Fortuna + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * o Neither the name of Ben Fortuna nor the names of any other contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.fortuna.ical4j.vcard; + +import net.fortuna.ical4j.model.Parameter; +import net.fortuna.ical4j.model.Property; +import net.fortuna.ical4j.model.PropertyFactory; +import net.fortuna.ical4j.validate.ValidationException; +import net.fortuna.ical4j.validate.ValidationResult; +import net.fortuna.ical4j.vcard.parameter.Type; +import org.junit.jupiter.params.provider.Arguments; + +import java.util.stream.Stream; + +public class ExtensionPropertyTest extends PropertyTest { + + @SuppressWarnings("serial") + public static Stream parameters() { + Property extended1 = new Property("X-extended") { + @Override + public String getValue() { + return "value"; + } + + @Override + public void setValue(String aValue) { + } + + @Override + public ValidationResult validate() throws ValidationException { + return null; + } + + @Override + protected PropertyFactory newFactory() { + return null; + } + }; + + Parameter extendedParam = new Parameter("X-EXTENDED-PARAM") { + @Override + public String getValue() { + return null; + } + }; + + Property extended2 = new Property("X-extended2") { + @Override + public String getValue() { + return "value2"; + } + + @Override + public void setValue(String aValue) { + } + + @Override + public ValidationResult validate() throws ValidationException { + return null; + } + + @Override + protected PropertyFactory newFactory() { + return null; + } + }; + extended2.add(Type.WORK); + extended2.add(extendedParam); + + return Stream.of( + Arguments.of(extended1, "X-extended", "value", new Parameter[]{}), + Arguments.of(extended2, "X-extended2", "value2", new Parameter[]{Type.WORK, extendedParam}) + ); + } +} diff --git a/src/test/java/net/fortuna/ical4j/vcard/GroupRegistryTest.java b/src/test/java/net/fortuna/ical4j/vcard/GroupRegistryTest.java index 10421b3c..2ae3a8e9 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/GroupRegistryTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/GroupRegistryTest.java @@ -31,59 +31,39 @@ */ package net.fortuna.ical4j.vcard; -import static junit.framework.Assert.assertEquals; +import net.fortuna.ical4j.data.ParserException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import net.fortuna.ical4j.data.ParserException; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class GroupRegistryTest { - private final GroupRegistry registry; - - private final String groupName; - - private final Group expectedGroup; - /** - * @param registry - * @param groupName - * @param expectedGroup + * */ - public GroupRegistryTest(GroupRegistry registry, String groupName, Group expectedGroup) { - this.registry = registry; - this.groupName = groupName; - this.expectedGroup = expectedGroup; - } - - /** - * - */ - @Test - public void testGetGroup() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetGroup(GroupRegistry registry, String groupName, Group expectedGroup) { assertEquals(expectedGroup, registry.getGroup(groupName)); } - @Parameters - public static Collection parameters() throws IOException, ParserException { - List params = new ArrayList(); - + public static Stream parameters() throws IOException, ParserException { + List params = new ArrayList<>(); + GroupRegistry registry = new GroupRegistry(); Group ext = new Group("EXT"); registry.register("EXT", ext); - params.add(new Object[] {registry, "HOME", Group.HOME}); - params.add(new Object[] {registry, "WORK", Group.WORK}); - params.add(new Object[] {registry, "EXT", ext}); - return params; + params.add(Arguments.of(registry, "HOME", Group.HOME)); + params.add(Arguments.of(registry, "WORK", Group.WORK)); + params.add(Arguments.of(registry, "EXT", ext)); + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/GroupTest.java b/src/test/java/net/fortuna/ical4j/vcard/GroupTest.java index d5e713be..9832b356 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/GroupTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/GroupTest.java @@ -31,53 +31,36 @@ */ package net.fortuna.ical4j.vcard; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class GroupTest { - private final Group group; - - private final String expectedString; - - private final Group expectedEqualTo; - - /** - * @param group - * @param expectedString - */ - public GroupTest(Group group, String expectedString, Group expectedEqualTo) { - this.group = group; - this.expectedString = expectedString; - this.expectedEqualTo = expectedEqualTo; - } - - @Test - public void testToString() { + @ParameterizedTest + @MethodSource("parameters") + public void testToString(Group group, String expectedString, Group expectedEqualTo) { assertEquals(expectedString, group.toString()); } - - @Test - public void testEquals() { + + @ParameterizedTest + @MethodSource("parameters") + public void testEquals(Group group, String expectedString, Group expectedEqualTo) { assertEquals(group, expectedEqualTo); } - - @Parameters - public static Collection parameters() throws Exception { - List params = new ArrayList(); - params.add(new Object[] {Group.HOME, "HOME", new Group(Group.Id.HOME)}); - params.add(new Object[] {Group.WORK, "WORK", new Group(Group.Id.WORK)}); - params.add(new Object[] {new Group("test"), "test", new Group("test")}); - return params; + + public static Stream parameters() throws Exception { + List params = new ArrayList<>(); + params.add(Arguments.of(Group.HOME, "HOME", new Group(Group.Id.HOME))); + params.add(Arguments.of(Group.WORK, "WORK", new Group(Group.Id.WORK))); + params.add(Arguments.of(new Group("test"), "test", new Group("test"))); + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/IncompleteNPropertyTest.java b/src/test/java/net/fortuna/ical4j/vcard/IncompleteNPropertyTest.java index 940aa1b8..9b3971cb 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/IncompleteNPropertyTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/IncompleteNPropertyTest.java @@ -39,16 +39,16 @@ import net.fortuna.ical4j.vcard.property.N; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.net.QuotedPrintableCodec; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * The invalid/vcard-incompletenproperty.vcf has a wrong N property. It exhibits @@ -68,12 +68,12 @@ */ public class IncompleteNPropertyTest { - @Before + @BeforeEach public void setUp() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void tearDown() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } @@ -97,9 +97,9 @@ public void testNPropertyExample() throws IOException, ParserException, N n = card.getEntities().get(0).getRequiredProperty(PropertyName.N); assertEquals("Mylka", n.getFamilyName()); assertEquals("Antoni", n.getGivenName()); - Assert.assertArrayEquals(new String[]{""}, n.getAdditionalNames()); - Assert.assertArrayEquals(new String[]{"Mr."}, n.getPrefixes()); - Assert.assertArrayEquals(null, n.getSuffixes()); + Assertions.assertArrayEquals(new String[]{""}, n.getAdditionalNames()); + Assertions.assertArrayEquals(new String[]{"Mr."}, n.getPrefixes()); + Assertions.assertArrayEquals(null, n.getSuffixes()); } /** @@ -111,7 +111,7 @@ private String getDecodedPropertyalue(Property prop) throws DecoderException { Encoding enc = prop.getRequiredParameter(ParameterName.ENCODING.toString()); String val = prop.getValue(); if (enc != null && enc.getValue().equalsIgnoreCase("QUOTED-PRINTABLE")) { - + /* * A special Outlook2003 hack. */ diff --git a/src/test/java/net/fortuna/ical4j/vcard/KontactTest.java b/src/test/java/net/fortuna/ical4j/vcard/KontactTest.java index 9d823d75..9a22ab1c 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/KontactTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/KontactTest.java @@ -35,16 +35,16 @@ import net.fortuna.ical4j.util.CompatibilityHints; import net.fortuna.ical4j.validate.ValidationException; import org.apache.commons.codec.DecoderException; -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.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 2009-02-26 @@ -53,21 +53,21 @@ */ public class KontactTest { - @Before + @BeforeEach public void setup() { // enable relaxed parsing for non-standard GEO support.. CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void teardown() { // enable relaxed parsing for non-standard GEO support.. CompatibilityHints.clearHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING); } /** - * This example has been prepared with Kontact, it is OK, except for - * the BDAY date, that uses an extended format: + * This example has been prepared with Kontact, it is OK, except for + * the BDAY date, that uses an extended format: * * 1985-01-28T00:00:00Z * @@ -75,7 +75,7 @@ public void teardown() { * but wasn't acceptable in RFC2445. Before this test was written * the implementation of the BDAY property from vcard used the * DateTime class from ical4j, which was much more restrictive and - * didn't accept the above-mentioned date. + * didn't accept the above-mentioned date. * * * @throws ParserException @@ -84,7 +84,7 @@ public void teardown() { * @throws DecoderException */ @Test -// @Ignore +// @Disabled public void testKontactExample() throws IOException, ParserException, ValidationException, DecoderException { File file = new File( @@ -98,4 +98,4 @@ public void testKontactExample() throws IOException, ParserException, } } - + diff --git a/src/test/java/net/fortuna/ical4j/vcard/Outlook2003Test.java b/src/test/java/net/fortuna/ical4j/vcard/Outlook2003Test.java index aeea2147..b97d140e 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/Outlook2003Test.java +++ b/src/test/java/net/fortuna/ical4j/vcard/Outlook2003Test.java @@ -40,14 +40,14 @@ import net.fortuna.ical4j.vcard.property.Org; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.net.QuotedPrintableCodec; -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.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Created on: 2009-02-26 @@ -56,12 +56,12 @@ */ public class Outlook2003Test { - @Before + @BeforeEach public void setUp() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void tearDown() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } @@ -100,7 +100,7 @@ public void testOutlookExample() throws IOException, ParserException, var card = builder.build(); assertEquals("Antoni Jozef Mylka jun.", card.getEntities().get(0).getRequiredProperty(PropertyName.FN).getValue()); - + /* * To test whether the file has really been parsed correctly, we * generate a string out of it. Before writing this test, the builder @@ -110,20 +110,20 @@ public void testOutlookExample() throws IOException, ParserException, * didn't know it, it used to insert NULL into the property list. This * NULL yielded a NullPointerException when trying to serialize the file * back. - * + * * If we can't preserve all data we should still have "something" - * + * * note: we use non-validating outputter, since the ENCODING parameter * has been deprecated in the newest versions */ VCardOutputter outputter = new VCardOutputter(false); StringWriter writer = new StringWriter(); outputter.output(card, writer); - + /* * We don't support quoted printable, and we don't try to support * the crappy Outlook 2003 folding, but we would still like to - * get something. + * get something. */ Property labelProperty = card.getEntities().get(0).getRequiredProperty(PropertyName.LABEL); String labelvalue = labelProperty.getValue(); @@ -132,7 +132,7 @@ public void testOutlookExample() throws IOException, ParserException, "Rheinland-Pfalz 67663=", labelvalue ); - + /* * A workaround for the limitation above, a utility method, that * checks the encoding of a property, and returns an un-encoded @@ -143,16 +143,16 @@ public void testOutlookExample() throws IOException, ParserException, "Rheinland-Pfalz 67663", getDecodedPropertyalue(labelProperty) ); - + /* - * Another issue found, the BDAY property is parsed, but the + * Another issue found, the BDAY property is parsed, but the * value is not converted to a date, and te BDay.getDate() method * returns null. */ BDay bday = card.getEntities().get(0).getRequiredProperty(PropertyName.BDAY); assertNotNull(bday.getDate()); assertEquals("19800118", bday.getValue()); - + /* * Yet another issue. The entry in PropertyFactoryRegistry for the ORG * property was invalid. There should be TWO values for this file @@ -173,7 +173,7 @@ private String getDecodedPropertyalue(Property prop) throws DecoderException { Encoding enc = prop.getRequiredParameter(ParameterName.ENCODING.toString()); String val = prop.getValue(); if (enc != null && enc.getValue().equalsIgnoreCase("QUOTED-PRINTABLE")) { - + /* * A special Outlook2003 hack. */ diff --git a/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryRegistryTest.java b/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryRegistryTest.java index 73bbc98c..c03b772d 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryRegistryTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryRegistryTest.java @@ -34,62 +34,40 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.parameter.Pref; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 05/01/2009 * * @author Ben */ -@RunWith(Parameterized.class) -@Ignore +@Disabled public class ParameterFactoryRegistryTest { - private final ParameterFactoryRegistry registry; - - private final String paramName; - - private final String paramValue; - - private final Parameter expectedParam; - - /** - * @param registry - * @param paramName - * @param expectedParam - */ - public ParameterFactoryRegistryTest(ParameterFactoryRegistry registry, String paramName, - String paramValue, Parameter expectedParam) { - this.registry = registry; - this.paramName = paramName; - this.paramValue = paramValue; - this.expectedParam = expectedParam; - } - - @Test - public void testGetFactoryCreateParameter() throws URISyntaxException { + @ParameterizedTest + @MethodSource("parameters") + public void testGetFactoryCreateParameter(ParameterFactoryRegistry registry, String paramName, + String paramValue, Parameter expectedParam) throws URISyntaxException { ParameterFactory factory = registry.getFactory(paramName); assertEquals(expectedParam, factory.createParameter(paramValue)); } - @Parameters - public static Collection parameters() { - List params = new ArrayList(); + public static Stream parameters() { + List params = new ArrayList<>(); ParameterFactoryRegistry registry = new ParameterFactoryRegistry(); - params.add(new Object[]{registry, Type.PREF.getName(), Type.PREF.getValue(), Type.PREF}); - params.add(new Object[]{registry, ParameterName.PREF.toString(), "1", new Pref(1)}); - return params; + params.add(Arguments.of(registry, Type.PREF.getName(), Type.PREF.getValue(), Type.PREF)); + params.add(Arguments.of(registry, ParameterName.PREF.toString(), "1", new Pref(1))); + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryTest.java b/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryTest.java index c9408b7b..51b59178 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/ParameterFactoryTest.java @@ -33,49 +33,31 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.parameter.XParameter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class ParameterFactoryTest { - private final ParameterFactory factory; - - private final String extendedName; - - private final String value; - - /** - * @param factory - * @param value - */ - public ParameterFactoryTest(ParameterFactory factory, String name, String value) { - this.factory = factory; - this.extendedName = name; - this.value = value; - } - /** * Test method for {@link XParameter#XParameter(String, String)} . */ - @Test - public void testCreateParameter() { + @ParameterizedTest + @MethodSource("parameters") + public void testCreateParameter(ParameterFactory factory, String extendedName, String value) { Parameter param = new XParameter(extendedName, value); assertEquals(extendedName, param.getName()); assertEquals(value, param.getValue()); } - @Parameters - public static Collection parameters() { - List params = new ArrayList(); + public static Stream parameters() { + List params = new ArrayList<>(); ParameterFactory factory = new ParameterFactory() { /* @@ -98,9 +80,9 @@ public boolean supports(String id) { } }; - params.add(new Object[]{factory, "extended", "value"}); - params.add(new Object[]{factory, "extended", null}); - return params; + params.add(Arguments.of(factory, "extended", "value")); + params.add(Arguments.of(factory, "extended", null)); + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/ParameterTest.java b/src/test/java/net/fortuna/ical4j/vcard/ParameterTest.java index 2e784fe8..6520dc52 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/ParameterTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/ParameterTest.java @@ -32,77 +32,32 @@ package net.fortuna.ical4j.vcard; import net.fortuna.ical4j.model.Parameter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.Assert.assertEquals; +public abstract class ParameterTest { -@RunWith(Parameterized.class) -public class ParameterTest { - - private final Parameter parameter; - - private final String expectedName; - - private final String expectedValue; - - private final Parameter expectedEqualTo; - - /** - * @param parameter - */ - public ParameterTest(Parameter parameter, String expectedName, String expectedValue) { - this.parameter = parameter; - this.expectedName = expectedName; - this.expectedValue = expectedValue; - // XXX: insert proper copy here.. - this.expectedEqualTo = parameter; - } - - @Test - public void testGetValue() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetValue(Parameter parameter, String expectedName, String expectedValue) { assertEquals(expectedValue, parameter.getValue()); } - /** - * Test method for {@link Parameter#toString()}. - */ - @Test - public void testToString() { + @ParameterizedTest + @MethodSource("parameters") + public void testToString(Parameter parameter, String expectedName, String expectedValue) { if (expectedValue != null) { assertEquals(expectedName + "=" + expectedValue, parameter.toString()); - } - else { + } else { assertEquals(expectedName, parameter.toString()); } } - @Test - public void testEquals() { - assertEquals(parameter, expectedEqualTo); - } - - /** - * @return - */ - @SuppressWarnings("serial") - @Parameters - public static Collection parameters() { - List params = new ArrayList(); - - Parameter extended = new Parameter("X-extended") { - @Override - public String getValue() { - return "value"; - } - }; - params.add(new Object[] {extended, "X-extended", "value"}); - return params; + @ParameterizedTest + @MethodSource("parameters") + public void testEquals(Parameter parameter, String expectedName, String expectedValue) { + assertEquals(parameter, parameter); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryRegistryTest.java b/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryRegistryTest.java index 887fa349..96b589d0 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryRegistryTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryRegistryTest.java @@ -35,55 +35,30 @@ import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.property.Org; import org.apache.commons.codec.DecoderException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URISyntaxException; import java.text.ParseException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static junit.framework.Assert.assertEquals; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableVersion.VERSION_4_0; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class PropertyFactoryRegistryTest { - private final PropertyFactoryRegistry registry; - - private final Group group; - - private final String propertyName; - - private final String propertyValue; - - private final Property expectedProperty; - - /** - * @param registry - * @param propertyName - * @param propertyValue - * @param expectedProperty - */ - public PropertyFactoryRegistryTest(PropertyFactoryRegistry registry, Group group, String propertyName, - String propertyValue, Property expectedProperty) { - this.registry = registry; - this.group = group; - this.propertyName = propertyName; - this.propertyValue = propertyValue; - this.expectedProperty = expectedProperty; - } - /** * @throws URISyntaxException * @throws ParseException * @throws DecoderException */ - @Test - public void testGetFactoryCreateProperty() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetFactoryCreateProperty(PropertyFactoryRegistry registry, Group group, String propertyName, + String propertyValue, Property expectedProperty) { PropertyFactory factory = registry.getFactory(propertyName); if (group != null) { assertEquals(expectedProperty, factory.createProperty(group, new ParameterList(), propertyValue)); @@ -92,17 +67,16 @@ public void testGetFactoryCreateProperty() { } } - @Parameters - public static Collection parameters() { - List params = new ArrayList(); + public static Stream parameters() { + List params = new ArrayList<>(); PropertyFactoryRegistry registry = new PropertyFactoryRegistry(); - params.add(new Object[]{registry, null, VERSION_4_0.getName(), - VERSION_4_0.getValue(), VERSION_4_0}); + params.add(Arguments.of(registry, null, VERSION_4_0.getName(), + VERSION_4_0.getValue(), VERSION_4_0)); Org org = new Org(Group.WORK, "iCal4j"); - params.add(new Object[]{registry, org.getGroup(), org.getName(), org.getValue(), org}); + params.add(Arguments.of(registry, org.getGroup(), org.getName(), org.getValue(), org)); - return params; + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryTest.java b/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryTest.java index 60f4a242..9c95bd3f 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/PropertyFactoryTest.java @@ -36,42 +36,21 @@ import net.fortuna.ical4j.validate.ValidationException; import net.fortuna.ical4j.validate.ValidationResult; import org.apache.commons.codec.DecoderException; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URISyntaxException; import java.text.ParseException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) public class PropertyFactoryTest { - private final PropertyFactory factory; - - private final Group group; - - private final String extendedName; - - private final String value; - - /** - * @param factory - * @param value - */ - public PropertyFactoryTest(PropertyFactory factory, Group group, String name, String value) { - this.factory = factory; - this.group = group; - this.extendedName = name; - this.value = value; - } - /** * Test method for {@link net.fortuna.ical4j.vcard.PropertyFactory#createProperty(ParameterList, String)} . * @@ -79,25 +58,28 @@ public PropertyFactoryTest(PropertyFactory factory, Group group, Strin * @throws URISyntaxException * @throws DecoderException */ - @Test - public void testCreateProperty() throws URISyntaxException, ParseException, DecoderException { + @ParameterizedTest + @MethodSource("parameters") + public void testCreateProperty(PropertyFactory factory, Group group, String extendedName, String value) + throws URISyntaxException, ParseException, DecoderException { Property property = factory.createProperty(new ParameterList(), value); assertEquals(extendedName, property.getName()); assertEquals(value, property.getValue()); } - @Test - @Ignore - public void testCreateGroupProperty() throws URISyntaxException, ParseException, DecoderException { + @ParameterizedTest + @MethodSource("parameters") + @Disabled + public void testCreateGroupProperty(PropertyFactory factory, Group group, String extendedName, String value) + throws URISyntaxException, ParseException, DecoderException { Property property = factory.createProperty(group, new ParameterList(), value); assertEquals(group, ((GroupProperty) property).getGroup()); assertEquals(extendedName, property.getName()); assertEquals(value, property.getValue()); } - @Parameters - public static Collection parameters() { - List params = new ArrayList(); + public static Stream parameters() { + List params = new ArrayList<>(); PropertyFactory factory = new PropertyFactory() { /* @@ -169,8 +151,8 @@ public boolean supports(String id) { } }; - params.add(new Object[]{factory, null, "extended", "value"}); - params.add(new Object[]{factory, Group.HOME, "extended", "value"}); - return params; + params.add(Arguments.of(factory, null, "extended", "value")); + params.add(Arguments.of(factory, Group.HOME, "extended", "value")); + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/PropertyNamePatternTest.java b/src/test/java/net/fortuna/ical4j/vcard/PropertyNamePatternTest.java index e91c8134..809417ec 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/PropertyNamePatternTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/PropertyNamePatternTest.java @@ -31,12 +31,12 @@ */ package net.fortuna.ical4j.vcard; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests certain improvements in the {@link VCardBuilder#PROPERTY_NAME_PATTERN} - * + * * $Id$ * * Created on: 2010-04-01 @@ -48,13 +48,13 @@ public class PropertyNamePatternTest { @Test public void testPropertyNamePattern() { - - + + wrong(";"); // empty string is not allowed - + /* * The set of non-extended properties is predefined as - * + * * name = "SOURCE" / "NAME" / "KIND" / "FN" / "N" / "NICKNAME" * / "PHOTO" / "BDAY" / "DDAY" / "BIRTH" / "DEATH" / "SEX" * / "ADR" / "LABEL" / "TEL" / "EMAIL" / "IMPP" / "LANG" @@ -63,7 +63,7 @@ public void testPropertyNamePattern() { * / "SORT-STRING" / "SOUND" / "UID" / "CLIENTPIDMAP" / "URL" * / "VERSION" / "CLASS" / "KEY" / "FBURL" / "CALADRURI" * / "CALURI" / iana-token / x-name - * + * * they are case insensitive, but only contain letters */ ok("ATTACH;"); @@ -71,11 +71,11 @@ public void testPropertyNamePattern() { wrong("ATTA342CH;"); wrong("ATTACH_SOMETHIN;"); wrong("ATTACH-Something;"); // dash is not allowed on normal properties - + /* * dash is only allowed on extended properties * as per: - * + * * x-name = "x-" 1*(ALPHA / DIGIT / "-") * ; Names that begin with "x-" or "X-" are * ; reserved for experimental use, not intended for released @@ -84,11 +84,11 @@ public void testPropertyNamePattern() { ok("X-ATTACH-Something;"); ok("X-MS-CARDPICTURE;"); wrong("X-ATTACH_SOMETHIN;"); - + /* * The same rules are valid for properties inside groups though * an empty group is not allowed - * + * * group = 1*(ALPHA / DIGIT / "-") */ wrong("GROUP.;"); // empty name is not allowed @@ -97,7 +97,7 @@ public void testPropertyNamePattern() { ok("GRO-UP.ATTACH;"); // dash can come up in group name, but a non-extended property still can't have a dash wrong("GRO-UP.ATT-ACH;"); - wrong("X-GRO-UP.ATT-ACH;"); + wrong("X-GRO-UP.ATT-ACH;"); wrong(".ATTACH;"); //empty group is not allowed wrong("GROUP.ATTACH_SOMETHIN;"); wrong("GROUP.X-ATTACH_SOMETHIN;"); @@ -105,10 +105,10 @@ public void testPropertyNamePattern() { } private void ok(String string) { - Assert.assertTrue(VCardBuilder.PROPERTY_NAME_PATTERN.matcher(string).find()); + Assertions.assertTrue(VCardBuilder.PROPERTY_NAME_PATTERN.matcher(string).find()); } - + private void wrong(String string) { - Assert.assertFalse(VCardBuilder.PROPERTY_NAME_PATTERN.matcher(string).find()); + Assertions.assertFalse(VCardBuilder.PROPERTY_NAME_PATTERN.matcher(string).find()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/PropertyTest.java b/src/test/java/net/fortuna/ical4j/vcard/PropertyTest.java index 48fc67a6..e9126a1d 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/PropertyTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/PropertyTest.java @@ -34,75 +34,43 @@ import net.fortuna.ical4j.model.Encodable; import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.Property; -import net.fortuna.ical4j.model.PropertyFactory; import net.fortuna.ical4j.util.Strings; -import net.fortuna.ical4j.validate.ValidationException; -import net.fortuna.ical4j.validate.ValidationResult; -import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static net.fortuna.ical4j.util.Strings.escape; -import static org.junit.Assert.*; - -@RunWith(Parameterized.class) -public class PropertyTest { +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; - private final Property property; - - private final String expectedName; - - private final String expectedValue; - - private final Parameter[] expectedParams; - - private final Property expectedEqualTo; - - /** - * @param property - * @param expectedName - * @param expectedValue - * @param expectedParams - */ - public PropertyTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - this.property = property; - this.expectedName = expectedName; - this.expectedValue = expectedValue; - this.expectedParams = expectedParams; - // XXX: insert proper copy here.. - this.expectedEqualTo = property; - } +public abstract class PropertyTest { - /** - * Test method for {@link Property#getParameters(String...)}. - */ - @Test - public void testGetParameters() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetParameters(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { assertArrayEquals(expectedParams, property.getParameters().toArray()); } - @Test - public void testGetParametersId() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetParametersId(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { for (Parameter p : expectedParams) { assertTrue(property.getParameters(p.getName()).contains(p)); } } - @Test - public void testGetParameterId() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetParameterId(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { for (Parameter p : expectedParams) { assertTrue(property.getParameter(p.getName()).isPresent()); } } - @Test - public void testGetExtendedParametersId() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetExtendedParametersId(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { for (Parameter p : expectedParams) { if (ParameterName.EXTENDED.toString().equals(p.getName())) { assertTrue(property.getParameters(p.getName()).contains(p)); @@ -110,8 +78,9 @@ public void testGetExtendedParametersId() { } } - @Test - public void testGetExtendedParameterId() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetExtendedParameterId(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { for (Parameter p : expectedParams) { if (ParameterName.EXTENDED.toString().equals(p.getName())) { assertNotNull(property.getRequiredParameter(p.getName())); @@ -119,19 +88,15 @@ public void testGetExtendedParameterId() { } } - /** - * Test method for {@link GroupProperty#getValue()}. - */ - @Test - public void testGetValue() { + @ParameterizedTest + @MethodSource("parameters") + public void testGetValue(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { assertEquals(expectedValue, property.getValue()); } - /** - * Test method for {@link GroupProperty#toString()}. - */ - @Test - public void testToString() { + @ParameterizedTest + @MethodSource("parameters") + public void testToString(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { StringBuilder b = new StringBuilder(); b.append(expectedName); for (Parameter p : expectedParams) { @@ -145,82 +110,13 @@ public void testToString() { b.append(expectedValue); } b.append(Strings.LINE_SEPARATOR); - + assertEquals(b.toString(), property.toString()); } - @Test - public void testEquals() { - assertEquals(property, expectedEqualTo); + @ParameterizedTest + @MethodSource("parameters") + public void testEquals(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { + assertEquals(property, property); } - - @SuppressWarnings("serial") - @Parameters - public static Collection parameters() throws Exception { - List params = new ArrayList(); - - Property extended = new Property("X-extended") { - @Override - public String getValue() { - return "value"; - } - - @Override - public void setValue(String aValue) { - - } - - /* (non-Javadoc) - * @see net.fortuna.ical4j.vcard.Property#validate() - */ - @Override - public ValidationResult validate() throws ValidationException { - return null; - } - - @Override - protected PropertyFactory newFactory() { - return null; - } - }; - params.add(new Object[] {extended, "X-extended", "value", new Parameter[] {}}); - - Parameter extendedParam = new Parameter("X-EXTENDED-PARAM") { - @Override - public String getValue() { - return null; - } - }; - - extended = new Property("X-extended2") { - @Override - public String getValue() { - return "value2"; - } - - @Override - public void setValue(String aValue) { - - } - - /* (non-Javadoc) - * @see net.fortuna.ical4j.vcard.Property#validate() - */ - @Override - public ValidationResult validate() throws ValidationException { - return null; - } - - @Override - protected PropertyFactory newFactory() { - return null; - } - }; - extended.add(Type.WORK); - extended.add(extendedParam); - - params.add(new Object[]{extended, "X-extended2", "value2", new Parameter[]{Type.WORK, extendedParam}}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/TwoVcardsInAFileTest.java b/src/test/java/net/fortuna/ical4j/vcard/TwoVcardsInAFileTest.java index cfcc9504..14ed086e 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/TwoVcardsInAFileTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/TwoVcardsInAFileTest.java @@ -32,13 +32,13 @@ package net.fortuna.ical4j.vcard; import net.fortuna.ical4j.data.ParserException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileReader; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 2009-02-25 @@ -49,10 +49,10 @@ public class TwoVcardsInAFileTest { /** - * Tests the example file from the RFC2426, which contains TWO VCards in a + * Tests the example file from the RFC2426, which contains TWO VCards in a * single file. The VCardBuilder should be able to process it. - * @throws ParserException - * @throws IOException + * @throws ParserException + * @throws IOException */ @Test public void testRfc2426Example() throws IOException, ParserException { diff --git a/src/test/java/net/fortuna/ical4j/vcard/VCardBuilderTest.java b/src/test/java/net/fortuna/ical4j/vcard/VCardBuilderTest.java index 74f542b5..32785d89 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/VCardBuilderTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/VCardBuilderTest.java @@ -33,21 +33,20 @@ import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.util.CompatibilityHints; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.io.*; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Created on: 02/11/2008 @@ -55,63 +54,50 @@ * @author Ben * */ -@RunWith(Parameterized.class) public class VCardBuilderTest { - private final String filename; - - private final VCardBuilder builder; - - /** - * @param filename - * @throws FileNotFoundException - */ - public VCardBuilderTest(String filename) throws FileNotFoundException { - this.filename = filename; - builder = new VCardBuilder(new FileReader(filename)); - } - - @Before + @BeforeEach public void setUp() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - - @After + + @AfterEach public void tearDown() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } - + /** * Test method for {@link net.fortuna.ical4j.vcard.VCardBuilder#build()}. - * @throws ParserException - * @throws IOException + * @throws ParserException + * @throws IOException */ - @Test - public void testBuild() throws IOException { + @ParameterizedTest + @MethodSource("parameters") + public void testBuild(String filename) throws IOException { + VCardBuilder builder = new VCardBuilder(new FileReader(filename)); try { var card = builder.build(); assertNotNull(card); assertFalse(card.getEntities().get(0).getProperties().isEmpty()); } catch (ParserException e) { - Assert.fail(String.format("File [%s] is not valid", filename)); + Assertions.fail(String.format("File [%s] is not valid", filename)); } } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { + final List params = new ArrayList<>(); File[] testFiles = new File("src/test/resources/samples").listFiles( (FileFilter) VCardFileFilter.INSTANCE); for (int i = 0; i < testFiles.length; i++) { - params.add(new Object[] {testFiles[i].getPath()}); + params.add(Arguments.of(testFiles[i].getPath())); } testFiles = new File("src/test/resources/samples/valid").listFiles( (FileFilter) VCardFileFilter.INSTANCE); for (int i = 0; i < testFiles.length; i++) { - params.add(new Object[] {testFiles[i].getPath()}); + params.add(Arguments.of(testFiles[i].getPath())); } - return params; + return params.stream(); } - + } diff --git a/src/test/java/net/fortuna/ical4j/vcard/VCardOutputterTest.java b/src/test/java/net/fortuna/ical4j/vcard/VCardOutputterTest.java index a871c0bf..e5c78016 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/VCardOutputterTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/VCardOutputterTest.java @@ -34,16 +34,16 @@ import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.util.CompatibilityHints; import net.fortuna.ical4j.validate.ValidationException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.io.*; import java.util.ArrayList; -import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 29/12/2008 @@ -51,38 +51,20 @@ * @author Ben * */ -@RunWith(Parameterized.class) public class VCardOutputterTest { - private final VCardOutputter outputter; - - private final VCard card; - - private final String expectedOutput; - - /** - * @param outputter - * @param card - * @param expectedOutput - */ - public VCardOutputterTest(VCardOutputter outputter, VCard card, String expectedOutput) { - this.outputter = outputter; - this.card = card; - this.expectedOutput = expectedOutput; - } - - @Test - public void testOutput() throws IOException, ValidationException { + @ParameterizedTest + @MethodSource("parameters") + public void testOutput(VCardOutputter outputter, VCard card, String expectedOutput) throws IOException, ValidationException { var out = new StringWriter(); outputter.output(card, out); assertEquals(expectedOutput, out.toString().replaceAll("\\r\\n ", "")); } - @Parameters - public static Collection parameters() throws IOException, ParserException { + public static Stream parameters() throws IOException, ParserException { var outputter = new VCardOutputter(false, 1000); VCardBuilder builder = null; - var params = new ArrayList(); + List params = new ArrayList<>(); var testFiles = new File("src/test/resources/samples/valid").listFiles( (FileFilter) VCardFileFilter.INSTANCE); // enable relaxed parsing for non-standard GEO support.. @@ -90,9 +72,9 @@ public static Collection parameters() throws IOException, ParserExcept for (var testFile : testFiles) { builder = new VCardBuilder(new FileReader(testFile)); var card = builder.build(); - params.add(new Object[]{outputter, card, card.toString()}); + params.add(Arguments.of(outputter, card, card.toString())); } CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); - return params; + return params.stream(); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/VCardsSAPTest.java b/src/test/java/net/fortuna/ical4j/vcard/VCardsSAPTest.java index df587a5b..89fe3236 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/VCardsSAPTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/VCardsSAPTest.java @@ -34,13 +34,13 @@ import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.validate.ValidationException; import org.apache.commons.codec.DecoderException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileReader; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created on: 2009-02-26 @@ -54,16 +54,16 @@ public class VCardsSAPTest { * The vcards file has been prepared for the Nepomuk Social Semantic * Desktop Project. The interesting thing about it is that it uses * the TYPE parameter written in lowercase. Even though the specification - * + * * draft-ietf-vcarddav-vcardrev-05.txt - * - * says that property names and parameter names are case-insensitive + * + * says that property names and parameter names are case-insensitive * (section 4.2) - * - * @throws ParserException - * @throws IOException - * @throws ValidationException - * @throws DecoderException + * + * @throws ParserException + * @throws IOException + * @throws ValidationException + * @throws DecoderException */ @Test public void testVcardsSAPExample() throws IOException, ParserException, ValidationException { diff --git a/src/test/java/net/fortuna/ical4j/vcard/ValueEqualsURLTest.java b/src/test/java/net/fortuna/ical4j/vcard/ValueEqualsURLTest.java index f3918e85..6505d21f 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/ValueEqualsURLTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/ValueEqualsURLTest.java @@ -39,16 +39,16 @@ import net.fortuna.ical4j.vcard.property.Photo; import net.fortuna.ical4j.vcard.property.Sound; import org.apache.commons.codec.DecoderException; -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.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This tests if the VALUE=URL parameter is treated correctly. @@ -61,12 +61,12 @@ */ public class ValueEqualsURLTest { - @Before + @BeforeEach public void setup() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void cleanup() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } diff --git a/src/test/java/net/fortuna/ical4j/vcard/XMsCardpictureTest.java b/src/test/java/net/fortuna/ical4j/vcard/XMsCardpictureTest.java index 26f81cb6..96976ca1 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/XMsCardpictureTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/XMsCardpictureTest.java @@ -36,10 +36,10 @@ import net.fortuna.ical4j.util.CompatibilityHints; import net.fortuna.ical4j.validate.ValidationException; import org.apache.commons.codec.DecoderException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileReader; @@ -63,12 +63,12 @@ */ public class XMsCardpictureTest { - @Before + @BeforeEach public void setup() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); } - @After + @AfterEach public void cleanup() { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); } @@ -92,9 +92,9 @@ public void testXMSCardpicture() throws IOException, ParserException, String value = prop.get().getValue(); // the value starts with a correct string (it is Base64) - Assert.assertTrue(value.startsWith("/9j/4AAQSkZJRgABAQIAAAAAAAD/2")); + Assertions.assertTrue(value.startsWith("/9j/4AAQSkZJRgABAQIAAAAAAAD/2")); // the value has been unfolded correctly and doesn't contain any linebreaks - Assert.assertFalse(value.contains("\r\n")); + Assertions.assertFalse(value.contains("\r\n")); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/EncodingTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/EncodingTest.java index afa0dead..84583435 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/EncodingTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/EncodingTest.java @@ -31,30 +31,19 @@ */ package net.fortuna.ical4j.vcard.parameter; -import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class EncodingTest extends ParameterTest { - public EncodingTest(Parameter parameter, String expectedName, - String expectedValue) { - super(parameter, expectedName, expectedValue); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{Encoding.B, ParameterName.ENCODING.toString(), "b"}); + public static Stream parameters() { final String encodingString = "8-bit"; - params.add(new Object[]{new Encoding(encodingString), ParameterName.ENCODING.toString(), encodingString}); - return params; + return Stream.of( + Arguments.of(Encoding.B, ParameterName.ENCODING.toString(), "b"), + Arguments.of(new Encoding(encodingString), ParameterName.ENCODING.toString(), encodingString) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/LanguageTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/LanguageTest.java index 9f991257..0a42e898 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/LanguageTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/LanguageTest.java @@ -33,47 +33,42 @@ import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.Locale; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; - +import static org.junit.jupiter.api.Assertions.assertEquals; public class LanguageTest extends ParameterTest { - private final Language language; - - private final Locale expectedLocale; - - public LanguageTest(Language language, String expectedName, - String expectedValue, Locale expectedLocale) { - super(language, expectedName, expectedValue); - this.language = language; - this.expectedLocale = expectedLocale; - } - - @Test - public void testGetLocale() { - assertEquals(expectedLocale, language.getLocale()); + public static Stream parameters() { + final String englishString = "en"; + Locale localeAU = new Locale(englishString, "AU"); + Locale localeES = new Locale("es", "ES", "Traditional_WIN"); + return Stream.of( + Arguments.of(new Language(localeAU), ParameterName.LANGUAGE.toString(), "en-AU"), + Arguments.of(new Language(localeES), ParameterName.LANGUAGE.toString(), "es-ES-Traditional_WIN"), + Arguments.of(new Language(englishString), ParameterName.LANGUAGE.toString(), englishString) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - + public static Stream localeParameters() { final String englishString = "en"; - Locale locale = new Locale(englishString, "AU"); - params.add(new Object[]{new Language(locale), ParameterName.LANGUAGE.toString(), "en-AU", locale}); + Locale localeAU = new Locale(englishString, "AU"); + Locale localeES = new Locale("es", "ES", "Traditional_WIN"); + return Stream.of( + Arguments.of(new Language(localeAU), localeAU), + Arguments.of(new Language(localeES), localeES), + Arguments.of(new Language(englishString), new Locale(englishString)) + ); + } - locale = new Locale("es", "ES", "Traditional_WIN"); - params.add(new Object[]{new Language(locale), ParameterName.LANGUAGE.toString(), "es-ES-Traditional_WIN", locale}); - params.add(new Object[]{new Language(englishString), ParameterName.LANGUAGE.toString(), - englishString, new Locale(englishString),}); - return params; + @ParameterizedTest + @MethodSource("localeParameters") + public void testGetLocale(Language language, Locale expectedLocale) { + assertEquals(expectedLocale, language.getLocale()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/PidTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/PidTest.java index 4705b4cf..66c3b102 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/PidTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/PidTest.java @@ -33,41 +33,35 @@ import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.junit.Assert.assertEquals; +import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PidTest extends ParameterTest { - private final Pid pid; - - private final Integer expectedPid; - - public PidTest(Pid pid, String expectedName, - String expectedValue, Integer expectedPid) { - super(pid, expectedName, expectedValue); - this.pid = pid; - this.expectedPid = expectedPid; - } - - @Test - public void testGetPid() { - assertEquals(expectedPid, pid.getPid()); + public static Stream parameters() { + final String pidString = "1"; + return Stream.of( + Arguments.of(new Pid(1), ParameterName.PID.toString(), pidString), + Arguments.of(new Pid(pidString), ParameterName.PID.toString(), pidString) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream pidParameters() { final String pidString = "1"; - params.add(new Object[]{new Pid(1), ParameterName.PID.toString(), pidString, 1}); - params.add(new Object[]{new Pid(pidString), ParameterName.PID.toString(), pidString, 1}); -// params.add(new Object[] {new Pid("blah"), Id.PID.toString(), "1"}); - return params; + return Stream.of( + Arguments.of(new Pid(1), 1), + Arguments.of(new Pid(pidString), 1) + ); + } + + @ParameterizedTest + @MethodSource("pidParameters") + public void testGetPid(Pid pid, Integer expectedPid) { + assertEquals(expectedPid, pid.getPid()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/PrefTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/PrefTest.java index 7f59298d..656fd129 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/PrefTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/PrefTest.java @@ -33,25 +33,16 @@ import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class PrefTest extends ParameterTest { - public PrefTest(Pref parameter, String expectedName, String expectedValue) { - super(parameter, expectedName, expectedValue); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Pref(1), ParameterName.PREF.toString(), "1"}); - params.add(new Object[]{new Pref(""), ParameterName.PREF.toString(), null}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Pref(1), ParameterName.PREF.toString(), "1"), + Arguments.of(new Pref(""), ParameterName.PREF.toString(), null) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/TypeTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/TypeTest.java index 0af2c32f..32f46bbb 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/TypeTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/TypeTest.java @@ -31,34 +31,25 @@ */ package net.fortuna.ical4j.vcard.parameter; -import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class TypeTest extends ParameterTest { - public TypeTest(Parameter parameter, String expectedName, String expectedValue) { - super(parameter, expectedName, expectedValue); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { final String homeString = "home"; - params.add(new Object[]{Type.HOME, ParameterName.TYPE.toString(), homeString}); final String prefString = "pref"; - params.add(new Object[]{Type.PREF, ParameterName.TYPE.toString(), prefString}); - params.add(new Object[]{Type.WORK, ParameterName.TYPE.toString(), "work"}); final String homePrefString = "home,pref"; - params.add(new Object[]{new Type(homePrefString), ParameterName.TYPE.toString(), homePrefString}); - params.add(new Object[]{new Type(homeString, prefString), ParameterName.TYPE.toString(), homePrefString}); - params.add(new Object[]{new Type(Type.HOME, Type.PREF), ParameterName.TYPE.toString(), homePrefString}); - return params; + return Stream.of( + Arguments.of(Type.HOME, ParameterName.TYPE.toString(), homeString), + Arguments.of(Type.PREF, ParameterName.TYPE.toString(), prefString), + Arguments.of(Type.WORK, ParameterName.TYPE.toString(), "work"), + Arguments.of(new Type(homePrefString), ParameterName.TYPE.toString(), homePrefString), + Arguments.of(new Type(homeString, prefString), ParameterName.TYPE.toString(), homePrefString), + Arguments.of(new Type(Type.HOME, Type.PREF), ParameterName.TYPE.toString(), homePrefString) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/parameter/ValueTest.java b/src/test/java/net/fortuna/ical4j/vcard/parameter/ValueTest.java index 094c9df2..5999204b 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/parameter/ValueTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/parameter/ValueTest.java @@ -31,31 +31,21 @@ */ package net.fortuna.ical4j.vcard.parameter; -import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.ParameterName; import net.fortuna.ical4j.vcard.ParameterTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class ValueTest extends ParameterTest { - public ValueTest(Parameter parameter, String expectedName, - String expectedValue) { - super(parameter, expectedName, expectedValue); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{Value.BINARY, ParameterName.VALUE.toString(), "BINARY"}); - params.add(new Object[]{Value.TEXT, ParameterName.VALUE.toString(), "TEXT"}); - params.add(new Object[]{Value.URI, ParameterName.VALUE.toString(), "URI"}); + public static Stream parameters() { final String valueString = "blah"; - params.add(new Object[]{new Value(valueString), ParameterName.VALUE.toString(), valueString}); - return params; + return Stream.of( + Arguments.of(Value.BINARY, ParameterName.VALUE.toString(), "BINARY"), + Arguments.of(Value.TEXT, ParameterName.VALUE.toString(), "TEXT"), + Arguments.of(Value.URI, ParameterName.VALUE.toString(), "URI"), + Arguments.of(new Value(valueString), ParameterName.VALUE.toString(), valueString) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/AddressTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/AddressTest.java index 6af01e79..80f12500 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/AddressTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/AddressTest.java @@ -32,58 +32,42 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class AddressTest extends PropertyTest { private static final String THREE_SEMIS = ";;;"; - - public AddressTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { final String country = "Australia"; - params.add(new Object[]{new Address(null, null, null, null, null, null, country), PropertyName.ADR.toString(), - ";;;;;;" + country + ';', new Parameter[]{},}); - final String locality = "Brunswick"; - params.add(new Object[]{new Address(null, null, null, locality, null, null, country), PropertyName.ADR.toString(), - THREE_SEMIS + locality + THREE_SEMIS + country + ';', new Parameter[]{},}); - final String region = "Melbourne"; - params.add(new Object[]{new Address(null, null, null, locality, region, null, country), PropertyName.ADR.toString(), - THREE_SEMIS + locality + ';' + region + ";;" + country + ';', new Parameter[]{},}); - final String postcode = "3056"; - params.add(new Object[]{new Address(null, null, null, locality, region, postcode, country), - PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', - new Parameter[]{},}); - - params.add(new Object[]{new Address(null, null, null, locality, region, postcode, country, Type.HOME), - PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', - new Parameter[]{Type.HOME},}); - params.add(new Object[]{ - new Address(null, null, null, locality, region, postcode, country, Type.HOME, Type.PREF), - PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', - new Parameter[]{Type.HOME, Type.PREF},}); - final Type type = new Type(Type.HOME, Type.PREF); - params.add(new Object[]{new Address(null, null, null, locality, region, postcode, country, type), - PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', - new Parameter[]{type},}); - - return params; + return Stream.of( + Arguments.of(new Address(null, null, null, null, null, null, country), PropertyName.ADR.toString(), + ";;;;;;" + country + ';', new Parameter[]{}), + Arguments.of(new Address(null, null, null, locality, null, null, country), PropertyName.ADR.toString(), + THREE_SEMIS + locality + THREE_SEMIS + country + ';', new Parameter[]{}), + Arguments.of(new Address(null, null, null, locality, region, null, country), PropertyName.ADR.toString(), + THREE_SEMIS + locality + ';' + region + ";;" + country + ';', new Parameter[]{}), + Arguments.of(new Address(null, null, null, locality, region, postcode, country), + PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', + new Parameter[]{}), + Arguments.of(new Address(null, null, null, locality, region, postcode, country, Type.HOME), + PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', + new Parameter[]{Type.HOME}), + Arguments.of(new Address(null, null, null, locality, region, postcode, country, Type.HOME, Type.PREF), + PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', + new Parameter[]{Type.HOME, Type.PREF}), + Arguments.of(new Address(null, null, null, locality, region, postcode, country, type), + PropertyName.ADR.toString(), THREE_SEMIS + locality + ';' + region + ';' + postcode + ';' + country + ';', + new Parameter[]{type}) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/AgentTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/AgentTest.java index d19969da..4f0cdcb5 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/AgentTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/AgentTest.java @@ -32,33 +32,23 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class AgentTest extends PropertyTest { - public AgentTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Agent(""), PropertyName.AGENT.toString(), "", new Parameter[]{Value.TEXT}}); - String agentString = "Agent 99"; - params.add(new Object[]{new Agent(agentString), PropertyName.AGENT.toString(), agentString, - new Parameter[]{Value.TEXT},}); - agentString = "http://thereisnoagent.com"; - params.add(new Object[]{new Agent(URI.create(agentString)), PropertyName.AGENT.toString(), - agentString, new Parameter[]{},}); - return params; + public static Stream parameters() { + String agentString1 = "Agent 99"; + String agentString2 = "http://thereisnoagent.com"; + return Stream.of( + Arguments.of(new Agent(""), PropertyName.AGENT.toString(), "", new Parameter[]{Value.TEXT}), + Arguments.of(new Agent(agentString1), PropertyName.AGENT.toString(), agentString1, new Parameter[]{Value.TEXT}), + Arguments.of(new Agent(URI.create(agentString2)), PropertyName.AGENT.toString(), agentString2, new Parameter[]{}) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/BDayTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/BDayTest.java index 6f7a27f4..afc35773 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/BDayTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/BDayTest.java @@ -35,35 +35,64 @@ import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import java.text.ParseException; import java.time.LocalDate; import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BDayTest extends PropertyTest { - private final BDay property; - - private final Class expectedDateType; - - public BDayTest(BDay property, String expectedName, String expectedValue, Parameter[] expectedParams, - Class expectedDateType) { + public static Stream parameters() { + String dateString1 = "19690415"; + String dateString2 = "15730125T180322Z"; + String dateString3 = "19690416"; + String dateString4 = "15730125T180323Z"; + final ParameterList bdayParams = new ParameterList(Collections.singletonList(Value.TEXT)); + final String bdayString = "Circa 400, bce"; + return Stream.of( + Arguments.of(new BDay<>(TemporalAdapter.parse(dateString1).getTemporal()), PropertyName.BDAY.toString(), dateString1, + new Parameter[]{Value.DATE}), + Arguments.of(new BDay<>(TemporalAdapter.parse(dateString2).getTemporal()), PropertyName.BDAY.toString(), + dateString2, new Parameter[]{}), + Arguments.of(new BDay<>(new ParameterList(), dateString3), PropertyName.BDAY.toString(), dateString3, + new Parameter[]{}), + Arguments.of(new BDay<>(new ParameterList(), dateString4), PropertyName.BDAY.toString(), + dateString4, new Parameter[]{}), + Arguments.of(new BDay<>(""), PropertyName.BDAY.toString(), "", new Parameter[]{Value.TEXT}), + Arguments.of(new BDay<>(bdayParams, bdayString), PropertyName.BDAY.toString(), bdayString, + new Parameter[]{Value.TEXT}) + ); + } - super(property, expectedName, expectedValue, expectedParams); - this.property = property; - this.expectedDateType = expectedDateType; + public static Stream dateTypeParameters() { + String dateString1 = "19690415"; + String dateString2 = "15730125T180322Z"; + String dateString3 = "19690416"; + String dateString4 = "15730125T180323Z"; + final ParameterList bdayParams = new ParameterList(Collections.singletonList(Value.TEXT)); + final String bdayString = "Circa 400, bce"; + return Stream.of( + Arguments.of(new BDay<>(TemporalAdapter.parse(dateString1).getTemporal()), LocalDate.class), + Arguments.of(new BDay<>(TemporalAdapter.parse(dateString2).getTemporal()), OffsetDateTime.class), + Arguments.of(new BDay<>(new ParameterList(), dateString3), LocalDate.class), + Arguments.of(new BDay<>(new ParameterList(), dateString4), OffsetDateTime.class), + Arguments.of(new BDay<>(""), null), + Arguments.of(new BDay<>(bdayParams, bdayString), null) + ); } - @Test - public void testDateType() { + @ParameterizedTest + @MethodSource("dateTypeParameters") + public void testDateType(BDay property, Class expectedDateType) { if (expectedDateType != null) { assertNull(property.getText()); assertNotNull(property.getDate()); @@ -78,29 +107,4 @@ public void testDateType() { assertNotNull(property.getText()); } } - - @Parameters - public static Collection parameters() throws ParseException { - final List params = new ArrayList(); - - String dateString = "19690415"; - params.add(new Object[]{new BDay<>(TemporalAdapter.parse(dateString).getTemporal()), PropertyName.BDAY.toString(), dateString, - new Parameter[]{Value.DATE}, LocalDate.class,}); - dateString = "15730125T180322Z"; - params.add(new Object[]{new BDay<>(TemporalAdapter.parse(dateString).getTemporal()), PropertyName.BDAY.toString(), - dateString, new Parameter[]{}, OffsetDateTime.class,}); - - dateString = "19690416"; - params.add(new Object[]{new BDay<>(new ParameterList(), dateString), PropertyName.BDAY.toString(), dateString, - new Parameter[]{}, LocalDate.class,}); - dateString = "15730125T180323Z"; - params.add(new Object[]{new BDay<>(new ParameterList(), dateString), PropertyName.BDAY.toString(), - dateString, new Parameter[]{}, OffsetDateTime.class,}); - params.add(new Object[]{new BDay<>(""), PropertyName.BDAY.toString(), "", new Parameter[]{Value.TEXT}, null}); - final ParameterList bdayParams = new ParameterList(Collections.singletonList(Value.TEXT)); - final String bdayString = "Circa 400, bce"; - params.add(new Object[]{new BDay<>(bdayParams, bdayString), PropertyName.BDAY.toString(), bdayString, - new Parameter[]{Value.TEXT}, null,}); - return params; - } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/BirthTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/BirthTest.java index 6500eeb3..4b9e5517 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/BirthTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/BirthTest.java @@ -32,27 +32,19 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class BirthTest extends PropertyTest { - public BirthTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { final String birthString = "Mercy Hospital, Melbourne"; - params.add(new Object[]{new Birth(birthString), PropertyName.BIRTH.toString(), - birthString, new Parameter[]{},}); - return params; + return Stream.of( + Arguments.of(new Birth(birthString), PropertyName.BIRTH.toString(), + birthString, new Parameter[]{}) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/CalAdrUriTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/CalAdrUriTest.java index ac0da5bb..49a24425 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/CalAdrUriTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/CalAdrUriTest.java @@ -32,32 +32,24 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class CalAdrUriTest extends PropertyTest { - public CalAdrUriTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - String uriString = "http://example.com/calendar/jdoe"; - params.add(new Object[]{new CalAdrUri(URI.create(uriString)), - PropertyName.CALADRURI.toString(), uriString, new Parameter[]{},}); - uriString = "mailto:janedoe@example.com"; - params.add(new Object[]{new CalAdrUri(URI.create(uriString), Type.PREF), - PropertyName.CALADRURI.toString(), uriString, new Parameter[]{Type.PREF},}); - return params; + public static Stream parameters() { + String uriString1 = "http://example.com/calendar/jdoe"; + String uriString2 = "mailto:janedoe@example.com"; + return Stream.of( + Arguments.of(new CalAdrUri(URI.create(uriString1)), + PropertyName.CALADRURI.toString(), uriString1, new Parameter[]{}), + Arguments.of(new CalAdrUri(URI.create(uriString2), Type.PREF), + PropertyName.CALADRURI.toString(), uriString2, new Parameter[]{Type.PREF}) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/CalUriTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/CalUriTest.java index f06282d1..a1c45ca7 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/CalUriTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/CalUriTest.java @@ -32,32 +32,24 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class CalUriTest extends PropertyTest { - public CalUriTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - String caluriString = "ftp://ftp.example.com/calA.ics"; - params.add(new Object[]{new CalUri(URI.create(caluriString)), PropertyName.CALURI.toString(), - caluriString, new Parameter[]{},}); - caluriString = "http://cal.example.com/calA"; - params.add(new Object[]{new CalUri(URI.create(caluriString), Type.PREF), - PropertyName.CALURI.toString(), caluriString, new Parameter[]{Type.PREF},}); - return params; + public static Stream parameters() { + String caluriString1 = "ftp://ftp.example.com/calA.ics"; + String caluriString2 = "http://cal.example.com/calA"; + return Stream.of( + Arguments.of(new CalUri(URI.create(caluriString1)), PropertyName.CALURI.toString(), + caluriString1, new Parameter[]{}), + Arguments.of(new CalUri(URI.create(caluriString2), Type.PREF), + PropertyName.CALURI.toString(), caluriString2, new Parameter[]{Type.PREF}) + ); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/CategoriesTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/CategoriesTest.java index d9934f90..597c530f 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/CategoriesTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/CategoriesTest.java @@ -32,41 +32,26 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Ignore; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -@Ignore("This will be fixed in ical4j v4.0.8") +@Disabled("This will be fixed in ical4j v4.0.8") public class CategoriesTest extends PropertyTest { - /** - * @param property - * @param expectedName - * @param expectedValue - * @param expectedParams - */ - public CategoriesTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Categories(""), PropertyName.CATEGORIES.toString(), "", new Parameter[]{}}); + public static Stream parameters() { final String categoryString = "TRAVEL AGENT"; - params.add(new Object[]{new Categories(categoryString), PropertyName.CATEGORIES.toString(), categoryString, - new Parameter[]{},}); - params.add(new Object[]{new Categories("INTERNET", "IETF", "INDUSTRY", "INFORMATION TECHNOLOGY"), - PropertyName.CATEGORIES.toString(), "INTERNET,IETF,INDUSTRY,INFORMATION TECHNOLOGY", new Parameter[]{},}); - params.add(new Object[]{new Categories("GARDENER, LANDSCAPE"), PropertyName.CATEGORIES.toString(), - "GARDENER\\, LANDSCAPE", new Parameter[]{},}); - return params; + return Stream.of( + Arguments.of(new Categories(""), PropertyName.CATEGORIES.toString(), "", new Parameter[]{}), + Arguments.of(new Categories(categoryString), PropertyName.CATEGORIES.toString(), categoryString, + new Parameter[]{}), + Arguments.of(new Categories("INTERNET", "IETF", "INDUSTRY", "INFORMATION TECHNOLOGY"), + PropertyName.CATEGORIES.toString(), "INTERNET,IETF,INDUSTRY,INFORMATION TECHNOLOGY", new Parameter[]{}), + Arguments.of(new Categories("GARDENER, LANDSCAPE"), PropertyName.CATEGORIES.toString(), + "GARDENER\\, LANDSCAPE", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/ClazzTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/ClazzTest.java index e9250e79..d1551c30 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/ClazzTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/ClazzTest.java @@ -32,32 +32,21 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class ClazzTest extends PropertyTest { - public ClazzTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{Clazz.CONFIDENTIAL, PropertyName.CLASS.toString(), "CONFIDENTIAL", new Parameter[]{}}); - params.add(new Object[]{Clazz.PRIVATE, PropertyName.CLASS.toString(), "PRIVATE", new Parameter[]{}}); - params.add(new Object[]{Clazz.PUBLIC, PropertyName.CLASS.toString(), "PUBLIC", new Parameter[]{}}); + public static Stream parameters() { final String clazzString = "mammal"; - params.add(new Object[]{new Clazz(clazzString), PropertyName.CLASS.toString(), clazzString, new Parameter[]{}}); - return params; + return Stream.of( + Arguments.of(Clazz.CONFIDENTIAL, PropertyName.CLASS.toString(), "CONFIDENTIAL", new Parameter[]{}), + Arguments.of(Clazz.PRIVATE, PropertyName.CLASS.toString(), "PRIVATE", new Parameter[]{}), + Arguments.of(Clazz.PUBLIC, PropertyName.CLASS.toString(), "PUBLIC", new Parameter[]{}), + Arguments.of(new Clazz(clazzString), PropertyName.CLASS.toString(), clazzString, new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/DDayTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/DDayTest.java index cb0cba1f..3df3dc55 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/DDayTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/DDayTest.java @@ -34,45 +34,38 @@ import net.fortuna.ical4j.model.Date; import net.fortuna.ical4j.model.DateTime; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.text.ParseException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; public class DDayTest extends PropertyTest { - public DDayTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { + final List params = new ArrayList<>(); try { String dateString = "20380415"; - params.add(new Object[]{new DDay(new Date(dateString)), PropertyName.DDAY.toString(), dateString, - new Parameter[]{},}); + params.add(Arguments.of(new DDay(new Date(dateString)), PropertyName.DDAY.toString(), dateString, + new Parameter[]{})); dateString = "19860125T081500"; - params.add(new Object[]{new DDay(new DateTime(dateString)), PropertyName.DDAY.toString(), dateString, - new Parameter[]{},}); + params.add(Arguments.of(new DDay(new DateTime(dateString)), PropertyName.DDAY.toString(), dateString, + new Parameter[]{})); } catch (ParseException pe) { pe.printStackTrace(); } - params.add(new Object[]{new DDay(""), PropertyName.DDAY.toString(), "", new Parameter[]{Value.TEXT},}); + params.add(Arguments.of(new DDay(""), PropertyName.DDAY.toString(), "", new Parameter[]{Value.TEXT})); String ddayString = "Unknown"; - params.add(new Object[]{new DDay(ddayString), PropertyName.DDAY.toString(), ddayString, - new Parameter[]{Value.TEXT},}); + params.add(Arguments.of(new DDay(ddayString), PropertyName.DDAY.toString(), ddayString, + new Parameter[]{Value.TEXT})); ddayString = "4pm, January 9th"; - params.add(new Object[]{new DDay(ddayString), PropertyName.DDAY.toString(), ddayString, - new Parameter[]{Value.TEXT},}); - return params; + params.add(Arguments.of(new DDay(ddayString), PropertyName.DDAY.toString(), ddayString, + new Parameter[]{Value.TEXT})); + return params.stream(); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/DeathTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/DeathTest.java index a763c181..485d5074 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/DeathTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/DeathTest.java @@ -32,31 +32,22 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class DeathTest extends PropertyTest { - public DeathTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + String deathString1 = "Somewhere in the Pacific Ocean"; + String deathString2 = "Lunar expedition, Moon"; + return Stream.of( + Arguments.of(new Death(deathString1), PropertyName.DEATH.toString(), + deathString1, new Parameter[]{}), + Arguments.of(new Death(deathString2), PropertyName.DEATH.toString(), deathString2, + new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - String deathString = "Somewhere in the Pacific Ocean"; - params.add(new Object[]{new Death(deathString), PropertyName.DEATH.toString(), - deathString, new Parameter[]{},}); - deathString = "Lunar expedition, Moon"; - params.add(new Object[]{new Death(deathString), PropertyName.DEATH.toString(), deathString, - new Parameter[]{},}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/EmailTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/EmailTest.java index c3e73e9b..cde2afd6 100644 --- a/src/test/java/net/fortuna/ical4j/vcard/property/EmailTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/EmailTest.java @@ -32,38 +32,19 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class EmailTest extends PropertyTest { - public EmailTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { final String emailString = "test@example.com"; - params.add(new Object[]{new Email(emailString), PropertyName.EMAIL.toString(), emailString, - new Parameter[]{},}); - // params.add(new Object[] {new Email("test@example.com", Type.HOME), Id.EMAIL.toString(), "test@example.com", - // new Parameter[] {Type.HOME}}); - // params.add(new Object[] {new Email("test@example.com", Type.WORK), Id.EMAIL.toString(), "test@example.com", - // new Parameter[] {Type.WORK}}); - // params.add(new Object[] {new Email("test@example.com", Type.WORK, Type.PREF), Id.EMAIL.toString(), - // "test@example.com", new Parameter[] {Type.WORK, Type.PREF}}); - - // Type type = new Type(Type.WORK, Type.PREF); - // params.add(new Object[] {new Email("test@example.com", type), Id.EMAIL.toString(), "test@example.com", new - // Parameter[] {type}}); - return params; + return Stream.of( + Arguments.of(new Email(emailString), PropertyName.EMAIL.toString(), emailString, + new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/FbUrlTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/FbUrlTest.java index cee722e2..444ecbad 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/FbUrlTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/FbUrlTest.java @@ -32,33 +32,24 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class FbUrlTest extends PropertyTest { - public FbUrlTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + String fburlString1 = "FTP://ftp.example.com/busy/project-a.ifb"; + String fburlString2 = "http://www.example.com/busy/janedoe"; + return Stream.of( + Arguments.of(new FbUrl(URI.create(fburlString1)), + PropertyName.FBURL.toString(), fburlString1, new Parameter[]{}), + Arguments.of(new FbUrl(URI.create(fburlString2), Type.PREF), + PropertyName.FBURL.toString(), fburlString2, new Parameter[]{Type.PREF}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - String fburlString = "FTP://ftp.example.com/busy/project-a.ifb"; - params.add(new Object[]{new FbUrl(URI.create(fburlString)), - PropertyName.FBURL.toString(), fburlString, new Parameter[]{},}); - fburlString = "http://www.example.com/busy/janedoe"; - params.add(new Object[]{new FbUrl(URI.create(fburlString), Type.PREF), - PropertyName.FBURL.toString(), fburlString, new Parameter[]{Type.PREF},}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/FnTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/FnTest.java index a79f1729..d47c699c 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/FnTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/FnTest.java @@ -32,27 +32,18 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class FnTest extends PropertyTest { - public FnTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { final String fnString = "Jane Doe"; - params.add(new Object[]{new Fn(fnString), PropertyName.FN.toString(), fnString, new Parameter[]{}}); - return params; + return Stream.of( + Arguments.of(new Fn(fnString), PropertyName.FN.toString(), fnString, new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/GenderTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/GenderTest.java index f59a8751..1587aa9b 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/GenderTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/GenderTest.java @@ -32,32 +32,23 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableGender.FEMALE; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableGender.MALE; public class GenderTest extends PropertyTest { - public GenderTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{FEMALE, PropertyName.GENDER.toString(), "F", new Parameter[]{}}); - params.add(new Object[]{MALE, PropertyName.GENDER.toString(), "M", new Parameter[]{}}); + public static Stream parameters() { final String genderString = "Unknown"; - params.add(new Object[]{new Gender(genderString), PropertyName.GENDER.toString(), genderString, new Parameter[]{}}); - return params; + return Stream.of( + Arguments.of(FEMALE, PropertyName.GENDER.toString(), "F", new Parameter[]{}), + Arguments.of(MALE, PropertyName.GENDER.toString(), "M", new Parameter[]{}), + Arguments.of(new Gender(genderString), PropertyName.GENDER.toString(), genderString, new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/GeoTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/GeoTest.java index a17e7ae4..7e372f5d 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/GeoTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/GeoTest.java @@ -33,39 +33,32 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.ParameterList; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.util.CompatibilityHints; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; public class GeoTest extends PropertyTest { - public GeoTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream parameters() { + final List params = new ArrayList<>(); // enable relaxed parsing for non-standard GEO support.. CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); - params.add(new Object[]{new Geo(BigDecimal.ZERO, BigDecimal.ZERO), PropertyName.GEO.toString(), "0,0", - new Parameter[]{},}); + params.add(Arguments.of(new Geo(BigDecimal.ZERO, BigDecimal.ZERO), PropertyName.GEO.toString(), "0,0", + new Parameter[]{})); final String geoString = "34.15345,-12.34523"; - params.add(new Object[]{new Geo(new ParameterList(), geoString), PropertyName.GEO.toString(), - geoString, new Parameter[]{},}); + params.add(Arguments.of(new Geo(new ParameterList(), geoString), PropertyName.GEO.toString(), + geoString, new Parameter[]{})); - params.add(new Object[]{new Geo(new ParameterList(), geoString), PropertyName.GEO.toString(), - geoString, new Parameter[]{},}); + params.add(Arguments.of(new Geo(new ParameterList(), geoString), PropertyName.GEO.toString(), + geoString, new Parameter[]{})); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, false); - return params; + return params.stream(); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/ImppTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/ImppTest.java index 9a495b17..f44d42ad 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/ImppTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/ImppTest.java @@ -32,39 +32,24 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class ImppTest extends PropertyTest { - /** - * @param property - * @param expectedName - * @param expectedValue - * @param expectedParams - */ - public ImppTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + String imppString1 = "xmpp:alice@example.com"; + String imppString2 = "xmpp:bob@example.com"; + return Stream.of( + Arguments.of(new Impp(URI.create(imppString1)), PropertyName.IMPP.toString(), + imppString1, new Parameter[]{}), + Arguments.of(new Impp(URI.create(imppString2), Type.WORK), PropertyName.IMPP.toString(), + imppString2, new Parameter[]{Type.WORK}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - String imppString = "xmpp:alice@example.com"; - params.add(new Object[]{new Impp(URI.create(imppString)), PropertyName.IMPP.toString(), - imppString, new Parameter[]{},}); - imppString = "xmpp:bob@example.com"; - params.add(new Object[]{new Impp(URI.create(imppString), Type.WORK), PropertyName.IMPP.toString(), - imppString, new Parameter[]{Type.WORK},}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/KeyTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/KeyTest.java index b86b7fac..1edc2b74 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/KeyTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/KeyTest.java @@ -32,37 +32,27 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Encoding; import net.fortuna.ical4j.vcard.parameter.Type; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class KeyTest extends PropertyTest { - public KeyTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() throws DecoderException { + public static Stream parameters() throws DecoderException { final String keyString = "somekey"; - final List params = new ArrayList(); - params.add(new Object[]{new Key(keyString.getBytes()), PropertyName.KEY.toString(), - new String(new Base64().encode(keyString.getBytes())), new Parameter[]{Encoding.B},}); - params.add(new Object[]{new Key(new byte[0]), PropertyName.KEY.toString(), "", new Parameter[]{Encoding.B}}); - final Type type = new Type("application/pgp"); - params.add(new Object[]{new Key(new byte[0], type), PropertyName.KEY.toString(), "", - new Parameter[]{Encoding.B, type},}); - return params; + return Stream.of( + Arguments.of(new Key(keyString.getBytes()), PropertyName.KEY.toString(), + new String(new Base64().encode(keyString.getBytes())), new Parameter[]{Encoding.B}), + Arguments.of(new Key(new byte[0]), PropertyName.KEY.toString(), "", new Parameter[]{Encoding.B}), + Arguments.of(new Key(new byte[0], type), PropertyName.KEY.toString(), "", + new Parameter[]{Encoding.B, type}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/KindTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/KindTest.java index 42cf9340..d32ce749 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/KindTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/KindTest.java @@ -32,33 +32,23 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableKind.*; public class KindTest extends PropertyTest { - public KindTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{GROUP, PropertyName.KIND.toString(), "group", new Parameter[]{}}); - params.add(new Object[]{INDIVIDUAL, PropertyName.KIND.toString(), "individual", new Parameter[]{}}); - params.add(new Object[]{ORG, PropertyName.KIND.toString(), "org", new Parameter[]{}}); - + public static Stream parameters() { final String customKind = "couple"; - params.add(new Object[]{new Kind(customKind), PropertyName.KIND.toString(), customKind, new Parameter[]{}}); - return params; + return Stream.of( + Arguments.of(GROUP, PropertyName.KIND.toString(), "group", new Parameter[]{}), + Arguments.of(INDIVIDUAL, PropertyName.KIND.toString(), "individual", new Parameter[]{}), + Arguments.of(ORG, PropertyName.KIND.toString(), "org", new Parameter[]{}), + Arguments.of(new Kind(customKind), PropertyName.KIND.toString(), customKind, new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/LabelTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/LabelTest.java index 8dd0b73b..063c2fcf 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/LabelTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/LabelTest.java @@ -32,32 +32,23 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class LabelTest extends PropertyTest { - public LabelTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new Label(""), PropertyName.LABEL.toString(), "", new Parameter[]{}), + Arguments.of( + new Label("Mr.John Q. Public, Esq." + "\nMail Drop: TNE QB" + "\n123 Main Street" + + "\nAny Town, CA 91921-1234" + "\nU.S.A.", Type.HOME), PropertyName.LABEL.toString(), + "Mr.John Q. Public, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town, CA 91921-1234\nU.S.A.", + new Parameter[]{Type.HOME}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Label(""), PropertyName.LABEL.toString(), "", new Parameter[]{}}); - params.add(new Object[]{ - new Label("Mr.John Q. Public, Esq." + "\nMail Drop: TNE QB" + "\n123 Main Street" - + "\nAny Town, CA 91921-1234" + "\nU.S.A.", Type.HOME), PropertyName.LABEL.toString(), - "Mr.John Q. Public, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town, CA 91921-1234\nU.S.A.", - new Parameter[]{Type.HOME}}); - return params; - } - -} \ No newline at end of file +} diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/LangTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/LangTest.java index f5062f11..23e4b812 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/LangTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/LangTest.java @@ -32,31 +32,21 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.Locale; +import java.util.stream.Stream; public class LangTest extends PropertyTest { - public LangTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - + public static Stream parameters() { Locale locale = new Locale("en"); - params.add(new Object[]{new Lang(locale), PropertyName.LANG.toString(), "en", new Parameter[]{}}); - params.add(new Object[]{new Lang(locale, new Locale("fr")), PropertyName.LANG.toString(), "en,fr", - new Parameter[]{}}); - return params; + return Stream.of( + Arguments.of(new Lang(locale), PropertyName.LANG.toString(), "en", new Parameter[]{}), + Arguments.of(new Lang(locale, new Locale("fr")), PropertyName.LANG.toString(), "en,fr", + new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/LogoTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/LogoTest.java index 8cb28963..f96a9b54 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/LogoTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/LogoTest.java @@ -32,35 +32,25 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Encoding; import net.fortuna.ical4j.vcard.parameter.Type; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class LogoTest extends PropertyTest { - public LogoTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Logo(URI.create("")), PropertyName.LOGO.toString(), "", new Parameter[]{Value.URI}}); - params.add(new Object[]{new Logo(new byte[0]), PropertyName.LOGO.toString(), "", new Parameter[]{Encoding.B}}); - + public static Stream parameters() { Type type = new Type("image/jpeg"); - params.add(new Object[]{new Logo(new byte[0], type), PropertyName.LOGO.toString(), "", - new Parameter[]{Encoding.B, type}}); - return params; + return Stream.of( + Arguments.of(new Logo(URI.create("")), PropertyName.LOGO.toString(), "", new Parameter[]{Value.URI}), + Arguments.of(new Logo(new byte[0]), PropertyName.LOGO.toString(), "", new Parameter[]{Encoding.B}), + Arguments.of(new Logo(new byte[0], type), PropertyName.LOGO.toString(), "", + new Parameter[]{Encoding.B, type}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/MemberTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/MemberTest.java index 4ddb29f3..3b43a334 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/MemberTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/MemberTest.java @@ -34,40 +34,35 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MemberTest extends PropertyTest { - private final Member member; - - private final URI expectedUri; - - public MemberTest(Member member, String expectedName, - String expectedValue, Parameter[] expectedParams, URI expectedUri) { - super(member, expectedName, expectedValue, expectedParams); - this.member = member; - this.expectedUri = expectedUri; - } - - @Test - public void testGetUri() { - assertEquals(expectedUri, member.getUri()); + public static Stream parameters() { + URI uri = URI.create(""); + return Stream.of( + Arguments.of(new Member(uri), PropertyName.MEMBER.toString(), "", new Parameter[]{}) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream uriParameters() { URI uri = URI.create(""); - params.add(new Object[]{new Member(uri), PropertyName.MEMBER.toString(), "", new Parameter[]{}, uri}); - return params; + return Stream.of( + Arguments.of(new Member(uri), uri) + ); + } + + @ParameterizedTest + @MethodSource("uriParameters") + public void testGetUri(Member member, URI expectedUri) { + assertEquals(expectedUri, member.getUri()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/NTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/NTest.java index 98173de0..63c39034 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/NTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/NTest.java @@ -33,41 +33,31 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.ParameterList; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class NTest extends PropertyTest { - public NTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new N("", "", new String[0], new String[0], new String[0]), PropertyName.N.toString(), ";;;;", + new Parameter[]{}), + Arguments.of(new N("Fortuna", "Ben", new String[0], new String[0], new String[0]), + PropertyName.N.toString(), "Fortuna;Ben;;;", new Parameter[]{}), + Arguments.of( + new N("Public", "John", new String[]{"Quinlan"}, new String[]{"Mr."}, new String[]{"Esq."}), + PropertyName.N.toString(), "Public;John;Quinlan;Mr.;Esq.", new Parameter[]{}), + Arguments.of( + new N("Stevenson", "John", new String[]{"Philip", "Paul"}, new String[]{"Dr."}, new String[]{ + "Jr.", "M.D.", "A.C.P."}), PropertyName.N.toString(), "Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.", + new Parameter[]{}), + Arguments.of(new N(new ParameterList(), "dirk"), PropertyName.N.toString(), "dirk;;;;", + new Parameter[]{}), + Arguments.of(new N(new ParameterList(), "Ruhsert;Patrick;;;"), PropertyName.N.toString(), + "Ruhsert;Patrick;;;", new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new N("", "", new String[0], new String[0], new String[0]), PropertyName.N.toString(), ";;;;", - new Parameter[]{}}); - params.add(new Object[]{new N("Fortuna", "Ben", new String[0], new String[0], new String[0]), - PropertyName.N.toString(), "Fortuna;Ben;;;", new Parameter[]{}}); - params.add(new Object[]{ - new N("Public", "John", new String[]{"Quinlan"}, new String[]{"Mr."}, new String[]{"Esq."}), - PropertyName.N.toString(), "Public;John;Quinlan;Mr.;Esq.", new Parameter[]{}}); - params.add(new Object[]{ - new N("Stevenson", "John", new String[]{"Philip", "Paul"}, new String[]{"Dr."}, new String[]{ - "Jr.", "M.D.", "A.C.P."}), PropertyName.N.toString(), "Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.", - new Parameter[]{}}); - params.add(new Object[]{new N(new ParameterList(), "dirk"), PropertyName.N.toString(), "dirk;;;;", - new Parameter[]{}}); - params.add(new Object[]{new N(new ParameterList(), "Ruhsert;Patrick;;;"), PropertyName.N.toString(), - "Ruhsert;Patrick;;;", new Parameter[]{}}); - - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/NameTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/NameTest.java index 69679cac..ce17d876 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/NameTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/NameTest.java @@ -32,29 +32,20 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class NameTest extends PropertyTest { - public NameTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new net.fortuna.ical4j.vcard.property.Name(""), PropertyName.NAME.toString(), "", + new Parameter[]{}), + Arguments.of(new net.fortuna.ical4j.vcard.property.Name("Babs Jensen's Contact Information,"), + PropertyName.NAME.toString(), "Babs Jensen's Contact Information,", new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new net.fortuna.ical4j.vcard.property.Name(""), PropertyName.NAME.toString(), "", - new Parameter[]{}}); - params.add(new Object[]{new net.fortuna.ical4j.vcard.property.Name("Babs Jensen's Contact Information,"), - PropertyName.NAME.toString(), "Babs Jensen's Contact Information,", new Parameter[]{}}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/NicknameTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/NicknameTest.java index 37b48354..117572ac 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/NicknameTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/NicknameTest.java @@ -32,28 +32,17 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class NicknameTest extends PropertyTest { - public NicknameTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Nickname(""), PropertyName.NICKNAME.toString(), "", new Parameter[]{}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Nickname(""), PropertyName.NICKNAME.toString(), "", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/NoteTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/NoteTest.java index ded6feb8..d8ef3c04 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/NoteTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/NoteTest.java @@ -32,28 +32,19 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class NoteTest extends PropertyTest { - public NoteTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new Note(""), PropertyName.NOTE.toString(), "", new Parameter[]{}), + Arguments.of(new Note("This fax number is operational 0800 to 1715 EST, Mon-Fri."), + PropertyName.NOTE.toString(), "This fax number is operational 0800 to 1715 EST, Mon-Fri.", new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Note(""), PropertyName.NOTE.toString(), "", new Parameter[]{}}); - params.add(new Object[]{new Note("This fax number is operational 0800 to 1715 EST, Mon-Fri."), - PropertyName.NOTE.toString(), "This fax number is operational 0800 to 1715 EST, Mon-Fri.", new Parameter[]{}}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/OrgTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/OrgTest.java index 2835faef..a067bbca 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/OrgTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/OrgTest.java @@ -33,38 +33,28 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.ParameterList; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class OrgTest extends PropertyTest { - public OrgTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new Org(""), PropertyName.ORG.toString(), "", + new Parameter[]{}), + Arguments.of( + new Org("ABC, Inc.", "North American Division", "Marketing"), + PropertyName.ORG.toString(), + "ABC\\, Inc.;North American Division;Marketing", + new Parameter[]{}), + Arguments.of( + new Org(new ParameterList(), "ABC, Inc.;North American Division;Marketing"), + PropertyName.ORG.toString(), + "ABC\\, Inc.;North American Division;Marketing", + new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Org(""), PropertyName.ORG.toString(), "", - new Parameter[]{}}); - params.add(new Object[]{ - new Org("ABC, Inc.", "North American Division", "Marketing"), - PropertyName.ORG.toString(), - "ABC\\, Inc.;North American Division;Marketing", - new Parameter[]{}}); - params.add(new Object[]{ - new Org(new ParameterList(), "ABC, Inc.;North American Division;Marketing"), - PropertyName.ORG.toString(), - "ABC\\, Inc.;North American Division;Marketing", - new Parameter[]{}}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/PhotoTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/PhotoTest.java index 11c5a9ae..ca172404 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/PhotoTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/PhotoTest.java @@ -32,35 +32,25 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Encoding; import net.fortuna.ical4j.vcard.parameter.Type; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class PhotoTest extends PropertyTest { - public PhotoTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Photo(URI.create("")), PropertyName.PHOTO.toString(), "", new Parameter[]{Value.URI}}); - params.add(new Object[]{new Photo(new byte[0]), PropertyName.PHOTO.toString(), "", new Parameter[]{Encoding.B}}); - + public static Stream parameters() { Type type = new Type("image/jpeg"); - params.add(new Object[]{new Photo(new byte[0], type), PropertyName.PHOTO.toString(), "", - new Parameter[]{Encoding.B, type}}); - return params; + return Stream.of( + Arguments.of(new Photo(URI.create("")), PropertyName.PHOTO.toString(), "", new Parameter[]{Value.URI}), + Arguments.of(new Photo(new byte[0]), PropertyName.PHOTO.toString(), "", new Parameter[]{Encoding.B}), + Arguments.of(new Photo(new byte[0], type), PropertyName.PHOTO.toString(), "", + new Parameter[]{Encoding.B, type}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/ProdIdTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/ProdIdTest.java index d488d5af..39a5226e 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/ProdIdTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/ProdIdTest.java @@ -32,28 +32,17 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class ProdIdTest extends PropertyTest { - public ProdIdTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new ProdId(""), PropertyName.PRODID.toString(), "", new Parameter[]{}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new ProdId(""), PropertyName.PRODID.toString(), "", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/RelatedTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/RelatedTest.java index be0ca1be..a7b350d9 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/RelatedTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/RelatedTest.java @@ -32,31 +32,20 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - +import java.util.stream.Stream; public class RelatedTest extends PropertyTest { - public RelatedTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Related(URI.create("")), PropertyName.RELATED.toString(), "", new Parameter[]{}}); - params.add(new Object[]{new Related(""), PropertyName.RELATED.toString(), "", new Parameter[]{Value.TEXT}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Related(URI.create("")), PropertyName.RELATED.toString(), "", new Parameter[]{}), + Arguments.of(new Related(""), PropertyName.RELATED.toString(), "", new Parameter[]{Value.TEXT}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/RevisionTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/RevisionTest.java index e0ce3478..14a7b7a8 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/RevisionTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/RevisionTest.java @@ -35,42 +35,36 @@ import net.fortuna.ical4j.model.ParameterList; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import java.text.ParseException; import java.time.Instant; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RevisionTest extends PropertyTest { - private final Revision revision; - - private final Instant expectedDate; - - public RevisionTest(Revision revision, String expectedName, String expectedValue, Parameter[] expectedParams, - Instant expectedDate) { - super(revision, expectedName, expectedValue, expectedParams); - this.revision = revision; - this.expectedDate = expectedDate; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Revision(Instant.EPOCH), PropertyName.REV.toString(), "19700101T000000Z", new Parameter[]{}), + Arguments.of(new Revision(new ParameterList(), "1970-01-01T00:00:00Z"), PropertyName.REV.toString(), "19700101T000000Z", + new Parameter[]{}) + ); } - @Test - public void testGetDate() { - assertEquals(expectedDate, revision.getDate()); + public static Stream dateParameters() { + return Stream.of( + Arguments.of(new Revision(Instant.EPOCH), Instant.EPOCH), + Arguments.of(new Revision(new ParameterList(), "1970-01-01T00:00:00Z"), Instant.EPOCH) + ); } - @Parameters - public static Collection parameters() throws ParseException { - final List params = new ArrayList(); - params.add(new Object[]{new Revision(Instant.EPOCH), PropertyName.REV.toString(), "19700101T000000Z", new Parameter[]{}, Instant.EPOCH}); - params.add(new Object[]{new Revision(new ParameterList(), "1970-01-01T00:00:00Z"), PropertyName.REV.toString(), "19700101T000000Z", - new Parameter[]{}, Instant.EPOCH}); - return params; + @ParameterizedTest + @MethodSource("dateParameters") + public void testGetDate(Revision revision, Instant expectedDate) { + assertEquals(expectedDate, revision.getDate()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/RoleTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/RoleTest.java index 671d495a..68f85290 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/RoleTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/RoleTest.java @@ -32,29 +32,18 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class RoleTest extends PropertyTest { - public RoleTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Role(""), PropertyName.ROLE.toString(), "", new Parameter[]{}}); - params.add(new Object[]{new Role("Programmer"), PropertyName.ROLE.toString(), "Programmer", new Parameter[]{}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Role(""), PropertyName.ROLE.toString(), "", new Parameter[]{}), + Arguments.of(new Role("Programmer"), PropertyName.ROLE.toString(), "Programmer", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/SortStringTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/SortStringTest.java index 725f3703..2f7f89ac 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/SortStringTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/SortStringTest.java @@ -32,28 +32,17 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import org.junit.jupiter.params.provider.Arguments; +import java.util.stream.Stream; public class SortStringTest extends PropertyTest { - public SortStringTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new SortString(""), PropertyName.SORT_STRING.toString(), "", new Parameter[]{}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new SortString(""), PropertyName.SORT_STRING.toString(), "", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/SoundTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/SoundTest.java index 2884dc9e..7b5ee75d 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/SoundTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/SoundTest.java @@ -32,35 +32,25 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Encoding; import net.fortuna.ical4j.vcard.parameter.Type; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class SoundTest extends PropertyTest { - public SoundTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Sound(URI.create("")), PropertyName.SOUND.toString(), "", new Parameter[]{Value.URI}}); - params.add(new Object[]{new Sound(new byte[0]), PropertyName.SOUND.toString(), "", new Parameter[]{Encoding.B}}); - + public static Stream parameters() { Type type = new Type("application/wav"); - params.add(new Object[]{new Sound(new byte[0], type), PropertyName.SOUND.toString(), "", - new Parameter[]{Encoding.B, type}}); - return params; + return Stream.of( + Arguments.of(new Sound(URI.create("")), PropertyName.SOUND.toString(), "", new Parameter[]{Value.URI}), + Arguments.of(new Sound(new byte[0]), PropertyName.SOUND.toString(), "", new Parameter[]{Encoding.B}), + Arguments.of(new Sound(new byte[0], type), PropertyName.SOUND.toString(), "", + new Parameter[]{Encoding.B, type}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/SourceTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/SourceTest.java index 4499505d..4683a0a1 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/SourceTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/SourceTest.java @@ -34,40 +34,35 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SourceTest extends PropertyTest { - private final Source source; - - private final URI expectedUri; - - public SourceTest(Source source, String expectedName, - String expectedValue, Parameter[] expectedParams, URI expectedUri) { - super(source, expectedName, expectedValue, expectedParams); - this.source = source; - this.expectedUri = expectedUri; - } - - @Test - public void testGetUri() { - assertEquals(expectedUri, source.getUri()); + public static Stream parameters() { + URI uri = URI.create(""); + return Stream.of( + Arguments.of(new Source(uri), PropertyName.SOURCE.toString(), "", new Parameter[]{}) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream uriParameters() { URI uri = URI.create(""); - params.add(new Object[]{new Source(uri), PropertyName.SOURCE.toString(), "", new Parameter[]{}, uri}); - return params; + return Stream.of( + Arguments.of(new Source(uri), uri) + ); + } + + @ParameterizedTest + @MethodSource("uriParameters") + public void testGetUri(Source source, URI expectedUri) { + assertEquals(expectedUri, source.getUri()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/TelephoneTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/TelephoneTest.java index 9c5ae79b..dc8ee56f 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/TelephoneTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/TelephoneTest.java @@ -33,52 +33,41 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.ParameterList; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Type; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class TelephoneTest extends PropertyTest { - public TelephoneTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() throws URISyntaxException { - final List params = new ArrayList(); - + public static Stream parameters() throws URISyntaxException { final ParameterList uriParams = (ParameterList) new ParameterList().add(Value.URI); - params.add(new Object[]{new Telephone(URI.create("")), PropertyName.TEL.toString(), "", - new Parameter[]{Value.URI}}); - params.add(new Object[]{new Telephone(URI.create(""), Type.HOME), PropertyName.TEL.toString(), "", - new Parameter[]{Value.URI, Type.HOME}}); - params.add(new Object[]{new Telephone(uriParams, "+1 555 3423 2342"), PropertyName.TEL.toString(), - "tel:+1-555-3423-2342", new Parameter[]{Value.URI}}); - params.add(new Object[]{new Telephone(uriParams, "49 631 234 341"), PropertyName.TEL.toString(), - "tel:49-631-234-341", new Parameter[]{Value.URI}}); - params.add(new Object[]{new Telephone(uriParams, "+61 (0) 3 9283 8374"), PropertyName.TEL.toString(), - "tel:+61-(0)-3-9283-8374", new Parameter[]{Value.URI}}); + return Stream.of( + Arguments.of(new Telephone(URI.create("")), PropertyName.TEL.toString(), "", + new Parameter[]{Value.URI}), + Arguments.of(new Telephone(URI.create(""), Type.HOME), PropertyName.TEL.toString(), "", + new Parameter[]{Value.URI, Type.HOME}), + Arguments.of(new Telephone(uriParams, "+1 555 3423 2342"), PropertyName.TEL.toString(), + "tel:+1-555-3423-2342", new Parameter[]{Value.URI}), + Arguments.of(new Telephone(uriParams, "49 631 234 341"), PropertyName.TEL.toString(), + "tel:49-631-234-341", new Parameter[]{Value.URI}), + Arguments.of(new Telephone(uriParams, "+61 (0) 3 9283 8374"), PropertyName.TEL.toString(), + "tel:+61-(0)-3-9283-8374", new Parameter[]{Value.URI}), - // vCard 3.0 style.. - params.add(new Object[]{new Telephone("", Type.HOME), PropertyName.TEL.toString(), "", new Parameter[]{Type.HOME}}); - params.add(new Object[]{new Telephone(new ParameterList(), "+1 555 3423 2342"), PropertyName.TEL.toString(), - "+1 555 3423 2342", new Parameter[]{}}); - params.add(new Object[]{new Telephone(new ParameterList(), "49 631 234 341"), PropertyName.TEL.toString(), - "49 631 234 341", new Parameter[]{}}); - params.add(new Object[]{new Telephone(new ParameterList(), "+61 (0) 3 9283 8374"), PropertyName.TEL.toString(), - "+61 (0) 3 9283 8374", new Parameter[]{}}); - - return params; + // vCard 3.0 style.. + Arguments.of(new Telephone("", Type.HOME), PropertyName.TEL.toString(), "", new Parameter[]{Type.HOME}), + Arguments.of(new Telephone(new ParameterList(), "+1 555 3423 2342"), PropertyName.TEL.toString(), + "+1 555 3423 2342", new Parameter[]{}), + Arguments.of(new Telephone(new ParameterList(), "49 631 234 341"), PropertyName.TEL.toString(), + "49 631 234 341", new Parameter[]{}), + Arguments.of(new Telephone(new ParameterList(), "+61 (0) 3 9283 8374"), PropertyName.TEL.toString(), + "+61 (0) 3 9283 8374", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/TitleTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/TitleTest.java index 01122170..2e273b51 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/TitleTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/TitleTest.java @@ -32,28 +32,19 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; public class TitleTest extends PropertyTest { - public TitleTest(Property property, String expectedName, String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(new Title(""), PropertyName.TITLE.toString(), "", new Parameter[]{}), + Arguments.of(new Title("Director, Research and Development"), PropertyName.TITLE.toString(), + "Director, Research and Development", new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Title(""), PropertyName.TITLE.toString(), "", new Parameter[]{}}); - params.add(new Object[]{new Title("Director, Research and Development"), PropertyName.TITLE.toString(), - "Director, Research and Development", new Parameter[]{}}); - return params; - } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/TzTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/TzTest.java index 0c76ad6f..4f840618 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/TzTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/TzTest.java @@ -32,31 +32,20 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; import net.fortuna.ical4j.vcard.parameter.Value; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import java.time.ZoneOffset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - +import java.util.stream.Stream; public class TzTest extends PropertyTest { - public TzTest(Property property, String expectedName, String expectedValue, - Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); - } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{new Tz(""), PropertyName.TZ.toString(), "", new Parameter[]{Value.TEXT}}); - params.add(new Object[]{new Tz(ZoneOffset.of("+1000")), PropertyName.TZ.toString(), "+1000", new Parameter[]{}}); - return params; + public static Stream parameters() { + return Stream.of( + Arguments.of(new Tz(""), PropertyName.TZ.toString(), "", new Parameter[]{Value.TEXT}), + Arguments.of(new Tz(ZoneOffset.of("+1000")), PropertyName.TZ.toString(), "+1000", new Parameter[]{}) + ); } - } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/UidTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/UidTest.java index ed8dace0..8ae4db5b 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/UidTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/UidTest.java @@ -34,40 +34,35 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class UidTest extends PropertyTest { - private final Uid uid; - - private final URI expectedUri; - - public UidTest(Uid uid, String expectedName, - String expectedValue, Parameter[] expectedParams, URI expectedUri) { - super(uid, expectedName, expectedValue, expectedParams); - this.uid = uid; - this.expectedUri = expectedUri; - } - - @Test - public void testGetUri() { - assertEquals(expectedUri, uid.getUri()); + public static Stream parameters() { + URI uri = URI.create(""); + return Stream.of( + Arguments.of(new Uid(uri), PropertyName.UID.toString(), "", new Parameter[]{}) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream uriParameters() { URI uri = URI.create(""); - params.add(new Object[]{new Uid(uri), PropertyName.UID.toString(), "", new Parameter[]{}, uri}); - return params; + return Stream.of( + Arguments.of(new Uid(uri), uri) + ); + } + + @ParameterizedTest + @MethodSource("uriParameters") + public void testGetUri(Uid uid, URI expectedUri) { + assertEquals(expectedUri, uid.getUri()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/UrlTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/UrlTest.java index 70473691..cf8c77a8 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/UrlTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/UrlTest.java @@ -34,40 +34,35 @@ import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class UrlTest extends PropertyTest { - private final Url url; - - private final URI expectedUri; - - public UrlTest(Url url, String expectedName, - String expectedValue, Parameter[] expectedParams, URI expectedUri) { - super(url, expectedName, expectedValue, expectedParams); - this.url = url; - this.expectedUri = expectedUri; - } - - @Test - public void testGetUri() { - assertEquals(expectedUri, url.getUri()); + public static Stream parameters() { + URI uri = URI.create(""); + return Stream.of( + Arguments.of(new Url(uri), PropertyName.URL.toString(), "", new Parameter[]{}) + ); } - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); + public static Stream uriParameters() { URI uri = URI.create(""); - params.add(new Object[]{new Url(uri), PropertyName.URL.toString(), "", new Parameter[]{}, uri}); - return params; + return Stream.of( + Arguments.of(new Url(uri), uri) + ); + } + + @ParameterizedTest + @MethodSource("uriParameters") + public void testGetUri(Url url, URI expectedUri) { + assertEquals(expectedUri, url.getUri()); } } diff --git a/src/test/java/net/fortuna/ical4j/vcard/property/VersionTest.java b/src/test/java/net/fortuna/ical4j/vcard/property/VersionTest.java index 21f1d458..96947f74 100755 --- a/src/test/java/net/fortuna/ical4j/vcard/property/VersionTest.java +++ b/src/test/java/net/fortuna/ical4j/vcard/property/VersionTest.java @@ -32,30 +32,20 @@ package net.fortuna.ical4j.vcard.property; import net.fortuna.ical4j.model.Parameter; -import net.fortuna.ical4j.model.Property; import net.fortuna.ical4j.vcard.PropertyName; import net.fortuna.ical4j.vcard.PropertyTest; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.stream.Stream; import static net.fortuna.ical4j.vcard.property.immutable.ImmutableVersion.VERSION_4_0; public class VersionTest extends PropertyTest { - public VersionTest(Property property, String expectedName, - String expectedValue, Parameter[] expectedParams) { - super(property, expectedName, expectedValue, expectedParams); + public static Stream parameters() { + return Stream.of( + Arguments.of(VERSION_4_0, PropertyName.VERSION.toString(), "4.0", new Parameter[]{}), + Arguments.of(new Version("3.0"), PropertyName.VERSION.toString(), "3.0", new Parameter[]{}) + ); } - - @Parameters - public static Collection parameters() { - final List params = new ArrayList(); - params.add(new Object[]{VERSION_4_0, PropertyName.VERSION.toString(), "4.0", new Parameter[]{}}); - params.add(new Object[]{new Version("3.0"), PropertyName.VERSION.toString(), "3.0", new Parameter[]{}}); - return params; - } - }