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 /application/src/test/java/com/yahoo/application/ApplicationBuilderTest.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 'application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java')
-rw-r--r-- | application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java index 800c30ac8b8..503f11ca0d7 100644 --- a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java +++ b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java @@ -2,13 +2,12 @@ package com.yahoo.application; import com.yahoo.io.IOUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import java.nio.file.Files; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Tony Vaagenes @@ -16,55 +15,53 @@ import static org.junit.Assert.assertTrue; */ public class ApplicationBuilderTest { @Test - public void query_profile_types_can_be_added() throws Exception { + void query_profile_types_can_be_added() throws Exception { withApplicationBuilder(builder -> { builder.queryProfileType("MyProfileType", "<query-profile-type id=\"MyProfileType\">" + // - "<field name=\"age\" type=\"integer\" />" + // - "<field name=\"profession\" type=\"string\" />" + // - "<field name=\"user\" type=\"query-profile:MyUserProfile\" />" + // - "</query-profile-type>"); + "<field name=\"age\" type=\"integer\" />" + // + "<field name=\"profession\" type=\"string\" />" + // + "<field name=\"user\" type=\"query-profile:MyUserProfile\" />" + // + "</query-profile-type>"); assertTrue(Files.exists(builder.getPath().resolve("search/query-profiles/types/MyProfileType.xml"))); }); } @Test - public void query_profile_can_be_added() throws Exception { + void query_profile_can_be_added() throws Exception { withApplicationBuilder(builder -> { builder.queryProfile("MyProfile", - "<query-profile id=\"MyProfile\">" + - "<field name=\"message\">Hello world!</field>" + - "</query-profile>"); + "<query-profile id=\"MyProfile\">" + + "<field name=\"message\">Hello world!</field>" + + "</query-profile>"); assertTrue(Files.exists(builder.getPath().resolve("search/query-profiles/MyProfile.xml"))); }); } @Test - public void rank_expression_can_be_added() throws Exception { + void rank_expression_can_be_added() throws Exception { withApplicationBuilder(builder -> { builder.rankExpression("myExpression", "content"); assertTrue(Files.exists(builder.getPath().resolve("schemas/myExpression.expression"))); }); } - @SuppressWarnings("deprecation") - @Rule - public ExpectedException expectedException = ExpectedException.none(); - + // application unreferenced inside try @Test - @SuppressWarnings("try") // application unreferenced inside try - public void builder_cannot_be_reused() throws Exception { - expectedException.expect(RuntimeException.class); - expectedException.expectMessage("build method"); + @SuppressWarnings("try") + void builder_cannot_be_reused() throws Exception { + Throwable exception = assertThrows(RuntimeException.class, () -> { - ApplicationBuilder builder = new ApplicationBuilder(); - builder.servicesXml("<container version=\"1.0\" />"); - try (Application application = builder.build()) { - // do nothing - } + ApplicationBuilder builder = new ApplicationBuilder(); + builder.servicesXml("<container version=\"1.0\" />"); + try (Application application = builder.build()) { + // do nothing + } - builder.servicesXml(""); // should fail + builder.servicesXml(""); // should fail + }); + assertTrue(exception.getMessage().contains("build method")); // should fail } private interface TestCase { |