use of org.apache.http.impl.nio.DefaultNHttpServerConnection in project wso2-synapse by wso2.
the class PassThroughHttpSenderTest method testSubmitResponse.
/**
* This method tests the submitting of response when the source request is null
* @throws Exception
*/
@Test
public void testSubmitResponse() throws Exception {
MockitoAnnotations.initMocks(this);
MessageContext messageContext = new MessageContext();
messageContext.setProperty(Constants.Configuration.TRANSPORT_URL, "http://sample.url");
messageContext.setProperty(NhttpConstants.FORCE_HTTP_CONTENT_LENGTH, true);
messageContext.setProperty(PassThroughConstants.COPY_CONTENT_LENGTH_FROM_INCOMING, true);
messageContext.setProperty(PassThroughConstants.ORGINAL_CONTEN_LENGTH, "1000");
messageContext.setOperationContext(new OperationContext());
IOSession session = PowerMockito.mock(IOSession.class);
NHttpServerConnection conn = new DefaultNHttpServerConnection(session, 12);
messageContext.setProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONNECTION, conn);
messageContext.setProperty(PassThroughConstants.HTTP_ETAG_ENABLED, true);
Map headers = new HashMap();
headers.put("randomKey", "randomValue");
messageContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);
sender = PowerMockito.spy(sender);
PowerMockito.when(digestGenerator.getDigest(any(MessageContext.class))).thenReturn("testString");
sender.submitResponse(messageContext);
}
use of org.apache.http.impl.nio.DefaultNHttpServerConnection in project wso2-synapse by wso2.
the class ServerConnFactory method createConnection.
public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
SSLContextDetails customSSL = null;
if (sslByIPMap != null) {
customSSL = sslByIPMap.get(iosession.getLocalAddress());
if (customSSL == null && allNetworkAddress != null) {
customSSL = sslByIPMap.get(allNetworkAddress);
}
}
if (customSSL == null) {
customSSL = ssl;
}
IOSession customSession;
if (customSSL != null) {
customSession = new SSLIOSession(iosession, SSLMode.SERVER, customSSL.getContext(), customSSL.getHandler());
iosession.setAttribute(SSLIOSession.SESSION_KEY, customSession);
} else {
customSession = iosession;
}
DefaultNHttpServerConnection conn = LoggingUtils.createServerConnection(customSession, requestFactory, allocator, params);
int timeout = HttpConnectionParams.getSoTimeout(params);
conn.setSocketTimeout(timeout);
return conn;
}
Aggregations