Revision: b25e6b5c7055
Author: Sergey Vetyutnev <[email protected]>
Date: Tue Dec 11 00:37:01 2012
Log: TCAP previewMode unitTests part2
http://code.google.com/p/jss7/source/detail?r=b25e6b5c7055
Added:
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImplWrapper.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPStackImplWrapper.java
Modified:
/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/MAPFunctionalTest.java
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/PrevewDialogData.java
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/asn/InvokeImpl.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventTestHarness.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/PreviewModeFunctionalTest.java
/tools/trace-parser/Ss7ParseParameters.xml
=======================================
--- /dev/null
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImplWrapper.java
Tue Dec 11 00:37:01 2012
@@ -0,0 +1,42 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.tcap;
+
+import java.util.Map;
+import org.mobicents.protocols.ss7.sccp.SccpProvider;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class TCAPProviderImplWrapper extends TCAPProviderImpl {
+
+ protected TCAPProviderImplWrapper(SccpProvider sccpProvider,
TCAPStackImpl stack, int ssn) {
+ super(sccpProvider, stack, ssn);
+ }
+
+ public Map<PrevewDialogDataKey, PrevewDialogData>
getDialogPreviewList() {
+ return dialogPreviewList;
+ }
+}
=======================================
--- /dev/null
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPStackImplWrapper.java
Tue Dec 11 00:37:01 2012
@@ -0,0 +1,48 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.tcap;
+
+import java.util.Map;
+
+import org.mobicents.protocols.ss7.sccp.SccpProvider;
+import
org.mobicents.protocols.ss7.tcap.TCAPProviderImpl.PrevewDialogDataKey;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class TCAPStackImplWrapper extends TCAPStackImpl {
+
+ public TCAPStackImplWrapper(SccpProvider sccpProvider, int ssn) {
+ super();
+
+ this.tcapProvider = new TCAPProviderImplWrapper(sccpProvider,
this, ssn);
+ }
+
+ public Map<PrevewDialogDataKey, PrevewDialogData>
getDialogPreviewList() {
+ TCAPProviderImplWrapper prov = (TCAPProviderImplWrapper)
this.getProvider();
+ return prov.getDialogPreviewList();
+ }
+
+}
=======================================
---
/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/MAPFunctionalTest.java
Mon Dec 10 02:49:37 2012
+++
/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/MAPFunctionalTest.java
Tue Dec 11 00:37:01 2012
@@ -762,6 +762,10 @@
// Server side events
List<TestEvent> serverExpectedEvents = new
ArrayList<TestEvent>();
+ // !!!! ---
+// this.saveTrafficInFile();
+// !!!! ---
+
client.actionA();
waitForEnd();
client.compareEvents(clientExpectedEvents);
@@ -1110,10 +1114,6 @@
};
- // !!!! ---
-// this.saveTrafficInFile();
-// !!!! ---
-
long stamp = System.currentTimeMillis();
int count = 0;
// Client side events
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
Mon Dec 10 02:57:05 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
Tue Dec 11 00:37:01 2012
@@ -139,6 +139,7 @@
// only originating side keeps FSM, see: Q.771 - 3.1.5
protected InvokeImpl[] operationsSent = new
InvokeImpl[invokeIDTable.length];
+ protected InvokeImpl[] operationsSentA = new
InvokeImpl[invokeIDTable.length];
private ScheduledExecutorService executor;
// scheduled components list
@@ -164,10 +165,18 @@
return new Long(tmp);
}
- // DialogImpl(SccpAddress localAddress, SccpAddress remoteAddress, Long
- // origTransactionId, ScheduledExecutorService executor,
- // TCAProviderImpl provider, ApplicationContextName acn,
UserInformation[]
- // ui) {
+ /**
+ * Creating a Dialog for normal mode
+ *
+ * @param localAddress
+ * @param remoteAddress
+ * @param origTransactionId
+ * @param structured
+ * @param executor
+ * @param provider
+ * @param seqControl
+ * @param previewMode
+ */
protected DialogImpl(SccpAddress localAddress, SccpAddress remoteAddress,
Long origTransactionId,
boolean structured, ScheduledExecutorService executor, TCAPProviderImpl
provider, int seqControl,
boolean previewMode) {
@@ -192,8 +201,20 @@
startIdleTimer();
}
- protected DialogImpl(long dialogId, SccpAddress localAddress, SccpAddress
remoteAddress, int seqControl,
- ScheduledExecutorService executor, TCAPProviderImpl provider,
PrevewDialogData prevewDialogData) {
+ /**
+ * Create a Dialog for previewMode
+ *
+ * @param dialogId
+ * @param localAddress
+ * @param remoteAddress
+ * @param seqControl
+ * @param executor
+ * @param provider
+ * @param pdd
+ * @param sideB
+ */
+ protected DialogImpl(long dialogId, SccpAddress localAddress, SccpAddress
remoteAddress, int seqControl, ScheduledExecutorService executor,
+ TCAPProviderImpl provider, PrevewDialogData pdd,
boolean sideB) {
this.localAddress = localAddress;
this.remoteAddress = remoteAddress;
this.localTransactionId = dialogId;
@@ -207,23 +228,38 @@
TCAPStack stack = this.provider.getStack();
this.idleTaskTimeout = stack.getDialogIdleTimeout();
- this.prevewDialogData = prevewDialogData;
- this.lastACN = prevewDialogData.getLastACN();
- if (prevewDialogData.getOperationsSent() != null)
- this.operationsSent =
prevewDialogData.getOperationsSent();
+ this.prevewDialogData = pdd;
+ this.lastACN = pdd.getLastACN();
+ if (sideB) {
+ if (pdd.getOperationsSentA() != null)
+ this.operationsSent = pdd.getOperationsSentA();
+ if (pdd.getOperationsSentB() != null)
+ this.operationsSentA = pdd.getOperationsSentB();
+ } else {
+ if (pdd.getOperationsSentA() != null)
+ this.operationsSentA = pdd.getOperationsSentA();
+ if (pdd.getOperationsSentB() != null)
+ this.operationsSent = pdd.getOperationsSentB();
+ }
- // start
- startIdleTimer();
+ for (InvokeImpl invoke : this.operationsSent) {
+ if (invoke != null) {
+ invoke.setDialog(this);
+ }
+ }
}
public void release() {
- for (int i = 0; i < this.operationsSent.length; i++) {
- InvokeImpl invokeImpl = this.operationsSent[i];
- if (invokeImpl != null) {
- invokeImpl.setState(OperationState.Idle);
- // TODO whether to call operationTimedOut or
not is still not
- // clear
- // operationTimedOut(invokeImpl);
+ if (!this.previewMode) {
+ for (int i = 0; i < this.operationsSent.length; i++) {
+ InvokeImpl invokeImpl = this.operationsSent[i];
+ if (invokeImpl != null) {
+
invokeImpl.setState(OperationState.Idle);
+ // TODO whether to call
operationTimedOut or not is still
+ // not
+ // clear
+ // operationTimedOut(invokeImpl);
+ }
}
}
@@ -1719,7 +1755,9 @@
if (this.previewMode) {
if (ci.getType() == ComponentType.Invoke) {
- this.operationsSent[index] =
(InvokeImpl) ci;
+ this.operationsSentA[index] =
(InvokeImpl) ci;
+ ((InvokeImpl) ci).setDialog(this);
+ ((InvokeImpl)
ci).setState(OperationState.Sent);
}
}
@@ -1756,8 +1794,8 @@
private void startIdleTimer() {
if (!this.structured)
return;
- // if (this.previewMode)
- // return;
+ if (this.previewMode)
+ return;
try {
this.dialogLock.lock();
@@ -1807,13 +1845,10 @@
d.idleTimerInvoked = true;
provider.timeout(d);
// send abort
- if (d.idleTimerActionTaken &&
!getPreviewMode()) {
+ if (d.idleTimerActionTaken) {
startIdleTimer();
} else {
d.release();
- if (d.getPreviewMode()) {
- provider.removePreviewDialog(d);
- }
}
} finally {
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/PrevewDialogData.java
Tue Dec 4 05:29:11 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/PrevewDialogData.java
Tue Dec 11 00:37:01 2012
@@ -22,6 +22,12 @@
package org.mobicents.protocols.ss7.tcap;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.mobicents.protocols.ss7.tcap.api.TCAPStack;
import org.mobicents.protocols.ss7.tcap.asn.ApplicationContextName;
import org.mobicents.protocols.ss7.tcap.asn.InvokeImpl;
@@ -32,19 +38,37 @@
*/
public class PrevewDialogData {
private ApplicationContextName lastACN;
- private InvokeImpl[] operationsSent;
+ private InvokeImpl[] operationsSentA;
+ private InvokeImpl[] operationsSentB;
private Object upperDialog;
- protected TCAPProviderImpl.PrevewDialogDataKey prevewDialogDataKey1;
- protected TCAPProviderImpl.PrevewDialogDataKey prevewDialogDataKey2;
+ private TCAPProviderImpl.PrevewDialogDataKey prevewDialogDataKey1;
+ private TCAPProviderImpl.PrevewDialogDataKey prevewDialogDataKey2;
+
+ private ReentrantLock dialogLock = new ReentrantLock();
+ private Future idleTimerFuture;
+ private ScheduledExecutorService executor;
+ private TCAPProviderImpl provider;
+ private long idleTaskTimeout;
+
+ public PrevewDialogData(TCAPProviderImpl provider) {
+ this.provider = provider;
+ TCAPStack stack = provider.getStack();
+ this.idleTaskTimeout = stack.getDialogIdleTimeout();
+ this.executor = provider._EXECUTOR;
+ }
public ApplicationContextName getLastACN() {
return lastACN;
}
- public InvokeImpl[] getOperationsSent() {
- return operationsSent;
+ public InvokeImpl[] getOperationsSentA() {
+ return operationsSentA;
+ }
+
+ public InvokeImpl[] getOperationsSentB() {
+ return operationsSentB;
}
public Object getUpperDialog() {
@@ -55,11 +79,81 @@
lastACN = val;
}
- public void setOperationsSent(InvokeImpl[] val) {
- operationsSent = val;
+ public void setOperationsSentA(InvokeImpl[] val) {
+ operationsSentA = val;
+ }
+
+ public void setOperationsSentB(InvokeImpl[] val) {
+ operationsSentB = val;
}
public void setUpperDialog(Object val) {
upperDialog = val;
}
+
+ protected TCAPProviderImpl.PrevewDialogDataKey
getPrevewDialogDataKey1() {
+ return prevewDialogDataKey1;
+ }
+
+ protected TCAPProviderImpl.PrevewDialogDataKey
getPrevewDialogDataKey2() {
+ return prevewDialogDataKey2;
+ }
+
+ protected void
setPrevewDialogDataKey1(TCAPProviderImpl.PrevewDialogDataKey val) {
+ prevewDialogDataKey1 = val;
+ }
+
+ protected void
setPrevewDialogDataKey2(TCAPProviderImpl.PrevewDialogDataKey val) {
+ prevewDialogDataKey2 = val;
+ }
+
+ protected void startIdleTimer() {
+
+ try {
+ this.dialogLock.lock();
+ if (this.idleTimerFuture != null) {
+ throw new IllegalStateException();
+ }
+
+ IdleTimerTask t = new IdleTimerTask();
+ t.pdd = this;
+ this.idleTimerFuture = this.executor.schedule(t, this.idleTaskTimeout,
TimeUnit.MILLISECONDS);
+
+ } finally {
+ this.dialogLock.unlock();
+ }
+ }
+
+ protected void stopIdleTimer() {
+ try {
+ this.dialogLock.lock();
+ if (this.idleTimerFuture != null) {
+ this.idleTimerFuture.cancel(false);
+ this.idleTimerFuture = null;
+ }
+
+ } finally {
+ this.dialogLock.unlock();
+ }
+ }
+
+ protected void restartIdleTimer() {
+ stopIdleTimer();
+ startIdleTimer();
+ }
+
+ private class IdleTimerTask implements Runnable {
+ PrevewDialogData pdd;
+
+ public void run() {
+ try {
+ dialogLock.lock();
+
+ provider.removePreviewDialog(pdd);
+ } finally {
+ dialogLock.unlock();
+ }
+ }
+
+ }
}
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Mon Dec 10 02:57:05 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Tue Dec 11 00:37:01 2012
@@ -106,7 +106,7 @@
//
mapping, but not described
// explicitly...
private transient Map<Long, DialogImpl> dialogs = new HashMap<Long,
DialogImpl>();
- private transient Map<PrevewDialogDataKey, PrevewDialogData>
dialogPreviewList = new HashMap<PrevewDialogDataKey, PrevewDialogData>();
+ protected transient Map<PrevewDialogDataKey, PrevewDialogData>
dialogPreviewList = new HashMap<PrevewDialogDataKey, PrevewDialogData>();
private int seqControl = 0;
private int ssn;
@@ -373,8 +373,12 @@
synchronized (this.dialogs) {
this.dialogs.remove(did);
}
+
+ this.doRelease(d);
}
-
+ }
+
+ private void doRelease(DialogImpl d) {
try {
for (TCListener lst : this.tcListeners) {
lst.onDialogReleased(d);
@@ -575,9 +579,9 @@
} else {
di.processContinue(tcm, localAddress,
remoteAddress);
- if (this.stack.getPreviewMode()) {
- di.release();
- }
+// if (this.stack.getPreviewMode()) {
+// di.release();
+// }
}
break;
@@ -632,8 +636,9 @@
if (this.stack.getPreviewMode()) {
di.getPrevewDialogData().setLastACN(di.getApplicationContextName());
-
di.getPrevewDialogData().setOperationsSent(di.operationsSent);
- di.release();
+
di.getPrevewDialogData().setOperationsSentB(di.operationsSent);
+
di.getPrevewDialogData().setOperationsSentA(di.operationsSentA);
+// di.release();
}
break;
@@ -663,7 +668,7 @@
if (this.stack.getPreviewMode()) {
this.removePreviewDialog(di);
- di.release();
+// di.release();
}
}
break;
@@ -694,7 +699,7 @@
if (this.stack.getPreviewMode()) {
this.removePreviewDialog(di);
- di.release();
+// di.release();
}
}
break;
@@ -797,12 +802,18 @@
}
- private Dialog createPreviewDialog(PrevewDialogDataKey ky, SccpAddress
localAddress, SccpAddress remoteAddress, int seqControl) {
+ private Dialog createPreviewDialog(PrevewDialogDataKey ky, SccpAddress
localAddress, SccpAddress remoteAddress, int seqControl) throws
TCAPException {
synchronized (this.dialogPreviewList) {
- PrevewDialogData pdd = new PrevewDialogData();
+ if (this.dialogPreviewList.size() >=
this.stack.getMaxDialogs())
+ throw new TCAPException("Current dialog count exceeds its maximum
value");
+
+ PrevewDialogData pdd = new PrevewDialogData(this);
this.dialogPreviewList.put(ky, pdd);
- DialogImpl di = new DialogImpl(0, localAddress, remoteAddress,
seqControl, this._EXECUTOR, this, pdd);
- pdd.prevewDialogDataKey1 = ky;
+ DialogImpl di = new DialogImpl(0, localAddress, remoteAddress,
seqControl, this._EXECUTOR, this, pdd, false);
+ pdd.setPrevewDialogDataKey1(ky);
+
+ pdd.startIdleTimer();
+
return di;
}
}
@@ -811,23 +822,28 @@
synchronized (this.dialogPreviewList) {
PrevewDialogData pdd = this.dialogPreviewList.get(ky1);
DialogImpl di = null;
+ boolean sideB = false;
if (pdd != null) {
- di = new DialogImpl(0, localAddress, remoteAddress, seqControl,
this._EXECUTOR, this, pdd);
+ sideB =
pdd.getPrevewDialogDataKey1().equals(ky1);
+ di = new DialogImpl(0, localAddress, remoteAddress, seqControl,
this._EXECUTOR, this, pdd, sideB);
} else {
pdd = this.dialogPreviewList.get(ky2);
if (pdd != null) {
- di = new DialogImpl(0, localAddress, remoteAddress, seqControl,
this._EXECUTOR, this, pdd);
+ sideB =
pdd.getPrevewDialogDataKey1().equals(ky1);
+ di = new DialogImpl(0, localAddress, remoteAddress, seqControl,
this._EXECUTOR, this, pdd, sideB);
} else {
return null;
}
}
+
+ pdd.restartIdleTimer();
- if (pdd.prevewDialogDataKey2 == null && ky2 != null) {
- if (pdd.prevewDialogDataKey1.equals(ky1))
- pdd.prevewDialogDataKey2 = ky2;
+ if (pdd.getPrevewDialogDataKey2() == null && ky2 !=
null) {
+ if (pdd.getPrevewDialogDataKey1().equals(ky1))
+ pdd.setPrevewDialogDataKey2(ky2);
else
- pdd.prevewDialogDataKey2 = ky1;
-
this.dialogPreviewList.put(pdd.prevewDialogDataKey2, pdd);
+ pdd.setPrevewDialogDataKey2(ky1);
+
this.dialogPreviewList.put(pdd.getPrevewDialogDataKey2(), pdd);
}
return di;
@@ -835,12 +851,29 @@
}
protected void removePreviewDialog(DialogImpl di) {
+ PrevewDialogData pdd =
this.dialogPreviewList.get(di.prevewDialogData.getPrevewDialogDataKey1());
synchronized (this.dialogPreviewList) {
-
this.dialogPreviewList.remove(di.prevewDialogData.prevewDialogDataKey1);
-
this.dialogPreviewList.remove(di.prevewDialogData.prevewDialogDataKey2);
+ pdd =
this.dialogPreviewList.get(di.prevewDialogData.getPrevewDialogDataKey1());
+ if (pdd == null) {
+ pdd =
this.dialogPreviewList.get(di.prevewDialogData.getPrevewDialogDataKey2());
+ }
}
+
+ if (pdd != null)
+ removePreviewDialog(pdd);
+
+ this.doRelease(di);
}
+ protected void removePreviewDialog(PrevewDialogData pdd) {
+ synchronized (this.dialogPreviewList) {
+
this.dialogPreviewList.remove(pdd.getPrevewDialogDataKey1());
+
this.dialogPreviewList.remove(pdd.getPrevewDialogDataKey2());
+ }
+ pdd.stopIdleTimer();
+
+ // TODO ??? : create Dialog and invoke "this.doRelease(di);"
+ }
protected class PrevewDialogDataKey {
public int dpc;
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/asn/InvokeImpl.java
Wed Aug 29 02:12:29 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/asn/InvokeImpl.java
Tue Dec 11 00:37:01 2012
@@ -378,6 +378,9 @@
}
public synchronized void startTimer() {
+ if (this.dialog == null || this.dialog.getPreviewMode())
+ return;
+
this.stopTimer();
if (this.invokeTimeout > 0)
this.timerFuture =
this.provider.createOperationTimer(this.operationTimerTask,
this.invokeTimeout);
=======================================
---
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventTestHarness.java
Wed May 30 02:04:43 2012
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventTestHarness.java
Tue Dec 11 00:37:01 2012
@@ -276,12 +276,15 @@
public List<TestEvent> getObserverdEvents() {
return observerdEvents;
}
-
public void compareEvents(List<TestEvent> expectedEvents) {
+ doCompareEvents(this.observerdEvents, expectedEvents);
+ }
- if (expectedEvents.size() != this.observerdEvents.size()) {
- fail("Size of received events: " + this.observerdEvents.size() + ",
does not equal expected events: " + expectedEvents.size() + "\n"
+ public static void doCompareEvents(List<TestEvent> observerdEvents,
List<TestEvent> expectedEvents) {
+
+ if (expectedEvents.size() != observerdEvents.size()) {
+ fail("Size of received events: " + observerdEvents.size() + ", does not
equal expected events: " + expectedEvents.size() + "\n"
+ doStringCompare(expectedEvents,
observerdEvents));
}
@@ -290,7 +293,7 @@
}
}
- protected String doStringCompare(List lst1, List lst2) {
+ protected static String doStringCompare(List lst1, List lst2) {
StringBuilder sb = new StringBuilder();
int size1 = lst1.size();
int size2 = lst2.size();
=======================================
---
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/PreviewModeFunctionalTest.java
Mon Dec 10 02:49:37 2012
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/PreviewModeFunctionalTest.java
Tue Dec 11 00:37:01 2012
@@ -27,6 +27,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.mobicents.protocols.ss7.indicator.NatureOfAddress;
+import org.mobicents.protocols.ss7.indicator.NumberingPlan;
import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
import org.mobicents.protocols.ss7.sccp.SccpListener;
import org.mobicents.protocols.ss7.sccp.SccpProvider;
@@ -34,6 +36,7 @@
import org.mobicents.protocols.ss7.sccp.impl.message.SccpDataMessageImpl;
import org.mobicents.protocols.ss7.sccp.message.MessageFactory;
import org.mobicents.protocols.ss7.sccp.message.SccpDataMessage;
+import org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle;
import org.mobicents.protocols.ss7.sccp.parameter.ParameterFactory;
import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
import org.mobicents.protocols.ss7.tcap.api.TCListener;
@@ -45,6 +48,7 @@
import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCPAbortIndication;
import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCUniIndication;
import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCUserAbortIndication;
+import org.mobicents.protocols.ss7.tcap.asn.ReturnResultLastImpl;
import org.mobicents.protocols.ss7.tcap.asn.comp.Component;
import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke;
import org.testng.annotations.AfterClass;
@@ -60,7 +64,7 @@
*/
public class PreviewModeFunctionalTest {
private SccpHarnessPreview sccpProv = new SccpHarnessPreview();
- private TCAPStackImpl tcapStack1;
+ private TCAPStackImplWrapper tcapStack1;
private TCAPListenerHarness tcapListener;
protected List<TestEvent> observerdEvents;
protected int sequence;
@@ -87,7 +91,7 @@
public void setUp() throws Exception {
System.out.println("setUp");
- this.tcapStack1 = new TCAPStackImpl(this.sccpProv, 8);
+ this.tcapStack1 = new TCAPStackImplWrapper(this.sccpProv, 8);
// this.tcapStack1.setInvokeTimeout(0);
this.tcapStack1.setPreviewMode(true);
@@ -101,6 +105,7 @@
observerdEvents = new ArrayList<TestEvent>();
sequence = 0;
}
+
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
@@ -132,6 +137,19 @@
SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, 102, null, 6);
// RoutingIndicator ri, int dpc, GlobalTitle gt, int ssn
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.End, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnError, null, 3,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, 4,
stamp);
+ expectedEvents.add(te);
+
SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
msg.setIncomingOpc(101);
msg.setIncomingDpc(102);
@@ -141,8 +159,344 @@
msg.setIncomingDpc(101);
this.sccpProv.sccpListener.onMessage(msg);
- int i1 = 0;
- i1++;
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * Responses as ReturnResult (this case is simulated) and
ReturnResultLast
+ *
+ * TC-BEGIN + addProcessUnstructuredSSRequest
+ * TC-CONTINUE + ReturnResult (addProcessUnstructuredSSResponse)
+ * TC-CONTINUE
+ * TC-END + ReturnResultLast (addProcessUnstructuredSSResponse)
+ */
+ @Test(groups = { "functional.flow"})
+ public void beginContContEndTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -109, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 29, -95,
27, 2, 1, 1, 2, 1, 59, 48, 19, 4, 1, 15, 4, 5, -86, -40, 108, 54, 2, -128,
+ 7, -111, 19, 38, -120, -125, 0, -14 };
+ byte[] m2 = new byte[] { 101, 92, 72, 4, 0, 0, 0, 1, 73, 4, 0, 0, 0, 1,
107, 42, 40, 40, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 29, 97, 27, -128, 2, 7,
+ -128, -95, 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -94, 3, 2, 1, 0, -93, 5,
-95, 3, 2, 1, 0, 108, 34, -89, 32, 2, 1, 1, 48, 27, 2, 1, 59, 48, 22, 4, 1,
+ 15, 4, 17, -39, 119, 93, 14, 18, -121, -39, 97, -9, -72, 12, 74, -49,
65, 53, 24, 12 };
+ byte[] m3 = new byte[] { 101, 12, 72, 4, 0, 0, 0, 1, 73, 4, 0,
0, 0, 1 };
+ byte[] m4 = new byte[] { 100, 42, 73, 4, 0, 0, 0, 1, 108, 34, -94, 32,
2, 1, 1, 48, 27, 2, 1, 59, 48, 22, 4, 1, 15, 4, 17, -39, 119, 93, 14, 18,
-121,
+ -39, 97, -9, -72, 12, 74, -49, 65, 53, 24, 12 };
+
+ GlobalTitle gt1 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "11111");
+ GlobalTitle gt2 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "22222");
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt1, 6); //
101
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt2, 6); //
102
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Continue, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnResult, null, 3,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Continue, null, 4,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.End, null, 5,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnResultLast, null, 6,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, 7,
stamp);
+ expectedEvents.add(te);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m2, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1,
m3, 0, 0, false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m4, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * TC-BEGIN + ExtensionContainer + addProcessUnstructuredSSRequest
+ * TC-CONTINUE + ExtensionContainer + addUnstructuredSSRequest
+ * TC-CONTINUE + addUnstructuredSSResponse
+ * TC-END + addProcessUnstructuredSSResponse
+ */
+ @Test(groups = { "functional.flow"})
+ public void crossInvokeTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -109, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 29, -95,
27, 2, 1, 1, 2, 1, 59, 48, 19, 4, 1, 15, 4, 5, -86, -40, 108, 54, 2, -128,
+ 7, -111, 19, 38, -120, -125, 0, -14 };
+ byte[] m2 = new byte[] { 101, -127, -92, 72, 4, 0, 0, 0, 1, 73, 4, 0, 0,
0, 1, 107, 100, 40, 98, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 87, 97, 85,
-128,
+ 2, 7, -128, -95, 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -94, 3, 2, 1, 0, -93,
5, -95, 3, 2, 1, 0, -66, 56, 40, 54, 6, 7, 4, 0, 0, 1, 1, 1, 1, -96, 43,
+ -95, 41, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15,
48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26,
+ -95, 3, 31, 32, 33, 108, 48, -95, 46, 2, 1, 1, 2, 1, 60, 48, 38, 4, 1,
15, 4, 33, -45, 50, -69, 60, -90, -125, 98, -87, 107, -104, -51, -122,
+ -121, -31, 101, 57, 72, -106, -110, -90, -35, 103, -6, -37, 93, 6,
-51, 82, -57, 112, -69, 60, 7 };
+ byte[] m3 = new byte[] { 101, 32, 72, 4, 0, 0, 0, 1, 73, 4, 0, 0, 0, 1,
108, 18, -94, 16, 2, 1, 1, 48, 11, 2, 1, 60, 48, 6, 4, 1, 15, 4, 1, 49 };
+ byte[] m4 = new byte[] { 100, 33, 73, 4, 0, 0, 0, 1, 108, 25, -94, 23,
2, 1, 1, 48, 18, 2, 1, 59, 48, 13, 4, 1, 15, 4, 8, 84, 116, -40, -67, 6,
-27,
+ -33, 117 };
+
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, 101, null, 6);
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, 102, null, 6);
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Continue, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 3,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Continue, null, 4,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnResultLast, null, 5,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.End, null, 6,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnResultLast, null, 7,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, 8,
stamp);
+ expectedEvents.add(te);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 1);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m2, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 2);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1,
m3, 0, 0, false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 2);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m4, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 0);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * TC-BEGIN + ForwardSMRequest_V2
+ * TC-END + ForwardSMResponse_V2
+ */
+ @Test(groups = { "functional.flow"})
+ public void noOperCodeInReturnTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -103, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 21, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 35, -95,
33, 2, 1, 1, 2, 1, 46, 48, 25, -128, 6, 82, -112, 25, 83, -105, -103, -126,
+ 6, -111, 17, 33, 34, 51, -13, 4, 5, 21, 22, 23,
24, 25, 5, 0 };
+ byte[] m2 = new byte[] { 100, 57, 73, 4, 0, 0, 0, 1, 107, 42, 40, 40, 6,
7, 0, 17, -122, 5, 1, 1, 1, -96, 29, 97, 27, -128, 2, 7, -128, -95, 9, 6, 7,
+ 4, 0, 0, 1, 0, 21, 2, -94, 3, 2, 1, 0, -93, 5, -95, 3, 2, 1, 0, 108,
5, -94, 3, 2, 1, 1 };
+
+ GlobalTitle gt1 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "11111");
+ GlobalTitle gt2 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "22222");
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt1, 6); //
101
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt2, 6); //
102
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.End, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.ReturnResultLast, null, 3,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, 4,
stamp);
+ expectedEvents.add(te);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m2, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+
+ // ReturnResultLast without a Paramater: no oparation code i transmitted
in ReturnResultLast - it must be obtained from saved Invoke
+ Object o = observerdEvents.get(3).getEvent();
+ ReturnResultLastImpl rrl = (ReturnResultLastImpl) o;
+ assertEquals((long)
rrl.getOperationCode().getLocalOperationCode(), 46);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * TC-BEGIN + addProcessUnstructuredSSRequest
+ * TC-ABORT(Reason=ACN_Not_Supprted) + alternativeApplicationContextName
+ */
+ @Test(groups = { "functional.flow"})
+ public void abortTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -109, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 29, -95,
27, 2, 1, 1, 2, 1, 59, 48, 19, 4, 1, 15, 4, 5, -86, -40, 108, 54, 2, -128,
+ 7, -111, 19, 38, -120, -125, 0, -14 };
+ byte[] m2 = new byte[] { 103, 65, 73, 4, 0, 0, 0, 1, 107, 57, 40, 55, 6,
7, 0, 17, -122, 5, 1, 1, 1, -96, 44, 97, 42, -128, 2, 7, -128, -95, 4, 6, 2,
+ 42, 3, -94, 3, 2, 1, 1, -93, 5, -95, 3, 2, 1, 2, -66, 18, 40, 16, 6,
7, 4, 0, 0, 1, 1, 1, 1, -96, 5, -93, 3, 10, 1, 0 };
+
+ GlobalTitle gt1 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "11111");
+ GlobalTitle gt2 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "22222");
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt1, 6); //
101
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt2, 6); //
102
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.UAbort, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, 3,
stamp);
+ expectedEvents.add(te);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m2, 0, 0, false, null, null);
+ msg.setIncomingOpc(102);
+ msg.setIncomingDpc(101);
+ this.sccpProv.sccpListener.onMessage(msg);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * TC-BEGIN + addProcessUnstructuredSSRequest
+ * DialogTimeout
+ */
+ @Test(groups = { "functional.flow"})
+ public void dialogTimeoutTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -109, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 29, -95,
27, 2, 1, 1, 2, 1, 59, 48, 19, 4, 1, 15, 4, 5, -86, -40, 108, 54, 2, -128,
+ 7, -111, 19, 38, -120, -125, 0, -14 };
+
+ GlobalTitle gt1 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "11111");
+ GlobalTitle gt2 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "22222");
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt1, 6); //
101
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt2, 6); //
102
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+
+ this.tcapStack1.setInvokeTimeout(1000);
+ this.tcapStack1.setDialogIdleTimeout(2000);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 1);
+
+ Thread.sleep(3000);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 0);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
+ }
+
+ /**
+ * TC-BEGIN + addProcessUnstructuredSSRequest
+ * DialogTimeout
+ */
+ @Test(groups = { "functional.flow"})
+ public void tooManyDialogsTest() throws Exception {
+
+ MessageFactory fact = new MessageFactoryImpl(null);
+
+ byte[] m1 = new byte[] { 98, -127, -109, 72, 4, 0, 0, 0, 1, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 19, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 29, -95,
27, 2, 1, 1, 2, 1, 59, 48, 19, 4, 1, 15, 4, 5, -86, -40, 108, 54, 2, -128,
+ 7, -111, 19, 38, -120, -125, 0, -14 };
+ byte[] m2 = new byte[] { 98, -127, -103, 72, 4, 0, 0, 0, 2, 107, 108,
40, 106, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 95, 96, 93, -128, 2, 7, -128,
-95,
+ 9, 6, 7, 4, 0, 0, 1, 0, 21, 2, -66, 76, 40, 74, 6, 7, 4, 0, 0, 1, 1,
1, 1, -96, 63, -96, 61, -128, 9, -106, 2, 36, -128, 3, 0, -128, 0, -14,
+ -127, 7, -111, 19, 38, -104, -122, 3, -16, 48, 39, -96, 32, 48, 10, 6,
3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
+ 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 108, 35, -95,
33, 2, 1, 1, 2, 1, 46, 48, 25, -128, 6, 82, -112, 25, 83, -105, -103, -126,
+ 6, -111, 17, 33, 34, 51, -13, 4, 5, 21, 22, 23,
24, 25, 5, 0 };
+
+ GlobalTitle gt1 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "11111");
+ GlobalTitle gt2 = GlobalTitle.getInstance(0, NumberingPlan.ISDN_MOBILE,
NatureOfAddress.INTERNATIONAL, "22222");
+ SccpAddress addr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt1, 6); //
101
+ SccpAddress addr2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt2, 6); //
102
+
+ long stamp = System.currentTimeMillis();
+ List<TestEvent> expectedEvents = new ArrayList<TestEvent>();
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, null, 0,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 1,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Begin, null, 2,
stamp);
+ expectedEvents.add(te);
+ te = TestEvent.createReceivedEvent(EventType.Invoke, null, 3,
stamp);
+ expectedEvents.add(te);
+
+ this.tcapStack1.setMaxDialogs(1);
+
+ SccpDataMessageImpl msg =
(SccpDataMessageImpl)fact.createDataMessageClass1(addr2, addr1, m1, 0, 0,
false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 1);
+ msg = (SccpDataMessageImpl)fact.createDataMessageClass1(addr1, addr2,
m2, 0, 0, false, null, null);
+ msg.setIncomingOpc(101);
+ msg.setIncomingDpc(102);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 1);
+
+ this.tcapStack1.setMaxDialogs(100);
+ this.sccpProv.sccpListener.onMessage(msg);
+ assertEquals(this.tcapStack1.getDialogPreviewList().size(), 2);
+
+ EventTestHarness.doCompareEvents(observerdEvents,
expectedEvents);
}
private class SccpHarnessPreview implements SccpProvider {
=======================================
--- /tools/trace-parser/Ss7ParseParameters.xml Mon Dec 10 02:49:37 2012
+++ /tools/trace-parser/Ss7ParseParameters.xml Tue Dec 11 00:37:01 2012
@@ -7,17 +7,11 @@
<void property="detailedDialog">
<boolean>true</boolean>
</void>
- <void property="fileTypeN">
- <object class="java.lang.Enum" method="valueOf">
-
<class>org.mobicents.protocols.ss7.tools.traceparser.ParseDriverType</class>
- <string>SimpleSeq</string>
- </object>
- </void>
<void property="msgLogFilePath">
<string>C:\111\MsgLog.txt</string>
</void>
<void property="sourceFilePath">
- <string>E:\git\jss7n\map\MsgLog.txt</string>
+ <string>E:\Java_workspace\Trace\mi\mnrf.p01</string>
</void>
<void property="tcapMsgData">
<boolean>true</boolean>