Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jun 16, 2024
1 parent 6bb851b commit bd1d7f8
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.springframework.data.aerospike.cache.CacheUtils.sha256;
import static org.springframework.data.aerospike.util.AwaitilityUtils.awaitTenSecondsUntil;

@SuppressWarnings("NewObjectEquality")
public class AerospikeCacheManagerIntegrationTests extends BaseBlockingIntegrationTests {

private static final String STRING_PARAM = "foo";
Expand Down Expand Up @@ -125,6 +126,25 @@ public void shouldCacheWithNumericParam() {
assertThat(cachingComponent.getNoOfCalls()).isEqualTo(1);
}

@Test
@SuppressWarnings("StringEquality")
public void shouldCacheInstances() {
assertThat(aerospikeOperations.count(DEFAULT_SET_NAME)).isEqualTo(0);
String stringInstance1 = new String(STRING_PARAM.toCharArray());
String stringInstance2 = new String(STRING_PARAM.toCharArray());
// assert that variables are referencing different objects in memory
assertThat(stringInstance1 != stringInstance2).isTrue();

CachedObject response1 = cachingComponent.cacheableMethod(stringInstance1);
CachedObject response2 = cachingComponent.cacheableMethod(stringInstance2);

assertThat(response1).isNotNull();
assertThat(response1.getValue()).isEqualTo(VALUE);
assertThat(response2).isNotNull();
assertThat(response2.getValue()).isEqualTo(VALUE);
assertThat(cachingComponent.getNoOfCalls()).isEqualTo(1);
}

@Test
public void shouldCacheWithMapParam() {
assertThat(aerospikeOperations.count(DEFAULT_SET_NAME)).isEqualTo(0);
Expand Down

0 comments on commit bd1d7f8

Please sign in to comment.