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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations