summaryrefslogtreecommitdiffstats
path: root/application/src
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2018-05-28 12:36:35 +0200
committerOlli Virtanen <olli.virtanen@oath.com>2018-05-28 12:36:35 +0200
commit289eaa829511b7aa536c86793f86f46a31d4a28e (patch)
treebf37943316df8c5f0b789197509d0cf2b93a4c97 /application/src
parentccaffce681ce3f1fa0eab9fbf8627483fd9cbe37 (diff)
Stricter verification of exception in builder_cannot_be_reused using @Rule; visibility cleanups
Diffstat (limited to 'application/src')
-rw-r--r--application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
index 410ecdf886e..42f3a7267d8 100644
--- a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
+++ b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
@@ -2,14 +2,14 @@
package com.yahoo.application;
import com.yahoo.io.IOUtils;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.nio.file.Files;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
* @author Tony Vaagenes
@@ -48,9 +48,15 @@ public class ApplicationBuilderTest {
});
}
- @Test(expected = RuntimeException.class)
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
@SuppressWarnings("try") // application unreferenced inside try
public void builder_cannot_be_reused() throws Exception {
+ expectedException.expect(RuntimeException.class);
+ expectedException.expectMessage(containsString("build method"));
+
ApplicationBuilder builder = new ApplicationBuilder();
builder.servicesXml("<jdisc version=\"1.0\" />");
try (Application application = builder.build()) {
@@ -61,10 +67,10 @@ public class ApplicationBuilderTest {
}
private interface TestCase {
- public void accept(ApplicationBuilder ab) throws Exception;
+ void accept(ApplicationBuilder ab) throws Exception;
}
- public void withApplicationBuilder(TestCase f) throws Exception {
+ private static void withApplicationBuilder(TestCase f) throws Exception {
ApplicationBuilder builder = new ApplicationBuilder();
try {
f.accept(builder);