Search in sources :

Example 6 with NativeWorkerPool

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);
}
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 7 with NativeWorkerPool

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

Example 8 with NativeWorkerPool

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);
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with NativeWorkerPool

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);
}
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) AxisService(org.apache.axis2.description.AxisService) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) Parameter(org.apache.axis2.description.Parameter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with NativeWorkerPool

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);
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) Parameter(org.apache.axis2.description.Parameter) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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