use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-axis2-transports by wso2.
the class RabbitMQEndpoint method loadConfiguration.
@Override
public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
// We only support endpoints configured at service level
if (!(params instanceof AxisService)) {
return false;
}
AxisService service = (AxisService) params;
rabbitMQConnectionFactory = rabbitMQListener.getConnectionFactory(service);
if (rabbitMQConnectionFactory == null) {
return false;
}
serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(rabbitMQConnectionFactory, service, workerPool);
serviceTaskManager.setRabbitMQMessageReceiver(new RabbitMQMessageReceiver(rabbitMQListener, rabbitMQConnectionFactory, this));
return true;
}
use of org.apache.axis2.transport.base.threads.WorkerPool 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);
}
use of org.apache.axis2.transport.base.threads.WorkerPool 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!");
}
}
use of org.apache.axis2.transport.base.threads.WorkerPool 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!");
}
}
use of org.apache.axis2.transport.base.threads.WorkerPool 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);
}
Aggregations