-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
inject/src/test/java/io/micronaut/context/DefaultApplicationContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.micronaut.context; | ||
|
||
import io.micronaut.context.env.Environment; | ||
import org.junit.jupiter.api.Test; | ||
import spock.lang.Issue; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class DefaultApplicationContextTest { | ||
@Issue("https://github.com/micronaut-projects/micronaut-test/issues/615#issuecomment-1516355815") | ||
@Test | ||
public void applicationContextShouldShutDownTheEnvironmentItCreated() { | ||
DefaultApplicationContext ctx = new DefaultApplicationContext(); | ||
ctx.start(); | ||
Environment env = ctx.getEnvironment(); | ||
assertTrue(env.isRunning()); | ||
ctx.stop(); | ||
assertFalse(env.isRunning(), "expected to be stopped"); | ||
} | ||
|
||
@Test | ||
public void applicationContextShouldNotStopTheEnvironmentItDidNotCreate() { | ||
DefaultApplicationContext ctx = new DefaultApplicationContext(); | ||
// make DefaultApplicationContext create and stop it's managed environment, | ||
// so it thinks it manages it | ||
ctx.start(); | ||
ctx.stop(); | ||
|
||
// providing ctx with an external environment | ||
ApplicationContext ctx2 = ApplicationContext.run(); | ||
ctx.setEnvironment(ctx2.getEnvironment()); | ||
|
||
ctx.start(); | ||
ctx.stop(); | ||
assertTrue(ctx2.getEnvironment().isRunning(), "shouldn't stop an external environment"); | ||
|
||
ctx2.stop(); //cleanup | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters