use of org.wso2.carbon.apimgt.gateway.threatprotection.configuration.JSONConfig in project carbon-apimgt by wso2.
the class JsonSchemaValidatorTest method testConfigureSchemaProperties.
/**
* Test Json configure properties method.
*/
@Test
public void testConfigureSchemaProperties() {
log.info("Running the test case to Configure the schema properties.");
JSONConfig testJsonConfig = new JSONConfig();
testJsonConfig.setMaxPropertyCount(Integer.valueOf("5"));
testJsonConfig.setMaxStringLength(Integer.valueOf("5"));
testJsonConfig.setMaxArrayElementCount(Integer.valueOf("5"));
testJsonConfig.setMaxKeyLength(Integer.valueOf("5"));
testJsonConfig.setMaxJsonDepth(Integer.valueOf("5"));
Mockito.when(messageContext.getProperty(ThreatProtectorConstants.MAX_PROPERTY_COUNT)).thenReturn("5");
Mockito.when(messageContext.getProperty(ThreatProtectorConstants.MAX_STRING_LENGTH)).thenReturn("5");
Mockito.when(messageContext.getProperty(ThreatProtectorConstants.MAX_ARRAY_ELEMENT_COUNT)).thenReturn("5");
Mockito.when(messageContext.getProperty(ThreatProtectorConstants.MAX_KEY_LENGTH)).thenReturn("5");
Mockito.when(messageContext.getProperty(ThreatProtectorConstants.MAX_JSON_DEPTH)).thenReturn("5");
JsonSchemaValidator jsonSchemaValidator = new JsonSchemaValidator();
JSONConfig jsonConfig = jsonSchemaValidator.configureSchemaProperties(messageContext);
assertEquals(jsonConfig.getMaxPropertyCount(), testJsonConfig.getMaxPropertyCount());
assertEquals(jsonConfig.getMaxStringLength(), testJsonConfig.getMaxStringLength());
assertEquals(jsonConfig.getMaxArrayElementCount(), testJsonConfig.getMaxArrayElementCount());
assertEquals(jsonConfig.getMaxKeyLength(), testJsonConfig.getMaxKeyLength());
assertEquals(jsonConfig.getMaxJsonDepth(), testJsonConfig.getMaxJsonDepth());
log.info("Successfully completed testConfigureSchemaProperties test case.");
}
Aggregations