use of org.wso2.carbon.apimgt.core.template.APIConfigContext in project carbon-apimgt by wso2.
the class EndpointConfigContextTest method testEndpointConfigContext.
@Test(expected = APITemplateException.class)
public void testEndpointConfigContext() throws Exception {
API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
api.setStatus(APIConstants.CREATED);
api.setContextTemplate("/");
String url = "http://maps.googleapis.com/maps/api/geocode/json?address=Colombo";
String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + url + "\", \"config\":null}," + "\"sandbox_endpoint\":{\"url\":\"" + url + "\",\"config\":null},\"endpoint_type\":\"http\"}";
api.setEndpointConfig(endpointConfig);
api.setUrl(url);
api.setSandboxUrl(url);
ConfigContext configcontext = new APIConfigContext(api);
EndpointConfigContext endpointConfigContext = new EndpointConfigContext(configcontext, api);
endpointConfigContext.validate();
Assert.assertNotNull(endpointConfigContext.getContext().get("endpoint_config"));
// set an empty string and check the validation
endpointConfig = "";
api.setEndpointConfig(endpointConfig);
endpointConfigContext = new EndpointConfigContext(configcontext, api);
endpointConfigContext.validate();
// set a null value and check the validation
endpointConfig = null;
api.setEndpointConfig(endpointConfig);
endpointConfigContext = new EndpointConfigContext(configcontext, api);
endpointConfigContext.validate();
// set invalid value and check the validation
String invalidEndpointConfig = "\"production_endpoints\"{\"url\":\"" + url + "\", \"config\":null}," + "\"sandbox_endpoint\":{\"url\":\"" + url + "\",\"config\":null},\"endpoint_type\":\"http\"";
api.setEndpointConfig(invalidEndpointConfig);
endpointConfigContext = new EndpointConfigContext(configcontext, api);
endpointConfigContext.validate();
}
use of org.wso2.carbon.apimgt.core.template.APIConfigContext in project carbon-apimgt by wso2.
the class HandlerConfigContextTest method testHandlerConfigContex.
@Test
public void testHandlerConfigContex() throws Exception {
API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
api.setStatus(APIConstants.CREATED);
api.setContextTemplate("/");
ConfigContext configcontext = new APIConfigContext(api);
List<HandlerConfig> handlers = new ArrayList<HandlerConfig>();
HandlerConfigContex handlerConfigContex = new HandlerConfigContex(configcontext, handlers);
Assert.assertNotNull(handlerConfigContex.getContext().get("handlers"));
}
Aggregations