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);
}
Aggregations