Revision: c32e5d351348
Author: baranowb <[email protected]>
Date: Sat Jul 27 10:28:01 2013
Log: ISSUE_311_1.x
http://code.google.com/p/jss7/source/detail?r=c32e5d351348
Modified:
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/ConnectMessageImpl.java
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberImpl.java
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CPGTest.java
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberTest.java
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ParameterHarness.java
=======================================
---
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/ConnectMessageImpl.java
Sun Apr 22 10:01:35 2012
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/ConnectMessageImpl.java
Sat Jul 27 10:28:01 2013
@@ -649,7 +649,31 @@
return (HTRInformation)
super.o_Parameters.get(_INDEX_O_HTRInformation);
}
-
+ protected int decodeMandatoryParameters(ISUPParameterFactory
parameterFactory, byte[] b, int index)
+ throws ParameterException {
+ int localIndex = index;
+ index += super.decodeMandatoryParameters(parameterFactory, b,
index);
+
+ if (b.length - index > 2) {
+
+ try {
+ byte[] body = new byte[2];
+ body[0] = b[index++];
+ body[1] = b[index++];
+
+ BackwardCallIndicators v =
parameterFactory.createBackwardCallIndicators();
+ ((AbstractISUPParameter) v).decode(body);
+ this.setBackwardCallIndicators(v);
+ } catch (Exception e) {
+ throw new ParameterException("Failed to parse
BackwardCallIndicators due to: ", e);
+ }
+
+ return index - localIndex;
+ } else {
+ throw new ParameterException("byte[] must have at least 5
octets");
+ }
+ }
+
protected int decodeMandatoryVariableParameters(ISUPParameterFactory
parameterFactory, byte[] b, int index) throws ParameterException {
throw new UnsupportedOperationException("This message does not support
mandatory variable parameters.");
}
@@ -688,10 +712,9 @@
this.setBackwardGVNS(backwardGVNS);
break;
case ConnectedNumber._PARAMETER_CODE:
- ConnectedNumber value = new
ConnectedNumberImpl(parameterBody);
- parameterFactory.createConnectedNumber();
- ((AbstractISUPParameter) value).decode(parameterBody);
- this.setConnectedNumber(value);
+ ConnectedNumber connectedNumber =
parameterFactory.createConnectedNumber();
+ ((AbstractISUPParameter)
connectedNumber).decode(parameterBody);
+ this.setConnectedNumber(connectedNumber);
break;
case CallReference._PARAMETER_CODE:
CallReference callReference =
parameterFactory.createCallReference();
=======================================
---
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
Sun Apr 22 10:01:35 2012
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
Sat Jul 27 10:28:01 2013
@@ -109,10 +109,6 @@
public AbstractNumber(String address) {
super();
- if (address == null) {
- throw new IllegalArgumentException("Address is null.");
- }
-
this.setAddress(address);
}
@@ -258,7 +254,9 @@
* - thrown if read error is encountered.
*/
public int decodeDigits(ByteArrayInputStream bis) throws
ParameterException {
-
+ if(skipDigits()){
+ return 0;
+ }
if (bis.available() == 0) {
throw new ParameterException("No more data to read.");
}
@@ -302,6 +300,9 @@
* @throws IllegalArgumentException
*/
public int decodeDigits(ByteArrayInputStream bis, int octetsCount) throws
ParameterException {
+ if(skipDigits()){
+ return 0;
+ }
if (bis.available() == 0) {
throw new ParameterException("No more data to read.");
}
@@ -376,6 +377,9 @@
*
*/
public int encodeDigits(ByteArrayOutputStream bos) {
+ if(skipDigits()){
+ return 0;
+ }
boolean isOdd = this.oddFlag == _FLAG_ODD;
byte b = 0;
@@ -414,10 +418,16 @@
}
public void setAddress(String address) {
- this.address = address;
+ this.address = address;
+ if(address!=null){
+ // lets compute odd flag
+ oddFlag = this.address.length() % 2;
+ } else {
+ oddFlag = 0;
+ }
+ }
- // lets compute odd flag
- oddFlag = this.address.length() % 2;
+ protected boolean skipDigits(){
+ return false;
}
-
}
=======================================
---
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberImpl.java
Sun Apr 22 10:01:35 2012
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberImpl.java
Sat Jul 27 10:28:01 2013
@@ -46,7 +46,7 @@
protected int numberingPlanIndicator;
- protected int addressRepresentationREstrictedIndicator;
+ protected int addressRepresentationRestrictedIndicator;
protected int screeningIndicator;
@@ -79,7 +79,7 @@
public ConnectedNumberImpl(int natureOfAddresIndicator, String address,
int numberingPlanIndicator, int addressRepresentationREstrictedIndicator,
int screeningIndicator) {
super(natureOfAddresIndicator, address);
this.numberingPlanIndicator = numberingPlanIndicator;
- this.addressRepresentationREstrictedIndicator =
addressRepresentationREstrictedIndicator;
+ this.addressRepresentationRestrictedIndicator =
addressRepresentationREstrictedIndicator;
this.screeningIndicator = screeningIndicator;
}
@@ -100,7 +100,7 @@
int b = bis.read() & 0xff;
this.numberingPlanIndicator = (b & 0x70) >> 4;
- this.addressRepresentationREstrictedIndicator = (b & 0x0c) >> 2;
+ this.addressRepresentationRestrictedIndicator = (b & 0x0c) >> 2;
this.screeningIndicator = (b & 0x03);
return 1;
}
@@ -108,24 +108,24 @@
/**
* makes checks on APRI - see NOTE to APRI in Q.763, p 23
*/
- protected void doAddressPresentationRestricted() {
+ protected void doAddressPresentationRestricted() {
- if (this.addressRepresentationREstrictedIndicator ==
_APRI_NOT_AVAILABLE)
- return;
-
- // NOTE 1 � If the parameter is included and the address
presentation
- // restricted indicator indicates
- // address not available, octets 3 to n( this are digits.) are
omitted,
- // the subfields in items a - odd/evem, b -nai , c - ni and d
-npi, are
- // coded with
- // 0's, and the subfield f - filler, is coded with 11.
- this.oddFlag = 0;
- this.natureOfAddresIndicator = 0;
- this.numberingPlanIndicator = 0;
- // 11
- this.screeningIndicator = 3;
- this.setAddress("");
- }
+ if (this.addressRepresentationRestrictedIndicator ==
_APRI_NOT_AVAILABLE) {
+
+ // NOTE 1 � If the parameter is included and the address
presentation
+ // restricted indicator indicates
+ // address not available, octets 3 to n( this are digits.) are
omitted,
+ // the subfields in items a - odd/evem, b -nai , c - ni and d
-npi, are
+ // coded with
+ // 0's, and the subfield f - filler, is coded with 11.
+ this.oddFlag = 0;
+ this.natureOfAddresIndicator = 0;
+ this.numberingPlanIndicator = 0;
+ // 11
+ this.screeningIndicator = 3;
+ this.setAddress("");
+ }
+ }
/*
* (non-Javadoc)
@@ -137,12 +137,21 @@
public int encodeBody(ByteArrayOutputStream bos) {
int c = this.numberingPlanIndicator << 4;
- c |= (this.addressRepresentationREstrictedIndicator << 2);
+ c |= (this.addressRepresentationRestrictedIndicator << 2);
c |= (this.screeningIndicator);
bos.write(c & 0x7F);
return 1;
}
+ protected boolean skipDigits() {
+
+ if (this.addressRepresentationRestrictedIndicator ==
_APRI_NOT_AVAILABLE) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
public int getNumberingPlanIndicator() {
return numberingPlanIndicator;
}
@@ -152,11 +161,11 @@
}
public int getAddressRepresentationRestrictedIndicator() {
- return addressRepresentationREstrictedIndicator;
+ return addressRepresentationRestrictedIndicator;
}
public void setAddressRepresentationRestrictedIndicator(int
addressRepresentationREstrictedIndicator) {
- this.addressRepresentationREstrictedIndicator =
addressRepresentationREstrictedIndicator;
+ this.addressRepresentationRestrictedIndicator =
addressRepresentationREstrictedIndicator;
}
public int getScreeningIndicator() {
=======================================
---
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CPGTest.java
Tue Sep 27 03:09:07 2011
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CPGTest.java
Sat Jul 27 10:28:01 2013
@@ -87,7 +87,7 @@
assertEquals(cn.getNatureOfAddressIndicator(),cn._NAI_SUBSCRIBER_NUMBER,"ConnectedNumber
value getNatureOfAddressIndicator does not match:");
assertEquals(cn.getNumberingPlanIndicator(),cn._NPI_TELEX,"ConnectedNumber
value getNumberingPlanIndicator does not match:");
-
assertEquals(cn.getAddressRepresentationRestrictedIndicator(),cn._APRI_NOT_AVAILABLE,"ConnectedNumber
value getAddressRepresentationRestrictedIndicator does not match:");
+
assertEquals(cn.getAddressRepresentationRestrictedIndicator(),cn._APRI_ALLOWED,"ConnectedNumber
value getAddressRepresentationRestrictedIndicator does not match:");
assertEquals(cn._SI_NETWORK_PROVIDED,cn.getScreeningIndicator(),cn._SI_NETWORK_PROVIDED,"ConnectedNumber
value getScreeningIndicator does not match:");
assertEquals(cn.getAddress(),"380683","ConnectedNumber value getAddress
does not match:");
@@ -123,7 +123,7 @@
,ConnectedNumber._PARAMETER_CODE
,0x05
,0x01
- ,0x4B
+ ,0x43
,(byte) (0x83&0xFF)
,0x60
,0x38
=======================================
---
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberTest.java
Sun Apr 22 10:01:35 2012
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberTest.java
Sat Jul 27 10:28:01 2013
@@ -51,26 +51,24 @@
* @throws IOException
*/
public ConnectedNumberTest() throws IOException {
- super.badBodies.add(new byte[1]);
+ //super.badBodies.add(new byte[1]);
super.goodBodies.add(getBody1());
- // This will fail, cause this body has APRI allowed, so
hardcoded body
- // does nto match encoded body :)
- // super.goodBodies.add(getBody2());
+ super.goodBodies.add(getBody2());
+ super.goodBodies.add(getBody3());
}
private byte[] getBody1() throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// we will use odd number of digits, so we leave zero as MSB
- int v = ConnectedNumber._NAI_SUBSCRIBER_NUMBER;
+ // 0 because - _APRI_NOT_AVAILABLE
+ int v = 0;
bos.write(v);
v = 0;
- v = ConnectedNumberImpl._NPI_TELEX << 4;
v |= ConnectedNumberImpl._APRI_NOT_AVAILABLE << 2;
v |= ConnectedNumberImpl._SI_NETWORK_PROVIDED;
bos.write(v & 0x7F);
- bos.write(super.getSixDigits());
return bos.toByteArray();
}
@@ -88,13 +86,30 @@
bos.write(super.getFiveDigits());
return bos.toByteArray();
}
+
+ private byte[] getBody3() throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ // We have odd number
+ int v = ConnectedNumber._NAI_SUBSCRIBER_NUMBER;
+ bos.write(v);
+ v = 0;
+ v = ConnectedNumberImpl._NPI_TELEX << 4;
+ v |= ConnectedNumberImpl._APRI_ALLOWED << 2;
+ v |= ConnectedNumberImpl._SI_NETWORK_PROVIDED;
+ bos.write(v & 0x7F);
+ bos.write(super.getSixDigits());
+ return bos.toByteArray();
+ }
+
@Test(groups = { "functional.encode","functional.decode","parameter"})
public void testBody1EncodedValues() throws SecurityException,
NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
InvocationTargetException, IOException, ParameterException {
ConnectedNumberImpl bci = new ConnectedNumberImpl(getBody1());
String[] methodNames =
{ "getNumberingPlanIndicator", "getAddressRepresentationRestrictedIndicator", "getNatureOfAddressIndicator", "getScreeningIndicator", "isOddFlag", "getAddress"
};
- Object[] expectedValues = { ConnectedNumberImpl._NPI_TELEX,
ConnectedNumberImpl._APRI_NOT_AVAILABLE,
ConnectedNumber._NAI_SUBSCRIBER_NUMBER,
ConnectedNumberImpl._SI_NETWORK_PROVIDED, false,
- super.getSixDigitsString() };
+ Object[] expectedValues = { 0,
ConnectedNumberImpl._APRI_NOT_AVAILABLE,
+ 0, ConnectedNumberImpl._SI_NETWORK_PROVIDED, false,
+ null };
super.testValues(bci, methodNames, expectedValues);
}
@Test(groups = { "functional.encode","functional.decode","parameter"})
@@ -106,6 +121,19 @@
super.testValues(bci, methodNames, expectedValues);
}
+ @Test(groups = { "functional.encode", "functional.decode", "parameter"
})
+ public void testBody3EncodedValues() throws SecurityException,
NoSuchMethodException, IllegalArgumentException,
+ IllegalAccessException, InvocationTargetException,
IOException, ParameterException {
+ ConnectedNumberImpl bci = new ConnectedNumberImpl(getBody3());
+
+ String[] methodNames =
{ "getNumberingPlanIndicator", "getAddressRepresentationRestrictedIndicator",
+ "getNatureOfAddressIndicator", "getScreeningIndicator", "isOddFlag", "getAddress"
};
+ Object[] expectedValues = { ConnectedNumberImpl._NPI_TELEX,
ConnectedNumberImpl._APRI_ALLOWED,
+ ConnectedNumber._NAI_SUBSCRIBER_NUMBER,
ConnectedNumberImpl._SI_NETWORK_PROVIDED, false,
+ super.getSixDigitsString() };
+ super.testValues(bci, methodNames, expectedValues);
+ }
+
/*
* (non-Javadoc)
*
@@ -115,7 +143,7 @@
*/
public AbstractISUPParameter getTestedComponent() {
- return new ConnectedNumberImpl(1, "1", 1, 1, 1);
+ return new ConnectedNumberImpl(0, null, 0, 0, 0);
}
}
=======================================
---
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ParameterHarness.java
Sun Apr 22 10:01:35 2012
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ParameterHarness.java
Sat Jul 27 10:28:01 2013
@@ -199,10 +199,10 @@
Method m =
cClass.getMethod(getterMethodNames[index], null);
// Should not be null by now
Object v = m.invoke(component, null);
- if (v == null && expectedValues != null) {
+ if (v == null && expectedValues[index] != null)
{
fail("Failed to validate values in component: " +
component.getClass().getName() + ". Value of: " + getterMethodNames[index]
+ " is null, but test values is not.");
}
- if(expectedValues[index].getClass().isArray() )
+ if (expectedValues[index] != null &&
expectedValues[index].getClass().isArray())
{
assertTrue(Arrays.deepEquals(new Object[]{expectedValues[index]},new
Object[]{ v}),"Failed to validate values in component: " +
component.getClass().getName() + ". Value of: " + getterMethodNames[index]);
}else
--
---
You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.