use of org.mule.runtime.api.store.ObjectStore in project mule by mulesoft.
the class IdempotentRedeliveryPolicyTestCase method testMessageRedeliveryUsingSerializationStore.
@Test
public void testMessageRedeliveryUsingSerializationStore() throws Exception {
when(expressionManager.evaluate(eq(format(SECURE_HASH_EXPR_FORMAT, "SHA-256")), eq(STRING), eq(NULL_BINDING_CONTEXT), any())).thenAnswer(inv -> {
return new TypedValue<>("" + inv.getArgumentAt(3, CoreEvent.class).getMessage().getPayload().hashCode(), STRING);
});
when(message.getPayload()).thenReturn(new TypedValue<>(STRING_MESSAGE, STRING));
reset(mockObjectStoreManager);
final ObjectStore serializationObjectStore = new SerializationObjectStore();
when(mockObjectStoreManager.createObjectStore(any(), any())).thenReturn(serializationObjectStore);
irp.initialise();
processUntilFailure();
assertThat(count.get(), equalTo(MAX_REDELIVERY_COUNT + 1));
}
use of org.mule.runtime.api.store.ObjectStore in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method storeUsingBigKey.
@Test
public void storeUsingBigKey() throws Exception {
ObjectStore os = objectStoreFactory.createObjectStore("myOs");
StringBuilder bigKey = new StringBuilder();
for (int i = 0; i < 50; i++) {
bigKey.append("abcdefghijklmnopqrstuvwxyz");
}
os.store(bigKey.toString(), 1);
assertThat(os.retrieve(bigKey.toString()), Is.is(1));
}
use of org.mule.runtime.api.store.ObjectStore in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method expirationIntervalWithLowTTL.
@Test
public void expirationIntervalWithLowTTL() throws Exception {
int maxEntries = 5;
int entryTTL = 10;
int expirationInterval = 100;
final ObjectStore os = objectStoreFactory.createObjectStore("myOs", maxEntries, entryTTL, expirationInterval);
for (int i = 0; i < maxEntries; i++) {
os.store(valueOf(i), i);
}
PollingProber prober = new PollingProber(1000, expirationInterval);
prober.check(new JUnitProbe() {
@Override
public boolean test() throws Exception {
return os.allKeys().isEmpty();
}
@Override
public String describeFailure() {
return "not all entries were evicted";
}
});
}
use of org.mule.runtime.api.store.ObjectStore in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method expirationIntervalWithHighTTLPersistentObjectStore.
@Test
public void expirationIntervalWithHighTTLPersistentObjectStore() throws Exception {
int maxEntries = 5;
int entryTTL = 10000;
ObjectStore os = objectStoreFactory.createObjectStore("myOs", maxEntries, entryTTL, 100);
os.store("0", 0);
ensureMilisecondChanged();
for (int i = 1; i < maxEntries; i++) {
os.store(valueOf(i), i);
}
os.store(OBJECT_KEY, OBJECT_KEY_VALUE_1);
Thread.sleep(entryTTL / 5);
assertThat(os.allKeys().size(), is(maxEntries));
for (int i = 1; i < maxEntries; i++) {
assertThat(os.contains(valueOf(i)), is(true));
}
assertThat(os.contains(OBJECT_KEY), is(true));
}
use of org.mule.runtime.api.store.ObjectStore in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method partitionObjectStoreDoesNotCollide.
@Test
public void partitionObjectStoreDoesNotCollide() throws Exception {
ObjectStore os = objectStoreFactory.createObjectStore("myOs");
ObjectStore os2 = objectStoreFactory.createObjectStore("myOs2");
os.store(OBJECT_KEY, OBJECT_KEY_VALUE_1);
os2.store(OBJECT_KEY, OBJECT_KEY_VALUE_2);
assertThat(os.contains(OBJECT_KEY), is(true));
assertThat(os.retrieve(OBJECT_KEY), is(OBJECT_KEY_VALUE_1));
assertThat(os2.contains(OBJECT_KEY), is(true));
assertThat(os2.retrieve(OBJECT_KEY), is(OBJECT_KEY_VALUE_2));
assertThat(os.remove(OBJECT_KEY), is(OBJECT_KEY_VALUE_1));
assertThat(os2.remove(OBJECT_KEY), is(OBJECT_KEY_VALUE_2));
}
Aggregations