use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method correctReportNotQueryableCache.
private void correctReportNotQueryableCache(String name, Configuration configuration) {
createAndWriteToCache(name, configuration);
RestResponse response = queryCache(name);
assertThat(response).isBadRequest();
Json json = Json.read(response.getBody());
assertTrue(json.at("error").at("cause").toString().matches(".*ISPN028015.*"));
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method createDeleteCache.
private void createDeleteCache(String xml) {
RestEntity xmlEntity = RestEntity.create(APPLICATION_XML, xml);
RestCacheClient cacheClient = client.cache("cacheCRUD");
CompletionStage<RestResponse> response = cacheClient.createWithConfiguration(xmlEntity, VOLATILE);
assertThat(response).isOk();
response = cacheClient.stats();
assertThat(response).isOk().hasJson().hasProperty("current_number_of_entries").is(-1);
response = cacheClient.delete();
assertThat(response).isOk();
response = cacheClient.stats();
assertThat(response).isNotFound().hasReturnedText("ISPN012010: Cache with name 'cacheCRUD' not found amongst the configured caches");
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testIndexDataSyncInvalidSchema.
@Test
public void testIndexDataSyncInvalidSchema() {
String notQuiteIndexed = "package schemas;\n" + " /* @Indexed */\n" + " message Entity {\n" + " optional string name=1;\n" + " }";
// Register schema
RestResponse restResponse = join(client.schemas().put("schemas.proto", notQuiteIndexed));
assertThat(restResponse).isOk();
// Create the indexed cache
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.indexing().enable().storage(LOCAL_HEAP).addIndexedEntities("schemas.Entity");
String cacheConfig = cacheConfigToJson("sync-data-index", builder.build());
RestCacheClient cacheClient = client.cache("sync-data-index");
RestEntity config = RestEntity.create(APPLICATION_JSON, cacheConfig);
CompletionStage<RestResponse> response = cacheClient.createWithConfiguration(config);
assertThat(response).isOk();
// Write an entry, it should error
String value = Json.object().set("_type", "schemas.Entity").set("name", "Jun").toString();
RestEntity restEntity = RestEntity.create(APPLICATION_JSON, value);
restResponse = join(cacheClient.put("key", restEntity));
assertThat(restResponse).containsReturnedText("make sure at least one field has the @Field annotation");
// Cache should not have any data
response = cacheClient.size();
assertThat(response).containsReturnedText("0");
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testGetAllKeys.
@Test
public void testGetAllKeys() {
RestResponse response = join(client.cache("default").keys());
Collection<?> emptyKeys = Json.read(response.getBody()).asJsonList();
assertEquals(0, emptyKeys.size());
putTextEntryInCache("default", "1", "value");
response = join(client.cache("default").keys());
Collection<?> singleSet = Json.read(response.getBody()).asJsonList();
assertEquals(1, singleSet.size());
int entries = 10;
for (int i = 0; i < entries; i++) {
putTextEntryInCache("default", String.valueOf(i), "value");
}
response = join(client.cache("default").keys());
Set<?> keys = Json.read(response.getBody()).asJsonList().stream().map(Json::asInteger).collect(Collectors.toSet());
assertEquals(entries, keys.size());
assertTrue(IntStream.range(0, entries).allMatch(keys::contains));
response = join(client.cache("default").keys(5));
Set<?> keysLimited = Json.read(response.getBody()).asJsonList().stream().map(Json::asInteger).collect(Collectors.toSet());
assertEquals(5, keysLimited.size());
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testSourceConnected.
@Test
public void testSourceConnected() {
RestCacheClient cacheClient = client.cache("default");
RestResponse restResponse = join(cacheClient.sourceConnected());
ResponseAssertion.assertThat(restResponse).isNotFound();
}
Aggregations