-
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.
Quartz + Scheduler: Allow to use config in Identity field. Fixes #14967
- Loading branch information
Showing
12 changed files
with
260 additions
and
17 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
35 changes: 35 additions & 0 deletions
35
...artz/deployment/src/test/java/io/quarkus/quartz/test/DuplicateIdentityExpressionTest.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,35 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DuplicateIdentityExpressionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(IllegalStateException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(DuplicateIdentityExpressionTest.InvalidBean.class) | ||
.addAsResource(new StringAsset("my.identity=my_name"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
|
||
static class InvalidBean { | ||
|
||
@Scheduled(every = "1s", identity = "{my.identity}") | ||
@Scheduled(every = "1s", identity = "my_name") | ||
void wrong() { | ||
} | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
.../deployment/src/test/java/io/quarkus/quartz/test/MissingConfigIdentityExpressionTest.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,33 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MissingConfigIdentityExpressionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(NoSuchElementException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MissingConfigIdentityExpressionTest.InvalidBean.class)); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
|
||
static class InvalidBean { | ||
|
||
@Scheduled(every = "1s", identity = "{my.identity}") | ||
void wrong() { | ||
} | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/SimpleIdentityTest.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,44 @@ | ||
package io.quarkus.quartz.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class SimpleIdentityTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Jobs.class) | ||
.addAsResource(new StringAsset("jobs.identity=every_1s_another_name"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testJobsWithIdentity() throws InterruptedException { | ||
// Only assert that the scheduled method is working fine | ||
assertTrue(Jobs.LATCH.await(5, TimeUnit.SECONDS)); | ||
} | ||
|
||
public static class Jobs { | ||
|
||
static final CountDownLatch LATCH = new CountDownLatch(2); | ||
|
||
@Scheduled(every = "1s", identity = "every_1s_name") | ||
@Scheduled(every = "1s", identity = "{jobs.identity}") | ||
void ping() { | ||
LATCH.countDown(); | ||
} | ||
|
||
} | ||
|
||
} |
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
35 changes: 35 additions & 0 deletions
35
...r/deployment/src/test/java/io/quarkus/scheduler/test/DuplicateIdentityExpressionTest.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,35 @@ | ||
package io.quarkus.scheduler.test; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DuplicateIdentityExpressionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(IllegalStateException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(DuplicateIdentityExpressionTest.InvalidBean.class) | ||
.addAsResource(new StringAsset("my.identity=my_name"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
|
||
static class InvalidBean { | ||
|
||
@Scheduled(every = "1s", identity = "{my.identity}") | ||
@Scheduled(every = "1s", identity = "my_name") | ||
void wrong() { | ||
} | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...ployment/src/test/java/io/quarkus/scheduler/test/MissingConfigIdentityExpressionTest.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,33 @@ | ||
package io.quarkus.scheduler.test; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MissingConfigIdentityExpressionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(NoSuchElementException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MissingConfigIdentityExpressionTest.InvalidBean.class)); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
|
||
static class InvalidBean { | ||
|
||
@Scheduled(every = "1s", identity = "{my.identity}") | ||
void wrong() { | ||
} | ||
|
||
} | ||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
...ions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/SimpleIdentityTest.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,44 @@ | ||
package io.quarkus.scheduler.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class SimpleIdentityTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Jobs.class) | ||
.addAsResource(new StringAsset("jobs.identity=every_1s_another_name"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testJobsWithIdentity() throws InterruptedException { | ||
// Only assert that the scheduled method is working fine | ||
assertTrue(Jobs.LATCH.await(5, TimeUnit.SECONDS)); | ||
} | ||
|
||
public static class Jobs { | ||
|
||
static final CountDownLatch LATCH = new CountDownLatch(2); | ||
|
||
@Scheduled(every = "1s", identity = "every_1s_name") | ||
@Scheduled(every = "1s", identity = "{jobs.identity}") | ||
void ping() { | ||
LATCH.countDown(); | ||
} | ||
|
||
} | ||
|
||
} |
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