forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#44064 from manovotn/quartzDriverDelegate
Quartz - add configuration option for custom JDBC delegate option
- Loading branch information
Showing
5 changed files
with
179 additions
and
14 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
53 changes: 53 additions & 0 deletions
53
...loyment/src/test/java/io/quarkus/quartz/test/customDelegate/DelegateNotASubclassTest.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,53 @@ | ||
package io.quarkus.quartz.test.customDelegate; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.builder.BuildChainBuilder; | ||
import io.quarkus.builder.BuildContext; | ||
import io.quarkus.builder.BuildStep; | ||
import io.quarkus.deployment.Capability; | ||
import io.quarkus.deployment.builditem.CapabilityBuildItem; | ||
import io.quarkus.quartz.test.SimpleJobs; | ||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DelegateNotASubclassTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
// add a mock pretending to provide Agroal Capability to pass our validation | ||
.addBuildChainCustomizer(new Consumer<>() { | ||
@Override | ||
public void accept(BuildChainBuilder buildChainBuilder) { | ||
buildChainBuilder.addBuildStep(new BuildStep() { | ||
@Override | ||
public void execute(BuildContext context) { | ||
context.produce( | ||
new CapabilityBuildItem(Capability.AGROAL, "fakeProvider")); | ||
} | ||
}).produces(CapabilityBuildItem.class).build(); | ||
} | ||
}) | ||
.assertException(t -> { | ||
assertEquals(ConfigurationException.class, t.getClass()); | ||
Assertions.assertTrue(t.getMessage().contains( | ||
"Custom JDBC delegate implementation with name 'io.quarkus.quartz.test.customDelegate.InvalidDelegate' needs to be a subclass")); | ||
}) | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(SimpleJobs.class, InvalidDelegate.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.quartz.driver-delegate=io.quarkus.quartz.test.customDelegate.InvalidDelegate\nquarkus.quartz.store-type=jdbc-cmt"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void shouldFailIfNotASubclass() { | ||
Assertions.fail(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...eployment/src/test/java/io/quarkus/quartz/test/customDelegate/DelegateNotIndexedTest.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,53 @@ | ||
package io.quarkus.quartz.test.customDelegate; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.builder.BuildChainBuilder; | ||
import io.quarkus.builder.BuildContext; | ||
import io.quarkus.builder.BuildStep; | ||
import io.quarkus.deployment.Capability; | ||
import io.quarkus.deployment.builditem.CapabilityBuildItem; | ||
import io.quarkus.quartz.test.SimpleJobs; | ||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DelegateNotIndexedTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
// add a mock pretending to provide Agroal Capability to pass our validation | ||
.addBuildChainCustomizer(new Consumer<>() { | ||
@Override | ||
public void accept(BuildChainBuilder buildChainBuilder) { | ||
buildChainBuilder.addBuildStep(new BuildStep() { | ||
@Override | ||
public void execute(BuildContext context) { | ||
context.produce( | ||
new CapabilityBuildItem(Capability.AGROAL, "fakeProvider")); | ||
} | ||
}).produces(CapabilityBuildItem.class).build(); | ||
} | ||
}) | ||
.assertException(t -> { | ||
assertEquals(ConfigurationException.class, t.getClass()); | ||
Assertions.assertTrue(t.getMessage().contains( | ||
"Custom JDBC delegate implementation class 'org.acme.DoesNotExist' was not found in Jandex index")); | ||
}) | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(SimpleJobs.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.quartz.driver-delegate=org.acme.DoesNotExist\nquarkus.quartz.store-type=jdbc-cmt"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void shouldFailWhenNotIndexed() { | ||
Assertions.fail(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...uartz/deployment/src/test/java/io/quarkus/quartz/test/customDelegate/InvalidDelegate.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,5 @@ | ||
package io.quarkus.quartz.test.customDelegate; | ||
|
||
// dummy class representing an invalid JDBC delegate by not subclassing a known one | ||
public class InvalidDelegate { | ||
} |
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