Search in sources :

Example 11 with AxisConfiguration

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);
}
Also used : ThrottleContext(org.apache.synapse.commons.throttle.core.ThrottleContext) RoleBaseThrottleContext(org.apache.synapse.commons.throttle.core.impl.rolebase.RoleBaseThrottleContext) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AuthenticationContext(org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext) ThrottleContext(org.apache.synapse.commons.throttle.core.ThrottleContext) MessageContext(org.apache.synapse.MessageContext) RoleBaseThrottleContext(org.apache.synapse.commons.throttle.core.impl.rolebase.RoleBaseThrottleContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) CallerConfiguration(org.apache.synapse.commons.throttle.core.CallerConfiguration) Timer(org.wso2.carbon.metrics.manager.Timer) VerbInfoDTO(org.wso2.carbon.apimgt.impl.dto.VerbInfoDTO) ThrottleConfiguration(org.apache.synapse.commons.throttle.core.ThrottleConfiguration) Before(org.junit.Before)

Example 12 with AxisConfiguration

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);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with AxisConfiguration

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());
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with AxisConfiguration

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());
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 15 with AxisConfiguration

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");
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)161 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)115 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)74 Test (org.junit.Test)68 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)61 Parameter (org.apache.axis2.description.Parameter)50 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)49 OMElement (org.apache.axiom.om.OMElement)36 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 MessageContext (org.apache.synapse.MessageContext)31 AxisService (org.apache.axis2.description.AxisService)28 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)19 AxisFault (org.apache.axis2.AxisFault)17 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)13 SynapseException (org.apache.synapse.SynapseException)13 Map (java.util.Map)12 MessageContext (org.apache.axis2.context.MessageContext)12 ServiceContext (org.apache.axis2.context.ServiceContext)12