-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e04b1a4
commit f518fb0
Showing
4 changed files
with
80 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
config/src/test/java/de/sovity/edc/utils/config/utils/UrlPathUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2024 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.utils.config.utils; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static de.sovity.edc.utils.config.utils.UrlPathUtils.urlPathJoin; | ||
|
||
class UrlPathUtilsTest { | ||
@Test | ||
void urlPathJoin_empty() { | ||
Assertions.assertThat(urlPathJoin()).isEmpty(); | ||
Assertions.assertThat(urlPathJoin("")).isEmpty(); | ||
Assertions.assertThat(urlPathJoin("/")).isEqualTo("/"); | ||
} | ||
|
||
@Test | ||
void urlPathJoin_relative() { | ||
Assertions.assertThat(urlPathJoin("a")).isEqualTo("a"); | ||
Assertions.assertThat(urlPathJoin("a/")).isEqualTo("a/"); | ||
Assertions.assertThat(urlPathJoin("a", "b")).isEqualTo("a/b"); | ||
Assertions.assertThat(urlPathJoin("a/", "b")).isEqualTo("a/b"); | ||
Assertions.assertThat(urlPathJoin("a", "/b")).isEqualTo("a/b"); | ||
Assertions.assertThat(urlPathJoin("a/", "/b")).isEqualTo("a/b"); | ||
} | ||
|
||
@Test | ||
void urlPathJoin_absolute() { | ||
Assertions.assertThat(urlPathJoin("/a")).isEqualTo("/a"); | ||
Assertions.assertThat(urlPathJoin("/a/")).isEqualTo("/a/"); | ||
Assertions.assertThat(urlPathJoin("/a", "b")).isEqualTo("/a/b"); | ||
Assertions.assertThat(urlPathJoin("/a/", "b")).isEqualTo("/a/b"); | ||
Assertions.assertThat(urlPathJoin("/a", "/b")).isEqualTo("/a/b"); | ||
Assertions.assertThat(urlPathJoin("/a/", "/b")).isEqualTo("/a/b"); | ||
} | ||
|
||
@Test | ||
void urlPathJoin_immediate_protocol() { | ||
Assertions.assertThat(urlPathJoin("https://")).isEqualTo("https://"); | ||
Assertions.assertThat(urlPathJoin("https://", "b")).isEqualTo("https://b"); | ||
Assertions.assertThat(urlPathJoin("https://", "/b")).isEqualTo("https://b"); | ||
} | ||
|
||
@Test | ||
void urlPathJoin_protocol() { | ||
Assertions.assertThat(urlPathJoin("https://a")).isEqualTo("https://a"); | ||
Assertions.assertThat(urlPathJoin("https://a/")).isEqualTo("https://a/"); | ||
Assertions.assertThat(urlPathJoin("https://a", "b")).isEqualTo("https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://a/", "b")).isEqualTo("https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://a", "/b")).isEqualTo("https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://a/", "/b")).isEqualTo("https://a/b"); | ||
} | ||
|
||
@Test | ||
void urlPathJoin_protocol_overruling_not_enabled() { | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a")).isEqualTo("https://ignored/https://a"); | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a/")).isEqualTo("https://ignored/https://a/"); | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a", "b")).isEqualTo("https://ignored/https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a/", "b")).isEqualTo("https://ignored/https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a", "/b")).isEqualTo("https://ignored/https://a/b"); | ||
Assertions.assertThat(urlPathJoin("https://ignored", "https://a/", "/b")).isEqualTo("https://ignored/https://a/b"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters