Revision: 9f1b3937a30c
Author: baranowb <[email protected]>
Date: Sat Jul 27 09:28:21 2013
Log: ISSUE_311_2.0.x
http://code.google.com/p/jss7/source/detail?r=9f1b3937a30c
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
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/ConnectMessageImpl.java
Sat Jul 27 09:28:21 2013
@@ -28,14 +28,11 @@
*/
package org.mobicents.protocols.ss7.isup.impl.message;
-import java.util.Map;
-import java.util.Set;
-
import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
import org.mobicents.protocols.ss7.isup.ParameterException;
import
org.mobicents.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter;
import
org.mobicents.protocols.ss7.isup.impl.message.parameter.BackwardGVNSImpl;
-import
org.mobicents.protocols.ss7.isup.impl.message.parameter.ConnectedNumberImpl;
+
import
org.mobicents.protocols.ss7.isup.impl.message.parameter.MessageTypeImpl;
import org.mobicents.protocols.ss7.isup.message.ConnectMessage;
import
org.mobicents.protocols.ss7.isup.message.parameter.AccessDeliveryInformation;
@@ -64,6 +61,9 @@
import
org.mobicents.protocols.ss7.isup.message.parameter.UserToUserInformation;
import
org.mobicents.protocols.ss7.isup.message.parameter.accessTransport.AccessTransport;
+import java.util.Map;
+import java.util.Set;
+
/**
* Start time:23:58:48 2009-09-06<br>
* Project: mobicents-isup-stack<br>
@@ -350,7 +350,6 @@
*/
public void
setApplicationTransportParameter(ApplicationTransportParameter value) {
super.o_Parameters.put(this._INDEX_O_ApplicationTransportParameter, value);
-
}
/*
@@ -582,6 +581,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 {
@@ -593,7 +617,6 @@
*
* @see
org.mobicents.protocols.ss7.isup.ISUPMessageImpl#decodeMandatoryVariableBody
(byte [], int)
*/
-
protected void decodeMandatoryVariableBody(ISUPParameterFactory
parameterFactory, byte[] parameterBody, int parameterIndex)
throws ParameterException {
throw new UnsupportedOperationException("This message does not
support mandatory variable parameters.");
@@ -604,7 +627,6 @@
*
* @see
org.mobicents.protocols.ss7.isup.ISUPMessageImpl#decodeOptionalBody(byte
[], byte)
*/
-
protected void decodeOptionalBody(ISUPParameterFactory
parameterFactory, byte[] parameterBody, byte parameterCode)
throws ParameterException {
switch (parameterCode & 0xFF) {
@@ -621,10 +643,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();
@@ -742,7 +763,6 @@
*
* @see
org.mobicents.protocols.ss7.isup.ISUPMessageImpl#getMessageType()
*/
-
public MessageType getMessageType() {
return this._MESSAGE_TYPE;
}
@@ -752,7 +772,6 @@
*
* @seeorg.mobicents.protocols.ss7.isup.ISUPMessageImpl#
getNumberOfMandatoryVariableLengthParameters()
*/
-
protected int getNumberOfMandatoryVariableLengthParameters() {
return _MANDATORY_VAR_COUNT;
}
@@ -762,9 +781,7 @@
*
* @see
org.mobicents.protocols.ss7.isup.ISUPMessageImpl#hasAllMandatoryParameters
()
*/
-
public boolean hasAllMandatoryParameters() {
-
if (super.f_Parameters.get(_INDEX_F_BackwardCallIndicators) !=
null) {
return true;
} else {
@@ -777,7 +794,6 @@
*
* @see
org.mobicents.protocols.ss7.isup.impl.ISUPMessageImpl#optionalPartIsPossible
()
*/
-
protected boolean optionalPartIsPossible() {
return true;
=======================================
---
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
Sat Jul 27 09:28:21 2013
@@ -104,10 +104,6 @@
public AbstractNumber(String address) {
super();
- if (address == null) {
- throw new IllegalArgumentException("Address is null.");
- }
-
this.setAddress(address);
}
@@ -241,7 +237,9 @@
* @throws IllegalArgumentException - 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.");
}
@@ -283,6 +281,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.");
}
@@ -353,6 +354,9 @@
*
*/
public int encodeDigits(ByteArrayOutputStream bos) {
+ if(skipDigits()){
+ return 0;
+ }
boolean isOdd = this.oddFlag == _FLAG_ODD;
byte b = 0;
@@ -392,9 +396,16 @@
public void setAddress(String 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
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberImpl.java
Sat Jul 27 09:28:21 2013
@@ -46,7 +46,7 @@
protected int numberingPlanIndicator;
- protected int addressRepresentationREstrictedIndicator;
+ protected int addressRepresentationRestrictedIndicator;
protected int screeningIndicator;
@@ -57,7 +57,6 @@
*/
public ConnectedNumberImpl(byte[] representation) throws
ParameterException {
super(representation);
-
}
public ConnectedNumberImpl() {
@@ -80,7 +79,7 @@
int addressRepresentationREstrictedIndicator, int
screeningIndicator) {
super(natureOfAddresIndicator, address);
this.numberingPlanIndicator = numberingPlanIndicator;
- this.addressRepresentationREstrictedIndicator =
addressRepresentationREstrictedIndicator;
+ this.addressRepresentationRestrictedIndicator =
addressRepresentationREstrictedIndicator;
this.screeningIndicator = screeningIndicator;
}
@@ -99,7 +98,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;
}
@@ -109,21 +108,21 @@
*/
protected void doAddressPresentationRestricted() {
- if (this.addressRepresentationREstrictedIndicator ==
_APRI_NOT_AVAILABLE)
- return;
+ 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("");
+ // 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 = _SI_NETWORK_PROVIDED;
+ this.setAddress("");
+ }
}
/*
@@ -135,11 +134,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;
@@ -150,11 +159,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
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CPGTest.java
Sat Jul 27 09:28:21 2013
@@ -100,7 +100,7 @@
"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,
+ 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:");
@@ -124,7 +124,7 @@
, TransmissionMediumUsed._PARAMETER_CODE, 0x01, 0x03
// Connected Number
- , ConnectedNumber._PARAMETER_CODE, 0x05, 0x01, 0x4B,
(byte) (0x83 & 0xFF), 0x60, 0x38
+ , ConnectedNumber._PARAMETER_CODE, 0x05, 0x01, 0x43,
(byte) (0x83 & 0xFF), 0x60, 0x38
// End of Opt Part
, 0x00
=======================================
---
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberTest.java
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ConnectedNumberTest.java
Sat Jul 27 09:28:21 2013
@@ -50,26 +50,23 @@
* @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._APRI_NOT_AVAILABLE << 2;
v |= ConnectedNumberImpl._SI_NETWORK_PROVIDED;
bos.write(v & 0x7F);
-
- bos.write(super.getSixDigits());
return bos.toByteArray();
}
@@ -87,6 +84,21 @@
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,
@@ -95,9 +107,9 @@
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);
}
@@ -113,6 +125,19 @@
super.getFiveDigitsString() };
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)
@@ -121,7 +146,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
Wed Jun 12 12:00:55 2013
+++
/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/ParameterHarness.java
Sat Jul 27 09:28:21 2013
@@ -34,7 +34,9 @@
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
@@ -204,11 +206,11 @@
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]);
@@ -220,7 +222,10 @@
}
} catch (Exception e) {
- fail("Failed to check values on component: " +
component.getClass().getName() + ", due to: " + e);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ e.printStackTrace(pw);
+ fail("Failed to check values on component: " +
component.getClass().getName() + ", due to: " + new
String(baos.toByteArray()));
e.printStackTrace();
}
}
--
---
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.