use of com.alibaba.csp.sentinel.node.ClusterNode in project Sentinel by alibaba.
the class SentinelJaxRsQuarkusAdapterTest method testAsyncGetHello.
@Test
public void testAsyncGetHello() {
String url = "/test/async-hello";
String resourceName = "GET:" + url;
Response response = given().get(url);
response.then().statusCode(200).body(equalTo(HELLO_STR));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(1, cn.passQps(), 0.01);
String context = "";
for (Node n : Constants.ROOT.getChildList()) {
if (n instanceof EntranceNode) {
String id = ((EntranceNode) n).getId().getName();
if (url.equals(id)) {
context = ((EntranceNode) n).getId().getName();
}
}
}
assertEquals("", context);
}
use of com.alibaba.csp.sentinel.node.ClusterNode in project Sentinel by alibaba.
the class SentinelJaxRsQuarkusAdapterTest method testDefaultFallback.
@Test
public void testDefaultFallback() {
String url = "/test/hello";
String resourceName = "GET:" + url;
configureRulesFor(resourceName, 0);
Response response = given().get(url);
response.then().statusCode(javax.ws.rs.core.Response.Status.TOO_MANY_REQUESTS.getStatusCode()).body(equalTo("Blocked by Sentinel (flow limiting)"));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(0, cn.passQps(), 0.01);
}
Aggregations