diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySession.java
new file mode 100644
index 000000000..8fd20039b
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySession.java
@@ -0,0 +1,52 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy;
+
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+import org.jdiameter.api.app.AppSession;
+import org.jdiameter.api.app.StateMachine;
+
+import org.jdiameter.api.auth.events.SessionTermRequest;
+
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+
+/**
+ * Basic class for Sy Client Interface specific session.
+ * Listener must be injected from constructor of implementation class.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ClientSySession extends AppSession, StateMachine {
+
+ void sendSpendingLimitRequest(SpendingLimitRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void sendSessionTerminationRequest(SessionTermRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void sendSpendingStatusNotificationAnswer(SpendingStatusNotificationAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySessionListener.java
new file mode 100644
index 000000000..dd76f46e2
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ClientSySessionListener.java
@@ -0,0 +1,52 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy;
+
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+
+/**
+ * This interface defines the possible actions for the different states in the client
+ * Sy Interface state machine.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ClientSySessionListener {
+
+ void doSpendingLimitAnswer(ClientSySession session, SpendingLimitRequest request, SpendingLimitAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void doSessionTerminationAnswer(ClientSySession session, SessionTermRequest request, SessionTermAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void doSpendingStatusNotificationRequest(ClientSySession session, SpendingStatusNotificationRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+}
\ No newline at end of file
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySession.java
new file mode 100644
index 000000000..c2f2f44f1
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySession.java
@@ -0,0 +1,52 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy;
+
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+import org.jdiameter.api.app.AppSession;
+import org.jdiameter.api.app.StateMachine;
+
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+
+/**
+ * Basic class for Sy Server Interface specific session.
+ * Listener must be injected from constructor of implementation class
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ServerSySession extends AppSession, StateMachine {
+
+ void sendSpendingLimitAnswer(SpendingLimitAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void sendSessionTerminationAnswer(SessionTermAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void sendSpendingStatusNotificationRequest(SpendingStatusNotificationRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySessionListener.java
new file mode 100644
index 000000000..1386b9a9f
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/ServerSySessionListener.java
@@ -0,0 +1,51 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy;
+
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+
+import org.jdiameter.api.auth.events.SessionTermRequest;
+
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+
+/**
+ * This interface defines the possible actions for th;e different states in the server Sy
+ * Interface state machine.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ServerSySessionListener {
+
+ void doSpendingLimitRequest(ServerSySession session, SpendingLimitRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void doSessionTerminationRequest(ServerSySession session, SessionTermRequest request)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+ void doSpendingStatusNotificationAnswer(ServerSySession session, SpendingStatusNotificationRequest request, SpendingStatusNotificationAnswer answer)
+ throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
+
+}
\ No newline at end of file
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/SySession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/SySession.java
new file mode 100644
index 000000000..09c1b8948
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/SySession.java
@@ -0,0 +1,33 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy;
+
+/**
+ * This interface defines the Sy Session marker class
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+import org.jdiameter.api.app.AppSession;
+import org.jdiameter.api.app.StateMachine;
+
+public interface SySession extends AppSession, StateMachine {
+ // simple marker interface.
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitAnswer.java
new file mode 100644
index 000000000..fc398ab1d
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitAnswer.java
@@ -0,0 +1,38 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy.events;
+
+import org.jdiameter.api.app.AppAnswerEvent;
+
+/**
+ * The Spending-Limit-Answer (SLA) message, indicated by the Command-Code field set to 8388635 is sent
+ * by the OCS to the PCRF as a response to SLR message.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface SpendingLimitAnswer extends AppAnswerEvent {
+
+ String _SHORT_NAME = "SLA";
+ String _LONG_NAME = "Spending-Limit-Answer";
+
+ int code = 8388635;
+
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitRequest.java
new file mode 100644
index 000000000..8b934b927
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingLimitRequest.java
@@ -0,0 +1,40 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy.events;
+
+import org.jdiameter.api.app.AppRequestEvent;
+
+/**
+ * The Spending-Limit-Request (SLR) message, indicated by the Command-Code field set to 8388635 is sent
+ * by the PCRF ot the OCS to retrieve subscription information that indicates that policy decision depends
+ * on policy counters held on the OCS.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface SpendingLimitRequest extends AppRequestEvent {
+
+ String _SHORT_NAME = "SLR";
+ String _LONG_NAME = "Spending-Limit-Request";
+
+ int code = 8388635;
+
+ int getSLRequestType();
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationAnswer.java
new file mode 100644
index 000000000..32c6c7ea9
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationAnswer.java
@@ -0,0 +1,38 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy.events;
+
+import org.jdiameter.api.app.AppAnswerEvent;
+
+/**
+ * The Spending-Notification-Answer (SNA) message, indicated by the Command-Code field set to 8388636 is sent
+ * by the PCRF to the OCS in reply to the SNR message.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface SpendingStatusNotificationAnswer extends AppAnswerEvent {
+
+ String _SHORT_NAME = "SNA";
+ String _LONG_NAME = "Spending-Status-Notification-Answer";
+
+ int code = 8388636;
+
+}
diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationRequest.java
new file mode 100644
index 000000000..28eea0f91
--- /dev/null
+++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/sy/events/SpendingStatusNotificationRequest.java
@@ -0,0 +1,39 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.api.sy.events;
+
+import org.jdiameter.api.app.AppAnswerEvent;
+import org.jdiameter.api.app.AppRequestEvent;
+
+/**
+ * The Spending-Notification-Request (SNR) message, indicated by the Command-Code field set to 8388636 is sent
+ * by the OCS to the PCRF when the OCS detects that status of a policy counter identifier(s) had changed.
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface SpendingStatusNotificationRequest extends AppRequestEvent {
+
+ String _SHORT_NAME = "SNR";
+ String _LONG_NAME = "Spending-Status-Notification-Request";
+
+ int code = 8388636;
+
+}
diff --git a/core/jdiameter/impl/pom.xml b/core/jdiameter/impl/pom.xml
index d804db3e4..5b646d76c 100644
--- a/core/jdiameter/impl/pom.xml
+++ b/core/jdiameter/impl/pom.xml
@@ -67,6 +67,16 @@
true
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/ISessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/ISessionFactory.java
index 5be96d93d..3df119927 100644
--- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/ISessionFactory.java
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/ISessionFactory.java
@@ -79,14 +79,14 @@ T getNewAppSession(String sessionId, ApplicationId applic
* @param sessionClass the class of the objects being generated by the factory
* @param factory the factory to generate app sessions
*/
- void registerAppFacory(Class extends AppSession> sessionClass, IAppSessionFactory factory);
+ void registerAppFactory(Class extends AppSession> sessionClass, IAppSessionFactory factory);
/**
* Unregisters an existing App Session factory.
*
* @param sessionClass the class identifier for this factory
*/
- void unRegisterAppFacory(Class extends AppSession> sessionClass);
+ void unRegisterAppFactory(Class extends AppSession> sessionClass);
/**
* Retrieves the app session factory associated with an app session class
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionFactoryImpl.java
index 12b4e4c1a..037b02d67 100644
--- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionFactoryImpl.java
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionFactoryImpl.java
@@ -162,12 +162,12 @@ public T getNewAppSession(String sessionId, ApplicationId
}
@Override
- public void registerAppFacory(Class extends AppSession> sessionClass, IAppSessionFactory factory) {
+ public void registerAppFactory(Class extends AppSession> sessionClass, IAppSessionFactory factory) {
appFactories.put(sessionClass, factory);
}
@Override
- public void unRegisterAppFacory(Class extends AppSession> sessionClass) {
+ public void unRegisterAppFactory(Class extends AppSession> sessionClass) {
appFactories.remove(sessionClass);
}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ClientSySessionState.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ClientSySessionState.java
new file mode 100644
index 000000000..fe9a5baba
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ClientSySessionState.java
@@ -0,0 +1,57 @@
+/*
+* TeleStax, Open Source Cloud Communications
+* Copyright 2011-2016, Telestax Inc and individual contributors
+* by the @authors tag.
+*
+* This program is free software: you can redistribute it and/or modify
+* under the terms of the GNU Affero General Public License as
+* published by the Free Software Foundation; either version 3 of
+* the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see
+*/
+
+package org.jdiameter.common.api.app.sy;
+
+import org.jdiameter.common.api.app.IAppSessionState;
+
+/**
+* Policy and charging control - Sy session implementation
+*
+* @author Alejandro Ferreira Guido
+*/
+
+public enum ClientSySessionState implements IAppSessionState {
+
+ IDLE(0),
+ OPEN(1);
+
+ private int stateValue = -1;
+
+ ClientSySessionState(int stateV) {
+ this.stateValue = stateV;
+ }
+
+ @Override
+ public ClientSySessionState fromInt(int v) throws IllegalArgumentException {
+ switch (v) {
+ case 0:
+ return IDLE;
+ case 1:
+ return OPEN;
+ default:
+ throw new IllegalArgumentException("Illegal value of int representation!!!!");
+ }
+ }
+
+ @Override
+ public int getValue() {
+ return stateValue;
+ }
+ }
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISyMessageFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISyMessageFactory.java
new file mode 100644
index 000000000..5fda682ff
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISyMessageFactory.java
@@ -0,0 +1,41 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.api.app.sy;
+
+import org.jdiameter.api.Request;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ISyMessageFactory {
+
+ SpendingLimitRequest createSpendingLimitRequest(Request request);
+
+ SessionTermRequest createSessionTerminationRequest(Request request);
+
+ SpendingStatusNotificationRequest createSpendingStatusNotificationRequest(Request request);
+
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionData.java
new file mode 100644
index 000000000..6a5d4b072
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionData.java
@@ -0,0 +1,29 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.api.app.sy;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ISySessionData {
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionFactory.java
new file mode 100644
index 000000000..bf30bbc07
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ISySessionFactory.java
@@ -0,0 +1,31 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.api.app.sy;
+
+import org.jdiameter.common.api.app.IAppSessionFactory;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface ISySessionFactory extends IAppSessionFactory {
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ServerSySessionState.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ServerSySessionState.java
new file mode 100644
index 000000000..63bc5af4f
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/sy/ServerSySessionState.java
@@ -0,0 +1,60 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.api.app.sy;
+
+import org.jdiameter.common.api.app.IAppSessionState;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+ public enum ServerSySessionState implements IAppSessionState {
+
+ IDLE(0),
+ OPEN(1);
+
+ private int stateRepresentation = -1;
+
+ ServerSySessionState(int v) {
+ this.stateRepresentation = v;
+ }
+
+ @Override
+ public ServerSySessionState fromInt(int v) throws IllegalArgumentException {
+ switch (v) {
+ case 0:
+ return IDLE;
+
+ case 1:
+ return OPEN;
+
+ default:
+ throw new IllegalArgumentException("Illegal value of int representation!!!!");
+ }
+ }
+
+ @Override
+ public int getValue() {
+ return stateRepresentation;
+ }
+
+ }
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/cca/CCASessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/cca/CCASessionFactoryImpl.java
index d8bf0d2f7..a8b1eeffb 100644
--- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/cca/CCASessionFactoryImpl.java
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/cca/CCASessionFactoryImpl.java
@@ -94,7 +94,7 @@ public CCASessionFactoryImpl(SessionFactory sessionFactory) {
}
/**
- * @param sessionFactory2
+ * @param sessionFactory
*/
public void init(SessionFactory sessionFactory) {
this.sessionFactory = (ISessionFactory) sessionFactory;
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/AppSySessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/AppSySessionImpl.java
new file mode 100644
index 000000000..3b800e021
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/AppSySessionImpl.java
@@ -0,0 +1,67 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.NetworkReqListener;
+import org.jdiameter.api.app.StateChangeListener;
+import org.jdiameter.api.sy.SySession;
+import org.jdiameter.client.api.ISessionFactory;
+import org.jdiameter.common.api.app.IAppSessionData;
+import org.jdiameter.common.impl.app.AppSessionImpl;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public abstract class AppSySessionImpl extends AppSessionImpl implements SySession, NetworkReqListener {
+
+ protected Lock sendAndStateLock = new ReentrantLock();
+
+ protected List stateListeners = new CopyOnWriteArrayList();
+
+ public AppSySessionImpl(ISessionFactory sf, IAppSessionData appSessionData) {
+ super(sf, appSessionData);
+ }
+
+ @Override
+ public void addStateChangeNotification(StateChangeListener listener) {
+ if (!stateListeners.contains(listener)) {
+ stateListeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeStateChangeNotification(StateChangeListener listener) {
+ stateListeners.remove(listener);
+ }
+
+ @Override
+ public void release() {
+ //stateListeners.clear();
+ super.release();
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitAnswerImpl.java
new file mode 100644
index 000000000..196525664
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitAnswerImpl.java
@@ -0,0 +1,37 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.Request;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.common.impl.app.AppAnswerEventImpl;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class SpendingLimitAnswerImpl extends AppAnswerEventImpl implements SpendingLimitAnswer {
+
+ public SpendingLimitAnswerImpl(Request request, long resultCode) {
+ super(request, resultCode);
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitRequestImpl.java
new file mode 100644
index 000000000..f4fceda4d
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingLimitRequestImpl.java
@@ -0,0 +1,42 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.Message;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.common.impl.app.AppRequestEventImpl;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class SpendingLimitRequestImpl extends AppRequestEventImpl implements SpendingLimitRequest {
+
+ public SpendingLimitRequestImpl(Message message) {
+ super(message);
+ }
+
+ @Override
+ public int getSLRequestTypeAVPValue() {
+ return 0;
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationAnswerImpl.java
new file mode 100644
index 000000000..285b1969b
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationAnswerImpl.java
@@ -0,0 +1,37 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.Request;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.common.impl.app.AppAnswerEventImpl;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class SpendingStatusNotificationAnswerImpl extends AppAnswerEventImpl implements SpendingStatusNotificationAnswer {
+
+ public SpendingStatusNotificationAnswerImpl(Request request, long resultCode) {
+ super(request, resultCode);
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationRequestImpl.java
new file mode 100644
index 000000000..cb985c808
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SpendingStatusNotificationRequestImpl.java
@@ -0,0 +1,37 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.Message;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+import org.jdiameter.common.impl.app.AppRequestEventImpl;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class SpendingStatusNotificationRequestImpl extends AppRequestEventImpl implements SpendingStatusNotificationRequest {
+
+ public SpendingStatusNotificationRequestImpl(Message message) {
+ super(message);
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SySessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SySessionFactoryImpl.java
new file mode 100644
index 000000000..3d1cd7d97
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/sy/SySessionFactoryImpl.java
@@ -0,0 +1,121 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.common.impl.app.sy;
+
+import org.jdiameter.api.ApplicationId;
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.Request;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+import org.jdiameter.api.app.AppSession;
+import org.jdiameter.api.app.StateChangeListener;
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.ClientSySession;
+import org.jdiameter.api.sy.ClientSySessionListener;
+import org.jdiameter.api.sy.ServerSySession;
+import org.jdiameter.api.sy.ServerSySessionListener;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+import org.jdiameter.client.api.ISessionFactory;
+import org.jdiameter.common.api.app.sy.ISyMessageFactory;
+import org.jdiameter.common.api.app.sy.ISySessionFactory;
+
+/**
+ * Policy and charging control - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class SySessionFactoryImpl implements ISySessionFactory, ClientSySessionListener, ServerSySessionListener, StateChangeListener,
+ ISyMessageFactory {
+
+ public SySessionFactoryImpl(ISessionFactory sessionFactory) {
+
+ }
+
+ @Override
+ public SpendingLimitRequest createSpendingLimitRequest(Request request) {
+ return null;
+ }
+
+ @Override
+ public SessionTermRequest createSessionTerminationRequest(Request request) {
+ return null;
+ }
+
+ @Override
+ public SpendingStatusNotificationRequest createSpendingStatusNotificationRequest(Request request) {
+ return null;
+ }
+
+ @Override
+ public void doSpendingLimitRequest(ServerSySession session, SpendingLimitRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doFinalSpendingLimitRequest(ServerSySession session, SessionTermRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doSpendingStatusNotificationAnswer(ServerSySession session, SpendingStatusNotificationRequest request, SpendingStatusNotificationAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doSpendingLimitAnswer(ClientSySession session, SpendingLimitRequest request, SpendingLimitAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doFinalSpendingLimitAnswer(ClientSySession session, SessionTermRequest request, SessionTermAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doSpendingStatusNotificationRequest(ClientSySession session, SpendingStatusNotificationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public AppSession getNewSession(String sessionId, Class extends AppSession> aClass, ApplicationId applicationId, Object[] args) {
+ return null;
+ }
+
+ @Override
+ public AppSession getSession(String sessionId, Class extends AppSession> aClass) {
+ return null;
+ }
+
+ @Override
+ public void stateChanged(Enum oldState, Enum newState) {
+
+ }
+
+ @Override
+ public void stateChanged(AppSession source, Enum oldState, Enum newState) {
+
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
index 1dd02f414..8333fd912 100644
--- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
@@ -298,7 +298,7 @@ protected void parseTypeDefs(Document doc) {
}
/**
- * Parses the attributes from a Dictionary XML Document
+ * Parses the attributes from a Dictionary XML Document
*
* @param doc the DOM object representing the XML Document with the Dictionary definitions
*/
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/Event.java
index 4bcb55bd3..c9bc87d95 100644
--- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/Event.java
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/Event.java
@@ -67,7 +67,7 @@ public enum Type {
SENT_TERMINATE_RESPONSE,
// These have no transition, no state resources, timers
SENT_RAR,
- RECEIVED_RAA;
+ RECEIVED_RAA
}
Type type;
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/Event.java
new file mode 100644
index 000000000..90d7b7e0b
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/Event.java
@@ -0,0 +1,136 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.server.impl.sy;
+
+import org.jdiameter.api.app.AppAnswerEvent;
+import org.jdiameter.api.app.AppEvent;
+import org.jdiameter.api.app.AppRequestEvent;
+import org.jdiameter.api.app.StateEvent;
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class Event implements StateEvent {
+
+ public enum Type {
+ RECEIVED_INITIAL,
+ SENT_INITIAL_RESPONSE,
+ RECEIVED_INTERMEDIATE,
+ SENT_INTERMEDIATE_RESPONSE,
+ RECEIVED_TERMINATION,
+ SENT_TERMINATION_RESPONSE,
+ RECEIVED_STATUS_NOTIFICATION,
+ SENT_STATUS_NOTIFICATION_RESPONSE
+ }
+
+ Type type;
+
+ AppRequestEvent request;
+ AppAnswerEvent answer;
+
+ public Event(boolean isRequest, SessionTermRequest request, SessionTermAnswer answer) {
+
+ this.request = request;
+ this.answer = answer;
+
+ if (isRequest) {
+ type = Type.RECEIVED_TERMINATION;
+ } else {
+ type = Type.SENT_TERMINATION_RESPONSE;
+ }
+ }
+
+ public Event(boolean isRequest, SpendingLimitRequest request, SpendingLimitAnswer answer) {
+
+ this.request = request;
+ this.answer = answer;
+
+ int slRequestTypeAvpValue = request.getSLRequestType();
+ if (isRequest) {
+ switch (slRequestTypeAvpValue) {
+ case 0:
+ type = Type.RECEIVED_INITIAL;
+ break;
+ case 1:
+ type = Type.RECEIVED_INTERMEDIATE;
+ break;
+ }
+ } else {
+ switch (slRequestTypeAvpValue) {
+ case 0:
+ type = Type.SENT_INITIAL_RESPONSE;
+ break;
+ case 1:
+ type = Type.SENT_INTERMEDIATE_RESPONSE;
+ break;
+ }
+ }
+ }
+
+ public Event(boolean isRequest, SpendingStatusNotificationRequest request, SpendingStatusNotificationAnswer answer) {
+
+ this.request = request;
+ this.answer = answer;
+
+ if (isRequest) {
+ type = Type.RECEIVED_STATUS_NOTIFICATION;
+ } else {
+ type = Type.SENT_STATUS_NOTIFICATION_RESPONSE;
+ }
+ }
+
+ @Override
+ public E encodeType(Class enumType) {
+ return null;
+ }
+
+ @Override
+ public Enum getType() {
+ return null;
+ }
+
+ @Override
+ public void setData(Object data) {
+
+ }
+
+ @Override
+ public Object getData() {
+ return null;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return 0;
+ }
+
+ public AppEvent getRequest() {
+ return request;
+ }
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/IServerSySessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/IServerSySessionData.java
new file mode 100644
index 000000000..1cb7fd27b
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/IServerSySessionData.java
@@ -0,0 +1,36 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.server.impl.sy;
+
+import org.jdiameter.common.api.app.sy.ISySessionData;
+import org.jdiameter.common.api.app.sy.ServerSySessionState;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public interface IServerSySessionData extends ISySessionData {
+
+ ServerSySessionState getServerSySessionState();
+
+ void setServerSySessionState(ServerSySessionState newState);
+}
diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/ServerSySessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/ServerSySessionImpl.java
new file mode 100644
index 000000000..2eb33d11b
--- /dev/null
+++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/sy/ServerSySessionImpl.java
@@ -0,0 +1,306 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.jdiameter.server.impl.sy;
+
+import org.jdiameter.api.ApplicationId;
+import org.jdiameter.api.Session;
+import org.jdiameter.api.Request;
+import org.jdiameter.api.Answer;
+import org.jdiameter.api.NetworkReqListener;
+import org.jdiameter.api.EventListener;
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.OverloadException;
+import org.jdiameter.api.RouteException;
+import org.jdiameter.api.app.AppEvent;
+import org.jdiameter.api.app.StateChangeListener;
+import org.jdiameter.api.app.StateEvent;
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.ServerSySession;
+import org.jdiameter.api.sy.ServerSySessionListener;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+import org.jdiameter.client.api.ISessionFactory;
+import org.jdiameter.common.api.app.IAppSessionData;
+import org.jdiameter.common.api.app.IAppSessionState;
+import org.jdiameter.common.api.app.sy.ISyMessageFactory;
+import org.jdiameter.common.api.app.sy.ServerSySessionState;
+import org.jdiameter.common.impl.app.sy.AppSySessionImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy session implementation
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class ServerSySessionImpl extends AppSySessionImpl implements ServerSySession, NetworkReqListener, EventListener {
+
+ private static final Logger logger = LoggerFactory.getLogger(ServerSySessionImpl.class);
+
+ protected IServerSySessionData sessionData;
+ // Session State Handling ---------------------------------------------------
+ protected Lock sendAndStateLock = new ReentrantLock();
+
+ protected transient ISyMessageFactory factory = null;
+ protected transient ServerSySessionListener listener = null;
+
+ public ServerSySessionImpl(IServerSySessionData data, ISessionFactory sf, ServerSySessionListener lst, IAppSessionData appSessionData) {
+ super(sf, appSessionData);
+
+ this.sessionData = data;
+ this.listener = lst;
+ }
+
+ @Override
+ public Answer processRequest(Request request) {
+ RequestDelivery rd = new RequestDelivery();
+ rd.session = this;
+ rd.request = request;
+ super.scheduler.execute(rd);
+ return null;
+ }
+
+ @Override
+ public void sendSpendingLimitAnswer(SpendingLimitAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ handleEvent(new Event(false, null, answer));
+ }
+
+ @Override
+ public void sendSessionTerminationAnswer(SessionTermAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ handleEvent(new Event(false, null, answer));
+ }
+
+ @Override
+ public void sendSpendingStatusNotificationRequest(SpendingStatusNotificationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ handleEvent(new Event(true, request, null));
+ }
+
+ @Override
+ public void receivedSuccessMessage(Request request, Answer answer) {
+ AnswerDelivery ad = new AnswerDelivery();
+ ad.session = this;
+ ad.request = request;
+ ad.answer = answer;
+ super.scheduler.execute(ad);
+ }
+
+ @Override
+ public void timeoutExpired(Request request) {
+
+ }
+
+ @Override
+ public boolean isStateless() {
+ return false;
+ }
+
+ @Override
+ public ApplicationId getSessionAppId() {
+ return null;
+ }
+
+ @Override
+ public List getSessions() {
+ return null;
+ }
+
+ @Override
+ public void addStateChangeNotification(StateChangeListener listener) {
+
+ }
+
+ @Override
+ public void removeStateChangeNotification(StateChangeListener listener) {
+
+ }
+
+ @Override
+ public boolean handleEvent(StateEvent event) throws InternalException, OverloadException {
+ ServerSySessionState newState = null;
+
+ try {
+ ServerSySessionState state = this.sessionData.getServerSySessionState();
+
+ Event localEvent = (Event) event;
+
+ Event.Type eventType = (Event.Type) event.getType();
+
+ switch(state) {
+ case IDLE:
+ switch(eventType) {
+ case RECEIVED_INITIAL:
+ listener.doSpendingLimitRequest(this, (SpendingLimitRequest) localEvent.getRequest());
+ break;
+ case SENT_INITIAL_RESPONSE:
+ newState = ServerSySessionState.OPEN;
+
+ // dispatchEvent()
+ session.send(((AppEvent)localEvent).getMessage());
+
+ setState(newState);
+ break;
+ }
+ break;
+ case OPEN:
+ switch(eventType) {
+ case RECEIVED_INTERMEDIATE:
+ listener.doSpendingLimitRequest(this, (SpendingLimitRequest) localEvent.getRequest());
+ break;
+ case RECEIVED_TERMINATION:
+ listener.doSessionTerminationRequest(this, (SessionTermRequest) localEvent.getRequest());
+ break;
+ }
+ break;
+ }
+ return false;
+ }
+ catch (Exception e) {
+ throw new InternalException(e);
+ }
+ finally {
+ sendAndStateLock.unlock();
+ }
+ }
+
+ @Override
+ public E getState(Class stateType) {
+ return null;
+ }
+
+ @Override
+ public long getCreationTime() {
+ return 0;
+ }
+
+ @Override
+ public long getLastAccessedTime() {
+ return 0;
+ }
+
+ @Override
+ public boolean isValid() {
+ return false;
+ }
+
+ protected void setState(ServerSySessionState newState) {
+ setState(newState, true);
+ }
+
+ protected void setState(ServerSySessionState newState, boolean release) {
+ IAppSessionState oldState = this.sessionData.getServerSySessionState();
+ this.sessionData.setServerSySessionState(newState);
+
+ for (StateChangeListener i : stateListeners) {
+ i.stateChanged(this, (Enum) oldState, (Enum) newState);
+ }
+ if (newState == ServerSySessionState.IDLE) {
+ // do EVERYTHING before this!
+ //stopTcc(false);
+ if (release) {
+ this.release();
+ }
+ }
+ }
+
+ @Override
+ public void release() {
+
+ }
+
+ @Override
+ public boolean isAppSession() {
+ return false;
+ }
+
+ @Override
+ public boolean isReplicable() {
+ return false;
+ }
+
+ @Override
+ public void onTimer(String timerName) {
+
+ }
+
+ @Override
+ public String getSessionId() {
+ return null;
+ }
+
+ private class RequestDelivery implements Runnable {
+ ServerSySession session;
+ Request request;
+
+ @Override
+ public void run() {
+ try {
+ switch (request.getCommandCode()) {
+ case SpendingLimitRequest.code:
+ handleEvent(new Event(true, factory.createSpendingLimitRequest(request), null));
+ break;
+ case SessionTermRequest.code:
+ handleEvent(new Event(true, factory.createSessionTerminationRequest(request), null));
+ break;
+ default:
+ logger.debug("Unexpected request received on Sy channel", request);
+ break;
+ }
+ }
+ catch (Exception e) {
+ logger.debug("Failed to process request message", e);
+ }
+ }
+ }
+
+ private class AnswerDelivery implements Runnable {
+ ServerSySession session;
+ Answer answer;
+ Request request;
+
+ @Override
+ public void run() {
+ try {
+ // FIXME: baranowb: add message validation here!!!
+ // We handle CCR, STR, ACR, ASR other go into extension
+ switch (request.getCommandCode()) {
+ /*case ReAuthRequest.code:
+ handleEvent(new Event(Event.Type.RECEIVED_RAA, factory.createReAuthRequest(request), factory.createReAuthAnswer(answer)));
+ break;*/
+ default:
+ //listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer));
+ break;
+ }
+
+ }
+ catch (Exception e) {
+ logger.debug("Failed to process success message", e);
+ }
+ }
+ }
+
+}
diff --git a/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java b/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java
index aaa30633f..9bdfe8930 100644
--- a/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java
+++ b/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java
@@ -84,8 +84,8 @@ public ChargingServerSimulator() throws Exception {
sessionFactory = (ISessionFactory) stackCreator.getSessionFactory();
init(sessionFactory); // damn.. this doesn't looks good
- sessionFactory.registerAppFacory(ServerCCASession.class, this);
- sessionFactory.registerAppFacory(ClientCCASession.class, this);
+ sessionFactory.registerAppFactory(ServerCCASession.class, this);
+ sessionFactory.registerAppFactory(ClientCCASession.class, this);
// Read users from properties file
Properties properties = new Properties();
diff --git a/testsuite/tests/pom.xml b/testsuite/tests/pom.xml
index 91d6b4520..c9e8a34c3 100644
--- a/testsuite/tests/pom.xml
+++ b/testsuite/tests/pom.xml
@@ -1,5 +1,17 @@
4.0.0
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+ org.mobicents.diameter.testsuite
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractClient.java
index 365f949ee..72dd20588 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractClient.java
@@ -69,8 +69,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAccAppId(0, 300));
AccSessionFactoryImpl creditControlSessionFactory = new AccSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerAccSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientAccSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerAccSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientAccSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractServer.java
index 050a44991..ed6501303 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/acc/AbstractServer.java
@@ -64,8 +64,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAccAppId(0, 300));
AccSessionFactoryImpl creditControlSessionFactory = new AccSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerAccSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientAccSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerAccSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientAccSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setServerSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractClient.java
index 1c03fabb4..59922fd6e 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractClient.java
@@ -65,8 +65,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(0, 4));
CCASessionFactoryImpl creditControlSessionFactory = new CCASessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCCASession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientCCASession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerCCASession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientCCASession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractServer.java
index 454d9371b..ed6aff7bb 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cca/AbstractServer.java
@@ -59,8 +59,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(0, 4));
CCASessionFactoryImpl creditControlSessionFactory = new CCASessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCCASession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientCCASession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerCCASession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientCCASession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setServerSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractClient.java
index 9417ff594..e240af5c4 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractClient.java
@@ -67,8 +67,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl shSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, shSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, shSessionFactory);
shSessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractServer.java
index 55c2a887f..4236362ff 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/AbstractServer.java
@@ -65,8 +65,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl cxDxSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, cxDxSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, cxDxSessionFactory);
cxDxSessionFactory.setServerSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientPPR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientPPR.java
index 1365299d2..a22c0dc43 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientPPR.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientPPR.java
@@ -65,8 +65,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl cxdxSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, cxdxSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, cxdxSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, cxdxSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, cxdxSessionFactory);
cxdxSessionFactory.setClientSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientRTR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientRTR.java
index 731ff202c..a970ff8c2 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientRTR.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ClientRTR.java
@@ -65,8 +65,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl cxdxSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, cxdxSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, cxdxSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, cxdxSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, cxdxSessionFactory);
cxdxSessionFactory.setClientSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerPPR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerPPR.java
index 5ef740451..bf7f5ee52 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerPPR.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerPPR.java
@@ -60,8 +60,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl cxDxSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, cxDxSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, cxDxSessionFactory);
cxDxSessionFactory.setServerSessionListener(this);
this.serverCxDxSession = sessionFactory.getNewAppSession(getApplicationId(), ServerCxDxSession.class);
}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerRTR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerRTR.java
index 710f0b7fd..ad096db90 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerRTR.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/cxdx/base/ServerRTR.java
@@ -60,8 +60,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777216));
CxDxSessionFactoryImpl cxDxSessionFactory = new CxDxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerCxDxSession.class, cxDxSessionFactory);
- sessionFactory.registerAppFacory(ClientCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ServerCxDxSession.class, cxDxSessionFactory);
+ sessionFactory.registerAppFactory(ClientCxDxSession.class, cxDxSessionFactory);
cxDxSessionFactory.setServerSessionListener(this);
this.serverCxDxSession = sessionFactory.getNewAppSession(getApplicationId(), ServerCxDxSession.class);
}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractClient.java
index d2d1d4643..6437aab42 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractClient.java
@@ -68,8 +68,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777224));
GxSessionFactoryImpl creditControlSessionFactory = new GxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerGxSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientGxSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerGxSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientGxSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractServer.java
index 2b5a8eca6..86c2eca4e 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/gx/AbstractServer.java
@@ -69,8 +69,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777224));
GxSessionFactoryImpl creditControlSessionFactory = new GxSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerGxSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientGxSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerGxSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientGxSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setServerSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractClient.java
index f6b03eca0..4037c4b0b 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractClient.java
@@ -68,8 +68,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(0, 4));
RoSessionFactoryImpl creditControlSessionFactory = new RoSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerRoSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientRoSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerRoSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientRoSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractServer.java
index 80c3f6b96..e5ac21789 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/AbstractServer.java
@@ -64,8 +64,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(0, 4));
RoSessionFactoryImpl creditControlSessionFactory = new RoSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerRoSession.class, creditControlSessionFactory);
- sessionFactory.registerAppFacory(ClientRoSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ServerRoSession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientRoSession.class, creditControlSessionFactory);
creditControlSessionFactory.setStateListener(this);
creditControlSessionFactory.setServerSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractClient.java
index e7b2aef01..0c3c7a655 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractClient.java
@@ -57,8 +57,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777252));
S13SessionFactoryImpl s13SessionFactory = new S13SessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerS13Session.class, s13SessionFactory);
- sessionFactory.registerAppFacory(ClientS13Session.class, s13SessionFactory);
+ sessionFactory.registerAppFactory(ServerS13Session.class, s13SessionFactory);
+ sessionFactory.registerAppFactory(ClientS13Session.class, s13SessionFactory);
s13SessionFactory.setClientSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractServer.java
index c4de90c0e..0f6327ed3 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/s13/AbstractServer.java
@@ -58,8 +58,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777252));
S13SessionFactoryImpl s13SessionFactory = new S13SessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerS13Session.class, s13SessionFactory);
- sessionFactory.registerAppFacory(ClientS13Session.class, s13SessionFactory);
+ sessionFactory.registerAppFactory(ServerS13Session.class, s13SessionFactory);
+ sessionFactory.registerAppFactory(ClientS13Session.class, s13SessionFactory);
s13SessionFactory.setServerSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractClient.java
index e9f37cb7f..c5c56ed00 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractClient.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractClient.java
@@ -50,8 +50,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777217));
ShSessionFactoryImpl shSessionFactory = new ShSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerShSession.class, shSessionFactory);
- sessionFactory.registerAppFacory(ClientShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ServerShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ClientShSession.class, shSessionFactory);
shSessionFactory.setClientShSessionListener(this);
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractServer.java
index 796d5493d..12894af48 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractServer.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/AbstractServer.java
@@ -50,8 +50,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777217));
ShSessionFactoryImpl shSessionFactory = new ShSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerShSession.class, shSessionFactory);
- sessionFactory.registerAppFacory(ClientShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ServerShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ClientShSession.class, shSessionFactory);
shSessionFactory.setServerShSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/base/ClientPNR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/base/ClientPNR.java
index 138dc3081..a021f9a8e 100644
--- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/base/ClientPNR.java
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sh/base/ClientPNR.java
@@ -82,8 +82,8 @@ public void init(InputStream configStream, String clientID) throws Exception {
try {
super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777217));
ShSessionFactoryImpl shSessionFactory = new ShSessionFactoryImpl(this.sessionFactory);
- sessionFactory.registerAppFacory(ServerShSession.class, shSessionFactory);
- sessionFactory.registerAppFacory(ClientShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ServerShSession.class, shSessionFactory);
+ sessionFactory.registerAppFactory(ClientShSession.class, shSessionFactory);
shSessionFactory.setClientShSessionListener(this);
}
finally {
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractClient.java
new file mode 100644
index 000000000..e75b44507
--- /dev/null
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractClient.java
@@ -0,0 +1,134 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.mobicents.diameter.stack.functional.sy;
+
+import org.jdiameter.api.*;
+import org.jdiameter.api.sy.ClientSySession;
+import org.jdiameter.api.sy.ClientSySessionListener;
+import org.jdiameter.api.sy.ServerSySession;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.common.api.app.sy.ClientSySessionState;
+import org.jdiameter.common.impl.app.sy.SySessionFactoryImpl;
+import org.mobicents.diameter.stack.functional.StateChange;
+import org.mobicents.diameter.stack.functional.TBase;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy tests
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public abstract class AbstractClient extends TBase implements ClientSySessionListener {
+
+ protected static final int SL_REQUEST_TYPE_INITIAL = 0;
+ protected static final int SL_REQUEST_TYPE_INTERMEDIATE = 1;
+
+ protected ClientSySession clientSySession;
+ protected int slRequestNumber = 0;
+ protected List> stateChanges = new ArrayList>(); // state changes
+
+ public void init(InputStream configStream, String clientID) throws Exception {
+ try {
+ super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777302));
+
+ SySessionFactoryImpl spendingLimitSessionFactory = new SySessionFactoryImpl(this.sessionFactory);
+ sessionFactory.registerAppFactory(ServerSySession.class, spendingLimitSessionFactory);
+ sessionFactory.registerAppFactory(ClientSySession.class, spendingLimitSessionFactory);
+
+ /*spendingLimitSessionFactory.setStateListener(this);
+ spendingLimitSessionFactory.setClientSessionListener(this);
+ spendingLimitSessionFactory.setClientContextListener(this);*/
+ this.clientSySession = this.sessionFactory.getNewAppSession(this.sessionFactory.getSessionId("xxTESTxx"),
+ getApplicationId(), ClientSySession.class, (Object) null);
+ } finally {
+ try {
+ configStream.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ // ----------- delegate methods so
+
+ 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);
+ }
+
+ public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException {
+ stack.stop(timeOut, timeUnit, disconnectCause);
+ }
+
+ public void stop(int disconnectCause) {
+ stack.stop(disconnectCause);
+ }
+
+ @Override
+ public void receivedSuccessMessage(Request request, Answer answer) {
+ fail("Received \"SuccessMessage\" event, request[" + request + "], answer[" + answer + "]", null);
+
+ }
+
+ @Override
+ public Answer processRequest(Request request) {
+ fail("Received \"Request\" event, request[" + request + "]", null);
+ return null;
+ }
+
+ protected SpendingLimitRequest createSLR(int slRequestType, int requestNumber, ClientSySession sySession) throws Exception {
+ SpendingLimitRequest slr = null; // new SpendingLimitRequestImpl(sySession.getSessions().get(0).createRequest(SpendingLimitRequest.code, getApplicationId(), getServerRealmName()));
+
+ return slr;
+ }
+
+ protected SpendingStatusNotificationAnswer createSNR(int requestNumber, ClientSySession sySession) throws Exception {
+ SpendingStatusNotificationAnswer sna = null; // new SpendingStatusNotificationAnswerImpl(sySession.getSessions().get(0).createRequest(StatusNotificationSpendingLimitRequestAnswer.code, getApplicationId(), getServerRealmName()));
+
+ return sna;
+ }
+
+ public String getSessionId() {
+ return this.clientSySession.getSessionId();
+ }
+
+ public void fetchSession(String sessionId) throws InternalException {
+ this.clientSySession = stack.getSession(sessionId, ClientSySession.class);
+ }
+
+ public ClientSySession getSession() {
+ return this.clientSySession;
+ }
+
+ public List> getStateChanges() {
+ return stateChanges;
+ }
+
+}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractServer.java
new file mode 100644
index 000000000..ed35815f9
--- /dev/null
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/AbstractServer.java
@@ -0,0 +1,142 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.mobicents.diameter.stack.functional.sy;
+
+import org.jdiameter.api.ApplicationId;
+import org.jdiameter.api.IllegalDiameterStateException;
+import org.jdiameter.api.InternalException;
+import org.jdiameter.api.Mode;
+import org.jdiameter.api.sy.ClientSySession;
+import org.jdiameter.api.sy.ServerSySession;
+import org.jdiameter.api.sy.ServerSySessionListener;
+import org.jdiameter.common.api.app.sy.ServerSySessionState;
+import org.jdiameter.common.impl.app.sy.SySessionFactoryImpl;
+import org.mobicents.diameter.stack.functional.StateChange;
+import org.mobicents.diameter.stack.functional.TBase;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy tests
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public abstract class AbstractServer extends TBase implements ServerSySessionListener {
+
+ // NOTE: implementing NetworkReqListener since its required for stack to
+ // know we support it... ech.
+
+ protected static final int SL_REQUEST_TYPE_INITIAL = 0;
+ protected static final int SL_REQUEST_TYPE_INTERMEDIATE = 1;
+
+ protected ServerSySession serverSySession;
+ protected int ccRequestNumber = 0;
+
+ protected List> stateChanges = new ArrayList>(); // state changes
+
+ public void init(InputStream configStream, String clientID) throws Exception {
+ try {
+ super.init(configStream, clientID, ApplicationId.createByAuthAppId(0, 4));
+ SySessionFactoryImpl creditControlSessionFactory = new SySessionFactoryImpl(this.sessionFactory);
+ sessionFactory.registerAppFactory(ServerSySession.class, creditControlSessionFactory);
+ sessionFactory.registerAppFactory(ClientSySession.class, creditControlSessionFactory);
+
+ /*creditControlSessionFactory.setStateListener(this);
+ creditControlSessionFactory.setServerSessionListener(this);
+ creditControlSessionFactory.setServerContextListener(this);*/
+
+ }
+ finally {
+ try {
+ configStream.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ // ----------- delegate methods so
+
+ 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);
+ }
+
+ public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException {
+ stack.stop(timeOut, timeUnit, disconnectCause);
+ }
+
+ public void stop(int disconnectCause) {
+ stack.stop(disconnectCause);
+ }
+
+ // ----------- conf parts
+
+ /*@Override
+ public void sessionSupervisionTimerExpired(ServerCCASession session) {
+ // NOP
+ }
+
+ @Override
+ public void sessionSupervisionTimerStarted(ServerCCASession session, ScheduledFuture future) {
+ // NOP
+ }
+
+ @Override
+ public void sessionSupervisionTimerReStarted(ServerCCASession session, ScheduledFuture future) {
+ // NOP
+ }
+
+ @Override
+ public void sessionSupervisionTimerStopped(ServerCCASession session, ScheduledFuture future) {
+ // NOP
+ }
+
+ @Override
+ public long getDefaultValidityTime() {
+ return 120;
+ }
+
+ public String getSessionId() {
+ return this.serverCCASession.getSessionId();
+ }
+
+ public void fetchSession(String sessionId) throws InternalException {
+ this.serverCCASession = stack.getSession(sessionId, ServerCCASession.class);
+ }
+
+ public ServerCCASession getSession() {
+ return this.serverCCASession;
+ }
+
+ public List> getStateChanges() {
+ return stateChanges;
+ }*/
+}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Client.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Client.java
new file mode 100644
index 000000000..be7795810
--- /dev/null
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Client.java
@@ -0,0 +1,164 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.mobicents.diameter.stack.functional.sy.base;
+
+import org.jdiameter.api.*;
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.ClientSySession;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+import org.jdiameter.common.impl.app.auth.SessionTermRequestImpl;
+import org.mobicents.diameter.stack.functional.Utils;
+import org.mobicents.diameter.stack.functional.sy.AbstractClient;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy tests
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class Client extends AbstractClient {
+
+ protected boolean sentINITIAL;
+ protected boolean sentINTERMEDIATE;
+ protected boolean sentSTATUSNOTIFICATION;
+ protected boolean sentTERMINATE;
+ protected boolean receivedINITIAL;
+ protected boolean receivedINTERMEDIATE;
+ protected boolean receivedSTATUSNOTIFICATION;
+ protected boolean receivedTERMINATE;
+
+ public Client() {
+ }
+
+ public void sendInitial() throws Exception {
+ SpendingLimitRequest initialRequest = super.createSLR(SL_REQUEST_TYPE_INITIAL, this.slRequestNumber, super.clientSySession);
+ this.slRequestNumber++;
+ super.clientSySession.sendSpendingLimitRequest(initialRequest);
+ Utils.printMessage(log, super.stack.getDictionary(), initialRequest.getMessage(), true);
+
+ this.sentINITIAL = true;
+ }
+
+ public void sendIntermediate() throws Exception {
+ if (!receivedINITIAL) {
+ throw new Exception();
+ }
+
+ SpendingLimitRequest initialRequest = super.createSLR(SL_REQUEST_TYPE_INTERMEDIATE, this.slRequestNumber, super.clientSySession);
+ this.slRequestNumber++;
+ super.clientSySession.sendSpendingLimitRequest(initialRequest);
+ Utils.printMessage(log, super.stack.getDictionary(), initialRequest.getMessage(), true);
+
+ this.sentINTERMEDIATE = true;
+ }
+
+ public void sendTerminate() throws Exception {
+ if (!receivedINTERMEDIATE) {
+ throw new Exception();
+ }
+
+ SessionTermRequest terminateRequest = new SessionTermRequestImpl(null, 0, "realm.com", "realm.com");
+ this.slRequestNumber++;
+ super.clientSySession.sendFinalSpendingLimitRequest(terminateRequest);
+ Utils.printMessage(log, super.stack.getDictionary(), terminateRequest.getMessage(), true);
+
+ this.sentTERMINATE = true;
+ }
+
+ public void sendStatusNotification() throws Exception {
+ SpendingStatusNotificationAnswer statusNotificationAnswer = super.createSNR(this.slRequestNumber, super.clientSySession);
+ this.slRequestNumber++;
+ super.clientSySession.sendSpendingStatusNotificationAnswer(null);
+ Utils.printMessage(log, super.stack.getDictionary(), statusNotificationAnswer.getMessage(), true);
+
+ this.sentSTATUSNOTIFICATION = true;
+ }
+
+ public boolean isSentINITIAL() {
+ return sentINITIAL;
+ }
+
+ public boolean isSentINTERMEDIATE() {
+ return sentINTERMEDIATE;
+ }
+
+ public boolean isSentTERMINATE() {
+ return sentTERMINATE;
+ }
+
+ public boolean isReceivedINITIAL() {
+ return receivedINITIAL;
+ }
+
+ public boolean isReceivedINTERMEDIATE() {
+ return receivedINTERMEDIATE;
+ }
+
+ public boolean isReceivedTERMINATE() {
+ return receivedTERMINATE;
+ }
+
+ @Override
+ public void doSpendingLimitAnswer(ClientSySession session, SpendingLimitRequest request, SpendingLimitAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ try {
+ Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false);
+ switch (answer.getRequestSLTypeAVPValue()) {
+ case SL_REQUEST_TYPE_INITIAL:
+ if (receivedINITIAL) {
+ fail("Received INITIAL more than once!", null);
+ }
+ receivedINITIAL = true;
+ break;
+
+ case SL_REQUEST_TYPE_INTERMEDIATE:
+ if (receivedINTERMEDIATE) {
+ fail("Received INTERIM more than once!", null);
+ }
+ receivedINTERMEDIATE = true;
+ break;
+
+ default:
+ }
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void doFinalSpendingLimitAnswer(ClientSySession session, SessionTermRequest request, SessionTermAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false);
+ if (receivedTERMINATE) {
+ fail("Received TERMINATE more than once!", null);
+ }
+ receivedTERMINATE = true;
+ }
+
+ @Override
+ public void doSpendingStatusNotificationRequest(ClientSySession session, SpendingStatusNotificationRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+ Utils.printMessage(log, super.stack.getDictionary(), request.getMessage(), false);
+ receivedSTATUSNOTIFICATION = true;
+ }
+}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Server.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Server.java
new file mode 100644
index 000000000..6a43b423a
--- /dev/null
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/Server.java
@@ -0,0 +1,185 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.mobicents.diameter.stack.functional.sy.base;
+
+import org.jdiameter.api.*;
+import org.jdiameter.api.auth.events.SessionTermAnswer;
+import org.jdiameter.api.auth.events.SessionTermRequest;
+import org.jdiameter.api.sy.ServerSySession;
+import org.jdiameter.api.sy.events.SpendingLimitAnswer;
+import org.jdiameter.api.sy.events.SpendingLimitRequest;
+
+import org.jdiameter.api.sy.events.SpendingStatusNotificationAnswer;
+import org.jdiameter.api.sy.events.SpendingStatusNotificationRequest;
+import org.jdiameter.common.impl.app.auth.SessionTermAnswerImpl;
+import org.jdiameter.common.impl.app.sy.SpendingLimitAnswerImpl;
+import org.mobicents.diameter.stack.functional.Utils;
+import org.mobicents.diameter.stack.functional.sy.AbstractServer;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy tests
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+public class Server extends AbstractServer {
+
+ protected boolean sentINITIAL;
+ protected boolean sentINTERMEDIATE;
+ protected boolean sentTERMINATE;
+ protected boolean receiveINITIAL;
+ protected boolean receiveINTERMEDIATE;
+ protected boolean receiveTERMINATE;
+
+ protected SpendingLimitRequest request;
+
+ public void sendInitial() throws Exception {
+ if (!this.receiveINITIAL || this.request == null) {
+ fail("Did not receive INITIAL or answer already sent.", null);
+ throw new Exception("Request: " + this.request);
+ }
+
+ SpendingLimitAnswer answer = new SpendingLimitAnswerImpl((Request) request.getMessage(), 2001);
+ /*AvpSet reqSet = request.getMessage().getAvps();
+ AvpSet set = answer.getMessage().getAvps();
+ set.removeAvp(Avp.DESTINATION_HOST);
+ set.removeAvp(Avp.DESTINATION_REALM);
+ set.addAvp(reqSet.getAvp(Avp.CC_REQUEST_TYPE), reqSet.getAvp(Avp.CC_REQUEST_NUMBER), reqSet.getAvp(Avp.AUTH_APPLICATION_ID));*/
+
+ super.serverSySession.sendSpendingLimitAnswer(answer);
+
+ sentINITIAL = true;
+ request = null;
+ Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), true);
+ }
+
+ public void sendIntermediate() throws Exception {
+ if (!this.receiveINTERMEDIATE || this.request == null) {
+ fail("Did not receive INTERIM or answer already sent.", null);
+ throw new Exception("Request: " + this.request);
+ }
+
+ SpendingLimitAnswer answer = new SpendingLimitAnswerImpl((Request) request.getMessage(), 2001);
+
+ /*AvpSet reqSet = request.getMessage().getAvps();
+ AvpSet set = answer.getMessage().getAvps();
+ set.removeAvp(Avp.DESTINATION_HOST);
+ set.removeAvp(Avp.DESTINATION_REALM);
+ set.addAvp(reqSet.getAvp(Avp.CC_REQUEST_TYPE), reqSet.getAvp(Avp.CC_REQUEST_NUMBER), reqSet.getAvp(Avp.AUTH_APPLICATION_ID));*/
+
+ super.serverSySession.sendSpendingLimitAnswer(answer);
+ sentINTERMEDIATE = true;
+ request = null;
+ Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), true);
+ }
+
+ public void sendTerminate() throws Exception {
+ if (!this.receiveTERMINATE || this.request == null) {
+ fail("Did not receive TERMINATE or answer already sent.", null);
+ throw new Exception("Request: " + this.request);
+ }
+
+ SessionTermAnswer answer = new SessionTermAnswerImpl((Request) request.getMessage(), 2001);
+
+ /*AvpSet reqSet = request.getMessage().getAvps();
+ AvpSet set = answer.getMessage().getAvps();
+ set.removeAvp(Avp.DESTINATION_HOST);
+ set.removeAvp(Avp.DESTINATION_REALM);
+ set.addAvp(reqSet.getAvp(Avp.CC_REQUEST_TYPE), reqSet.getAvp(Avp.CC_REQUEST_NUMBER), reqSet.getAvp(Avp.AUTH_APPLICATION_ID));*/
+
+ super.serverSySession.sendFinalSpendingLimitAnswer(answer);
+
+ sentTERMINATE = true;
+ request = null;
+ Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), true);
+ }
+
+ @Override
+ public Answer processRequest(Request request) {
+ int commandCode = request.getCommandCode();
+ switch(commandCode) {
+ case 8388635:
+ case 8388636:
+ case 275:
+ break;
+ default:
+ fail("Received Request with code not equal 272!. Code[" + request.getCommandCode() + "]", null);
+ return null;
+ }
+
+ if (super.serverSySession == null) {
+ try {
+ super.serverSySession = this.sessionFactory.getNewAppSession(request.getSessionId(), getApplicationId(), ServerSySession.class, (Object) null);
+ ((NetworkReqListener) this.serverSySession).processRequest(request);
+ }
+ catch (Exception e) {
+ fail(null, e);
+ }
+ } else {
+ // do fail?
+ fail("Received Request in base listener, not in app specific!", null);
+ }
+
+ return null;
+ }
+
+ public boolean isSentINITIAL() {
+ return sentINITIAL;
+ }
+
+ public boolean isSentINTERMEDIATE() {
+ return sentINTERMEDIATE;
+ }
+
+ public boolean isSentTERMINATE() {
+ return sentTERMINATE;
+ }
+
+ public boolean isReceiveINITIAL() {
+ return receiveINITIAL;
+ }
+
+ public boolean isReceiveINTERMEDIATE() {
+ return receiveINTERMEDIATE;
+ }
+
+ public boolean isReceiveTERMINATE() {
+ return receiveTERMINATE;
+ }
+
+ public SpendingLimitRequest getRequest() {
+ return request;
+ }
+
+ @Override
+ public void doSpendingLimitRequest(ServerSySession session, SpendingLimitRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doFinalSpendingLimitRequest(ServerSySession session, SessionTermRequest request) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+
+ @Override
+ public void doSpendingStatusNotificationAnswer(ServerSySession session, SpendingStatusNotificationRequest request, SpendingStatusNotificationAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
+
+ }
+}
diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/SySessionBasicFlowTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/SySessionBasicFlowTest.java
new file mode 100644
index 000000000..3e88ed377
--- /dev/null
+++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/sy/base/SySessionBasicFlowTest.java
@@ -0,0 +1,229 @@
+/*
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2016, Telestax Inc and individual contributors
+ * by the @authors tag.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ */
+
+package org.mobicents.diameter.stack.functional.sy.base;
+
+import org.jdiameter.api.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Policy and charging control, Spending Limit Report - Sy tests
+ *
+ * @author Alejandro Ferreira Guido
+ */
+
+@RunWith(Parameterized.class)
+public class SySessionBasicFlowTest {
+
+ private URI clientConfigUri;
+ private URI serverConfigUri;
+
+ private Client clientNode;
+ private Server serverNode;
+
+ /**
+ * @param clientConfigUri
+ * @param serverConfigUri
+ */
+ public SySessionBasicFlowTest(String clientConfigUri, String serverConfigUri) throws Exception {
+ super();
+
+ this.clientConfigUri = new URI(clientConfigUri);
+ this.serverConfigUri = new URI(serverConfigUri);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ this.clientNode = new Client();
+ this.serverNode = new Server();
+
+ this.serverNode.init(new FileInputStream(new File(this.serverConfigUri)), "SERVER-SY");
+ this.serverNode.start();
+
+ this.clientNode.init(new FileInputStream(new File(this.clientConfigUri)), "CLIENT-SY");
+ this.clientNode.start(Mode.ANY_PEER, 10, TimeUnit.SECONDS);
+ Stack stack = this.clientNode.getStack();
+
+ List peers = stack.unwrap(PeerTable.class).getPeerTable();
+ if (peers.size() == 1) {
+ // ok
+ } else if (peers.size() > 1) {
+ // works better with replicated, since disconnected peers are also listed
+ boolean foundConnected = false;
+ for (Peer p : peers) {
+ if (p.getState(PeerState.class).equals(PeerState.OKAY)) {
+ if (foundConnected) {
+ throw new Exception("Wrong number of connected peers: " + peers);
+ }
+ foundConnected = true;
+ }
+ }
+ }
+ else {
+ throw new Exception("Wrong number of connected peers: " + peers);
+ }
+ }
+ catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void tearDown() {
+ if (this.serverNode != null) {
+ try {
+ this.serverNode.stop(DisconnectCause.REBOOTING);
+ }
+ catch (Exception e) {
+ }
+ this.serverNode = null;
+ }
+
+ if (this.clientNode != null) {
+ try {
+ this.clientNode.stop(DisconnectCause.REBOOTING);
+ }
+ catch (Exception e) {
+ }
+ this.clientNode = null;
+ }
+ }
+
+ @Test
+ public void testBasicFlow() throws Exception {
+ try {
+ // pain of parameter tests :) ?
+ clientNode.sendInitial();
+ waitForMessage();
+
+ serverNode.sendInitial();
+ waitForMessage();
+
+ clientNode.sendIntermediate();
+ waitForMessage();
+
+ serverNode.sendIntermediate();
+ waitForMessage();
+
+ clientNode.sendTerminate();
+ waitForMessage();
+
+ serverNode.sendTerminate();
+ waitForMessage();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ if (!clientNode.isReceivedINITIAL()) {
+ StringBuilder sb = new StringBuilder("Did not receive INITIAL! ");
+ sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ if (!clientNode.isReceivedINTERMEDIATE()) {
+ StringBuilder sb = new StringBuilder("Did not receive INTERIM! ");
+ sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ if (!clientNode.isReceivedTERMINATE()) {
+ StringBuilder sb = new StringBuilder("Did not receive TERMINATE! ");
+ sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ if (!clientNode.isPassed()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors()));
+
+ fail(sb.toString());
+ }
+
+ if (!serverNode.isReceiveINITIAL()) {
+ StringBuilder sb = new StringBuilder("Did not receive INITIAL! ");
+ sb.append("Server ER:\n").append(serverNode.createErrorReport(this.serverNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ else if (!serverNode.isReceiveINTERMEDIATE()) {
+ StringBuilder sb = new StringBuilder("Did not receive INTERIM! ");
+ sb.append("Server ER:\n").append(serverNode.createErrorReport(this.serverNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ else if (!serverNode.isReceiveTERMINATE()) {
+ StringBuilder sb = new StringBuilder("Did not receive TERMINATE! ");
+ sb.append("Server ER:\n").append(serverNode.createErrorReport(this.serverNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ if (!serverNode.isPassed()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Server ER:\n").append(serverNode.createErrorReport(this.serverNode.getErrors()));
+
+ fail(sb.toString());
+ }
+ }
+
+ @Parameters
+ public static Collection