-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for javax.cache:cache-api:1.1.1
#176
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
"resource-config.json", | ||
"serialization-config.json" | ||
] |
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,13 @@ | ||
{ | ||
"resources": { | ||
"includes": [ | ||
{ | ||
"condition": { | ||
"typeReachable": "javax.cache.Caching$CachingProviderRegistry$1" | ||
}, | ||
"pattern": "\\QMETA-INF/services/javax.cache.spi.CachingProvider\\E" | ||
} | ||
] | ||
}, | ||
"bundles": [] | ||
} |
48 changes: 48 additions & 0 deletions
48
metadata/javax.cache/cache-api/1.1.1/serialization-config.json
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 @@ | ||
{ | ||
"lambdaCapturingTypes": [], | ||
"proxies": [], | ||
"types": [ | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "javax.cache.configuration.FactoryBuilder$SingletonFactory" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "javax.cache.expiry.AccessedExpiryPolicy" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "javax.cache.expiry.Duration" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "javax.cache.expiry.EternalExpiryPolicy" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "java.lang.String" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "java.lang.Number" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "java.lang.Object" | ||
}, | ||
"name": "java.lang.Integer" | ||
} | ||
] | ||
} |
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,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "1.1.1", | ||
"module": "javax.cache:cache-api", | ||
"tested-versions": [ | ||
"1.1.1" | ||
] | ||
} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
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,34 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = tck.testedLibraryVersion.get() | ||
|
||
dependencies { | ||
testImplementation "javax.cache:cache-api:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
testImplementation "org.jsr107.ri:cache-ri-impl:$libraryVersion" | ||
} | ||
|
||
graalvmNative { | ||
agent { | ||
defaultMode = "conditional" | ||
modes { | ||
conditional { | ||
userCodeFilterPath = "user-code-filter.json" | ||
} | ||
} | ||
metadataCopy { | ||
mergeWithExisting = true | ||
inputTaskNames.add("test") | ||
outputDirectories.add("src/test/resources/META-INF/native-image/javax.cache/cache-api") | ||
} | ||
} | ||
} |
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,2 @@ | ||
library.version = 1.1.1 | ||
metadata.dir = javax.cache/cache-api/1.1.1/ |
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,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'javax.cache.cache-api_tests' |
102 changes: 102 additions & 0 deletions
102
...s/src/javax.cache/cache-api/1.1.1/src/test/java/javax_cache/cache_api/core/CacheTest.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,102 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package javax_cache.cache_api.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.cache.Cache; | ||
import javax.cache.CacheManager; | ||
import javax.cache.Caching; | ||
import javax.cache.configuration.Configuration; | ||
import javax.cache.configuration.MutableConfiguration; | ||
import javax.cache.expiry.AccessedExpiryPolicy; | ||
|
||
import static javax.cache.expiry.Duration.ONE_HOUR; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
public class CacheTest { | ||
@Test | ||
public void simpleCache() { | ||
CacheManager manager = Caching.getCachingProvider().getCacheManager(); | ||
Configuration<Integer, String> configuration = new MutableConfiguration<Integer, String>().setTypes(Integer.class, String.class); | ||
assertThat(manager.getCache("simpleCache22")).isNull(); | ||
Cache<Integer, String> simpleCache = manager.createCache("simpleCache22", configuration); | ||
simpleCache.put(2, "value"); | ||
assertThat(simpleCache.get(2)).isEqualTo("value"); | ||
} | ||
|
||
@Test | ||
public void simpleAPITypeEnforcement() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<String, Integer> config = new MutableConfiguration<String, Integer>() | ||
.setStoreByValue(true).setTypes(String.class, Integer.class) | ||
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
cacheManager.createCache("simpleCache", config); | ||
Cache<String, Integer> cache = Caching.getCache("simpleCache", String.class, Integer.class); | ||
cache.put("key", 1); | ||
assertEquals(1, cache.get("key")); | ||
cache.remove("key"); | ||
assertNull(cache.get("key")); | ||
} | ||
|
||
@Test | ||
public void simpleAPITypeEnforcementUsingCaching() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<String, Integer> config = new MutableConfiguration<>(); | ||
config.setTypes(String.class, Integer.class).setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
cacheManager.createCache("simpleCache2", config); | ||
Cache<String, Integer> cache = Caching.getCache("simpleCache2", String.class, Integer.class); | ||
cache.put("key", 1); | ||
assertEquals(1, cache.get("key")); | ||
cache.remove("key"); | ||
assertNull(cache.get("key")); | ||
} | ||
|
||
@Test | ||
public void simpleAPIWithGenericsAndNoTypeEnforcement() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<String, Integer> config = new MutableConfiguration<>(); | ||
config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
cacheManager.createCache("sampleCache3", config); | ||
Cache<String, Integer> cache = cacheManager.getCache("sampleCache3"); | ||
cache.put("key", 1); | ||
assertThat(cache.get("key")).isEqualTo(1); | ||
cache.remove("key"); | ||
assertNull(cache.get("key")); | ||
} | ||
|
||
|
||
@Test | ||
public void simpleAPINoGenericsAndNoTypeEnforcement() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
String cacheName = "sampleCache"; | ||
MutableConfiguration<Object, Object> config = new MutableConfiguration<>() | ||
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
cacheManager.createCache(cacheName, config); | ||
Cache<Object, Object> cache = cacheManager.getCache(cacheName); | ||
cache.put("key", 1); | ||
cache.put(1, "key"); | ||
assertEquals(1, (Integer) cache.get("key")); | ||
cache.remove("key"); | ||
assertNull(cache.get("key")); | ||
} | ||
|
||
@Test | ||
public void simpleAPITypeEnforcementObject() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<Object, Object> config = new MutableConfiguration<>() | ||
.setTypes(Object.class, Object.class).setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
cacheManager.createCache("simpleCache4", config); | ||
Cache<Object, Object> cache = Caching.getCache("simpleCache4", Object.class, Object.class); | ||
cache.put("key", 1); | ||
assertEquals(1, cache.get("key")); | ||
cache.remove("key"); | ||
assertNull(cache.get("key")); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ache/cache-api/1.1.1/src/test/java/javax_cache/cache_api/core/CompletionListenerTest.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 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package javax_cache.cache_api.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.cache.Cache; | ||
import javax.cache.CacheManager; | ||
import javax.cache.Caching; | ||
import javax.cache.configuration.MutableConfiguration; | ||
import javax.cache.expiry.AccessedExpiryPolicy; | ||
import javax.cache.integration.CompletionListenerFuture; | ||
import java.util.HashSet; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import static javax.cache.expiry.Duration.ONE_HOUR; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CompletionListenerTest { | ||
@Test | ||
public void testCompletionListener() { | ||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<String, Integer> config = new MutableConfiguration<String, Integer>() | ||
.setTypes(String.class, Integer.class).setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR)).setStatisticsEnabled(true); | ||
Cache<String, Integer> cache = cacheManager.createCache("simpleCache3", config); | ||
HashSet<String> keys = new HashSet<>(); | ||
keys.add("23432lkj"); | ||
keys.add("4fsdldkj"); | ||
CompletionListenerFuture future = new CompletionListenerFuture(); | ||
cache.loadAll(keys, true, future); | ||
try { | ||
future.get(); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} catch (ExecutionException e) { | ||
e.getCause(); | ||
} | ||
assertThat(future.isDone()).isEqualTo(true); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ax.cache/cache-api/1.1.1/src/test/java/javax_cache/cache_api/core/EntryProcessorTest.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 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package javax_cache.cache_api.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.cache.Cache; | ||
import javax.cache.CacheManager; | ||
import javax.cache.Caching; | ||
import javax.cache.configuration.MutableConfiguration; | ||
import javax.cache.processor.EntryProcessor; | ||
import javax.cache.processor.MutableEntry; | ||
import java.io.Serializable; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class EntryProcessorTest { | ||
@Test | ||
public void incrementValue() { | ||
CacheManager manager = Caching.getCachingProvider().getCacheManager(); | ||
MutableConfiguration<String, Integer> configuration = new MutableConfiguration<String, Integer>().setTypes(String.class, Integer.class); | ||
Cache<String, Integer> cache = manager.createCache("example", configuration); | ||
String key = "counter"; | ||
cache.put(key, 1); | ||
assertThat(cache.invoke(key, new IncrementProcessor<>())).isEqualTo(1); | ||
assertThat(cache.get(key)).isEqualTo(2); | ||
} | ||
|
||
public static class IncrementProcessor<K> implements EntryProcessor<K, Integer, Integer>, Serializable { | ||
public static final long serialVersionUID = 201306211238L; | ||
|
||
@Override | ||
public Integer process(MutableEntry<K, Integer> entry, Object... arguments) { | ||
if (entry.exists()) { | ||
Integer current = entry.getValue(); | ||
entry.setValue(current + 1); | ||
return current; | ||
} else { | ||
entry.setValue(0); | ||
return -1; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.