Search in sources :

Example 1 with NativeWorkerPool

use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.

the class PassThroughHttpSenderTest method testInit.

/**
 * This method tests the initialization of PassThroughHttpSender
 * @throws Exception
 */
@Test
public void testInit() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    configurationContext.setProperty(PassThroughConstants.PASS_THROUGH_TRANSPORT_WORKER_POOL, workerPool);
    TransportOutDescription transportOutDescription = new TransportOutDescription("passthru");
    PassThroughHttpSender passThroughHttpSender = new PassThroughHttpSender();
    passThroughHttpSender.init(configurationContext, transportOutDescription);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with NativeWorkerPool

use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testTrue.

/**
 * Testing the starting of target response when response body is expected
 *
 * @throws Exception
 */
@Test
public void testTrue() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    targetConfiguration.build();
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    PowerMockito.mockStatic(TargetContext.class);
    TargetContext cntxt = new TargetContext(targetConfiguration);
    PowerMockito.when(TargetContext.get(any(NHttpClientConnection.class))).thenReturn(cntxt);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, true, false);
    try {
        targetResponse.start(conn);
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Unable to start the target response!");
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) HttpResponse(org.apache.http.HttpResponse) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with NativeWorkerPool

use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testFalse.

/**
 * Testing the starting of target response when response body is not expected
 *
 * @throws Exception
 */
@Test
public void testFalse() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    TargetConnections connections = PowerMockito.mock(TargetConnections.class);
    targetConfiguration.setConnections(connections);
    PowerMockito.mockStatic(TargetContext.class);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, false, false);
    try {
        targetResponse.start(conn);
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Unable to start the target response!");
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) HttpResponse(org.apache.http.HttpResponse) TargetConnections(org.apache.synapse.transport.passthru.connections.TargetConnections) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with NativeWorkerPool

use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testRead.

/**
 * Testing reading from a pipe
 * @throws Exception
 */
@Test
public void testRead() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    targetConfiguration.build();
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    ContentDecoder decoder = PowerMockito.mock(ContentDecoder.class);
    TargetConnections connections = PowerMockito.mock(TargetConnections.class);
    targetConfiguration.setConnections(connections);
    PowerMockito.mockStatic(TargetContext.class);
    TargetContext cntxt = new TargetContext(targetConfiguration);
    PowerMockito.when(TargetContext.get(any(NHttpClientConnection.class))).thenReturn(cntxt);
    PowerMockito.when(decoder.read(any(ByteBuffer.class))).thenReturn(12);
    PowerMockito.when(decoder.isCompleted()).thenReturn(true);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, true, false);
    targetResponse.start(conn);
    int result = targetResponse.read(conn, decoder);
    Assert.assertEquals(12, result);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) ContentDecoder(org.apache.http.nio.ContentDecoder) HttpResponse(org.apache.http.HttpResponse) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) ByteBuffer(java.nio.ByteBuffer) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConnections(org.apache.synapse.transport.passthru.connections.TargetConnections) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with NativeWorkerPool

use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.

the class TargetHandlerTest method testOutputReady.

/**
 * Testing whether output-ready connection is processed
 *
 * @throws Exception
 */
@Test
public void testOutputReady() throws Exception {
    DeliveryAgent deliveryAgent = mock(DeliveryAgent.class);
    ClientConnFactory connFactory = mock(ClientConnFactory.class);
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    TargetContext targetContext = new TargetContext(targetConfiguration);
    MessageContext messageContext = new MessageContext();
    targetContext.setRequestMsgCtx(messageContext);
    TargetHandler targetHandler = new TargetHandler(deliveryAgent, connFactory, targetConfiguration);
    TargetRequest request = mock(TargetRequest.class);
    NHttpClientConnection conn = mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    ContentEncoder encoder = mock(ContentEncoder.class);
    mockStatic(TargetContext.class);
    when(TargetContext.get(conn)).thenReturn(targetContext);
    when(TargetContext.getState(conn)).thenReturn(ProtocolState.REQUEST_HEAD);
    when(TargetContext.getRequest(conn)).thenReturn(request);
    when(request.hasEntityBody()).thenReturn(true);
    when(request.write(conn, encoder)).thenReturn(12);
    when(encoder.isCompleted()).thenReturn(true);
    targetHandler.outputReady(conn, encoder);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) ContentEncoder(org.apache.http.nio.ContentEncoder) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) ClientConnFactory(org.apache.synapse.transport.http.conn.ClientConnFactory) MessageContext(org.apache.axis2.context.MessageContext) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ConfigurationContext (org.apache.axis2.context.ConfigurationContext)11 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)11 NativeWorkerPool (org.apache.axis2.transport.base.threads.NativeWorkerPool)11 WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)11 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 PassThroughTransportMetricsCollector (org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector)6 NHttpClientConnection (org.apache.http.nio.NHttpClientConnection)5 TargetConfiguration (org.apache.synapse.transport.passthru.config.TargetConfiguration)5 HttpResponse (org.apache.http.HttpResponse)3 Message (quickfix.Message)3 SessionID (quickfix.SessionID)3 BeginString (quickfix.field.BeginString)3 MsgSeqNum (quickfix.field.MsgSeqNum)3 MsgType (quickfix.field.MsgType)3 SenderCompID (quickfix.field.SenderCompID)3 TargetCompID (quickfix.field.TargetCompID)3 NewOrderSingle (quickfix.fix41.NewOrderSingle)3 MessageContext (org.apache.axis2.context.MessageContext)2 Parameter (org.apache.axis2.description.Parameter)2