use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIThrottleHandlerTest method init.
@Before
public void init() {
throttleContext = Mockito.mock(ThrottleContext.class);
timer = Mockito.mock(Timer.class);
context = Mockito.mock(Timer.Context.class);
throttleConfiguration = Mockito.mock(ThrottleConfiguration.class);
callerConfiguration = Mockito.mock(CallerConfiguration.class);
Mockito.when(timer.start()).thenReturn(context);
messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion);
axisConfiguration = new AxisConfiguration();
configurationContext = new ConfigurationContext(axisConfiguration);
throttleKey = "throttle_" + throttleID + "_cac_key";
verbInfoDTO = new VerbInfoDTO();
verbInfoDTO.setThrottling("Silver");
verbInfoDTO.setRequestKey("/weather");
verbInfoDTO.setHttpVerb("GET");
apiThrottleHandler = new APIThrottleHandlerWrapper(timer, throttleContext);
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIMgtLatencyStatsHandlerTest method handleResponseWhileAnalyticDisable.
@Test
public void handleResponseWhileAnalyticDisable() throws Exception {
PowerMockito.mockStatic(APIUtil.class);
BDDMockito.given(APIUtil.isAnalyticsEnabled()).willReturn(false);
SynapseConfiguration synCfg = new SynapseConfiguration();
org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = new AxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg, new Axis2SynapseEnvironment(cfgCtx, synCfg));
APIMgtLatencyStatsHandler apiMgtLatencyStatsHandler = new APIMgtLatencyStatsHandler();
apiMgtLatencyStatsHandler.handleResponse(synCtx);
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIMgtLatencyStatsHandlerTest method handleRequest.
@Test
public void handleRequest() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = new AxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg, new Axis2SynapseEnvironment(cfgCtx, synCfg));
synCfg.setProperty(APIMgtGatewayConstants.REQUEST_EXECUTION_START_TIME, "123456789");
synCtx.setProperty(APIMgtGatewayConstants.API_STATUS, APIConstants.PUBLISHED);
APIMgtLatencyStatsHandler apiMgtLatencyStatsHandler = new APIMgtLatencyStatsHandler();
apiMgtLatencyStatsHandler.handleRequest(synCtx);
long requestTime = Long.parseLong(String.valueOf(synCtx.getProperty("api.ut.requestTime")));
Assert.assertTrue(requestTime <= System.currentTimeMillis());
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIMgtLatencyStatsHandlerTest method handleRequestWithoutSetExecutionStartTime.
@Test
public void handleRequestWithoutSetExecutionStartTime() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = new AxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg, new Axis2SynapseEnvironment(cfgCtx, synCfg));
synCtx.setProperty(APIMgtGatewayConstants.API_STATUS, APIConstants.PUBLISHED);
APIMgtLatencyStatsHandler apiMgtLatencyStatsHandler = new APIMgtLatencyStatsHandler();
apiMgtLatencyStatsHandler.handleRequest(synCtx);
long requestTime = Long.parseLong(String.valueOf(synCtx.getProperty("api.ut.requestTime")));
Assert.assertTrue(requestTime <= System.currentTimeMillis());
Assert.assertTrue(Long.parseLong((String) synCtx.getProperty(APIMgtGatewayConstants.REQUEST_EXECUTION_START_TIME)) <= System.currentTimeMillis());
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class SynapsePropertiesHandlerTest method handleRequest.
@Test
public void handleRequest() throws Exception {
SynapseConfiguration synCfg = new SynapseConfiguration();
org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = new AxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg, new Axis2SynapseEnvironment(cfgCtx, synCfg));
System.setProperty("http.nio.port", "8280");
System.setProperty("https.nio.port", "8243");
System.setProperty(APIConstants.KEYMANAGER_PORT, "9443");
System.setProperty(APIConstants.KEYMANAGER_HOSTNAME, "api.wso2.com");
SynapsePropertiesHandler synapsePropertiesHandler = new SynapsePropertiesHandler();
synapsePropertiesHandler.handleRequest(synCtx);
Assert.assertEquals(synCtx.getProperty("http.nio.port"), "8280");
Assert.assertEquals(synCtx.getProperty("https.nio.port"), "8243");
Assert.assertEquals(synCtx.getProperty("keyManager.port"), "9443");
Assert.assertEquals(synCtx.getProperty("keyManager.hostname"), "api.wso2.com");
}
Aggregations