use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method isProxiableCopiedPUA.
@Test
public void isProxiableCopiedPUA() throws Exception {
ProfileUpdateRequest pur = shClientFactory.createProfileUpdateRequest();
ProfileUpdateAnswer pua = shServerFactory.createProfileUpdateAnswer(pur);
assertEquals("The 'P' bit is not copied from request in Profile-Update-Answer, it should. [RFC3588/6.2]", pur.getHeader().isProxiable(), pua.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) pur).getGenericData().setProxiable(!pur.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in Profile-Update-Request, it should.", pur.getHeader().isProxiable() != pua.getHeader().isProxiable());
pua = shServerFactory.createProfileUpdateAnswer(pur);
assertEquals("The 'P' bit is not copied from request in Profile-Update-Answer, it should. [RFC3588/6.2]", pur.getHeader().isProxiable(), pua.getHeader().isProxiable());
}
use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.
the class ShServerActivityImpl method sendProfileUpdateAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.sh.server.ShServerActivity#sendProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)
*/
public void sendProfileUpdateAnswer(ProfileUpdateAnswer message) throws IOException {
try {
DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
fetchSessionData(msg, false);
this.serverSession.sendProfileUpdateAnswer(new ProfileUpdateAnswerImpl((Answer) msg.getGenericData()));
clean(msg);
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.
the class ShServerActivityImpl method createProfileUpdateAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.sh.server.ShServerActivity#createProfileUpdateAnswer()
*/
public ProfileUpdateAnswer createProfileUpdateAnswer() {
// Fetch the session stored request
ProfileUpdateRequest req = (ProfileUpdateRequest) getSessionMessage(ProfileUpdateRequest.commandCode);
ProfileUpdateAnswer answer = null;
if (req != null) {
// Create answer from it
answer = this.messageFactory.createProfileUpdateAnswer(req);
// Add any extra session data
addSessionData(answer);
// Store request data FIXME: Commented by Alex. Is this needed?
// ((DiameterShMessageImpl)answer).setData(req);
}
return answer;
}
use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.
the class ShServerSubscriptionActivityImpl method sendProfileUpdateAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.sh.server.ShServerSubscriptionActivity#sendProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)
*/
public void sendProfileUpdateAnswer(ProfileUpdateAnswer message) throws IOException {
try {
DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
fetchSessionData(msg, false);
this.serverSession.sendProfileUpdateAnswer(new ProfileUpdateAnswerImpl((Answer) msg.getGenericData()));
clean(msg);
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to send message.", e);
}
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method testMessageFactoryApplicationIdChangePUA.
@Test
public void testMessageFactoryApplicationIdChangePUA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((ShServerMessageFactoryImpl) shServerFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Sh is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
ProfileUpdateAnswer originalPUA = shServerFactory.createProfileUpdateAnswer(shClientFactory.createProfileUpdateRequest());
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPUA);
// now we switch..
originalPUA = null;
isVendor = !isVendor;
((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
ProfileUpdateAnswer changedPUA = shServerFactory.createProfileUpdateAnswer(shClientFactory.createProfileUpdateRequest());
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPUA);
// revert back to default
((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Aggregations