use of net.java.slee.resource.diameter.s6a.events.NotifyAnswer in project jain-slee.diameter by RestComm.
the class S6aServerSessionImpl method createNotifyAnswer.
public NotifyAnswer createNotifyAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof NotifyRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
NotifyAnswer aia = (NotifyAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, NotifyAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(aia);
return aia;
} catch (InternalException e) {
logger.error("Failed to create Notify-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.s6a.events.NotifyAnswer in project jain-slee.diameter by RestComm.
the class S6aFactoriesTest method testServerSessionApplicationIdChangeNOA.
@Test
public void testServerSessionApplicationIdChangeNOA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((S6aMessageFactoryImpl) s6aMessageFactory).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 S6a is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
serverSession.fetchSessionData(nor);
NotifyAnswer originalNOA = serverSession.createNotifyAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalNOA);
// now we switch..
originalNOA = null;
isVendor = !isVendor;
((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
NotifyAnswer changedNOA = serverSession.createNotifyAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedNOA);
// revert back to default
((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of net.java.slee.resource.diameter.s6a.events.NotifyAnswer in project jain-slee.diameter by RestComm.
the class S6aFactoriesTest method hasTFlagSetNOA.
@Test
public void hasTFlagSetNOA() throws Exception {
NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
((DiameterMessageImpl) nor).getGenericData().setReTransmitted(true);
assertTrue("The 'T' flag should be set in Notify-Request", nor.getHeader().isPotentiallyRetransmitted());
serverSession.fetchSessionData(nor);
NotifyAnswer noa = serverSession.createNotifyAnswer();
assertFalse("The 'T' flag should not be set in Notify-Answer", noa.getHeader().isPotentiallyRetransmitted());
}
use of net.java.slee.resource.diameter.s6a.events.NotifyAnswer in project jain-slee.diameter by RestComm.
the class S6aFactoriesTest method hasDestinationHostNOA.
@Test
public void hasDestinationHostNOA() throws Exception {
NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
serverSession.fetchSessionData(nor);
NotifyAnswer noa = serverSession.createNotifyAnswer();
assertNull("The Destination-Host and Destination-Realm AVPs MUST NOT be present in the answer message. [RFC3588/6.2]", noa.getDestinationHost());
}
use of net.java.slee.resource.diameter.s6a.events.NotifyAnswer in project jain-slee.diameter by RestComm.
the class S6aFactoriesTest method isProxiableCopiedNOA.
@Test
public void isProxiableCopiedNOA() throws Exception {
NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
serverSession.fetchSessionData(nor);
NotifyAnswer noa = serverSession.createNotifyAnswer();
assertEquals("The 'P' bit is not copied from request in Location-Info-Answer, it should. [RFC3588/6.2]", nor.getHeader().isProxiable(), noa.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) nor).getGenericData().setProxiable(!nor.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in Notify-Request, it should.", nor.getHeader().isProxiable() != noa.getHeader().isProxiable());
serverSession.fetchSessionData(nor);
noa = serverSession.createNotifyAnswer();
assertEquals("The 'P' bit is not copied from request in Notify-Answer, it should. [RFC3588/6.2]", nor.getHeader().isProxiable(), noa.getHeader().isProxiable());
}
Aggregations