Revision: 4741905c4274
Author: [email protected] <[email protected]>
Date: Thu Dec 6 09:42:07 2012
Log: Issue 198: SCCP CLI interface update
http://code.google.com/p/jss7/source/detail?r=4741905c4274
Modified:
/sccp/sccp-impl/pom.xml
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutor.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
=======================================
--- /sccp/sccp-impl/pom.xml Mon Nov 19 14:23:05 2012
+++ /sccp/sccp-impl/pom.xml Thu Dec 6 09:42:07 2012
@@ -90,8 +90,8 @@
<fileset>
<directory>.</directory>
<includes>
-
<include>*_sccpresource.xml</include>
-
<include>*_sccprouter.xml</include>
+
<include>*_sccpresource*.xml</include>
+
<include>*_sccprouter*.xml</include>
<include>debuglog.txt</include>
</includes>
<!-- <excludes> <exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
=======================================
---
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutor.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutor.java
Thu Dec 6 09:42:07 2012
@@ -90,10 +90,8 @@
try {
if (firstOption.equals("rule")) {
return this.manageRule(options);
- } else if (firstOption.equals("primary_add")) {
- return this.managePrimAddress(options);
-// } else if (firstOption.equals("backup_add")) {
-// return this.manageBackupAddress(options);
+ } else if (firstOption.equals("address")) {
+ return this.manageAddress(options);
} else if (firstOption.equals("rsp")) {
return this.manageRsp(options);
} else if (firstOption.equals("rss")) {
@@ -293,7 +291,7 @@
return SccpOAMMessage.INVALID_COMMAND;
}
- private String managePrimAddress(String[] options) throws Exception {
+ private String manageAddress(String[] options) throws Exception {
// Minimum 3 needed. Show
if (options.length < 3) {
return SccpOAMMessage.INVALID_COMMAND;
@@ -309,33 +307,33 @@
if (options.length < 4) {
return SccpOAMMessage.INVALID_COMMAND;
}
- int primAddressId = Integer.parseInt(options[3]);
- SccpAddress primAddress = this.createAddress(options,
4);
+ int addressId = Integer.parseInt(options[3]);
+ SccpAddress address = this.createAddress(options, 4);
- this.router.addRoutingAddress(primAddressId,
primAddress);
+ this.router.addRoutingAddress(addressId, address);
return SccpOAMMessage.ADDRESS_SUCCESSFULLY_ADDED;
} else if (command.equals("modify")) {
if (options.length < 4) {
return SccpOAMMessage.INVALID_COMMAND;
}
- int primAddressId = Integer.parseInt(options[3]);
- SccpAddress primAddress = this.createAddress(options,
4);
+ int addressId = Integer.parseInt(options[3]);
+ SccpAddress address = this.createAddress(options, 4);
- this.router.modifyRoutingAddress(primAddressId,
primAddress);
+ this.router.modifyRoutingAddress(addressId, address);
return SccpOAMMessage.ADDRESS_SUCCESSFULLY_MODIFIED;
} else if (command.equals("delete")) {
if (options.length < 4) {
return SccpOAMMessage.INVALID_COMMAND;
}
- int primAddressId = Integer.parseInt(options[3]);
- this.router.removeRoutingAddress(primAddressId);
+ int addressId = Integer.parseInt(options[3]);
+ this.router.removeRoutingAddress(addressId);
return SccpOAMMessage.ADDRESS_SUCCESSFULLY_DELETED;
} else if (command.equals("show")) {
if (options.length == 4) {
- int primAddressId =
Integer.parseInt(options[3]);
- SccpAddress pa =
this.router.getRoutingAddress(primAddressId);
+ int addressId = Integer.parseInt(options[3]);
+ SccpAddress pa =
this.router.getRoutingAddress(addressId);
if (pa == null) {
return
SccpOAMMessage.ADDRESS_DOESNT_EXIST;
}
@@ -362,76 +360,6 @@
return SccpOAMMessage.INVALID_COMMAND;
}
-
-// private String manageBackupAddress(String[] options) throws Exception {
-// // Minimum 3 needed. Show
-// if (options.length < 3) {
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
-//
-// String command = options[2];
-//
-// if (command == null) {
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
-//
-// if (command.equals("create")) {
-// if (options.length < 4) {
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
-// int backupAddressId = Integer.parseInt(options[3]);
-//
-// SccpAddress backupAddress = this.createAddress(options,
4);
-// this.router.addBackupAddress(backupAddressId,
backupAddress);
-// return SccpOAMMessage.ADDRESS_SUCCESSFULLY_ADDED;
-// } else if (command.equals("modify")) {
-// if (options.length < 4) {
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
-// int backupAddressId = Integer.parseInt(options[3]);
-// SccpAddress backupAddress = this.createAddress(options,
4);
-//
-// this.router.modifyBackupAddress(backupAddressId,
backupAddress);
-// return SccpOAMMessage.ADDRESS_SUCCESSFULLY_MODIFIED;
-//
-// } else if (command.equals("delete")) {
-// if (options.length < 4) {
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
-// int backupAddressId = Integer.parseInt(options[3]);
-// this.router.removeBackupAddress(backupAddressId);
-// return SccpOAMMessage.ADDRESS_SUCCESSFULLY_DELETED;
-// } else if (command.equals("show")) {
-// if (options.length == 4) {
-// int backupAddressId =
Integer.parseInt(options[3]);
-// SccpAddress pa =
this.router.getBackupAddress(backupAddressId);
-// if (pa == null) {
-// return
SccpOAMMessage.ADDRESS_DOESNT_EXIST;
-// }
-// return pa.toString();
-// }
-//
-// if (this.router.getBackupAddresses().size() == 0) {
-// return SccpOAMMessage.ADDRESS_DOESNT_EXIST;
-// }
-//
-// StringBuffer sb = new StringBuffer();
-//
-// Map<Integer, SccpAddress> idVsBkAdd =
this.router.getBackupAddresses();
-// for (Integer e: idVsBkAdd.keySet()) {
-// SccpAddress address = idVsBkAdd.get(e);
-// sb.append("key=");
-// sb.append(e);
-// sb.append(" backup_add=");
-// sb.append(address);
-// sb.append("\n");
-// }
-// return sb.toString();
-//
-// }
-//
-// return SccpOAMMessage.INVALID_COMMAND;
-// }
private String manageRule(String[] options) throws Exception {
// Minimum 3 needed. Show
@@ -600,7 +528,8 @@
}
SccpAddress pattern = this.createAddress(options, 5);
- this.router.modifyRule(ruleId, ruleType, algo, OriginationType.All,
pattern, mask, pAddressId, sAddressId, null);
+ this.router
+ .modifyRule(ruleId, ruleType, algo, OriginationType.All, pattern,
mask, pAddressId, sAddressId, null);
return SccpOAMMessage.RULE_SUCCESSFULLY_MODIFIED;
}
@@ -652,9 +581,9 @@
}
Map<Integer, Rule> idVsRule = this.router.getRules();
-
+
StringBuffer sb = new StringBuffer();
- for (Integer e: idVsRule.keySet()) {
+ for (Integer e : idVsRule.keySet()) {
Rule rule = idVsRule.get(e);
sb.append("key=");
sb.append(e);
@@ -790,7 +719,7 @@
}
Map<Integer, LongMessageRule> idVsLngmsgRule =
this.router.getLongMessageRules();
-
+
StringBuffer sb = new StringBuffer();
for (Integer e : idVsLngmsgRule.keySet()) {
LongMessageRule lmr = idVsLngmsgRule.get(e);
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
Thu Dec 6 05:07:28 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
Thu Dec 6 09:42:07 2012
@@ -110,8 +110,8 @@
@Test(groups = { "oam", "functional.mgmt" })
public void testManageRule() {
- String prim_addressCmd = "sccp primary_add create 1 71 2 8 0 0 3
123456789";
- String result = this.sccpExecutor.execute(prim_addressCmd.split("
"));
+ String addressCmd = "sccp address create 1 71 2 8 0 0 3
123456789";
+ String result = this.sccpExecutor.execute(addressCmd.split("
"));
assertTrue(result.equals(SccpOAMMessage.ADDRESS_SUCCESSFULLY_ADDED));
assertEquals(this.router.getRoutingAddresses().size(), 1);
@@ -130,7 +130,7 @@
result = this.sccpExecutor.execute(createRuleCmd.split(" "));
assertEquals(
result,
- "key=1
Rule=ruleType(Solitary);patternSccpAddress(pc=2,ssn=8,AI=71,gt=GT0001{na=NATIONAL,
digits=123456789});paddress(1);saddress(-1);mask(R)\n");
+ "key=1
Rule=ruleType(Solitary);originatingType(All);patternSccpAddress(pc=2,ssn=8,AI=71,gt=GT0001{na=NATIONAL,
digits=123456789});paddress(1);saddress(-1);mask(R)\n");
createRuleCmd = "sccp rule create 2 K 18 0 180 0 1 4 * solitary
1";
result = this.sccpExecutor.execute(createRuleCmd.split(" "));
@@ -246,15 +246,15 @@
@Test(groups = { "oam", "functional.mgmt" })
public void testMaskSectionsValidations() {
- String incorrect_prim_addressCmd = "sccp primary_add create 1 71 6535 8
0 0 12 93707100007";
- String incorrect_prim_address_deleteCmd = "sccp primary_add delete
1";
- String correct_prim_addressCmd = "sccp primary_add create 1 71 6535 8 0
0 12 -/-";
+ String incorrect_prim_addressCmd = "sccp address create 1 71 6535 8 0 0
12 93707100007";
+ String incorrect_prim_address_deleteCmd = "sccp address delete
1";
+ String correct_prim_addressCmd = "sccp address create 1 71 6535 8 0 0 12
-/-";
String incorrectCreateRuleCmd = "sccp rule create 2 R/K 18 0 180 0 1 4 *
solitary 1";
String correctCreateRuleCmd = "sccp rule create 2 R/K 18 0 180 0 1 4
937/* solitary 1";
- String incorrect_sec_addressCmd = "sccp backup_add create 1 71 6535 8 0
0 12 93707100007";
- String correctCreateRuleCmdWithSecId = "sccp rule create 2 R/K 18 0 180
0 1 4 937/* solitary 1 1";
+ String incorrect_sec_addressCmd = "sccp address create 3 71 6535 8 0 0
12 93707100007";
+ String correctCreateRuleCmdWithSecId = "sccp rule create 2 R/K 18 0 180
0 1 4 937/* solitary 1 3";
String result =
this.sccpExecutor.execute(incorrectCreateRuleCmd.split(" "));
assertEquals(result, SccpOAMMessage.SEC_MISMATCH_PATTERN);
@@ -277,13 +277,13 @@
*/
@Test(groups = { "oam", "functional.mgmt" })
public void testManageAddress() {
- String prim_addressCmd = "sccp primary_add create 1 71 6535 8 0 0 12
93707100007";
+ String prim_addressCmd = "sccp address create 1 71 6535 8 0 0 12
93707100007";
String result = this.sccpExecutor.execute(prim_addressCmd.split("
"));
assertEquals(result, SccpOAMMessage.ADDRESS_SUCCESSFULLY_ADDED);
assertEquals(this.router.getRoutingAddresses().size(), 1);
// test show
- prim_addressCmd = "sccp primary_add show";
+ prim_addressCmd = "sccp address show";
result = this.sccpExecutor.execute(prim_addressCmd.split(" "));
assertEquals(result, "key=1 pc=6535,ssn=8,AI=71,gt=GT0001{na=SPARE_12,
digits=93707100007}\n");
}
@@ -291,7 +291,7 @@
@Test(groups = { "oam", "functional.mgmt" })
public void testPrimAddress() {
- String rspCmd = "sccp primary_add create 11 71 6535 8 0 0 12
93707100007";
+ String rspCmd = "sccp address create 11 71 6535 8 0 0 12
93707100007";
// <id> <address-indicator> <point-code> <subsystem-number>
// <translation-type> <numbering-plan>
<nature-of-address-indicator>
// <digits>
@@ -303,97 +303,41 @@
assertEquals(addr.getSubsystemNumber(), 8);
assertTrue(addr.getGlobalTitle().getDigits().equals("93707100007"));
- rspCmd = "sccp primary_add create 11 71 6536 8 0 0 12
93707100007";
+ rspCmd = "sccp address create 11 71 6536 8 0 0 12 93707100007";
res = this.sccpExecutor.execute(rspCmd.split(" "));
assertTrue(res.equals(SccpOAMMessage.ADDRESS_ALREADY_EXIST));
assertEquals(this.router.getRoutingAddresses().size(), 1);
addr = this.router.getRoutingAddress(11);
assertEquals(addr.getSignalingPointCode(), 6535);
- rspCmd = "sccp primary_add modify 11 71 6537 8 0 0 12
93707100007";
+ rspCmd = "sccp address modify 11 71 6537 8 0 0 12 93707100007";
res = this.sccpExecutor.execute(rspCmd.split(" "));
assertEquals(this.router.getRoutingAddresses().size(), 1);
addr = this.router.getRoutingAddress(11);
assertEquals(addr.getSignalingPointCode(), 6537);
- rspCmd = "sccp primary_add modify 12 71 6538 8 0 0 12
93707100007";
+ rspCmd = "sccp address modify 12 71 6538 8 0 0 12 93707100007";
res = this.sccpExecutor.execute(rspCmd.split(" "));
assertTrue(res.equals(SccpOAMMessage.ADDRESS_DOESNT_EXIST));
assertEquals(this.router.getRoutingAddresses().size(), 1);
addr = this.router.getRoutingAddress(11);
assertEquals(addr.getSignalingPointCode(), 6537);
- rspCmd = "sccp primary_add show 11";
+ rspCmd = "sccp address show 11";
res = this.sccpExecutor.execute(rspCmd.split(" "));
- rspCmd = "sccp primary_add show";
+ rspCmd = "sccp address show";
res = this.sccpExecutor.execute(rspCmd.split(" "));
- rspCmd = "sccp primary_add delete 12";
+ rspCmd = "sccp address delete 12";
res = this.sccpExecutor.execute(rspCmd.split(" "));
assertTrue(res.equals(SccpOAMMessage.ADDRESS_DOESNT_EXIST));
assertEquals(this.router.getRoutingAddresses().size(), 1);
- rspCmd = "sccp primary_add delete 11";
+ rspCmd = "sccp address delete 11";
res = this.sccpExecutor.execute(rspCmd.split(" "));
assertEquals(this.router.getRoutingAddresses().size(), 0);
}
-
-// @Test(groups = { "oam", "functional.mgmt" })
-// public void testBackupAddress() {
-//
-// String rspCmd = "sccp backup_add create 11 71 6535 8 0 0 12
93707100007";
-// // <id> <address-indicator> <point-code> <subsystem-number>
-// // <translation-type> <numbering-plan>
<nature-of-address-indicator>
-// // <digits>
-// String res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertEquals(this.router.getBackupAddresses().size(), 1);
-// SccpAddress addr = this.router.getBackupAddress(11);
-// assertEquals(addr.getAddressIndicator().getValue(), 71);
-// assertEquals(addr.getSignalingPointCode(), 6535);
-// assertEquals(addr.getSubsystemNumber(), 8);
-//
assertTrue(addr.getGlobalTitle().getDigits().equals("93707100007"));
-//
-// // test show
-// rspCmd = "sccp backup_add show";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertEquals(res, "key=11
backup_add=pc=6535,ssn=8,AI=71,gt=GT0001{na=SPARE_12,
digits=93707100007}\n");
-//
-// rspCmd = "sccp backup_add create 11 71 6536 8 0 0 12
93707100007";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertTrue(res.equals(SccpOAMMessage.ADDRESS_ALREADY_EXIST));
-// assertEquals(this.router.getBackupAddresses().size(), 1);
-// addr = this.router.getBackupAddress(11);
-// assertEquals(addr.getSignalingPointCode(), 6535);
-//
-// rspCmd = "sccp backup_add modify 11 71 6537 8 0 0 12
93707100007";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertEquals(this.router.getBackupAddresses().size(), 1);
-// addr = this.router.getBackupAddress(11);
-// assertEquals(addr.getSignalingPointCode(), 6537);
-//
-// rspCmd = "sccp backup_add modify 12 71 6538 8 0 0 12
93707100007";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertTrue(res.equals(SccpOAMMessage.ADDRESS_DOESNT_EXIST));
-// assertEquals(this.router.getBackupAddresses().size(), 1);
-// addr = this.router.getBackupAddress(11);
-// assertEquals(addr.getSignalingPointCode(), 6537);
-//
-// rspCmd = "sccp backup_add show 11";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-//
-// rspCmd = "sccp backup_add show";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-//
-// rspCmd = "sccp backup_add delete 12";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertTrue(res.equals(SccpOAMMessage.ADDRESS_DOESNT_EXIST));
-// assertEquals(this.router.getBackupAddresses().size(), 1);
-//
-// rspCmd = "sccp backup_add delete 11";
-// res = this.sccpExecutor.execute(rspCmd.split(" "));
-// assertEquals(this.router.getBackupAddresses().size(), 0);
-// }
@Test(groups = { "oam", "functional.mgmt" })
public void testLmr() {