use of org.apache.axis2.transport.base.threads.NativeWorkerPool 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.NativeWorkerPool 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();
}
use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.
the class FIXIncomingMessageHandlerTest method testFromAdmin.
@Test
public void testFromAdmin() throws Exception {
SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
Message message = new NewOrderSingle();
message.getHeader().setField(new BeginString("FIX.4.1"));
message.getHeader().setField(new SenderCompID("SYNAPSE"));
message.getHeader().setField(new TargetCompID("BANZAI"));
message.getHeader().setField(new MsgSeqNum(1));
message.getHeader().setField(new MsgType("A"));
ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
handler.fromAdmin(message, id);
}
use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.
the class FIXIncomingMessageHandlerTest method testInitialization.
@Test
public void testInitialization() throws Exception {
AxisService axisService = new AxisService("testFIXService");
axisService.addParameter(new Parameter(FIXConstants.FIX_ACCEPTOR_EVENT_HANDLER, "randomClass"));
ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, axisService, true);
Assert.assertNotNull("FIXIncomingMessageHandler not initialized!", handler);
}
use of org.apache.axis2.transport.base.threads.NativeWorkerPool in project wso2-synapse by wso2.
the class FIXIncomingMessageHandlerTest method testToAdmin.
@Test
public void testToAdmin() throws Exception {
initMocks(this);
SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
Message message = new NewOrderSingle();
message.getHeader().setField(new BeginString("FIX.4.1"));
message.getHeader().setField(new SenderCompID("SYNAPSE"));
message.getHeader().setField(new TargetCompID("BANZAI"));
message.getHeader().setField(new MsgSeqNum(1));
message.getHeader().setField(new MsgType("A"));
PowerMockito.when(service.getParameter(FIXConstants.FIX_USERNAME)).thenReturn(new Parameter(FIXConstants.FIX_USERNAME, "wos2"));
PowerMockito.when(service.getParameter(FIXConstants.FIX_PASSWORD)).thenReturn(new Parameter(FIXConstants.FIX_PASSWORD, "wos2"));
ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
handler.toAdmin(message, id);
}
Aggregations