2 new revisions:
Revision: 159bedb8bd80
Author: Sergey Vetyutnev <[email protected]>
Date: Mon Dec 10 02:49:37 2012
Log: TCAP prevewMode unitTest part1
http://code.google.com/p/jss7/source/detail?r=159bedb8bd80
Revision: aa98a7e570e3
Author: Sergey Vetyutnev <[email protected]>
Date: Mon Dec 10 02:57:05 2012
Log: Merge branch 'master' into tcap2
http://code.google.com/p/jss7/source/detail?r=aa98a7e570e3
==============================================================================
Revision: 159bedb8bd80
Author: Sergey Vetyutnev <[email protected]>
Date: Mon Dec 10 02:49:37 2012
Log: TCAP prevewMode unitTest part1
http://code.google.com/p/jss7/source/detail?r=159bedb8bd80
Added:
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/PreviewModeFunctionalTest.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/TCAPProviderImpl.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventType.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
/tools/trace-parser/Ss7ParseParameters.xml
=======================================
--- /dev/null
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/PreviewModeFunctionalTest.java
Mon Dec 10 02:49:37 2012
@@ -0,0 +1,291 @@
+/*
+ * 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 static org.testng.Assert.*;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
+import org.mobicents.protocols.ss7.sccp.SccpListener;
+import org.mobicents.protocols.ss7.sccp.SccpProvider;
+import org.mobicents.protocols.ss7.sccp.impl.message.MessageFactoryImpl;
+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.ParameterFactory;
+import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
+import org.mobicents.protocols.ss7.tcap.api.TCListener;
+import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog;
+import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCBeginIndication;
+import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCContinueIndication;
+import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCEndIndication;
+import
org.mobicents.protocols.ss7.tcap.api.tc.dialog.events.TCNoticeIndication;
+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.comp.Component;
+import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class PreviewModeFunctionalTest {
+ private SccpHarnessPreview sccpProv = new SccpHarnessPreview();
+ private TCAPStackImpl tcapStack1;
+ private TCAPListenerHarness tcapListener;
+ protected List<TestEvent> observerdEvents;
+ protected int sequence;
+
+ public PreviewModeFunctionalTest() {
+ }
+
+ @BeforeClass
+ public void setUpClass() {
+// this.sccpStack1Name = "TCAPFunctionalTestSccpStack1";
+// this.sccpStack2Name = "TCAPFunctionalTestSccpStack2";
+ System.out.println("setUpClass");
+ }
+
+ @AfterClass
+ public void tearDownClass() throws Exception {
+ System.out.println("tearDownClass");
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @BeforeMethod
+ public void setUp() throws Exception {
+ System.out.println("setUp");
+
+ this.tcapStack1 = new TCAPStackImpl(this.sccpProv, 8);
+
+// this.tcapStack1.setInvokeTimeout(0);
+ this.tcapStack1.setPreviewMode(true);
+
+
+ this.tcapStack1.start();
+
+ tcapListener = new TCAPListenerHarness();
+ this.tcapStack1.getProvider().addTCListener(tcapListener);
+
+ observerdEvents = new ArrayList<TestEvent>();
+ sequence = 0;
+ }
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @AfterMethod
+ public void tearDown() {
+ this.tcapStack1.getProvider().addTCListener(tcapListener);
+
+ this.tcapStack1.stop();
+ }
+
+ /**
+ * TC-BEGIN + addProcessUnstructuredSSRequest
+ * TC-END + ReturnError(systemFailure)
+ */
+ @Test(groups = { "functional.flow"})
+ public void beginEndTest() 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[] { 100, 60, 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,
8, -93, 6, 2, 1, 1, 2, 1, 34 };
+
+ 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);
+ // RoutingIndicator ri, int dpc, GlobalTitle gt, int ssn
+
+ 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);
+
+ int i1 = 0;
+ i1++;
+ }
+
+ private class SccpHarnessPreview implements SccpProvider {
+
+ @Override
+ public void deregisterSccpListener(int arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getMaxUserDataLength(SccpAddress arg0, SccpAddress
arg1) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public MessageFactory getMessageFactory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ParameterFactory getParameterFactory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected SccpListener sccpListener;
+
+ @Override
+ public void registerSccpListener(int arg0, SccpListener
listener) {
+ sccpListener = listener;
+ }
+
+ @Override
+ public void send(SccpDataMessage msg) throws IOException {
+ // we check here that no messages go from TCAP
previewMode
+
+ fail("No message must go from TCAP previewMode");
+ }
+ }
+
+ private class TCAPListenerHarness implements TCListener {
+
+ private void opComponents(Component[] comList) {
+ if (comList == null)
+ return;
+
+ for (Component comp : comList) {
+ EventType et = null;
+ switch (comp.getType()) {
+ case Invoke:
+ et = EventType.Invoke;
+ break;
+ case ReturnResult:
+ et = EventType.ReturnResult;
+ break;
+ case ReturnResultLast:
+ et = EventType.ReturnResultLast;
+ break;
+ case ReturnError:
+ et = EventType.ReturnError;
+ break;
+ case Reject:
+ et = EventType.Reject;
+ break;
+ }
+
+ if (et != null) {
+ TestEvent te =
TestEvent.createReceivedEvent(et, comp, sequence++);
+ observerdEvents.add(te);
+ }
+ }
+ }
+
+ @Override
+ public void onTCUni(TCUniIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Uni, ind,
sequence++);
+ observerdEvents.add(te);
+
+ opComponents(ind.getComponents());
+ }
+
+ @Override
+ public void onTCBegin(TCBeginIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Begin, ind,
sequence++);
+ observerdEvents.add(te);
+
+ opComponents(ind.getComponents());
+ }
+
+ @Override
+ public void onTCContinue(TCContinueIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Continue, ind,
sequence++);
+ observerdEvents.add(te);
+
+ opComponents(ind.getComponents());
+ }
+
+ @Override
+ public void onTCEnd(TCEndIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.End, ind,
sequence++);
+ observerdEvents.add(te);
+
+ opComponents(ind.getComponents());
+ }
+
+ @Override
+ public void onTCUserAbort(TCUserAbortIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.UAbort, ind,
sequence++);
+ observerdEvents.add(te);
+ }
+
+ @Override
+ public void onTCPAbort(TCPAbortIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.PAbort, ind,
sequence++);
+ observerdEvents.add(te);
+ }
+
+ @Override
+ public void onTCNotice(TCNoticeIndication ind) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.Notice, ind,
sequence++);
+ observerdEvents.add(te);
+ }
+
+ @Override
+ public void onDialogReleased(Dialog d) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.DialogRelease,
d, sequence++);
+ observerdEvents.add(te);
+ }
+
+ @Override
+ public void onInvokeTimeout(Invoke tcInvokeRequest) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.InvokeTimeout,
tcInvokeRequest, sequence++);
+ observerdEvents.add(te);
+ }
+
+ @Override
+ public void onDialogTimeout(Dialog d) {
+ TestEvent te = TestEvent.createReceivedEvent(EventType.DialogTimeout,
d, sequence++);
+ observerdEvents.add(te);
+ }
+
+ }
+}
=======================================
---
/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/MAPFunctionalTest.java
Fri Nov 16 00:02:07 2012
+++
/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/MAPFunctionalTest.java
Mon Dec 10 02:49:37 2012
@@ -1110,6 +1110,10 @@
};
+ // !!!! ---
+// 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
Tue Dec 4 05:29:11 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
Mon Dec 10 02:49:37 2012
@@ -1787,6 +1787,9 @@
startIdleTimer();
} else {
d.release();
+ if (d.getPreviewMode()) {
+ provider.removePreviewDialog(d);
+ }
}
} finally {
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Wed Dec 5 00:27:58 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Mon Dec 10 02:49:37 2012
@@ -369,9 +369,7 @@
public void release(DialogImpl d) {
Long did = d.getDialogId();
- if (d.getPreviewMode()) {
- this.removePreviewDialog(d);
- } else {
+ if (!d.getPreviewMode()) {
synchronized (this.dialogs) {
this.dialogs.remove(did);
}
@@ -836,7 +834,7 @@
}
}
- private void removePreviewDialog(DialogImpl di) {
+ protected void removePreviewDialog(DialogImpl di) {
synchronized (this.dialogPreviewList) {
this.dialogPreviewList.remove(di.prevewDialogData.prevewDialogDataKey1);
this.dialogPreviewList.remove(di.prevewDialogData.prevewDialogDataKey2);
=======================================
---
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventType.java
Sat May 5 21:33:05 2012
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/EventType.java
Mon Dec 10 02:49:37 2012
@@ -28,6 +28,6 @@
*/
public enum EventType {
- Begin, Continue,End,Uni, UAbort, PAbort, Notice, InvokeTimeout,
DialogTimeout,DialogRelease
+ Begin, Continue, End, Uni, UAbort, PAbort, Notice, InvokeTimeout,
DialogTimeout, DialogRelease, Invoke, ReturnResult, ReturnResultLast,
ReturnError, Reject
}
=======================================
---
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
Fri Nov 16 00:02:07 2012
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
Mon Dec 10 02:49:37 2012
@@ -59,7 +59,7 @@
public TCAPFunctionalTest(){
}
-
+
@BeforeClass
public void setUpClass() {
this.sccpStack1Name = "TCAPFunctionalTestSccpStack1";
@@ -110,7 +110,7 @@
@Test(groups = { "functional.flow"})
public void simpleTCWithDialogTest() throws Exception{
-
+
long stamp = System.currentTimeMillis();
List<TestEvent> clientExpectedEvents = new ArrayList<TestEvent>();
TestEvent te = TestEvent.createSentEvent(EventType.Begin, null,
0,stamp);
=======================================
--- /tools/trace-parser/Ss7ParseParameters.xml Fri Nov 2 07:24:19 2012
+++ /tools/trace-parser/Ss7ParseParameters.xml Mon Dec 10 02:49:37 2012
@@ -7,11 +7,17 @@
<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:\Java_workspace\Trace\mi\mnrf.p01</string>
+ <string>E:\git\jss7n\map\MsgLog.txt</string>
</void>
<void property="tcapMsgData">
<boolean>true</boolean>
==============================================================================
Revision: aa98a7e570e3
Author: Sergey Vetyutnev <[email protected]>
Date: Mon Dec 10 02:57:05 2012
Log: Merge branch 'master' into tcap2
http://code.google.com/p/jss7/source/detail?r=aa98a7e570e3
Modified:
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
Mon Dec 10 02:49:37 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/DialogImpl.java
Mon Dec 10 02:57:05 2012
@@ -1,6 +1,6 @@
/*
- * TeleStax, Open Source Cloud Communications Copyright 2012.
- * and individual contributors
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2012, Telestax Inc and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -89,7 +89,6 @@
import
org.mobicents.protocols.ss7.tcap.tc.dialog.events.TCUniIndicationImpl;
import
org.mobicents.protocols.ss7.tcap.tc.dialog.events.TCUserAbortIndicationImpl;
-
/**
* @author baranowb
* @author amit bhayani
@@ -100,19 +99,18 @@
// timeout of remove task after TC_END
private static final int _REMOVE_TIMEOUT = 30000;
-
private static final Logger logger = Logger.getLogger(DialogImpl.class);
-
+
private Object userObject;
-
+
// lock... ech
protected ReentrantLock dialogLock = new ReentrantLock();
-
+
// values for timer timeouts
- private long removeTaskTimeout = _REMOVE_TIMEOUT;
+ private long removeTaskTimeout = _REMOVE_TIMEOUT;
private long idleTaskTimeout;
-
+
// sent/received acn, holds last acn/ui.
private ApplicationContextName lastACN;
private UserInformation lastUI; // optional
@@ -120,6 +118,7 @@
private Long localTransactionIdObject;
private long localTransactionId;
private byte[] remoteTransactionId;
+ private Long remoteTransactionIdObject;
private SccpAddress localAddress;
private SccpAddress remoteAddress;
@@ -169,8 +168,9 @@
// origTransactionId, ScheduledExecutorService executor,
// TCAProviderImpl provider, ApplicationContextName acn,
UserInformation[]
// ui) {
- protected DialogImpl(SccpAddress localAddress, SccpAddress remoteAddress,
Long origTransactionId, boolean structured,
- ScheduledExecutorService executor, TCAPProviderImpl provider, int
seqControl, boolean previewMode) {
+ protected DialogImpl(SccpAddress localAddress, SccpAddress remoteAddress,
Long origTransactionId,
+ boolean structured, ScheduledExecutorService executor, TCAPProviderImpl
provider, int seqControl,
+ boolean previewMode) {
super();
this.localAddress = localAddress;
this.remoteAddress = remoteAddress;
@@ -184,7 +184,7 @@
this.seqControl = seqControl;
this.previewMode = previewMode;
-
+
TCAPStack stack = this.provider.getStack();
this.idleTaskTimeout = stack.getDialogIdleTimeout();
@@ -192,8 +192,8 @@
startIdleTimer();
}
- protected DialogImpl(long dialogId, SccpAddress localAddress, SccpAddress
remoteAddress, int seqControl, ScheduledExecutorService executor,
- TCAPProviderImpl provider, PrevewDialogData
prevewDialogData) {
+ protected DialogImpl(long dialogId, SccpAddress localAddress, SccpAddress
remoteAddress, int seqControl,
+ ScheduledExecutorService executor, TCAPProviderImpl provider,
PrevewDialogData prevewDialogData) {
this.localAddress = localAddress;
this.remoteAddress = remoteAddress;
this.localTransactionId = dialogId;
@@ -203,7 +203,7 @@
this.seqControl = seqControl;
this.previewMode = true;
-
+
TCAPStack stack = this.provider.getStack();
this.idleTaskTimeout = stack.getDialogIdleTimeout();
@@ -217,15 +217,16 @@
}
public void release() {
- for(int i=0; i<this.operationsSent.length;i++){
+ for (int i = 0; i < this.operationsSent.length; i++) {
InvokeImpl invokeImpl = this.operationsSent[i];
- if(invokeImpl != null){
+ if (invokeImpl != null) {
invokeImpl.setState(OperationState.Idle);
- //TODO whether to call operationTimedOut or not
is still not clear
- //operationTimedOut(invokeImpl);
+ // TODO whether to call operationTimedOut or
not is still not
+ // clear
+ // operationTimedOut(invokeImpl);
}
}
-
+
this.setState(TRPseudoState.Expunged);
}
@@ -234,10 +235,21 @@
*
* @see
org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog#getDialogId()
*/
- public Long getDialogId() {
+ public Long getLocalDialogId() {
return localTransactionIdObject;
}
+
+ /**
+ *
+ */
+ public Long getRemoteDialogId() {
+ if (this.remoteTransactionId != null && this.remoteTransactionIdObject
== null) {
+ this.remoteTransactionIdObject =
Utils.decodeTransactionId(this.remoteTransactionId);
+ }
+
+ return this.remoteTransactionIdObject;
+ }
/*
* (non-Javadoc)
@@ -364,20 +376,16 @@
}
public void keepAlive() {
- try
- {
+ try {
this.dialogLock.lock();
- if(this.idleTimerInvoked)
- {
+ if (this.idleTimerInvoked) {
this.idleTimerActionTaken = true;
}
-
-
- }finally
- {
+
+ } finally {
this.dialogLock.unlock();
}
-
+
}
/**
@@ -447,7 +455,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
tcbm.encode(aos);
- this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress, this.localAddress, this.seqControl);
+ this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress,
+ this.localAddress,
this.seqControl);
this.setState(TRPseudoState.InitialSent);
this.scheduledComponentList.clear();
} catch (Throwable e) {
@@ -523,7 +532,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
tcbm.encode(aos);
- this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress, this.localAddress,
this.seqControl);
+ this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress,
+ this.localAddress,
this.seqControl);
this.setState(TRPseudoState.Active);
this.scheduledComponentList.clear();
} catch (Exception e) {
@@ -554,7 +564,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
tcbm.encode(aos);
- this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress, this.localAddress,
this.seqControl);
+ this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress,
+ this.localAddress,
this.seqControl);
this.scheduledComponentList.clear();
} catch (Exception e) {
// FIXME: add proper handling here.
TC-NOTICE ?
@@ -588,7 +599,7 @@
throw new TCAPSendException("Unstructured dialogs do not use
End");
}
- try{
+ try {
dialogLock.lock();
TCEndMessageImpl tcbm = null;
@@ -667,15 +678,17 @@
// state
} else {
- throw new TCAPSendException(String.format("State is not %s or %s: it
is %s", TRPseudoState.Active, TRPseudoState.InitialReceived, this.state));
+ throw new TCAPSendException(String.format("State is not %s or %s: it
is %s", TRPseudoState.Active,
+ TRPseudoState.InitialReceived,
this.state));
}
// FIXME: SPECS SAY HERE UI/ACN CAN BE SENT,
HOOOOOOOWWW!?
AsnOutputStream aos = new AsnOutputStream();
try {
tcbm.encode(aos);
- this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress, this.localAddress, this.seqControl);
-
+ this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress,
+ this.localAddress,
this.seqControl);
+
this.scheduledComponentList.clear();
} catch (Exception e) {
// FIXME: remove freshly added invokes to free
invoke ID??
@@ -684,7 +697,8 @@
}
throw new TCAPSendException("Failed to send TC-End message: " +
e.getMessage(), e);
} finally {
- //FIXME: is this proper place - should we not release in case of
error ?
+ // FIXME: is this proper place - should we not
release in case
+ // of error ?
release();
}
} finally {
@@ -733,7 +747,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
msg.encode(aos);
- this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress, this.localAddress, this.seqControl);
+ this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(),
this.remoteAddress,
+ this.localAddress,
this.seqControl);
this.scheduledComponentList.clear();
} catch (Exception e) {
// FIXME: remove freshly added invokes to free
invoke ID??
@@ -741,8 +756,8 @@
logger.error("Failed to send message:
", e);
}
throw new TCAPSendException("Failed to send TC-Uni message: " +
e.getMessage(), e);
-// } finally {
-// release();
+ // } finally {
+ // release();
}
} finally {
this.dialogLock.unlock();
@@ -762,10 +777,11 @@
try {
this.dialogLock.lock();
- if (this.state == TRPseudoState.InitialReceived || this.state ==
TRPseudoState.InitialSent || this.state == TRPseudoState.Active) {
+ if (this.state == TRPseudoState.InitialReceived || this.state ==
TRPseudoState.InitialSent
+ || this.state == TRPseudoState.Active) {
// allowed
DialogPortion dp = null;
- if (event.getUserInformation() != null ||
event.getDialogServiceUserType() != null) {
+ if (event.getUserInformation() != null ||
event.getDialogServiceUserType() != null) {
// User information can be absent in
TCAP V1
dp = TcapFactory.createDialogPortion();
@@ -827,7 +843,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
msg.encode(aos);
- this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress, this.localAddress,
this.seqControl);
+ this.provider.send(aos.toByteArray(),
event.getReturnMessageOnError(), this.remoteAddress,
+ this.localAddress,
this.seqControl);
this.scheduledComponentList.clear();
} catch (Exception e) {
@@ -878,7 +895,8 @@
invoke.setDialog(this);
// if the Invoke timeout value has not be reset
by TCAP-User
- // for this invocation we are setting it to the the TCAP stack default
value
+ // for this invocation we are setting it to the
the TCAP stack
+ // default value
if (invoke.getTimeout() ==
TCAPStackImpl._EMPTY_INVOKE_TIMEOUT)
invoke.setTimeout(this.provider.getStack().getInvokeTimeout());
}
@@ -912,10 +930,10 @@
public int getMaxUserDataLength() {
return this.provider.getMaxUserDataLength(remoteAddress,
localAddress);
- }
+ }
public int getDataLength(TCBeginRequest event) throws TCAPSendException
{
-
+
TCBeginMessageImpl tcbm = (TCBeginMessageImpl)
TcapFactory.createTCBeginMessage();
if (event.getApplicationContextName() != null) {
@@ -998,7 +1016,7 @@
}
throw new TCAPSendException("Error encoding
TCContinueRequest", e);
}
-
+
return aos.size();
}
@@ -1055,7 +1073,7 @@
}
throw new TCAPSendException("Error encoding
TCEndRequest", e);
}
-
+
return aos.size();
}
@@ -1094,10 +1112,10 @@
}
throw new TCAPSendException("Error encoding
TCUniRequest", e);
}
-
+
return aos.size();
}
-
+
// /////////////////
// LOCAL METHODS //
// /////////////////
@@ -1128,26 +1146,29 @@
void processUni(TCUniMessage msg, SccpAddress localAddress, SccpAddress
remoteAddress) {
-// TCUniIndicationImpl tcUniIndication = null;
+ // TCUniIndicationImpl tcUniIndication = null;
try {
this.dialogLock.lock();
// this is invoked ONLY for server.
-// if (state != TRPseudoState.Idle) {
-// // should we terminate dialog here?
-// if (logger.isEnabledFor(Level.ERROR)) {
-// logger.error("Received Uni primitive, but state is not: " +
TRPseudoState.Idle + ". Dialog: " + this);
-// }
-// return;
-//// throw new TCAPException("Received Uni primitive, but state is
not: " + TRPseudoState.Idle + ". Dialog: " + this);
-// }
+ // if (state != TRPseudoState.Idle) {
+ // // should we terminate dialog here?
+ // if (logger.isEnabledFor(Level.ERROR)) {
+ // logger.error("Received Uni primitive, but state is not:
" +
+ // TRPseudoState.Idle + ". Dialog: " + this);
+ // }
+ // return;
+ // // throw new
+ // TCAPException("Received Uni primitive, but state is not:
" +
+ // TRPseudoState.Idle + ". Dialog: " + this);
+ // }
// lets setup
this.setRemoteAddress(remoteAddress);
this.setLocalAddress(localAddress);
// no dialog portion!
// convert to indications
- TCUniIndicationImpl tcUniIndication = (TCUniIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
- .createUniIndication(this);
+ TCUniIndicationImpl tcUniIndication = (TCUniIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createUniIndication(this);
tcUniIndication.setDestinationAddress(localAddress);
tcUniIndication.setOriginatingAddress(remoteAddress);
@@ -1168,7 +1189,7 @@
// lets deliver to provider, this MUST not throw
anything
this.provider.deliver(this, tcUniIndication);
// schedule removal
-// this.release();
+ // this.release();
} finally {
this.dialogLock.unlock();
@@ -1186,7 +1207,8 @@
if (state != TRPseudoState.Idle) {
// should we terminate dialog here?
if (logger.isEnabledFor(Level.ERROR)) {
- logger.error("Received Begin primitive, but state is not: " +
TRPseudoState.Idle + ". Dialog: " + this);
+ logger.error("Received Begin primitive, but state is not: " +
TRPseudoState.Idle + ". Dialog: "
+ + this);
}
this.sendAbnormalDialog();
return;
@@ -1199,8 +1221,8 @@
this.setLocalAddress(localAddress);
this.setRemoteTransactionId(msg.getOriginatingTransactionId());
// convert to indications
- tcBeginIndication = (TCBeginIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
- .createBeginIndication(this);
+ tcBeginIndication = (TCBeginIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createBeginIndication(this);
tcBeginIndication.setDestinationAddress(localAddress);
tcBeginIndication.setOriginatingAddress(remoteAddress);
@@ -1231,7 +1253,7 @@
}
// lets deliver to provider
this.provider.deliver(this, tcBeginIndication);
-
+
} finally {
this.dialogLock.unlock();
}
@@ -1242,10 +1264,10 @@
TCContinueIndicationImpl tcContinueIndication = null;
try {
this.dialogLock.lock();
-
- if(this.previewMode) {
- tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
- .createContinueIndication(this);
+
+ if (this.previewMode) {
+ tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createContinueIndication(this);
this.setRemoteTransactionId(msg.getOriginatingTransactionId());
// here we will receive DialogResponse APDU -
if request was
@@ -1277,8 +1299,8 @@
if (state == TRPseudoState.InitialSent) {
restartIdleTimer();
- tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
-
.createContinueIndication(this);
+ tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createContinueIndication(this);
// in continue remote address MAY
change be cjanged, so lets
// update!
this.setRemoteAddress(remoteAddress);
@@ -1358,8 +1380,8 @@
restartIdleTimer();
// XXX: here NO APDU will be present,
hence, no ACN/UI
// change
- tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
-
.createContinueIndication(this);
+ tcContinueIndication = (TCContinueIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createContinueIndication(this);
tcContinueIndication.setOriginatingAddress(remoteAddress);
@@ -1371,7 +1393,8 @@
} else {
if (logger.isEnabledFor(Level.ERROR)) {
- logger.error("Received Continue primitive, but state is not
proper: " + this.state + ", Dialog: " + this);
+ logger.error("Received Continue primitive, but state is not
proper: " + this.state
+ + ", Dialog: "
+ this);
}
this.sendAbnormalDialog();
return;
@@ -1387,10 +1410,11 @@
TCEndIndicationImpl tcEndIndication = null;
try {
this.dialogLock.lock();
-
+
try {
if (this.previewMode) {
- tcEndIndication = (TCEndIndicationImpl) ((DialogPrimitiveFactoryImpl)
this.provider.getDialogPrimitiveFactory()).createEndIndication(this);
+ tcEndIndication = (TCEndIndicationImpl) ((DialogPrimitiveFactoryImpl)
this.provider
+
.getDialogPrimitiveFactory()).createEndIndication(this);
DialogPortion dialogPortion =
msg.getDialogPortion();
if (dialogPortion != null) {
@@ -1414,7 +1438,8 @@
this.provider.deliver(this,
tcEndIndication);
} else {
restartIdleTimer();
- tcEndIndication = (TCEndIndicationImpl) ((DialogPrimitiveFactoryImpl)
this.provider.getDialogPrimitiveFactory()).createEndIndication(this);
+ tcEndIndication = (TCEndIndicationImpl) ((DialogPrimitiveFactoryImpl)
this.provider
+
.getDialogPrimitiveFactory()).createEndIndication(this);
DialogPortion dialogPortion =
msg.getDialogPortion();
if (dialogPortion != null) {
@@ -1453,7 +1478,7 @@
}
protected void processAbort(TCAbortMessage msg, SccpAddress
localAddress2, SccpAddress remoteAddress2) {
-
+
try {
this.dialogLock.lock();
@@ -1496,12 +1521,12 @@
type =
PAbortCauseType.NoReasonGiven;
}
}
-
+
if (type != null) {
// its TC-P-Abort
- TCPAbortIndicationImpl tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
-
.createPAbortIndication(this);
+ TCPAbortIndicationImpl tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createPAbortIndication(this);
tcAbortIndication.setPAbortCause(type);
this.provider.deliver(this,
tcAbortIndication);
@@ -1559,7 +1584,8 @@
AsnOutputStream aos = new AsnOutputStream();
try {
msg.encode(aos);
- this.provider.send(aos.toByteArray(), false, this.remoteAddress,
this.localAddress, this.seqControl);
+ this.provider
+ .send(aos.toByteArray(), false, this.remoteAddress,
this.localAddress, this.seqControl);
} catch (Exception e) {
if (logger.isEnabledFor(Level.ERROR)) {
logger.error("Failed to send
message: ", e);
@@ -1567,15 +1593,15 @@
}
// sending to the local side
- tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
- .createPAbortIndication(this);
+ tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createPAbortIndication(this);
tcAbortIndication.setPAbortCause(PAbortCauseType.AbnormalDialogue);
tcAbortIndication.setLocalProviderOriginated(true);
this.provider.deliver(this, tcAbortIndication);
} finally {
this.release();
-// this.scheduledComponentList.clear();
+ // this.scheduledComponentList.clear();
}
} finally {
this.dialogLock.unlock();
@@ -1593,18 +1619,19 @@
try {
// sending to the remote side
- this.provider.sendProviderAbort(pAbortCause, this.remoteTransactionId,
this.remoteAddress, this.localAddress, this.seqControl);
+ this.provider.sendProviderAbort(pAbortCause, this.remoteTransactionId,
this.remoteAddress,
+ this.localAddress,
this.seqControl);
// sending to the local side
- tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider.getDialogPrimitiveFactory())
- .createPAbortIndication(this);
+ tcAbortIndication = (TCPAbortIndicationImpl)
((DialogPrimitiveFactoryImpl) this.provider
+
.getDialogPrimitiveFactory()).createPAbortIndication(this);
tcAbortIndication.setPAbortCause(pAbortCause);
tcAbortIndication.setLocalProviderOriginated(true);
this.provider.deliver(this, tcAbortIndication);
} finally {
this.release();
-// this.scheduledComponentList.clear();
+ // this.scheduledComponentList.clear();
}
} finally {
this.dialogLock.unlock();
@@ -1615,7 +1642,7 @@
if (components == null) {
return null;
}
-
+
List<Component> resultingIndications = new
ArrayList<Component>();
for (Component ci : components) {
Long invokeId = ci.getInvokeId();
@@ -1714,9 +1741,10 @@
this.state = newState;
if (newState == TRPseudoState.Expunged) {
stopIdleTimer();
-// RemovalTimerTask rtt = new RemovalTimerTask();
-// rtt.d = this;
-// this.executor.schedule(rtt, removeTaskTimeout,
TimeUnit.MILLISECONDS);
+ // RemovalTimerTask rtt = new
RemovalTimerTask();
+ // rtt.d = this;
+ // this.executor.schedule(rtt,
removeTaskTimeout,
+ // TimeUnit.MILLISECONDS);
provider.release(this);
}
} finally {
@@ -1724,13 +1752,12 @@
}
}
-
- private void startIdleTimer()
- {
+
+ private void startIdleTimer() {
if (!this.structured)
return;
-// if (this.previewMode)
-// return;
+ // if (this.previewMode)
+ // return;
try {
this.dialogLock.lock();
@@ -1747,8 +1774,7 @@
}
}
- private void stopIdleTimer()
- {
+ private void stopIdleTimer() {
if (!this.structured)
return;
@@ -1764,16 +1790,14 @@
}
}
- private void restartIdleTimer()
- {
+ private void restartIdleTimer() {
stopIdleTimer();
startIdleTimer();
}
-
-
+
private class IdleTimerTask implements Runnable {
DialogImpl d;
-
+
public void run() {
try {
dialogLock.lock();
@@ -1804,7 +1828,7 @@
// IND like methods //
// ///////////////////
public void operationEnded(InvokeImpl tcInvokeRequestImpl) {
- try{
+ try {
this.dialogLock.lock();
// this op died cause of timeout, TC-L-CANCEL!
int index =
getIndexFromInvokeId(tcInvokeRequestImpl.getInvokeId());
@@ -1812,8 +1836,7 @@
this.operationsSent[index] = null;
// lets call listener
// This is done actually with COmponentIndication ....
- }finally
- {
+ } finally {
this.dialogLock.unlock();
}
}
@@ -1827,17 +1850,16 @@
*/
public void operationTimedOut(InvokeImpl invoke) {
// this op died cause of timeout, TC-L-CANCEL!
- try{
+ try {
this.dialogLock.lock();
int index = getIndexFromInvokeId(invoke.getInvokeId());
freeInvokeId(invoke.getInvokeId());
this.operationsSent[index] = null;
// lets call listener
-
- }finally
- {
+
+ } finally {
this.dialogLock.unlock();
-
+
}
this.provider.operationTimedOut(invoke);
}
@@ -1885,7 +1907,7 @@
@Override
public String toString() {
- return super.toString() + ": Local[" + this.localTransactionId + "]
Remote[" + this.remoteTransactionId
+ return super.toString() + ": Local[" + this.getLocalDialogId() + "]
Remote[" + this.getRemoteDialogId()
+ "], LocalAddress[" + localAddress + "] RemoteAddress[" +
this.remoteAddress + "]";
}
}
=======================================
---
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Mon Dec 10 02:49:37 2012
+++
/tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java
Mon Dec 10 02:57:05 2012
@@ -1,6 +1,6 @@
/*
- * TeleStax, Open Source Cloud Communications Copyright 2012.
- * and individual contributors
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2012, Telestax Inc and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -367,7 +367,7 @@
}
public void release(DialogImpl d) {
- Long did = d.getDialogId();
+ Long did = d.getLocalDialogId();
if (!d.getPreviewMode()) {
synchronized (this.dialogs) {
=======================================
---
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
Mon Dec 10 02:49:37 2012
+++
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/TCAPFunctionalTest.java
Mon Dec 10 02:57:05 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2012, Telestax Inc and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -24,6 +24,8 @@
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
import static org.testng.Assert.fail;
import java.util.ArrayList;
@@ -135,11 +137,21 @@
serverExpectedEvents.add(te);
client.startClientDialog();
+ assertNotNull(client.dialog.getLocalAddress());
+ assertNull(client.dialog.getRemoteDialogId());
+
client.sendBegin();
client.waitFor(WAIT_TIME);
+
server.sendContinue();
+ assertNotNull(server.dialog.getLocalAddress());
+ assertNotNull(server.dialog.getRemoteDialogId());
+
client.waitFor(WAIT_TIME);
client.sendEnd(TerminationType.Basic);
+ assertNotNull(client.dialog.getLocalAddress());
+ assertNotNull(client.dialog.getRemoteDialogId());
+
client.waitFor(WAIT_TIME);
// waitForEnd();