use of com.helger.phase4.ScopedConfig in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA10.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). Simulate the RMSH to not send receipts
* (can be done by intercepting the receipts). SMSH tries to send an AS4 User
* Message to the RMSH.<br>
* <br>
* Predicate: <br>
* The SMSH retries to send the AS4 User Message (at least once).
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA10() throws Exception {
final int nProxyPort = 8001;
final IStringMap aSettings = new StringMap();
aSettings.putIn(SETTINGS_SERVER_PROXY_ENABLED, true);
aSettings.putIn(SETTINGS_SERVER_PROXY_ADDRESS, "localhost");
aSettings.putIn(SETTINGS_SERVER_PROXY_PORT, nProxyPort);
try (final ScopedConfig aSC = ScopedConfig.createTestConfig(aSettings)) {
final HttpProxyServer aProxyServer = _startProxyServer(nProxyPort);
try {
// send message
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr), null);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), false, EEbmsError.EBMS_OTHER.getErrorCode());
} finally {
aProxyServer.stop();
}
}
}
use of com.helger.phase4.ScopedConfig in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA11.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). Simulate the RMSH to not send receipts.
* SMSH tries to send an AS4 User Message to the RMSH. Before a TIME_OUT is
* reached network connection is restored (RMSH is able to send a
* non-repudiation receipt).<br>
* <br>
* Predicate: <br>
* The RMSH sends back an AS4 non-repudiation receipt to the SMSH and delivers
* only one message to the consumer and the SMSH stops resending the original
* AS4 User Message.
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA11() throws Exception {
final int nProxyPort = 8001;
final IStringMap aSettings = new StringMap();
aSettings.putIn(SETTINGS_SERVER_PROXY_ENABLED, true);
aSettings.putIn(SETTINGS_SERVER_PROXY_ADDRESS, "localhost");
aSettings.putIn(SETTINGS_SERVER_PROXY_PORT, nProxyPort);
try (final ScopedConfig aSC = ScopedConfig.createTestConfig(aSettings)) {
// Simulating a timeout with Thread.sleep but before it entirely triggers
// let the program continue as if the Connection is back up again
final HttpProxyServer aProxyServer = DefaultHttpProxyServer.bootstrap().withPort(nProxyPort).withFiltersSource(new HttpFiltersSourceAdapter() {
@Override
public HttpFilters filterRequest(final HttpRequest originalRequest, final ChannelHandlerContext ctx) {
return new HttpFiltersAdapter(originalRequest) {
@Override
public HttpResponse clientToProxyRequest(final HttpObject httpObject) {
ThreadHelper.sleep(500);
return null;
}
@Override
public HttpObject serverToProxyResponse(final HttpObject httpObject) {
LOGGER.error("Forcing a timeout from retryhandler ");
return httpObject;
}
};
}
}).start();
try {
// send message
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr), null);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
} finally {
aProxyServer.stop();
}
}
}
use of com.helger.phase4.ScopedConfig in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA17.
/**
* Prerequisite:<br>
* eSENS_TA10. TIME_OUT for resending the messages is reached.<br>
* <br>
* Predicate: <br>
* The SMSH reports an error to the message producer.
*
* @throws Exception
* In case of error
*/
@Test(expected = NoHttpResponseException.class)
public void testEsens_TA17() throws Exception {
final int nProxyPort = 8001;
final IStringMap aSettings = new StringMap();
aSettings.putIn(SETTINGS_SERVER_PROXY_ENABLED, true);
aSettings.putIn(SETTINGS_SERVER_PROXY_ADDRESS, "localhost");
aSettings.putIn(SETTINGS_SERVER_PROXY_PORT, nProxyPort);
try (final ScopedConfig aSC = ScopedConfig.createTestConfig(aSettings)) {
// Forcing a Timeout from the retry handler
final HttpProxyServer aProxyServer = DefaultHttpProxyServer.bootstrap().withPort(nProxyPort).withFiltersSource(new HttpFiltersSourceAdapter() {
@Override
public HttpFilters filterRequest(final HttpRequest originalRequest, final ChannelHandlerContext ctx) {
return new HttpFiltersAdapter(originalRequest) {
@Override
public HttpResponse clientToProxyRequest(final HttpObject httpObject) {
return null;
}
@Override
public HttpObject serverToProxyResponse(final HttpObject httpObject) {
LOGGER.warn("Forcing a timeout from retryhandler for testing purposes.");
return null;
}
};
}
}).start();
try {
// send message
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr), null);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), false, EEbmsError.EBMS_OTHER.getErrorCode());
} finally {
aProxyServer.stop();
}
}
}
Aggregations