-
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.
Merge pull request #23177 from Ladicek/arc-initializer-method-validation
Add initializer method validation to ArC
- Loading branch information
Showing
7 changed files
with
196 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
...rc/test/java/io/quarkus/arc/test/validation/InitializerMethodMarkedAsyncObserverTest.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,31 @@ | ||
package io.quarkus.arc.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.ObservesAsync; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class InitializerMethodMarkedAsyncObserverTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(MyBean.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static class MyBean { | ||
@Inject | ||
void observeAsync(@ObservesAsync Object ignored) { | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...sts/src/test/java/io/quarkus/arc/test/validation/InitializerMethodMarkedDisposerTest.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,41 @@ | ||
package io.quarkus.arc.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Disposes; | ||
import javax.enterprise.inject.Produces; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class InitializerMethodMarkedDisposerTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Producers.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static class Producers { | ||
@Produces | ||
@ApplicationScoped | ||
MyBean produce() { | ||
return new MyBean(); | ||
} | ||
|
||
@Inject | ||
void dispose(@Disposes MyBean bean) { | ||
} | ||
} | ||
|
||
static class MyBean { | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...sts/src/test/java/io/quarkus/arc/test/validation/InitializerMethodMarkedObserverTest.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,31 @@ | ||
package io.quarkus.arc.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class InitializerMethodMarkedObserverTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(MyBean.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static class MyBean { | ||
@Inject | ||
void observe(@Observes Object ignored) { | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...sts/src/test/java/io/quarkus/arc/test/validation/InitializerMethodMarkedProducerTest.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,37 @@ | ||
package io.quarkus.arc.test.validation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
import javax.enterprise.inject.spi.DefinitionException; | ||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class InitializerMethodMarkedProducerTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Producers.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertTrue(error instanceof DefinitionException); | ||
} | ||
|
||
@ApplicationScoped | ||
static class Producers { | ||
@Inject | ||
@Produces | ||
@ApplicationScoped | ||
MyBean produce() { | ||
return new MyBean(); | ||
} | ||
} | ||
|
||
static class MyBean { | ||
} | ||
} |