-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for new main method launch protocol
- Loading branch information
Showing
6 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...sion/deployment/src/test/java/io/quarkus/commandmode/InstanceMainCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...eployment/src/test/java/io/quarkus/commandmode/InstanceMainNoArgsCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainNoArgsCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...ployment/src/test/java/io/quarkus/commandmode/NonPublicStaticMainCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class NonPublicStaticMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...deployment/src/test/java/io/quarkus/commandmode/PrivateStaticMainCommandModeTestCase.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,33 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class PrivateStaticMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectedException(IllegalStateException.class); | ||
|
||
@Test | ||
public void shouldNeverRun() { | ||
fail(); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
public static void main2(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...nt/src/test/java/io/quarkus/commandmode/ProtectedStaticMainNoArgsCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class ProtectedStaticMainNoArgsCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
protected static void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../deployment/src/test/java/io/quarkus/commandmode/StaticMainNoArgsCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class StaticMainNoArgsCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
static void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |