use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.
the class ClusterViewTest method testOneActiveOneInactive.
@Test
public void testOneActiveOneInactive() throws Exception {
String clusterId = UUID.randomUUID().toString();
ClusterViewBuilder builder = new ClusterViewBuilder(10, 2);
ClusterView view = builder.active(2).inactive(3).asView(clusterId);
// {"seq":10,"id":"35f60ed3-508d-4a81-b812-89f07f57db20","me":2,"active":[2],"deactivating":[],"inactive":[3]}
JsonObject o = asJsonObject(view);
Map<String, String> props = o.getProperties();
assertEquals("10", props.get("seq"));
assertEquals(clusterId, unwrapString(props.get("id")));
assertEquals("2", props.get("me"));
assertEquals(asJsonArray(2), props.get("active"));
assertEquals(asJsonArray(), props.get("deactivating"));
assertEquals(asJsonArray(3), props.get("inactive"));
}
use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.
the class ClusterViewTest method testSeveralActiveOneInactive.
@Test
public void testSeveralActiveOneInactive() throws Exception {
String clusterId = UUID.randomUUID().toString();
ClusterViewBuilder builder = new ClusterViewBuilder(10, 2);
ClusterView view = builder.active(2, 5, 6).inactive(3).asView(clusterId);
// {"seq":10,"id":"35f60ed3-508d-4a81-b812-89f07f57db20","me":2,"active":[2],"deactivating":[],"inactive":[3]}
JsonObject o = asJsonObject(view);
Map<String, String> props = o.getProperties();
assertEquals("10", props.get("seq"));
assertEquals("true", props.get("final"));
assertEquals(clusterId, unwrapString(props.get("id")));
assertEquals("2", props.get("me"));
assertEquals(asJsonArray(2, 5, 6), props.get("active"));
assertEquals(asJsonArray(), props.get("deactivating"));
assertEquals(asJsonArray(3), props.get("inactive"));
}
use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.
the class ClusterViewTest method testOneActiveOnly.
@Test
public void testOneActiveOnly() throws Exception {
String clusterId = UUID.randomUUID().toString();
ClusterViewBuilder builder = new ClusterViewBuilder(10, 21);
ClusterView view = builder.active(21).asView(clusterId);
// {"seq":10,"id":"35f60ed3-508d-4a81-b812-89f07f57db20","me":2,"active":[2],"deactivating":[],"inactive":[3]}
JsonObject o = asJsonObject(view);
Map<String, String> props = o.getProperties();
assertEquals("10", props.get("seq"));
assertEquals(clusterId, unwrapString(props.get("id")));
assertEquals("21", props.get("me"));
assertEquals(asJsonArray(21), props.get("active"));
assertEquals(asJsonArray(), props.get("deactivating"));
assertEquals(asJsonArray(), props.get("inactive"));
}
use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.
the class RandomizedClusterTest method normalize.
private static String normalize(String json) {
JsopTokenizer t = new JsopTokenizer(json);
t.read('{');
JsonObject o = JsonObject.create(t);
JsopBuilder w = new JsopBuilder();
o.toJson(w);
return w.toString();
}
use of org.apache.jackrabbit.oak.commons.json.JsonObject in project jackrabbit-oak by apache.
the class NodeCounterIndexTest method getCost.
private double getCost(String xpath) throws ParseException {
String plan = executeXPathQuery("explain measure " + xpath);
String cost = plan.substring(plan.lastIndexOf('{'));
JsonObject json = parseJson(cost);
double c = Double.parseDouble(json.getProperties().get("a"));
return c;
}
Aggregations