From 440801cf153e1bef5dea603f559e9288a40be16c Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Fri, 29 Jul 2022 13:55:06 +0200 Subject: Convert bundle-plugin-test to junit5 --- .../com/yahoo/container/plugin/BundleTest.java | 36 +++++++++++----------- .../container/plugin/ExportPackageVersionTest.java | 18 +++++------ 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'bundle-plugin-test/integration-test/src/test/java') diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java index faa33542f5c..2e3a3204ef5 100644 --- a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java +++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java @@ -2,8 +2,8 @@ package com.yahoo.container.plugin; import com.yahoo.vespa.config.VespaVersion; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -18,9 +18,9 @@ import java.util.jar.Manifest; import java.util.regex.Pattern; import java.util.zip.ZipEntry; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Verifies the bundle jar file built and its manifest. @@ -38,7 +38,7 @@ public class BundleTest { private JarFile jarFile; private Attributes mainAttributes; - @Before + @BeforeEach public void setup() { try { File componentJar = findBundleJar("main"); @@ -60,7 +60,7 @@ public class BundleTest { } @Test - public void require_that_bundle_version_is_added_to_manifest() { + void require_that_bundle_version_is_added_to_manifest() { String bundleVersion = mainAttributes.getValue("Bundle-Version"); // Because of snapshot builds, we can only verify the major version. @@ -69,12 +69,12 @@ public class BundleTest { } @Test - public void require_that_bundle_symbolic_name_matches_pom_artifactId() { + void require_that_bundle_symbolic_name_matches_pom_artifactId() { assertEquals("main", mainAttributes.getValue("Bundle-SymbolicName")); } @Test - public void require_that_manifest_contains_inferred_imports() { + void require_that_manifest_contains_inferred_imports() { String importPackage = mainAttributes.getValue("Import-Package"); // From SimpleSearcher @@ -87,35 +87,35 @@ public class BundleTest { } @Test - public void require_that_manifest_contains_manual_imports() { + void require_that_manifest_contains_manual_imports() { String importPackage = mainAttributes.getValue("Import-Package"); assertTrue(importPackage.contains("manualImport.withoutVersion")); assertTrue(importPackage.contains("manualImport.withVersion;version=\"12.3.4\"")); - for (int i=1; i<=2; ++i) + for (int i = 1; i <= 2; ++i) assertTrue(importPackage.contains("multiple.packages.with.the.same.version" + i + ";version=\"[1,2)\"")); } @Test - public void require_that_manifest_contains_exports() { + void require_that_manifest_contains_exports() { String exportPackage = mainAttributes.getValue("Export-Package"); assertTrue(exportPackage.contains("com.yahoo.test;version=1.2.3.RELEASE")); } - @Test // TODO: use another jar than jrt, which now pulls in a lot of dependencies that pollute the manifest of the // generated bundle. (It's compile scoped in pom.xml to be added to the bundle-cp.) - public void require_that_manifest_contains_bundle_class_path() { + @Test + void require_that_manifest_contains_bundle_class_path() { String bundleClassPath = mainAttributes.getValue("Bundle-ClassPath"); assertTrue(bundleClassPath.contains(".,")); Pattern jrtPattern = Pattern.compile("dependencies/jrt" + snapshotOrVersionOrNone); - assertTrue("Bundle class path did not contain jrt.", jrtPattern.matcher(bundleClassPath).find()); + assertTrue(jrtPattern.matcher(bundleClassPath).find(), "Bundle class path did not contain jrt."); } @Test - public void require_that_component_jar_file_contains_compile_artifacts() { + void require_that_component_jar_file_contains_compile_artifacts() { String depJrt = "dependencies/jrt"; Pattern jrtPattern = Pattern.compile(depJrt + snapshotOrVersionOrNone); ZipEntry jrtEntry = null; @@ -130,12 +130,12 @@ public class BundleTest { } } } - assertNotNull("Component jar file did not contain jrt dependency.", jrtEntry); + assertNotNull(jrtEntry, "Component jar file did not contain jrt dependency."); } @Test - public void require_that_web_inf_url_is_propagated_to_the_manifest() { + void require_that_web_inf_url_is_propagated_to_the_manifest() { String webInfUrl = mainAttributes.getValue("WebInfUrl"); assertTrue(webInfUrl.contains("/WEB-INF/web.xml")); } diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java index f99f1583324..67a191f1f94 100644 --- a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java +++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.plugin; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -10,8 +10,8 @@ import java.util.jar.Attributes; import java.util.jar.JarFile; import static com.yahoo.container.plugin.BundleTest.findBundleJar; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Verifies that the 'useArtifactVersionForExportPackages' setting for the bundle-plugin works as intended. @@ -23,7 +23,7 @@ public class ExportPackageVersionTest { private static Attributes mainAttributes; private static String bundleVersion; - @BeforeClass + @BeforeAll public static void setup() { try { File componentJar = findBundleJar("artifact-version-for-exports"); @@ -36,7 +36,7 @@ public class ExportPackageVersionTest { } @Test - public void artifact_version_without_qualifier_is_used_as_export_version() { + void artifact_version_without_qualifier_is_used_as_export_version() { // Bundle-Version is artifact version without qualifier String expectedExport = "ai.vespa.noversion;version=" + bundleVersion; @@ -48,13 +48,13 @@ public class ExportPackageVersionTest { } @Test - public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version() { + void explicit_version_in_ExportPackage_annotation_overrides_artifact_version() { String exportPackage = mainAttributes.getValue("Export-Package"); assertTrue(exportPackage.contains("ai.vespa.explicitversion;version=2.4.6.RELEASE")); } @Test - public void artifact_version_of_dependency_is_used_as_export_version_for_package_in_compile_scoped_dependency() { + void artifact_version_of_dependency_is_used_as_export_version_for_package_in_compile_scoped_dependency() { String exportPackage = mainAttributes.getValue("Export-Package"); // TODO: This test should have checked for a fixed version of the dependency bundle, different than the main bundle version. @@ -63,7 +63,7 @@ public class ExportPackageVersionTest { } @Test - public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version_of_compile_scoped_dependency() { + void explicit_version_in_ExportPackage_annotation_overrides_artifact_version_of_compile_scoped_dependency() { String exportPackage = mainAttributes.getValue("Export-Package"); assertTrue(exportPackage.contains("ai.vespa.explicitversion_dep;version=3.6.9.RELEASE")); } -- cgit v1.2.3