-
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.
Support Java Records in bytecode recorders
- Loading branch information
Showing
5 changed files
with
59 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
16 changes: 16 additions & 0 deletions
16
.../extension/deployment/src/main/java/io/quarkus/extest/deployment/TestRecordProcessor.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,16 @@ | ||
package io.quarkus.extest.deployment; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.extest.runtime.records.TestRecord; | ||
import io.quarkus.extest.runtime.records.TestRecordRecorder; | ||
|
||
public class TestRecordProcessor { | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
public void record(TestRecordRecorder recorder) { | ||
recorder.record(new TestRecord("foo", 100)); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...tension/extension/runtime/src/main/java/io/quarkus/extest/runtime/records/TestRecord.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,4 @@ | ||
package io.quarkus.extest.runtime.records; | ||
|
||
public record TestRecord(String name, int age) { | ||
} |
13 changes: 13 additions & 0 deletions
13
...extension/runtime/src/main/java/io/quarkus/extest/runtime/records/TestRecordRecorder.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,13 @@ | ||
package io.quarkus.extest.runtime.records; | ||
|
||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class TestRecordRecorder { | ||
|
||
public static TestRecord testRecord; | ||
|
||
public void record(TestRecord testRecord) { | ||
TestRecordRecorder.testRecord = testRecord; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ts/test-extension/tests/src/test/java/io/quarkus/it/extension/TestRecordRecorderTest.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,18 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.extest.runtime.records.TestRecordRecorder; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class TestRecordRecorderTest { | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("foo", TestRecordRecorder.testRecord.name()); | ||
assertEquals(100, TestRecordRecorder.testRecord.age()); | ||
} | ||
} |