use of org.teiid.adminapi.CacheStatistics in project teiid by teiid.
the class TestODataIntegration method testSkipToken.
@Test
public void testSkipToken() throws Exception {
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("vw");
mmd.addSourceMetadata("ddl", "create view x (a string primary key, b integer) " + "as select 'xyz', 123 union all select 'abc', 456;");
mmd.setModelType(Model.Type.VIRTUAL);
teiid.deployVDB("northwind", mmd);
Properties props = new Properties();
props.setProperty("batch-size", "1");
localClient = getClient(teiid.getDriver(), "northwind", props);
ContentResponse response = http.GET(baseURL + "/northwind/vw/x?$format=json");
assertEquals(200, response.getStatus());
String starts = "{\"@odata.context\":\"$metadata#x\",\"value\":[{\"a\":\"abc\",\"b\":456}]," + "\"@odata.nextLink\":\"" + baseURL + "/northwind/vw/x?$format=json&$skiptoken=";
String ends = ",1\"}";
assertTrue(response.getContentAsString(), response.getContentAsString().startsWith(starts));
assertTrue(response.getContentAsString(), response.getContentAsString().endsWith(ends));
JsonNode node = getJSONNode(response);
String nextLink = node.get("@odata.nextLink").asText();
response = http.GET(nextLink);
assertEquals(200, response.getStatus());
assertEquals("{\"@odata.context\":\"$metadata#x\",\"value\":[{\"a\":\"xyz\",\"b\":123}]}", response.getContentAsString());
CacheStatistics stats = teiid.getAdmin().getCacheStats(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.name()).iterator().next();
// first query misses, second hits
assertEquals(50, stats.getHitRatio(), 0);
} finally {
localClient = null;
teiid.undeployVDB("northwind");
}
}
Aggregations