blob: 10e9844f6de68c7349c8ce9b207f059fb66f9047 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package demo;
import com.yahoo.container.di.ContainerTest;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* @author tonytv
* @author gjoranv
*/
public class DeconstructTest extends ContainerTestBase {
public static class DeconstructableComponent extends ContainerTest.DestructableComponent {
private boolean isDeconstructed = false;
@Override
public void deconstruct() {
isDeconstructed = true;
}
}
@Test
public void require_that_unused_components_are_deconstructed() {
writeBootstrapConfigs("d1", DeconstructableComponent.class);
complete();
DeconstructableComponent d1 = getInstance(DeconstructableComponent.class);
writeBootstrapConfigs("d2", DeconstructableComponent.class);
complete();
assertTrue(d1.isDeconstructed);
}
}
|