diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-07-29 15:44:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 15:44:31 +0200 |
commit | 372f6d7371d42ef23b543d4349cfeabf25ac400b (patch) | |
tree | 9af9d03b14f4a3cf4747428071574ec668e3f3f7 /bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java | |
parent | 5aa9bb607b7d4262c8ea13d20671f7264c3c59c5 (diff) | |
parent | 4b53d0d135fcacc5964b2720678642f182fd15d1 (diff) |
Merge pull request #23555 from vespa-engine/bjorncs/more-junit5v8.26.15
Bjorncs/more junit5
Diffstat (limited to 'bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java')
-rw-r--r-- | bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java index 29f2be838a1..aa74746bfff 100644 --- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java +++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java @@ -4,9 +4,7 @@ package com.yahoo.container.plugin.osgi; import com.yahoo.container.plugin.osgi.ExportPackages.Export; import com.yahoo.container.plugin.osgi.ExportPackages.Parameter; import com.yahoo.container.plugin.osgi.ImportPackages.Import; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.HashSet; @@ -15,8 +13,9 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Tony Vaagenes @@ -34,37 +33,37 @@ public class ImportPackageTest { } @Test - public void require_that_non_implemented_import_with_matching_export_is_included() { + void require_that_non_implemented_import_with_matching_export_is_included() { Set<Import> imports = calculateImports(referencedPackages, Set.of(), exports); assertEquals(1, imports.stream().filter(imp -> imp.packageName().equals(PACKAGE_NAME) && imp.version().isEmpty()).count()); } @Test - public void require_that_non_implemented_import_without_matching_export_is_excluded() { + void require_that_non_implemented_import_without_matching_export_is_excluded() { Set<Import> imports = calculateImports(referencedPackages, Set.of(), Map.of()); assertTrue(imports.isEmpty()); } @Test - public void require_that_implemented_import_with_matching_export_is_excluded() { + void require_that_implemented_import_with_matching_export_is_excluded() { Set<Import> imports = calculateImports(referencedPackages, referencedPackages, exports); assertTrue(imports.isEmpty()); } @Test - public void require_that_version_is_included() { + void require_that_version_is_included() { Set<Import> imports = calculateImports(referencedPackages, Set.of(), exportsWithVersion); assertEquals(1, imports.stream().filter(imp -> imp.packageName().equals(PACKAGE_NAME) && imp.version().equals("1.3")).count()); } @Test - public void require_that_all_versions_up_to_the_next_major_version_is_in_range() { + void require_that_all_versions_up_to_the_next_major_version_is_in_range() { assertEquals("[1.2,2)", new Import("foo", Optional.of("1.2")).importVersionRange().get()); } // TODO: Detecting guava packages should be based on bundle-symbolicName, not package name. @Test - public void require_that_for_guava_all_future_major_versions_are_in_range() { + void require_that_for_guava_all_future_major_versions_are_in_range() { Optional<String> rangeWithInfiniteUpperLimit = Optional.of("[18.1," + ImportPackages.INFINITE_VERSION + ")"); assertEquals(rangeWithInfiniteUpperLimit, new Import("com.google.common", Optional.of("18.1")).importVersionRange()); assertEquals(rangeWithInfiniteUpperLimit, new Import("com.google.common.foo", Optional.of("18.1")).importVersionRange()); @@ -72,32 +71,29 @@ public class ImportPackageTest { } @Test - public void require_that_none_version_gives_non_version_range() { + void require_that_none_version_gives_non_version_range() { assertTrue(new Import("foo", Optional.empty()).importVersionRange().isEmpty()); } - @SuppressWarnings("deprecation") - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test - public void require_that_exception_is_thrown_when_major_component_is_non_numeric() { - expectedException.expect(IllegalArgumentException.class); - new Import("foo", Optional.of("1notValid.2")); + void require_that_exception_is_thrown_when_major_component_is_non_numeric() { + assertThrows(IllegalArgumentException.class, () -> { + new Import("foo", Optional.of("1notValid.2")); + }); } @Test - public void require_that_osgi_import_supports_missing_version() { + void require_that_osgi_import_supports_missing_version() { assertEquals("com.yahoo.exported", new Import("com.yahoo.exported", Optional.empty()).asOsgiImport()); } @Test - public void require_that_osgi_import_version_range_includes_all_versions_from_the_current_up_to_the_next_major_version() { + void require_that_osgi_import_version_range_includes_all_versions_from_the_current_up_to_the_next_major_version() { assertEquals("com.yahoo.exported;version=\"[1.2,2)\"", new Import("com.yahoo.exported", Optional.of("1.2")).asOsgiImport()); } @Test - public void require_that_osgi_import_version_range_ignores_qualifier() { + void require_that_osgi_import_version_range_ignores_qualifier() { assertEquals("com.yahoo.exported;version=\"[1.2.3,2)\"", new Import("com.yahoo.exported", Optional.of("1.2.3.qualifier")).asOsgiImport()); } |