2 new revisions:
Revision: c2d84e757689
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Dec 6 23:59:09 2012
Log: SCCP new features - implementations
http://code.google.com/p/jss7/source/detail?r=c2d84e757689
Revision: 0ec91bc9a404
Author: Sergey Vetyutnev <[email protected]>
Date: Fri Dec 7 00:03:57 2012
Log: Merge remote-tracking branch 'origin/sccp' into SCCP_198
http://code.google.com/p/jss7/source/detail?r=0ec91bc9a404
==============================================================================
Revision: c2d84e757689
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Dec 6 23:59:09 2012
Log: SCCP new features - implementations
http://code.google.com/p/jss7/source/detail?r=c2d84e757689
Added:
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/CallingPartyAddressTest.java
Modified:
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/Rule.java
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/message/SccpAddressedMessage.java
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/parameter/ProtocolClass.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpRoutingControl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageImpl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageImpl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/parameter/ProtocolClassImpl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterImpl.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparator.java
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleImpl.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterTest.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparatorTest.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleTest.java
=======================================
--- /dev/null
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/CallingPartyAddressTest.java
Thu Dec 6 23:59:09 2012
@@ -0,0 +1,135 @@
+/*
+ * 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.sccp.impl.messageflow;
+
+import static org.testng.Assert.*;
+
+import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
+import org.mobicents.protocols.ss7.sccp.LoadSharingAlgorithm;
+import org.mobicents.protocols.ss7.sccp.OriginationType;
+import org.mobicents.protocols.ss7.sccp.RuleType;
+import org.mobicents.protocols.ss7.sccp.impl.SccpHarness;
+import org.mobicents.protocols.ss7.sccp.impl.SccpStackImplProxy;
+import org.mobicents.protocols.ss7.sccp.impl.User;
+import org.mobicents.protocols.ss7.sccp.message.SccpDataMessage;
+import org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle;
+import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
+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 CallingPartyAddressTest extends SccpHarness {
+
+ private SccpAddress a1, a2;
+
+ public CallingPartyAddressTest() {
+ }
+
+ @BeforeClass
+ public void setUpClass() throws Exception {
+ this.sccpStack1Name = "MessageTransferTestSccpStack1";
+ this.sccpStack2Name = "MessageTransferTestSccpStack2";
+ }
+
+ @AfterClass
+ public void tearDownClass() throws Exception {
+ }
+
+ protected void createStack1() {
+ sccpStack1 = new SccpStackImplProxy("sspTestSccpStack1");
+ sccpProvider1 = sccpStack1.getSccpProvider();
+ }
+
+ protected void createStack2() {
+ sccpStack2 = new SccpStackImplProxy("sspTestSccpStack2");
+ sccpProvider2 = sccpStack2.getSccpProvider();
+ }
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ super.tearDown();
+ }
+
+ public byte[] getDataSrc() {
+ return new byte[] { 11, 12, 13, 14, 15 };
+ }
+
+ @Test(groups = { "SccpMessage", "functional.transfer" })
+ public void testTransfer() throws Exception {
+
+ a1 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN,
getStack1PC(), null, 8);
+ a2 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN,
getStack2PC(), null, 8);
+
+ User u1 = new User(sccpStack1.getSccpProvider(), a1, a2,
getSSN());
+ User u2 = new User(sccpStack2.getSccpProvider(), a2, a1,
getSSN());
+
+ u1.register();
+ u2.register();
+
+ Thread.sleep(100);
+
+ // no newCallingPartyAddress
+ SccpAddress primaryAddress = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, getStack2PC(),
GlobalTitle.getInstance(1, "111111"), 8);
+ sccpStack1.getRouter().addRoutingAddress(1, primaryAddress);
+ SccpAddress newCallingPartyAddress = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "222222"), 8);
+ sccpStack1.getRouter().addRoutingAddress(2,
newCallingPartyAddress);
+ SccpAddress pattern = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ sccpStack1.getRouter().addRule(1, RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern, "K", 1, -1,
null);
+
+ SccpAddress a3 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ SccpDataMessage message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+
+ assertEquals(u1.getMessages().size(), 0);
+ assertEquals(u2.getMessages().size(), 1);
+ SccpDataMessage dMsg = (SccpDataMessage)
u2.getMessages().get(0);
+ assertNull(dMsg.getCallingPartyAddress().getGlobalTitle());
+
+ // present newCallingPartyAddress
+ sccpStack1.getRouter().removeRule(1);
+ sccpStack1.getRouter().addRule(1, RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern, "K", 1, -1,
2);
+
+ message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+
+ assertEquals(u1.getMessages().size(), 0);
+ assertEquals(u2.getMessages().size(), 2);
+ dMsg = (SccpDataMessage) u2.getMessages().get(1);
+
assertTrue(dMsg.getCallingPartyAddress().getGlobalTitle().getDigits().equals("222222"));
+ }
+}
+
=======================================
--- /sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/Rule.java
Thu Dec 6 03:29:38 2012
+++ /sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/Rule.java
Thu Dec 6 23:59:09 2012
@@ -42,11 +42,11 @@
public int getSecondaryAddressId();
- public Integer getNewCallingPartyAddressAddressId();
+ public Integer getNewCallingPartyAddressId();
public OriginationType getOriginationType();
- public boolean matches(SccpAddress address);
+ public boolean matches(SccpAddress address, boolean isMtpOriginated);
public SccpAddress translate(SccpAddress address, SccpAddress
ruleAddress);
=======================================
---
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/message/SccpAddressedMessage.java
Mon Apr 23 10:53:14 2012
+++
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/message/SccpAddressedMessage.java
Thu Dec 6 23:59:09 2012
@@ -40,6 +40,8 @@
public boolean getReturnMessageOnError();
+ public void clearReturnMessageOnError();
+
public boolean getSccpCreatesSls();
public HopCounter getHopCounter();
=======================================
---
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/parameter/ProtocolClass.java
Sat Mar 31 03:29:55 2012
+++
/sccp/sccp-api/src/main/java/org/mobicents/protocols/ss7/sccp/parameter/ProtocolClass.java
Thu Dec 6 23:59:09 2012
@@ -54,4 +54,10 @@
* @return
*/
public boolean getReturnMessageOnError();
+
+
+ /**
+ * Clear a flag "ReturnMessageOnError"
+ */
+ public void clearReturnMessageOnError();
}
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpRoutingControl.java
Thu Dec 6 03:29:38 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpRoutingControl.java
Thu Dec 6 23:59:09 2012
@@ -309,7 +309,7 @@
SccpAddress calledPartyAddress = msg.getCalledPartyAddress();
- Rule rule =
this.sccpStackImpl.router.findRule(calledPartyAddress);
+ Rule rule = this.sccpStackImpl.router.findRule(calledPartyAddress,
msg.getIsMtpOriginated());
if (rule == null) {
if (logger.isEnabledFor(Level.WARN)) {
logger.warn(String.format("Received SccpMessage for Translation but no
matching Rule found for local routing\nSccpMessage=%s", msg));
@@ -352,15 +352,20 @@
}
}
- SccpAddress translationAddress;
+ SccpAddress translationAddress = null;
+ SccpAddress translationAddress2 = null;
if (resPri == TranslationAddressCheckingResult.destinationAvailable &&
resSec != TranslationAddressCheckingResult.destinationAvailable) {
translationAddress = translationAddressPri;
} else if (resPri !=
TranslationAddressCheckingResult.destinationAvailable && resSec ==
TranslationAddressCheckingResult.destinationAvailable) {
translationAddress = translationAddressSec;
} else {
- if (rule.getRuleType() != RuleType.Loadshared) {
+ switch(rule.getRuleType()) {
+ case Solitary:
+ case Dominant:
translationAddress = translationAddressPri;
- } else {
+ break;
+
+ case Loadshared:
// loadsharing case and both destinations are
available
if (msg.getSccpCreatesSls()) {
if (this.sccpStackImpl.newSelector())
@@ -373,6 +378,24 @@
else
translationAddress =
translationAddressSec;
}
+ break;
+
+ case Broadcast:
+ // Broadcast case and both destinations are
available
+ translationAddress = translationAddressPri;
+ translationAddress2 = translationAddressSec;
+ break;
+ }
+ }
+
+ // changing calling party address if a rule has
NewCallingPartyAddress
+ if (rule.getNewCallingPartyAddressId() != null) {
+ SccpAddress newCallingPartyAddress =
this.sccpStackImpl.router.getRoutingAddress(rule.getNewCallingPartyAddressId());
+ if (newCallingPartyAddress != null) {
+
msg.setCallingPartyAddress(newCallingPartyAddress);
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("New CallingPartyAddress assigned after
translation = %s", newCallingPartyAddress));
+ }
}
}
@@ -386,6 +409,20 @@
// routing procedures then continue's
this.route(msg);
+
+ if (translationAddress2 != null) {
+ // for broadcast mode - route to a secondary destination if it is
available
+ address = rule.translate(calledPartyAddress,
translationAddress2);
+ msg.setCalledPartyAddress(address);
+ msg.clearReturnMessageOnError();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("CalledPartyAddress after translation - a
second broadcast address = %s", address));
+ }
+
+ // routing procedures then continue's
+ this.route(msg);
+ }
}
private boolean selectLoadSharingRoute(LoadSharingAlgorithm
loadSharingAlgo, SccpAddressedMessageImpl msg) {
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java
Thu Dec 6 03:29:38 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java
Thu Dec 6 23:59:09 2012
@@ -520,7 +520,7 @@
private int getMaxUserDataLengthForGT(SccpAddress calledPartyAddress,
SccpAddress callingPartyAddress) {
- Rule rule = this.router.findRule(calledPartyAddress);
+ Rule rule = this.router.findRule(calledPartyAddress, false);
if (rule == null) {
return 0;
}
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageImpl.java
Wed May 30 01:47:09 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageImpl.java
Thu Dec 6 23:59:09 2012
@@ -91,6 +91,11 @@
else
return false;
}
+
+ public void clearReturnMessageOnError() {
+ if (this.protocolClass != null)
+ this.protocolClass.clearReturnMessageOnError();
+ }
public boolean getSccpCreatesSls() {
if (this.protocolClass == null || this.protocolClass.getProtocolClass()
== 0)
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageImpl.java
Wed May 30 01:47:09 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageImpl.java
Thu Dec 6 23:59:09 2012
@@ -90,6 +90,9 @@
public boolean getReturnMessageOnError() {
return false;
}
+
+ public void clearReturnMessageOnError() {
+ }
public boolean getSccpCreatesSls() {
return true;
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/parameter/ProtocolClassImpl.java
Wed May 30 01:47:09 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/parameter/ProtocolClassImpl.java
Thu Dec 6 23:59:09 2012
@@ -69,6 +69,11 @@
public boolean getReturnMessageOnError() {
return (this.msgHandling & HANDLING_RET_ERR) != 0 ? true :
false;
}
+
+ public void clearReturnMessageOnError() {
+ int mask = HANDLING_RET_ERR ^ (-1);
+ this.msgHandling = this.msgHandling & mask;
+ }
public void decode(InputStream in) throws IOException {
if (in.read() != 1) {
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterImpl.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterImpl.java
Thu Dec 6 23:59:09 2012
@@ -280,11 +280,11 @@
* called party address
* @return the rule with match to the called party address
*/
- public Rule findRule(SccpAddress calledParty) {
+ public Rule findRule(SccpAddress calledParty, boolean isMtpOriginated) {
for (FastMap.Entry<Integer, Rule> e = this.rulesMap.head(), end =
this.rulesMap.tail(); (e = e.getNext()) != end;) {
Rule rule = e.getValue();
- if (rule.matches(calledParty)) {
+ if (rule.matches(calledParty, isMtpOriginated)) {
return rule;
}
}
@@ -410,7 +410,7 @@
RuleImpl rule = new RuleImpl(ruleType, algo, originationType, pattern,
mask);
rule.setPrimaryAddressId(pAddressId);
rule.setSecondaryAddressId(sAddressId);
-
rule.setNewCallingPartyAddressAddressId(newCallingPartyAddressAddressId);
+
rule.setNewCallingPartyAddressId(newCallingPartyAddressAddressId);
rule.setRuleId(id);
RuleImpl[] rulesArray = new
RuleImpl[(this.rulesMap.size() + 1)];
@@ -482,7 +482,7 @@
RuleImpl rule = new RuleImpl(ruleType, algo, originationType, pattern,
mask);
rule.setPrimaryAddressId(pAddressId);
rule.setSecondaryAddressId(sAddressId);
-
rule.setNewCallingPartyAddressAddressId(newCallingPartyAddressAddressId);
+
rule.setNewCallingPartyAddressId(newCallingPartyAddressAddressId);
rule.setRuleId(id);
RuleImpl[] rulesArray = new
RuleImpl[(this.rulesMap.size() + 1)];
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparator.java
Tue Nov 13 06:18:58 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparator.java
Thu Dec 6 23:59:09 2012
@@ -23,6 +23,8 @@
import java.util.Comparator;
+import org.mobicents.protocols.ss7.sccp.OriginationType;
+
/**
* <p>
* A comparison function which imposes ordering on collection of {@link
RuleImpl}
@@ -75,6 +77,12 @@
digits1 = digits1.replaceAll(SECTION_SEPARTOR, "");
digits2 = digits2.replaceAll(SECTION_SEPARTOR, "");
+ // If a rule 1 is not OriginationType.All and rule 2 is
OriginationType.All we put rule 1 first
+ if (o1.getOriginationType() != OriginationType.All &&
o2.getOriginationType() == OriginationType.All)
+ return -1;
+ if (o1.getOriginationType() == OriginationType.All &&
o2.getOriginationType() != OriginationType.All)
+ return 1;
+
// If any digit is just wildcard "*" return 1 indicating it
should be
// below the other
if (digits1.equals(WILDCARD_ANY_STRING)) {
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleImpl.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleImpl.java
Thu Dec 6 23:59:09 2012
@@ -87,7 +87,7 @@
/** Translation method */
private int primaryAddressId = 0;
private int secondaryAddressId = 0;
- private Integer newCallingPartyAddressAddressId = null;
+ private Integer newCallingPartyAddressId = null;
private String mask = null;
@@ -184,12 +184,12 @@
this.secondaryAddressId = secondaryAddressId;
}
- public Integer getNewCallingPartyAddressAddressId() {
- return newCallingPartyAddressAddressId;
+ public Integer getNewCallingPartyAddressId() {
+ return newCallingPartyAddressId;
}
- public void setNewCallingPartyAddressAddressId(Integer
newCallingPartyAddressAddressId) {
- this.newCallingPartyAddressAddressId =
newCallingPartyAddressAddressId;
+ public void setNewCallingPartyAddressId(Integer newCallingPartyAddressId)
{
+ this.newCallingPartyAddressId = newCallingPartyAddressId;
}
/**
@@ -251,13 +251,13 @@
gt = GlobalTitle.getInstance(((GT0010) primaryGt).getTranslationType(),
translatedDigits);
break;
case NO_GLOBAL_TITLE_INCLUDED:
- // Use Global Title from received aadress
+ // Use Global Title from received address
break;
}
return gt;
}
- public boolean matches(SccpAddress address) {
+ public boolean matches(SccpAddress address, boolean isMtpOriginated) {
// Rule is for GTT only
if (address.getAddressIndicator().getRoutingIndicator() ==
RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN) {
@@ -267,6 +267,12 @@
return false;
}
+ // checking firstly about rule OriginationType
+ if (this.getOriginationType() == OriginationType.LocalOriginated &&
isMtpOriginated)
+ return false;
+ if (this.getOriginationType() == OriginationType.RemoteOriginated
&& !isMtpOriginated)
+ return false;
+
// Routing on GTT
GlobalTitleIndicator gti =
address.getAddressIndicator().getGlobalTitleIndicator();
GlobalTitle patternGT = pattern.getGlobalTitle();
@@ -497,9 +503,9 @@
rule.secondaryAddressId =
xml.getAttribute(SECONDARY_ADDRESS).toInt();
CharArray cha =
xml.getAttribute(NEW_CALLING_PARTY_ADDRESS);
if (cha != null)
- rule.newCallingPartyAddressAddressId =
cha.toInt();
+ rule.newCallingPartyAddressId = cha.toInt();
else
- rule.newCallingPartyAddressAddressId = null;
+ rule.newCallingPartyAddressId = null;
rule.pattern = xml.get(PATTERN, SccpAddress.class);
rule.configure();
}
@@ -511,8 +517,8 @@
xml.setAttribute(MASK, rule.mask);
xml.setAttribute(PRIMARY_ADDRESS,
rule.primaryAddressId);
xml.setAttribute(SECONDARY_ADDRESS,
rule.secondaryAddressId);
- if (rule.newCallingPartyAddressAddressId != null)
- xml.setAttribute(NEW_CALLING_PARTY_ADDRESS,
rule.newCallingPartyAddressAddressId);
+ if (rule.newCallingPartyAddressId != null)
+ xml.setAttribute(NEW_CALLING_PARTY_ADDRESS,
rule.newCallingPartyAddressId);
xml.add(rule.pattern, PATTERN, SccpAddress.class);
}
};
@@ -557,10 +563,10 @@
buff.append(CLOSE_BRACKET);
buff.append(SEPARATOR);
- if (newCallingPartyAddressAddressId != null) {
+ if (newCallingPartyAddressId != null) {
buff.append(NEW_CALLING_PARTY_ADDRESS);
buff.append(OPEN_BRACKET);
- buff.append(newCallingPartyAddressAddressId);
+ buff.append(newCallingPartyAddressId);
buff.append(CLOSE_BRACKET);
buff.append(SEPARATOR);
}
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java
Thu Dec 6 05:27:17 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java
Thu Dec 6 23:59:09 2012
@@ -315,6 +315,57 @@
this.mtp3UserPart1.sendResumeMessageToLocalUser(getStack2PC());
Thread.sleep(100);
+ // ---- Broadcast case
+ sccpStack1.getRouter().removeRule(1);
+ sccpStack1.getRouter().removeRule(2);
+ sccpStack1.getRouter().addRule(1, RuleType.Broadcast,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern, "K", 1, 3,
null);
+
+ // Primary and backup are available
+ a3 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+ assertEquals(u1.getMessages().size(), 4);
+ assertEquals(u2.getMessages().size(), 9);
+ assertEquals(mtp3UserPart11.getMessages().size(), 5);
+
+ // Primary is available backup is disabled
+ this.mtp3UserPart1.sendPauseMessageToLocalUser(12);
+ Thread.sleep(100);
+ a3 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+ assertEquals(u1.getMessages().size(), 4);
+ assertEquals(u2.getMessages().size(), 10);
+ assertEquals(mtp3UserPart11.getMessages().size(), 5);
+
+ // Primary is disabled backup is available
+ this.mtp3UserPart1.sendResumeMessageToLocalUser(12);
+ this.mtp3UserPart1.sendPauseMessageToLocalUser(getStack2PC());
+ Thread.sleep(100);
+ a3 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+ assertEquals(u1.getMessages().size(), 4);
+ assertEquals(u2.getMessages().size(), 10);
+ assertEquals(mtp3UserPart11.getMessages().size(), 6);
+
+ // Primary and backup are disabled
+ this.mtp3UserPart1.sendPauseMessageToLocalUser(12);
+ Thread.sleep(100);
+ a3 = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "111111"), 0);
+ message =
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a3, a1,
getDataSrc(), 0, 8, true, null, null);
+ sccpProvider1.send(message);
+ Thread.sleep(100);
+ assertEquals(u1.getMessages().size(), 5);
+ assertEquals(u2.getMessages().size(), 10);
+ assertEquals(mtp3UserPart11.getMessages().size(), 6);
+
+ this.mtp3UserPart1.sendResumeMessageToLocalUser(12);
+ this.mtp3UserPart1.sendResumeMessageToLocalUser(getStack2PC());
+ Thread.sleep(100);
}
}
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java
Tue Nov 13 06:18:58 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java
Thu Dec 6 23:59:09 2012
@@ -176,25 +176,6 @@
assertTrue(Arrays.equals(nMsg.getData(), getDataSrc()));
assertEquals(nMsg.getReturnCause().getValue(),
ReturnCauseValue.SCCP_FAILURE);
- // ....................
- // attempt to transfer a UDT message: U1 -> U2(unregistered ssn
at U2,
- // but this ssn is registered at U1 as remoteSsn) ->
- // error + SSP
- // message =
- //
this.sccpProvider1.getMessageFactory().createDataMessageClass1(a2_1,
- // a1, getDataSrc(), 0, 8, true, null, null);
- // resource1.addRemoteSsn(18, new
RemoteSubSystem(getStack2PC(), 18, 0,
- // false));
- // sccpProvider1.send(message);
- // Thread.sleep(100);
- // assertEquals(u1.getMessages().size(), 6);
- // assertEquals(u2.getMessages().size(), 1);
- // nMsg = (SccpNoticeMessage) u1.getMessages().get(3);
- // assertTrue(Arrays.equals(nMsg.getData(), getDataSrc()));
- // assertEquals(nMsg.getReturnCause().getValue(),
- // ReturnCauseValue.SCCP_FAILURE);
- // ....................
-
// transfer a splitted XUDT message: U1 -> U2 - success
sccpStack1.getRouter().removeLongMessageRule(1);
sccpStack1.getRouter().addLongMessageRule(1, 2, 2,
LongMessageRuleType.XudtEnabled);
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterTest.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RouterTest.java
Thu Dec 6 23:59:09 2012
@@ -117,20 +117,6 @@
assertEquals(pa.getSignalingPointCode(), 321);
assertEquals(router.getRoutingAddresses().size(), 1);
-// assertEquals(router.getBackupAddresses().size(), 0);
-//
-// router.addBackupAddress(1, primaryAddr1);
-// assertEquals(router.getBackupAddresses().size(), 1);
-//
-// router.addBackupAddress(2, primaryAddr2);
-// assertEquals(router.getBackupAddresses().size(), 2);
-
-// router.removeBackupAddress(1);
-// pa = router.getBackupAddresses().values().iterator().next();
-// assertNotNull(pa);
-// assertEquals(pa.getSignalingPointCode(), 321);
-// assertEquals(router.getBackupAddresses().size(), 1);
-
SccpAddress pattern = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "123456789"), 0);
@@ -181,7 +167,6 @@
public void testSerialization() throws Exception {
router.addRoutingAddress(1, primaryAddr1);
router.addRoutingAddress(2, primaryAddr2);
-// router.addBackupAddress(1, primaryAddr1);
SccpAddress pattern = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "123456789"), 0);
@@ -197,19 +182,17 @@
Rule rl = router1.getRule(1);
SccpAddress adp = router1.getRoutingAddress(2);
-// SccpAddress adb = router1.getBackupAddress(1);
LongMessageRule lmr = router1.getLongMessageRule(1);
Mtp3ServiceAccessPoint sap =
router1.getMtp3ServiceAccessPoint(3);
Mtp3Destination dst = sap.getMtp3Destination(1);
assertEquals(rl.getPrimaryAddressId(), 1);
assertEquals(rl.getSecondaryAddressId(), 2);
- assertNull(rl.getNewCallingPartyAddressAddressId());
+ assertNull(rl.getNewCallingPartyAddressId());
assertEquals(rl.getLoadSharingAlgorithm(),
LoadSharingAlgorithm.Bit4);
assertEquals(rl.getOriginationType(),
OriginationType.RemoteOriginated);
- assertNull(rl.getNewCallingPartyAddressAddressId());
+ assertNull(rl.getNewCallingPartyAddressId());
assertEquals(adp.getSignalingPointCode(),
primaryAddr2.getSignalingPointCode());
-// assertEquals(adb.getSignalingPointCode(),
primaryAddr1.getSignalingPointCode());
assertEquals(lmr.getFirstSpc(), 1);
assertEquals(sap.getMtp3Destinations().size(), 1);
assertEquals(dst.getLastDpc(), 110);
@@ -293,7 +276,7 @@
// Rule 6
SccpAddress calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "123456"), 0);
- Rule rule = router.findRule(calledParty);
+ Rule rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern6, rule.getPattern());
@@ -304,7 +287,7 @@
// Rule 7
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"1234567890"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern7, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -314,7 +297,7 @@
// Rule 1
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"80012039"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern1, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -324,7 +307,7 @@
// Rule 5
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"800120349"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern5, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -334,7 +317,7 @@
// Rule 4
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"801203459"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern4, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -344,7 +327,7 @@
// Rule 8
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"999123456"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern8, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -354,7 +337,7 @@
// Rule 3
calledParty = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1,
"919123456"), 0);
- rule = router.findRule(calledParty);
+ rule = router.findRule(calledParty, false);
assertEquals(LoadSharingAlgorithm.Undefined,
rule.getLoadSharingAlgorithm());
assertEquals(pattern3, rule.getPattern());
assertEquals(RuleType.Solitary, rule.getRuleType());
@@ -362,6 +345,56 @@
assertEquals("K/K/K/K", rule.getMask());
}
+
+ /**
+ * Test of Ordering with OriginationType.
+ */
+ @Test(groups = { "router", "functional.order" })
+ public void testOrderingWithOriginationType() throws Exception {
+ // Rule 1
+ primaryAddr1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 123,
GlobalTitle.getInstance(1,
+ "999"), 0);
+ router.addRoutingAddress(1, primaryAddr1);
+
+ SccpAddress pattern1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "*"), 0);
+ router.addRule(1, RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.All, pattern1, "K", 1, -1, null);
+
+ // Rule 2
+ router.addRule(2, RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.LocalOriginated, pattern1, "K", 1, -1, null);
+
+ // Rule 3
+ SccpAddress pattern2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "999"), 0);
+ router.addRule(3, RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.All, pattern2, "K", 1, -1, null);
+
+ // Rule 4
+ router.addRule(4, RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.RemoteOriginated, pattern2, "K", 1, -1, null);
+
+ // TEST find rule
+ boolean localOriginatedSign = false;
+ boolean remoteOriginatedSign = true;
+
+ SccpAddress calledParty1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "123456"), 0);
+ SccpAddress calledParty2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "999"), 0);
+
+ Rule rule1 = router.findRule(calledParty1, localOriginatedSign);
+ Rule rule2 = router.findRule(calledParty1,
remoteOriginatedSign);
+ Rule rule3 = router.findRule(calledParty2, localOriginatedSign);
+ Rule rule4 = router.findRule(calledParty2,
remoteOriginatedSign);
+
+
assertTrue(rule1.getPattern().getGlobalTitle().getDigits().equals("*"));
+ assertEquals(rule1.getOriginationType(),
OriginationType.LocalOriginated);
+
+
assertTrue(rule2.getPattern().getGlobalTitle().getDigits().equals("*"));
+ assertEquals(rule2.getOriginationType(), OriginationType.All);
+
+
assertTrue(rule3.getPattern().getGlobalTitle().getDigits().equals("*"));
+ assertEquals(rule3.getOriginationType(),
OriginationType.LocalOriginated);
+
+
assertTrue(rule4.getPattern().getGlobalTitle().getDigits().equals("999"));
+ assertEquals(rule4.getOriginationType(),
OriginationType.RemoteOriginated);
+
+
+ }
private class TestSccpStackImpl implements SccpStack {
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparatorTest.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleComparatorTest.java
Thu Dec 6 23:59:09 2012
@@ -66,12 +66,18 @@
SccpAddress pattern1 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "800/????/9"), 0);
RuleImpl rule1 = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern1, "R/K/R");
+ RuleImpl rule1a = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.LocalOriginated,
pattern1, "R/K/R");
+
SccpAddress pattern2 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "*"), 0);
RuleImpl rule2 = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern2, "K");
+ RuleImpl rule2a = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.LocalOriginated,
pattern2, "K");
+
SccpAddress pattern3 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "9/?/9/*"), 0);
RuleImpl rule3 = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern3, "K/K/K/K");
+ RuleImpl rule3a = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.RemoteOriginated,
pattern3, "K/K/K/K");
+
SccpAddress pattern4 = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "80/??/0/???/9"), 0);
RuleImpl rule4 = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern4, "R/K/R/K/R");
@@ -88,18 +94,22 @@
RuleImpl rule8 = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.All, pattern8, "R/K");
// This is unsorted
- RuleImpl[] rules = new RuleImpl[] { rule1, rule2, rule3, rule4, rule5,
rule6, rule7, rule8 };
+ RuleImpl[] rules = new RuleImpl[] { rule1, rule2, rule3, rule4, rule5,
rule6, rule7, rule8, rule1a, rule2a, rule3a };
// Sort
Arrays.sort(rules, ruleComparator);
- assertEquals(rule6, rules[0]);
- assertEquals(rule7, rules[1]);
- assertEquals(rule1, rules[2]);
- assertEquals(rule5, rules[3]);
- assertEquals(rule4, rules[4]);
- assertEquals(rule8, rules[5]);
- assertEquals(rule3, rules[6]);
- assertEquals(rule2, rules[7]);
+ assertEquals(rule1a, rules[0]);
+ assertEquals(rule3a, rules[1]);
+ assertEquals(rule2a, rules[2]);
+
+ assertEquals(rule6, rules[3]);
+ assertEquals(rule7, rules[4]);
+ assertEquals(rule1, rules[5]);
+ assertEquals(rule5, rules[6]);
+ assertEquals(rule4, rules[7]);
+ assertEquals(rule8, rules[8]);
+ assertEquals(rule3, rules[9]);
+ assertEquals(rule2, rules[10]);
}
}
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleTest.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/router/RuleTest.java
Thu Dec 6 23:59:09 2012
@@ -42,6 +42,9 @@
import org.mobicents.protocols.ss7.sccp.LoadSharingAlgorithm;
import org.mobicents.protocols.ss7.sccp.OriginationType;
import org.mobicents.protocols.ss7.sccp.RuleType;
+import org.mobicents.protocols.ss7.sccp.impl.SccpStackImpl;
+import org.mobicents.protocols.ss7.sccp.impl.message.MessageFactoryImpl;
+import org.mobicents.protocols.ss7.sccp.message.SccpMessage;
import org.mobicents.protocols.ss7.sccp.parameter.GT0100;
import org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle;
import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
@@ -92,7 +95,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "123456789"), 0);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -117,7 +120,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "1234567"), 0);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -142,7 +145,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "4414257897897"), 0);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -166,7 +169,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "4414257897897"), 0);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -192,7 +195,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(0, NumberingPlan.valueOf(1),
NatureOfAddress.valueOf(4), "4414257897897"),
6);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -222,7 +225,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "1234567"), 8);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -247,7 +250,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "55"), 8);
// TODO: the exception is here
- assertFalse(rule.matches(address));
+ assertFalse(rule.matches(address, false));
}
@Test(groups = { "router", "functional.translate" })
@@ -263,7 +266,7 @@
SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "222"), 8);
- assertTrue(rule.matches(address));
+ assertTrue(rule.matches(address, false));
// TODO: the exception is here
SccpAddress translatedAddress = rule.translate(address,
primaryAddress);
@@ -274,6 +277,43 @@
assertEquals(translatedAddress.getSubsystemNumber(), 8);
assertEquals(translatedAddress.getGlobalTitle().getDigits(),
"222");
}
+
+ @Test(groups = { "router", "functional.translate" })
+ public void testTranslate9() throws Exception {
+ // OriginationType checking
+
+ SccpAddress pattern = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "*"), 0);
+
+ SccpAddress address = new
SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0,
GlobalTitle.getInstance(1, "222"), 8);
+
+ SccpStackImpl stack = new SccpStackImpl("test");
+ MessageFactoryImpl mesFact = new MessageFactoryImpl(stack);
+ SccpMessage msgLocalOrig = mesFact.createDataMessageClass1(address,
null, new byte[5], 0, 6, false, null, null);
+ byte[] b = new byte[] { 9, 0x01, 0x03, 0x05, 0x09, 0x02, 0x42, 0x08,
0x04, 0x43, 0x01, 0x00, 0x08, 0x5D, 0x62, 0x5B, 0x48, 0x04, 0x00, 0x02,
0x00,
+ 0x30, 0x6B, 0x1A, 0x28, 0x18, 0x06, 0x07, 0x00, 0x11, (byte) 0x86,
0x05, 0x01, 0x01, 0x01, (byte) 0xA0, 0x0D, 0x60, 0x0B, (byte) 0xA1, 0x09,
+ 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x00, 0x19, 0x02, 0x6C, 0x37,
(byte) 0xA1, 0x35, 0x02, 0x01, 0x01, 0x02, 0x01, 0x2E, 0x30, 0x2D,
+ (byte) 0x80, 0x05, (byte) 0x89, 0x67, 0x45, 0x23, (byte) 0xF1, (byte)
0x84, 0x06, (byte) 0xA1, 0x21, 0x43, 0x65, (byte) 0x87, (byte) 0xF9,
+ 0x04, 0x1C, 0x2C, 0x09, 0x04, 0x21, 0x43, 0x65, (byte) 0x87, (byte)
0xF9, 0x04, 0x00, 0x11, 0x30, (byte) 0x92, 0x60, 0x60, 0x62, 0x00, 0x0B,
+ (byte) 0xC8, 0x32, (byte) 0x9B, (byte) 0xFD, 0x06, 0x5D, (byte) 0xDF,
0x72, 0x36, 0x19 };
+ ByteArrayInputStream buf = new ByteArrayInputStream(b);
+ int type = buf.read();
+ SccpMessage msgRemoteOrig = mesFact.createMessage(type, 101, 102, 0,
buf);
+
+ RuleImpl rule = new RuleImpl(RuleType.Solitary,
LoadSharingAlgorithm.Undefined, OriginationType.LocalOriginated,
pattern, "K");
+ rule.setPrimaryAddressId(1);
+ assertTrue(rule.matches(address,
msgLocalOrig.getIsMtpOriginated()));
+ assertFalse(rule.matches(address,
msgRemoteOrig.getIsMtpOriginated()));
+
+ rule = new RuleImpl(RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.RemoteOriginated, pattern, "K");
+ rule.setPrimaryAddressId(1);
+ assertFalse(rule.matches(address,
msgLocalOrig.getIsMtpOriginated()));
+ assertTrue(rule.matches(address,
msgRemoteOrig.getIsMtpOriginated()));
+
+ rule = new RuleImpl(RuleType.Solitary, LoadSharingAlgorithm.Undefined,
OriginationType.All, pattern, "K");
+ rule.setPrimaryAddressId(1);
+ assertTrue(rule.matches(address,
msgLocalOrig.getIsMtpOriginated()));
+ assertTrue(rule.matches(address,
msgRemoteOrig.getIsMtpOriginated()));
+ }
@Test(groups = { "router", "functional.encode" })
public void testSerialization() throws Exception {
@@ -306,13 +346,13 @@
assertTrue(aiOut.getMask().equals("R/K"));
assertEquals(aiOut.getPrimaryAddressId(), 1);
assertEquals(aiOut.getSecondaryAddressId(), 0);
- assertNull(aiOut.getNewCallingPartyAddressAddressId());
+ assertNull(aiOut.getNewCallingPartyAddressId());
rule = new RuleImpl(RuleType.Broadcast, LoadSharingAlgorithm.Bit2,
OriginationType.LocalOriginated, pattern, "R/K");
rule.setPrimaryAddressId(11);
rule.setSecondaryAddressId(12);
- rule.setNewCallingPartyAddressAddressId(13);
+ rule.setNewCallingPartyAddressId(13);
// Writes
output = new ByteArrayOutputStream();
@@ -336,7 +376,7 @@
assertTrue(aiOut.getMask().equals("R/K"));
assertEquals(aiOut.getPrimaryAddressId(), 11);
assertEquals(aiOut.getSecondaryAddressId(), 12);
- assertEquals((int)aiOut.getNewCallingPartyAddressAddressId(),
13);
+ assertEquals((int)aiOut.getNewCallingPartyAddressId(), 13);
}
@@ -358,3 +398,4 @@
// assertEquals( rule.toString(),RULE);
}
}
+
==============================================================================
Revision: 0ec91bc9a404
Author: Sergey Vetyutnev <[email protected]>
Date: Fri Dec 7 00:03:57 2012
Log: Merge remote-tracking branch 'origin/sccp' into SCCP_198
http://code.google.com/p/jss7/source/detail?r=0ec91bc9a404