Search in sources :

Example 11 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool 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)

Example 12 with WorkerPool

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

the class TargetHandlerTest method testInputReady.

/**
 * Testing whether input-ready connection is processed
 *
 * @throws Exception
 */
@Test
public void testInputReady() 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);
    TargetResponse response = mock(TargetResponse.class);
    NHttpClientConnection conn = mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    ContentDecoder decoder = mock(ContentDecoder.class);
    mockStatic(TargetContext.class);
    when(TargetContext.get(conn)).thenReturn(targetContext);
    when(TargetContext.getState(conn)).thenReturn(ProtocolState.RESPONSE_HEAD);
    when(TargetContext.getResponse(conn)).thenReturn(response);
    when(decoder.isCompleted()).thenReturn(true);
    targetHandler.inputReady(conn, decoder);
}
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) 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)

Example 13 with WorkerPool

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

the class BaseConfigurationTest method testDefaultWorkerPool.

@Test
public void testDefaultWorkerPool() throws Exception {
    WorkerPool workerPool = baseConfiguration.getWorkerPool(0, 0, 0, 0, null, null);
    Assert.assertNotNull("Worker pool hasn't been initialized.", workerPool);
}
Also used : WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) Test(org.junit.Test)

Example 14 with WorkerPool

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

the class SourceConfigurationTest method testSourceConfiguration.

@Test
public void testSourceConfiguration() throws Exception {
    WorkerPool workerPool = PassThroughTestUtils.getWorkerPool(passThroughConfiguration);
    SourceConfiguration sourceConfiguration = new SourceConfiguration(workerPool, metrics);
    Assert.assertNotNull("SourceConfiguration is null", sourceConfiguration);
}
Also used : WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) Test(org.junit.Test)

Example 15 with WorkerPool

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

the class TargetConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    configurationContext.setProperty(PASS_THROUGH_TRANSPORT_WORKER_POOL, workerPool);
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    targetConfiguration.build();
}
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) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) Before(org.junit.Before)

Aggregations

WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)15 Test (org.junit.Test)12 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)11 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)11 NativeWorkerPool (org.apache.axis2.transport.base.threads.NativeWorkerPool)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 PassThroughTransportMetricsCollector (org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector)8 TargetConfiguration (org.apache.synapse.transport.passthru.config.TargetConfiguration)6 AxisService (org.apache.axis2.description.AxisService)5 Parameter (org.apache.axis2.description.Parameter)5 NHttpClientConnection (org.apache.http.nio.NHttpClientConnection)5 HttpResponse (org.apache.http.HttpResponse)3 TargetConnections (org.apache.synapse.transport.passthru.connections.TargetConnections)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