Subject: [PATCH] ISPN-14466
---
Index: server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java
--- a/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java (revision c8fb5d70be9cb56153397e4b7d76f70bb8a6fe3c)
+++ b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java (date 1673971398808)
@@ -4,14 +4,7 @@
import static org.infinispan.client.rest.configuration.Protocol.HTTP_11;
import static org.infinispan.client.rest.configuration.Protocol.HTTP_20;
import static org.infinispan.commons.api.CacheContainerAdmin.AdminFlag.VOLATILE;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON_TYPE;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_OCTET_STREAM;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_XML;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_XML_TYPE;
-import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_YAML_TYPE;
-import static org.infinispan.commons.dataconversion.MediaType.TEXT_PLAIN;
-import static org.infinispan.commons.dataconversion.MediaType.TEXT_PLAIN_TYPE;
+import static org.infinispan.commons.dataconversion.MediaType.*;
import static org.infinispan.commons.test.CommonsTestingUtil.tmpDirectory;
import static org.infinispan.commons.util.Util.getResourceAsString;
import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
@@ -42,6 +35,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@@ -65,6 +59,7 @@
import org.infinispan.commons.dataconversion.internal.Json;
import org.infinispan.commons.marshall.ProtoStreamMarshaller;
import org.infinispan.commons.util.Util;
+import org.infinispan.commons.util.concurrent.CompletableFutures;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
@@ -135,9 +130,9 @@
public Object[] factory() {
return new Object[]{
new CacheResourceV2Test().withSecurity(false).protocol(HTTP_11).ssl(false),
- new CacheResourceV2Test().withSecurity(true).protocol(HTTP_20).ssl(false),
- new CacheResourceV2Test().withSecurity(true).protocol(HTTP_11).ssl(true),
- new CacheResourceV2Test().withSecurity(true).protocol(HTTP_20).ssl(true),
+++ };
}
@@ -316,6 +311,26 @@
assertThat(response).isBadRequest();
}
+ @Test
+ public void testUpdateFailure() {
+ String cacheConfig = "localCache:\n encoding:\n mediaType: \"application/x-protostream\"\n";
+ String cacheConfigAlter = "localCache:\n encoding:\n mediaType: \"application/x-java-serialized-object\"\n";
+
+ RestCacheClient cacheClient = client.cache("mutable");
+ CompletionStage<RestResponse> response = cacheClient.createWithConfiguration(RestEntity.create(APPLICATION_YAML, cacheConfig));
+ assertThat(response).isOk();
+ response = cacheClient.updateWithConfiguration(RestEntity.create(APPLICATION_YAML, cacheConfigAlter));
+ CompletableFuture<RestResponse> future = response.toCompletableFuture();
+ boolean completed = CompletableFutures.uncheckedAwait(future, 30, TimeUnit.SECONDS);
+ if (!completed) {
+ Assertions.fail("Timeout obtaining responses");
+ }
+ RestResponse rsp = future.getNow(null);
+ String body = rsp.getBody();
+ System.out.println(body);
+ assertThat(rsp).isOk();
+ }
+
@Test
public void testMutableAttributes() {
String cacheName = "mutable-attributes";