aboutsummaryrefslogtreecommitdiffstats
path: root/container-disc/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2020-12-08 01:22:25 +0100
committerGitHub <noreply@github.com>2020-12-08 01:22:25 +0100
commit71b593e14a2ae149af28e78fb76b57f8e7767b19 (patch)
tree3ba357bce820c97e3129279f7666ecd384ab67b6 /container-disc/src/test/java/com/yahoo
parent96cf054bba808ff36e80cf939fadbc358b5ed7aa (diff)
Revert "Revert "Revert "Revert "Always deconstruct in reverse creation order, including Provider objects""""
Diffstat (limited to 'container-disc/src/test/java/com/yahoo')
-rw-r--r--container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
index efdc8f44c17..9ae05f5c193 100644
--- a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
+++ b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
@@ -9,6 +9,9 @@ import com.yahoo.jdisc.SharedResource;
import org.junit.Before;
import org.junit.Test;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
import static java.util.Collections.emptyList;
import static java.util.Collections.singleton;
import static org.junit.Assert.assertTrue;
@@ -28,25 +31,25 @@ public class DeconstructorTest {
public void require_abstract_component_destructed() throws InterruptedException {
TestAbstractComponent abstractComponent = new TestAbstractComponent();
// Done by executor, so it takes some time even with a 0 delay.
- deconstructor.deconstruct(singleton(abstractComponent), emptyList());
- int cnt = 0;
- while (! abstractComponent.destructed && (cnt++ < 12000)) {
- Thread.sleep(10);
- }
+ deconstructor.deconstruct(List.of(abstractComponent), emptyList());
+ deconstructor.executor.shutdown();
+ deconstructor.executor.awaitTermination(1, TimeUnit.MINUTES);
assertTrue(abstractComponent.destructed);
}
@Test
- public void require_provider_destructed() {
+ public void require_provider_destructed() throws InterruptedException {
TestProvider provider = new TestProvider();
- deconstructor.deconstruct(singleton(provider), emptyList());
+ deconstructor.deconstruct(List.of(provider), emptyList());
+ deconstructor.executor.shutdown();
+ deconstructor.executor.awaitTermination(1, TimeUnit.MINUTES);
assertTrue(provider.destructed);
}
@Test
public void require_shared_resource_released() {
TestSharedResource sharedResource = new TestSharedResource();
- deconstructor.deconstruct(singleton(sharedResource), emptyList());
+ deconstructor.deconstruct(List.of(sharedResource), emptyList());
assertTrue(sharedResource.released);
}
@@ -55,10 +58,8 @@ public class DeconstructorTest {
var bundle = new UninstallableMockBundle();
// Done by executor, so it takes some time even with a 0 delay.
deconstructor.deconstruct(emptyList(), singleton(bundle));
- int cnt = 0;
- while (! bundle.uninstalled && (cnt++ < 12000)) {
- Thread.sleep(10);
- }
+ deconstructor.executor.shutdown();
+ deconstructor.executor.awaitTermination(1, TimeUnit.MINUTES);
assertTrue(bundle.uninstalled);
}