-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
d8e3768
commit aea7cf3
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...cdi/deployment/src/test/java/org/tkit/quarkus/log/cdi/test/ErrorDataServiceJdk17Test.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,66 @@ | ||
package org.tkit.quarkus.log.cdi.test; | ||
|
||
import static org.tkit.quarkus.log.cdi.test.app.DummyLogFriendlyException.DUMMY_ERROR_NUMBER; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.tkit.quarkus.log.cdi.test.app.DummyLogFriendlyException; | ||
import org.tkit.quarkus.log.cdi.test.app.ErrorDataService; | ||
import org.tkit.quarkus.log.cdi.test.app.ErrorWrapperService; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
@EnabledForJreRange(max = JRE.JAVA_17) | ||
public class ErrorDataServiceJdk17Test extends AbstractTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(ErrorDataService.class, ErrorWrapperService.class, DummyLogFriendlyException.class) | ||
.addAsResource("default.properties", "application.properties")); | ||
|
||
@Inject | ||
ErrorDataService service; | ||
|
||
@Inject | ||
ErrorWrapperService wrapper; | ||
|
||
@Test | ||
public void error1Test() { | ||
Assertions.assertThrows(RuntimeException.class, () -> service.error1("Error")); | ||
assertLogs() | ||
.assertLines(92) | ||
.assertContains(0, | ||
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error1(Error) throw java.lang.RuntimeException: Error"); | ||
} | ||
|
||
@Test | ||
public void error2Test() { | ||
Assertions.assertThrows(RuntimeException.class, () -> service.error2()); | ||
assertLogs().assertContains(0, | ||
DUMMY_ERROR_NUMBER | ||
+ " ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error2() throw org.tkit.quarkus.log.cdi.test.app.DummyLogFriendlyException"); | ||
} | ||
|
||
@Test | ||
public void noStacktraceTest() { | ||
Assertions.assertThrows(RuntimeException.class, () -> service.noStacktrace()); | ||
assertLogs().assertLines(1) | ||
.assertContains(0, | ||
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) noStacktrace() throw java.lang.RuntimeException: Error1"); | ||
} | ||
|
||
@Test | ||
public void wrapperTest() { | ||
Assertions.assertThrows(RuntimeException.class, () -> wrapper.wrapperMethod("WrapperError")); | ||
assertLogs().assertLines(106) | ||
.assertContains(0, | ||
"ERROR [org.tki.qua.log.cdi.tes.app.ErrorDataService] (main) error1(WrapperError) throw java.lang.RuntimeException: WrapperError"); | ||
} | ||
|
||
} |
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