Search in sources :

Example 6 with RawOperator

use of org.apache.servicecomb.governance.marker.operator.RawOperator in project incubator-servicecomb-java-chassis by apache.

the class OperatorTest method test_header_low_case.

@Test
public void test_header_low_case() {
    GovernanceRequest request = new GovernanceRequest();
    Map<String, String> reqHeaders = new HashMap<>();
    reqHeaders.put("hEadeR", "100");
    request.setHeaders(reqHeaders);
    Matcher matcher = new Matcher();
    Map<String, RawOperator> headers = new HashMap<>();
    RawOperator header1 = new RawOperator();
    header1.put("compare", ">10");
    headers.put("HeAder", header1);
    matcher.setHeaders(headers);
    Assert.assertTrue(requestProcessor.match(request, matcher));
}
Also used : GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) HashMap(java.util.HashMap) Matcher(org.apache.servicecomb.governance.marker.Matcher) RawOperator(org.apache.servicecomb.governance.marker.operator.RawOperator) Test(org.junit.Test)

Example 7 with RawOperator

use of org.apache.servicecomb.governance.marker.operator.RawOperator in project incubator-servicecomb-java-chassis by apache.

the class OperatorTest method test_suffix_api_path_match.

@Test
public void test_suffix_api_path_match() {
    GovernanceRequest request = new GovernanceRequest();
    request.setUri("/api/bulkhead");
    Matcher matcher = new Matcher();
    RawOperator apiPath = new RawOperator();
    apiPath.put("suffix", "/bulkhead");
    matcher.setApiPath(apiPath);
    Assert.assertTrue(requestProcessor.match(request, matcher));
}
Also used : GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) Matcher(org.apache.servicecomb.governance.marker.Matcher) RawOperator(org.apache.servicecomb.governance.marker.operator.RawOperator) Test(org.junit.Test)

Example 8 with RawOperator

use of org.apache.servicecomb.governance.marker.operator.RawOperator in project incubator-servicecomb-java-chassis by apache.

the class OperatorTest method test_exact_api_path_not_match.

@Test
public void test_exact_api_path_not_match() {
    GovernanceRequest request = new GovernanceRequest();
    request.setUri("/bulkhead/");
    Matcher matcher = new Matcher();
    RawOperator apiPath = new RawOperator();
    apiPath.put("exact", "/bulkhead");
    matcher.setApiPath(apiPath);
    Assert.assertFalse(requestProcessor.match(request, matcher));
    request.setUri("/bulkhead");
    request.setUri(null);
    Assert.assertFalse(requestProcessor.match(request, matcher));
    request.setUri("/bulkhead");
    apiPath.clear();
    matcher.setApiPath(apiPath);
    Assert.assertFalse(requestProcessor.match(request, matcher));
}
Also used : GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) Matcher(org.apache.servicecomb.governance.marker.Matcher) RawOperator(org.apache.servicecomb.governance.marker.operator.RawOperator) Test(org.junit.Test)

Example 9 with RawOperator

use of org.apache.servicecomb.governance.marker.operator.RawOperator in project incubator-servicecomb-java-chassis by apache.

the class OperatorTest method test_exact_api_path_match_header_not_match.

@Test
public void test_exact_api_path_match_header_not_match() {
    GovernanceRequest request = new GovernanceRequest();
    request.setUri("/bulkhead");
    request.setMethod("GET");
    Map<String, String> reqHeaders = new HashMap<>();
    reqHeaders.put("header1", "value2");
    request.setHeaders(reqHeaders);
    Matcher matcher = new Matcher();
    RawOperator apiPath = new RawOperator();
    apiPath.put("exact", "/bulkhead");
    matcher.setApiPath(apiPath);
    matcher.setMethod(Arrays.asList("GET"));
    Map<String, RawOperator> headers = new HashMap<>();
    RawOperator header1 = new RawOperator();
    header1.put("exact", "value1");
    headers.put("header1", header1);
    matcher.setHeaders(headers);
    Assert.assertFalse(requestProcessor.match(request, matcher));
    reqHeaders.clear();
    request.setHeaders(reqHeaders);
    Assert.assertFalse(requestProcessor.match(request, matcher));
}
Also used : GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) HashMap(java.util.HashMap) Matcher(org.apache.servicecomb.governance.marker.Matcher) RawOperator(org.apache.servicecomb.governance.marker.operator.RawOperator) Test(org.junit.Test)

Example 10 with RawOperator

use of org.apache.servicecomb.governance.marker.operator.RawOperator in project incubator-servicecomb-java-chassis by apache.

the class OperatorTest method test_suffix_api_path_not_match_null.

@Test
public void test_suffix_api_path_not_match_null() {
    GovernanceRequest request = new GovernanceRequest();
    request.setUri("/api/bulkhead");
    Matcher matcher = new Matcher();
    RawOperator apiPath = new RawOperator();
    apiPath.put("suffix", null);
    matcher.setApiPath(apiPath);
    Assert.assertFalse(requestProcessor.match(request, matcher));
}
Also used : GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) Matcher(org.apache.servicecomb.governance.marker.Matcher) RawOperator(org.apache.servicecomb.governance.marker.operator.RawOperator) Test(org.junit.Test)

Aggregations

GovernanceRequest (org.apache.servicecomb.governance.marker.GovernanceRequest)24 Matcher (org.apache.servicecomb.governance.marker.Matcher)24 RawOperator (org.apache.servicecomb.governance.marker.operator.RawOperator)24 Test (org.junit.Test)24 HashMap (java.util.HashMap)10