Search in sources :

Example 1 with XmlConverter

use of com.alibaba.cloud.sentinel.datasource.converter.XmlConverter in project spring-cloud-alibaba by alibaba.

the class SentinelConverterTests method testXmlConverter.

@Test
public void testXmlConverter() {
    XmlConverter jsonConverter = new XmlConverter(xmlMapper, FlowRule.class);
    List<FlowRule> flowRules = (List<FlowRule>) jsonConverter.convert(readFileContent("classpath: flowrule.xml"));
    assertThat(flowRules.size()).isEqualTo(2);
    assertThat(flowRules.get(0).getResource()).isEqualTo("resource");
    assertThat(flowRules.get(0).getLimitApp()).isEqualTo("default");
    assertThat(String.valueOf(flowRules.get(0).getCount())).isEqualTo("1.0");
    assertThat(flowRules.get(0).getControlBehavior()).isEqualTo(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
    assertThat(flowRules.get(0).getStrategy()).isEqualTo(RuleConstant.STRATEGY_DIRECT);
    assertThat(flowRules.get(0).getGrade()).isEqualTo(RuleConstant.FLOW_GRADE_QPS);
    assertThat(flowRules.get(1).getResource()).isEqualTo("test");
    assertThat(flowRules.get(1).getLimitApp()).isEqualTo("default");
    assertThat(String.valueOf(flowRules.get(1).getCount())).isEqualTo("1.0");
    assertThat(flowRules.get(1).getControlBehavior()).isEqualTo(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
    assertThat(flowRules.get(1).getStrategy()).isEqualTo(RuleConstant.STRATEGY_DIRECT);
    assertThat(flowRules.get(1).getGrade()).isEqualTo(RuleConstant.FLOW_GRADE_QPS);
}
Also used : List(java.util.List) FlowRule(com.alibaba.csp.sentinel.slots.block.flow.FlowRule) XmlConverter(com.alibaba.cloud.sentinel.datasource.converter.XmlConverter) Test(org.junit.Test)

Aggregations

XmlConverter (com.alibaba.cloud.sentinel.datasource.converter.XmlConverter)1 FlowRule (com.alibaba.csp.sentinel.slots.block.flow.FlowRule)1 List (java.util.List)1 Test (org.junit.Test)1