-
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.
Introduce build time flag property to disable the cache extension
- Loading branch information
Showing
3 changed files
with
63 additions
and
4 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
43 changes: 43 additions & 0 deletions
43
...ns/cache/deployment/src/test/java/io/quarkus/cache/test/deployment/DisabledCacheTest.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,43 @@ | ||
package io.quarkus.cache.test.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import javax.enterprise.context.Dependent; | ||
import javax.inject.Inject; | ||
|
||
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.cache.CacheResult; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DisabledCacheTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(new StringAsset("quarkus.cache.enabled=false"), "application.properties") | ||
.addClass(CachedService.class)); | ||
|
||
private static final String KEY = "key"; | ||
|
||
@Inject | ||
CachedService cachedService; | ||
|
||
@Test | ||
public void testEnabledFlagProperty() { | ||
assertNotEquals(cachedService.cachedMethod(KEY), cachedService.cachedMethod(KEY)); | ||
} | ||
|
||
@Dependent | ||
static class CachedService { | ||
|
||
@CacheResult(cacheName = "test-cache") | ||
public Object cachedMethod(String key) { | ||
return new Object(); | ||
} | ||
} | ||
} |