Skip to content

Commit

Permalink
Testsuite remaining classes. Fixed some issues in already commited (i…
Browse files Browse the repository at this point in the history
…ncluding code style consistency), added pending ones, and included SLh and SLg in SessionWithAppIdTest class. Issues #37 and #38. PR #48
  • Loading branch information
Fernando Mendioroz committed Oct 1, 2016
1 parent 8b23389 commit a81bfbf
Show file tree
Hide file tree
Showing 11 changed files with 1,489 additions and 610 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
import org.jdiameter.api.slg.ClientSLgSession;
import org.jdiameter.api.slg.ClientSLgSessionListener;
import org.jdiameter.api.slg.ServerSLgSession;
import org.jdiameter.api.slg.events.ProvideLocationAnswer;
import org.jdiameter.api.slg.events.ProvideLocationRequest;
import org.jdiameter.api.slg.events.ProvideLocationAnswer;
import org.jdiameter.api.slg.events.LocationReportRequest;
import org.jdiameter.api.slg.events.LocationReportAnswer;
import org.jdiameter.client.api.ISessionFactory;
import org.jdiameter.common.impl.app.slg.ProvideLocationAnswerImpl;
import org.jdiameter.common.impl.app.slg.LocationReportAnswerImpl;
Expand All @@ -74,181 +76,182 @@
*/
public abstract class AbstractServer extends TBase implements ServerSLgSessionListener {

// NOTE: implementing NetworkReqListener since its required for stack to
// know we support it... ech.

protected ServerSLgSession serverSLgSession;

public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255));
SLgSessionFactoryImpl slgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, slgSessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, slgSessionFactory);
slgSessionFactory.setServerSessionListener(this);
} finally {
try {
configStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// NOTE: implementing NetworkReqListener since its required for stack to
// know we support it... ech.

}
protected ServerSLgSession serverSLgSession;

// ----------- delegate methods so
public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255));
SLgSessionFactoryImpl slgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, slgSessionFactory);
((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, slgSessionFactory);
slgSessionFactory.setServerSessionListener(this);
} finally {
try {
configStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}

public void start() throws IllegalDiameterStateException, InternalException {
stack.start();
}
}

public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException {
stack.start(mode, timeOut, timeUnit);
}
// ----------- delegate methods so

public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException {
stack.stop(timeOut, timeUnit, disconnectCause);
}
public void start() throws IllegalDiameterStateException, InternalException {
stack.start();
}

public void stop(int disconnectCause) {
stack.stop(disconnectCause);
}
public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException {
stack.start(mode, timeOut, timeUnit);
}

public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, RouteException,
OverloadException {
fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null);
}
public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException {
stack.stop(timeOut, timeUnit, disconnectCause);
}

public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
fail("Received \"PLR\" event, request[" + request + "], on session[" + session + "]", null);
}
public void stop(int disconnectCause) {
stack.stop(disconnectCause);
}

public void doLocationReportRequestEvent(ServerSLgSession session, ProvideLocationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
fail("Received \"LRR\" event, request[" + request + "], on session[" + session + "]", null);
}
// -------- conf
public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, RouteException,
OverloadException {
fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null);
}

public String getSessionId() {
return this.serverSLgSession.getSessionId();
}
public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
fail("Received \"PLR\" event, request[" + request + "], on session[" + session + "]", null);
}

public void fetchSession(String sessionId) throws InternalException {
this.serverSLgSession = stack.getSession(sessionId, ServerSLgSession.class);
}
public void doLocationReportRequestEvent(ServerSLgSession session, ProvideLocationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
fail("Received \"LRR\" event, request[" + request + "], on session[" + session + "]", null);
}
// -------- conf

public ServerSLgSession getSession() {
return this.serverSLgSession;
}
public String getSessionId() {
return this.serverSLgSession.getSessionId();
}

public void fetchSession(String sessionId) throws InternalException {
this.serverSLgSession = stack.getSession(sessionId, ServerSLgSession.class);
}

public ServerSLgSession getSession() {
return this.serverSLgSession;
}

// protected abstract int TODO PENDING attributes
// protected abstract int TODO PENDING attributes

// ----------- helper
// ----------- helper

public ProvideLocationAnswer createPLA(ProvideLocationRequest plr, long resultCode) throws Exception {
public ProvideLocationAnswer createPLA(ProvideLocationRequest plr, long resultCode) throws Exception {
/*
< Provide-Location-Answer > ::= < Diameter Header: 8388620, PXY, 16777255 >
< Session-Id >
[ Vendor-Specific-Application-Id ]
[ Result-Code ]
[ Experimental-Result ]
{ Auth-Session-State }
{ Origin-Host }
{ Origin-Realm }
[ Location-Estimate ]
[ Accuracy-Fulfilment-Indicator ]
[ Age-Of-Location-Estimate]
[ Velocity-Estimate ]
[ EUTRAN-Positioning-Data]
[ ECGI ]
[ GERAN-Positioning-Info ]
[ Cell-Global-Identity ]
[ UTRAN-Positioning-Info ]
[ Service-Area-Identity ]
[ Serving-Node ]
[ PLA-Flags ]
[ ESMLC-Cell-Info ]
[ Civic-Address ]
[ Barometric-Pressure ]
*[ Supported-Features ]
*[ AVP ]
*[ Failed-AVP ]
*[ Proxy-Info ]
*[ Route-Record ]
*/
ProvideLocationAnswer pla = new ProvideLocationAnswerImpl((Request) plr.getMessage(), resultCode);

AvpSet reqSet = plr.getMessage().getAvps();
AvpSet set = pla.getMessage().getAvps();
set.removeAvp(Avp.DESTINATION_HOST);
set.removeAvp(Avp.DESTINATION_REALM);
set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID));

