-
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.
ArC: log warning about removed beans for BeanContainer operations
- this warning got accidentally removed in #28112 (quarkus 2.14) (cherry picked from commit c1e6248)
- Loading branch information
Showing
4 changed files
with
68 additions
and
7 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
57 changes: 57 additions & 0 deletions
57
...c/test/java/io/quarkus/arc/test/unused/ArcContainerSupplierLookupProblemDetectedTest.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,57 @@ | ||
package io.quarkus.arc.test.unused; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.logging.Formatter; | ||
import java.util.logging.LogRecord; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.jboss.logmanager.formatters.PatternFormatter; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.impl.ArcContainerImpl; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ArcContainerSupplierLookupProblemDetectedTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(Alpha.class)) | ||
.setLogRecordPredicate(log -> ArcContainerImpl.class.getPackage().getName().equals(log.getLoggerName())) | ||
.assertLogRecords(records -> { | ||
LogRecord warning = records.stream() | ||
.filter(l -> l.getMessage().contains("programmatic lookup problem detected")).findAny().orElse(null); | ||
assertNotNull(warning); | ||
Formatter fmt = new PatternFormatter("%m"); | ||
String message = fmt.format(warning); | ||
assertTrue(message.contains( | ||
"Stack frame: io.quarkus.arc.test.unused.ArcContainerSupplierLookupProblemDetectedTest.testWarning"), | ||
message); | ||
assertTrue(message.contains( | ||
"Required type: class io.quarkus.arc.test.unused.ArcContainerSupplierLookupProblemDetectedTest$Alpha"), | ||
message); | ||
}); | ||
|
||
@Test | ||
public void testWarning() { | ||
// Note that the warning is only displayed once, subsequent calls use a cached result | ||
assertNull(Arc.container().beanInstanceSupplier(Alpha.class)); | ||
} | ||
|
||
// unused bean, will be removed | ||
@ApplicationScoped | ||
static class Alpha { | ||
|
||
public String ping() { | ||
return "ok"; | ||
} | ||
|
||
} | ||
|
||
} |
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