Skip to content

Commit

Permalink
Merge pull request quarkusio#36164 from geoand/quarkusio#36154-take2
Browse files Browse the repository at this point in the history
Support Java 21 main launch protocol
  • Loading branch information
geoand authored Oct 2, 2023
2 parents 2c7e36f + fd9f134 commit 089bd28
Show file tree
Hide file tree
Showing 12 changed files with 636 additions and 9 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.quarkus.commandmode.launch;

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 IgnorePrivateMainCommandModeTestCase {
@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, 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 extends HelloWorldSuper {

private static void main(String[] args) {
System.out.println("Private Static World");
}
}

public static class HelloWorldSuperSuper {

protected void main() {
System.out.println("Hello World");
}
}

public static class HelloWorldSuper extends HelloWorldSuperSuper {

private void main(String[] args) {
System.out.println("Private Instance World");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.commandmode.launch;

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");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.quarkus.commandmode.launch;

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 InstanceMainInSuperClassCommandModeTestCase {
@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, 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 extends HelloWorldSuper {

}

public static class HelloWorldSuperSuper {

protected void main() {
System.out.println("Hello World");
}
}

public static class HelloWorldSuper extends HelloWorldSuperSuper {

protected void main2() {
System.out.println("Hello");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.commandmode.launch;

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 InstanceMainInSuperClassNoArgsCommandModeTestCase {
@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(HelloWorldSuper.class, 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 extends HelloWorldSuper {

}

public static class HelloWorldSuper {

void main() {
System.out.println("Hello World");
}

void main2() {
System.out.println("Hello");
}

void main3(String[] args) {
System.out.println("Hello");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.commandmode.launch;

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");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.commandmode.launch;

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 MixWithAndWithoutArgsMainCommandModeTestCase {
@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(String[] args) {
System.out.println("Hello World");
}

void main() {
System.out.println("Hi World");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.quarkus.commandmode.launch;

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 MultipleInstanceMainInSuperClassCommandModeTestCase {
@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, HelloWorldMain.class))
.setApplicationName("run-exit")
.setApplicationVersion("0.1-SNAPSHOT")
.setExpectExit(true)
.setRun(true);

@Test
public void testRun() {
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hi World");
Assertions.assertThat(config.getExitCode()).isEqualTo(0);
}

@QuarkusMain
public static class HelloWorldMain extends HelloWorldSuper {

}

public static class HelloWorldSuperSuper {

protected void main(String[] args) {
System.out.println("Hi World");
}

protected void main() {
System.out.println("Hello World");
}
}

public static class HelloWorldSuper extends HelloWorldSuperSuper {

protected void main2() {
System.out.println("Hello");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.commandmode.launch;

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");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.commandmode.launch;

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(RuntimeException.class);

@Test
public void shouldNeverRun() {
fail();
}

@QuarkusMain
public static class HelloWorldMain {

private static void main(String[] args) {
System.out.println("Hello World");
}
}

}
Loading

0 comments on commit 089bd28

Please sign in to comment.