Skip to content

Commit a4e28bf

Browse files
committed
Change test MyUseOfBackground component to also be Async
1 parent 5f79bb6 commit a4e28bf

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

blackbox-test-inject/src/main/java/org/example/myapp/async/BackgroundBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public BackgroundBean(@Nullable AtomicInteger intyAtomic) throws InterruptedExce
2626
intyAtomic.incrementAndGet();
2727
}
2828

29-
Thread.sleep(1200);
29+
Thread.sleep(200);
3030
}
3131
}

blackbox-test-inject/src/main/java/org/example/myapp/async/MyUseOfBackground.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package org.example.myapp.async;
22

3+
import io.avaje.inject.AsyncBean;
34
import io.avaje.inject.Component;
45
import jakarta.inject.Named;
56

6-
// @AsyncBean
7+
@AsyncBean
78
@Component
89
public class MyUseOfBackground {
910

blackbox-test-inject/src/test/java/org/example/myapp/async/AsyncTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void test() {
1919
try (var scope = BeanScope.builder().bean(AtomicInteger.class, inty).build()) {
2020

2121
// the async beans shouldn't slowdown initialization
22-
assertThat(Duration.between(start, Instant.now()).toMillis()).isLessThan(1000);
22+
assertThat(Duration.between(start, Instant.now()).toMillis()).isLessThan(300);
2323

2424
// prove it's not just lazy
2525
var beforeGet = Instant.now();
@@ -36,7 +36,7 @@ void testFactory() {
3636
var inty = new AtomicInteger();
3737
try (var scope = BeanScope.builder().bean(AtomicInteger.class, inty).build()) {
3838
// the async beans shouldn't slowdown initialization
39-
assertThat(Duration.between(start, Instant.now()).toMillis()).isLessThan(1000);
39+
assertThat(Duration.between(start, Instant.now()).toMillis()).isLessThan(300);
4040

4141
var bean = scope.get(BackgroundBean.class, "factory");
4242
// this works on my local but not on the CI for some unknown reason.

0 commit comments

Comments
 (0)