Java Code Examples for org.wso2.carbon.apimgt.api.model.API#setSandboxUrl()
The following examples show how to use
org.wso2.carbon.apimgt.api.model.API#setSandboxUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentConfigContextTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testEnvironmentConfigContext() 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); Environment environment = new Environment(); environment.setType("production"); EnvironmentConfigContext environmentConfigContext = new EnvironmentConfigContext(configcontext, environment); Assert.assertNotNull(environmentConfigContext.getContext().get("environment")); Assert.assertNotNull(environmentConfigContext.getContext().get("environmentType")); }
Example 2
Source File: EndpointBckConfigContextTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testEndpointBckConfigContext() 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"; api.setUrl(url); api.setSandboxUrl(url); ConfigContext configcontext = new APIConfigContext(api); EndpointBckConfigContext endpointBckConfigContext = new EndpointBckConfigContext(configcontext, api); Assert.assertTrue(api.getEndpointConfig().contains(url)); //setting an empty string as the endpoint config and checking the value which is returned api.setEndpointConfig(""); String endpoint_config = "{\"production_endpoints\":{\"url\":\"" + api.getUrl() + "\", \"config\":null}," + "\"sandbox_endpoint\":{\"url\":\"" + api.getSandboxUrl() + "\"," + "\"config\":null},\"endpoint_type\":\"http\"}"; EndpointBckConfigContext secondEndpointBckConfigContext = new EndpointBckConfigContext(configcontext, api); Assert.assertTrue(api.getEndpointConfig().contains(endpoint_config)); //setting null as the endpoint config and checking the value which is returned api.setEndpointConfig(null); EndpointBckConfigContext thirdEndpointBckConfigContext = new EndpointBckConfigContext(configcontext, api); Assert.assertTrue(api.getEndpointConfig().contains(endpoint_config)); }
Example 3
Source File: EndpointConfigContextTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@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(); }