-
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.
Merge pull request #13296 from gwenneg/issue-8140-cache-injection
Introduce cache injection and NoOpCache
- Loading branch information
Showing
30 changed files
with
803 additions
and
105 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
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
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
36 changes: 36 additions & 0 deletions
36
.../cache/deployment/src/test/java/io/quarkus/cache/test/deployment/MethodCacheNameTest.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,36 @@ | ||
package io.quarkus.cache.test.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
|
||
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.cache.CacheName; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MethodCacheNameTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(CachedService.class)) | ||
.setExpectedException(DeploymentException.class); | ||
|
||
@Test | ||
public void shouldNotBeInvoked() { | ||
fail("This method should not be invoked"); | ||
} | ||
|
||
@ApplicationScoped | ||
static class CachedService { | ||
|
||
@CacheName("illegal-annotation-target") | ||
public Object getObject(Object key) { | ||
return new Object(); | ||
} | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
.../test/java/io/quarkus/cache/test/deployment/UnknownConstructorParameterCacheNameTest.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,46 @@ | ||
package io.quarkus.cache.test.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.context.Dependent; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
|
||
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.cache.Cache; | ||
import io.quarkus.cache.CacheName; | ||
import io.quarkus.cache.CacheResult; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class UnknownConstructorParameterCacheNameTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(CachedService.class, TestBean.class)) | ||
.setExpectedException(DeploymentException.class); | ||
|
||
@Test | ||
public void shouldNotBeInvoked() { | ||
fail("This method should not be invoked"); | ||
} | ||
|
||
@ApplicationScoped | ||
static class CachedService { | ||
|
||
@CacheResult(cacheName = "test-cache") | ||
public Object getObject(Object key) { | ||
return new Object(); | ||
} | ||
} | ||
|
||
@Dependent | ||
static class TestBean { | ||
|
||
public TestBean(@CacheName("unknown-cache") Cache cache) { | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
.../deployment/src/test/java/io/quarkus/cache/test/deployment/UnknownFieldCacheNameTest.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,48 @@ | ||
package io.quarkus.cache.test.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.context.Dependent; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
import javax.inject.Inject; | ||
|
||
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.cache.Cache; | ||
import io.quarkus.cache.CacheName; | ||
import io.quarkus.cache.CacheResult; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class UnknownFieldCacheNameTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(CachedService.class, TestBean.class)) | ||
.setExpectedException(DeploymentException.class); | ||
|
||
@Test | ||
public void shouldNotBeInvoked() { | ||
fail("This method should not be invoked"); | ||
} | ||
|
||
@ApplicationScoped | ||
static class CachedService { | ||
|
||
@CacheResult(cacheName = "test-cache") | ||
public Object getObject(Object key) { | ||
return new Object(); | ||
} | ||
} | ||
|
||
@Dependent | ||
static class TestBean { | ||
|
||
@Inject | ||
@CacheName("unknown-cache") | ||
Cache cache; | ||
} | ||
} |
Oops, something went wrong.