// { Vendor-Specific-Application-Id }
if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {
AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false);
// 1* [ Vendor-Id ]
vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true);
// 0*1{ Auth-Application-Id }
vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true);
}
// [ Result-Code ]
// [ Experimental-Result ]
// { Auth-Session-State }
if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) {
set.addAvp(Avp.AUTH_SESSION_STATE, 1);
}

// TODO - PENDING
return pla;
< Session-Id >
[ Vendor-Specific-Application-Id ]
[ Result-Code ]
[ Experimental-Result ]
{ Auth-Session-State }
{ Origin-Host }
{ Origin-Realm }
[ Location-Estimate ]
[ Accuracy-Fulfilment-Indicator ]
[ Age-Of-Location-Estimate]
[ Velocity-Estimate ]
[ EUTRAN-Positioning-Data]
[ ECGI ]
[ GERAN-Positioning-Info ]
[ Cell-Global-Identity ]
[ UTRAN-Positioning-Info ]
[ Service-Area-Identity ]
[ Serving-Node ]
[ PLA-Flags ]
[ ESMLC-Cell-Info ]
[ Civic-Address ]
[ Barometric-Pressure ]
*[ Supported-Features ]
*[ AVP ]
*[ Failed-AVP ]
*[ Proxy-Info ]
*[ Route-Record ]
*/
ProvideLocationAnswer pla = new ProvideLocationAnswerImpl((Request) plr.getMessage(), resultCode);

AvpSet reqSet = plr.getMessage().getAvps();
AvpSet set = pla.getMessage().getAvps();
set.removeAvp(Avp.DESTINATION_HOST);
set.removeAvp(Avp.DESTINATION_REALM);
set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID));

// { Vendor-Specific-Application-Id }
if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {
AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false);
// 1* [ Vendor-Id ]
vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true);
// 0*1{ Auth-Application-Id }
vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true);
}
// [ Result-Code ]
// [ Experimental-Result ]
// { Auth-Session-State }
if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) {
set.addAvp(Avp.AUTH_SESSION_STATE, 1);
}

// TODO - PENDING
return pla;
}


public LocationReportAnswer createLRA(LocationReportRequest lrr, long resultCode) throws Exception {
/*
< Location-Report-Answer > ::= < Diameter Header: 8388621, PXY, 16777255>
< Session-Id >
[ Vendor-Specific-Application-Id ]
[ Result-Code ]
[ Experimental-Result ]
{ Auth-Session-State }
{ Origin-Host }
{ Origin-Realm }
[ GMLC-Address ]
[ LRA-Flags ]
[ Reporting-PLMN-List ]
[ LCS-Reference-Number ]
*[ Supported-Features ]
*[ AVP ]
*[ Failed-AVP ]
*[ Proxy-Info ]
*[ Route-Record ]
*/
ProvideLocationAnswer lra = new ProvideLocationAnswerImpl((Request) lrr.getMessage(), resultCode);

AvpSet reqSet = lrr.getMessage().getAvps();
AvpSet set = lra.getMessage().getAvps();
set.removeAvp(Avp.DESTINATION_HOST);
set.removeAvp(Avp.DESTINATION_REALM);
set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID));

// { Vendor-Specific-Application-Id }
if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {
AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false);
// 1* [ Vendor-Id ]
vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true);
// 0*1{ Auth-Application-Id }
vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true);
}
// [ Result-Code ]
// [ Experimental-Result ]
// { Auth-Session-State }
if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) {
set.addAvp(Avp.AUTH_SESSION_STATE, 1);
}

// TODO - PENDING
return lra;
}
}

public LocationReportAnswer createLRA(LocationReportRequest lrr, long resultCode) throws Exception {
/*
< Location-Report-Answer > ::= < Diameter Header: 8388621, PXY, 16777255>
< Session-Id >
[ Vendor-Specific-Application-Id ]
[ Result-Code ]
[ Experimental-Result ]
{ Auth-Session-State }
{ Origin-Host }
{ Origin-Realm }
[ GMLC-Address ]
[ LRA-Flags ]
[ Reporting-PLMN-List ]
[ LCS-Reference-Number ]
*[ Supported-Features ]
*[ AVP ]
*[ Failed-AVP ]
*[ Proxy-Info ]
*[ Route-Record ]
*/
ProvideLocationAnswer lra = new ProvideLocationAnswerImpl((Request) lrr.getMessage(), resultCode);

AvpSet reqSet = lrr.getMessage().getAvps();
AvpSet set = lra.getMessage().getAvps();
set.removeAvp(Avp.DESTINATION_HOST);
set.removeAvp(Avp.DESTINATION_REALM);
set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID));

// { Vendor-Specific-Application-Id }
if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {
AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false);
// 1* [ Vendor-Id ]
vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true);
// 0*1{ Auth-Application-Id }
vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true);
}
// [ Result-Code ]
// [ Experimental-Result ]
// { Auth-Session-State }
if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) {
set.addAvp(Avp.AUTH_SESSION_STATE, 1);
}

// TODO - PENDING
return lra;
}
}
Loading

0 comments on commit a81bfbf

Please sign in to comment.