Revision: 23449dad68b7
Author:   [email protected] <[email protected]>
Date:     Fri Jan 25 00:43:43 2013
Log: Issue 228:Adding XML serialization support for a list of MAP/CAP messages (that are used in CAP V2) : ApplyChargingRequest

http://code.google.com/p/jss7/source/detail?r=23449dad68b7

Modified:
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDImpl.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestImpl.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/primitive/CAMELAChBillingChargingCharacteristicsImpl.java /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/CAMELAChBillingChargingCharacteristicsTest.java /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDTest.java /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestTest.java

=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDImpl.java Mon Apr 23 10:53:14 2012 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDImpl.java Fri Jan 25 00:43:43 2013
@@ -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,9 @@

 import java.io.IOException;

+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
 import org.mobicents.protocols.asn.AsnException;
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
@@ -38,30 +41,31 @@
 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
 public class SendingSideIDImpl implements SendingSideID, CAPAsnPrimitive {
-
+
+       private static final String SENDING_SIDE_ID = "sendingSideID";
+
        public static final int _ID_sendingSideID = 0;

        public static final String _PrimitiveName = "SendingSideID";

        public LegType sendingSideID;

-
        public SendingSideIDImpl() {
        }

        public SendingSideIDImpl(LegType sendingSideID) {
                this.sendingSideID = sendingSideID;
        }
-
+
        @Override
        public LegType getSendingSideID() {
                return sendingSideID;
        }

-
        @Override
        public int getTag() throws CAPException {
                return _ID_sendingSideID;
@@ -84,14 +88,14 @@
                        int length = ansIS.readLength();
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (MAPParsingComponentException e) {
- throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + + ": " + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

@@ -101,29 +105,32 @@
                try {
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (MAPParsingComponentException e) {
- throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + + ": " + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

- private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, MAPParsingComponentException, IOException, AsnException {
-
+ private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException,
+                       MAPParsingComponentException, IOException, AsnException 
{
+
                this.sendingSideID = null;

if (ansIS.getTag() != _ID_sendingSideID || ansIS.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC) - throw new CAPParsingComponentException("Error when decoding " + _PrimitiveName + ": sendingSideID choice has bad tag oe tagClass, tag=" - + ansIS.getTag() + ", tagClass=" + ansIS.getTagClass(), CAPParsingComponentExceptionReason.MistypedParameter); + throw new CAPParsingComponentException("Error when decoding " + _PrimitiveName + + ": sendingSideID choice has bad tag oe tagClass, tag=" + ansIS.getTag() + ", tagClass=" + + ansIS.getTagClass(), CAPParsingComponentExceptionReason.MistypedParameter);

-               int i1 = (int)ansIS.readIntegerData(length);
+               int i1 = (int) ansIS.readIntegerData(length);
                this.sendingSideID = LegType.getInstance(i1);
                if (this.sendingSideID == null)
- throw new CAPParsingComponentException("Error when decoding " + _PrimitiveName + ": LegType must be leg1 or leg2, but the code = " + i1, + throw new CAPParsingComponentException("Error when decoding " + _PrimitiveName
+                                       + ": LegType must be leg1 or leg2, but the 
code = " + i1,
                                        
CAPParsingComponentExceptionReason.MistypedParameter);
        }

@@ -164,7 +171,7 @@
                StringBuilder sb = new StringBuilder();
                sb.append(_PrimitiveName);
                sb.append(" [");
-
+
                if (this.sendingSideID != null) {
                        sb.append("sendingSideID=");
                        sb.append(sendingSideID.toString());
@@ -174,4 +181,23 @@

                return sb.toString();
        }
+
+       /**
+        * XML Serialization/Deserialization
+        */
+ protected static final XMLFormat<SendingSideIDImpl> SENDING_SIDE_ID_XML = new XMLFormat<SendingSideIDImpl>(
+                       SendingSideIDImpl.class) {
+
+               @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml, SendingSideIDImpl sendingSideID)
+                               throws XMLStreamException {
+ sendingSideID.sendingSideID = LegType.getInstance(xml.get(SENDING_SIDE_ID, Integer.class));
+               }
+
+               @Override
+ public void write(SendingSideIDImpl sendingSideID, javolution.xml.XMLFormat.OutputElement xml)
+                               throws XMLStreamException {
+ xml.add(sendingSideID.sendingSideID.getCode(), SENDING_SIDE_ID, Integer.class);
+               }
+       };
 }
=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestImpl.java Mon Aug 6 06:08:42 2012 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestImpl.java Fri Jan 25 00:43:43 2013
@@ -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,9 @@

 import java.io.IOException;

+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
 import org.mobicents.protocols.asn.AsnException;
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
@@ -45,10 +48,16 @@
 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
public class ApplyChargingRequestImpl extends CircuitSwitchedCallMessageImpl implements ApplyChargingRequest {

+ private static final String A_CH_BILLING_CHARGING_CHARACTERISTICS = "aChBillingChargingCharacteristics";
+       private static final String PARTY_TO_CHARGE = "partyToCharge";
+       private static final String A_CH_CHARGING_ADDRESS = 
"aChChargingAddress";
+       private static final String EXTENSIONS = "extensions";
+
        public static final int _ID_aChBillingChargingCharacteristics = 0;
        public static final int _ID_partyToCharge = 2;
        public static final int _ID_extensions = 3;
@@ -61,12 +70,11 @@
        private CAPExtensions extensions;
        private AChChargingAddress aChChargingAddress;

-
        public ApplyChargingRequestImpl() {
        }
-
- public ApplyChargingRequestImpl(CAMELAChBillingChargingCharacteristics aChBillingChargingCharacteristics, SendingSideID partyToCharge,
-                       CAPExtensions extensions, AChChargingAddress 
aChChargingAddress) {
+
+ public ApplyChargingRequestImpl(CAMELAChBillingChargingCharacteristics aChBillingChargingCharacteristics, + SendingSideID partyToCharge, CAPExtensions extensions, AChChargingAddress aChChargingAddress) { this.aChBillingChargingCharacteristics = aChBillingChargingCharacteristics;
                this.partyToCharge = partyToCharge;
                this.extensions = extensions;
@@ -82,7 +90,7 @@
        public int getOperationCode() {
                return CAPOperationCode.applyCharging;
        }
-
+
        @Override
public CAMELAChBillingChargingCharacteristics getAChBillingChargingCharacteristics() {
                return aChBillingChargingCharacteristics;
@@ -103,7 +111,6 @@
                return aChChargingAddress;
        }

-
        @Override
        public int getTag() throws CAPException {
                return Tag.SEQUENCE;
@@ -126,11 +133,11 @@
                        int length = ansIS.readLength();
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

@@ -140,21 +147,23 @@
                try {
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

- private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, IOException, AsnException { + private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, IOException,
+                       AsnException {

                this.aChBillingChargingCharacteristics = null;
                this.partyToCharge = null;
-//             this.partyToCharge = new SendingSideIDImpl(LegType.leg1);
+               // this.partyToCharge = new SendingSideIDImpl(LegType.leg1);
                this.extensions = null;
-               this.aChChargingAddress = null; // TODO: DEFAULT 
legID:sendingSideID:leg1
+               this.aChChargingAddress = null; // TODO: DEFAULT
+                                                                               
// legID:sendingSideID:leg1

                AsnInputStream ais = ansIS.readSequenceStreamData(length);
                while (true) {
@@ -162,12 +171,13 @@
                                break;

                        int tag = ais.readTag();
-
+
                        if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) {
                                switch (tag) {
                                case _ID_aChBillingChargingCharacteristics:
this.aChBillingChargingCharacteristics = new CAMELAChBillingChargingCharacteristicsImpl(); - ((CAMELAChBillingChargingCharacteristicsImpl) this.aChBillingChargingCharacteristics).decodeAll(ais); + ((CAMELAChBillingChargingCharacteristicsImpl) this.aChBillingChargingCharacteristics)
+                                                       .decodeAll(ais);
                                        break;
                                case _ID_partyToCharge:
                                        AsnInputStream ais2 = 
ais.readSequenceStream();
@@ -192,8 +202,9 @@
                        }
                }

-               if (this.aChBillingChargingCharacteristics==null)
- throw new CAPParsingComponentException("Error while decoding " + _PrimitiveName + ": aChBillingChargingCharacteristics is mandatory but not found ",
+               if (this.aChBillingChargingCharacteristics == null)
+ throw new CAPParsingComponentException("Error while decoding " + _PrimitiveName
+                                       + ": aChBillingChargingCharacteristics is 
mandatory but not found ",
                                        
CAPParsingComponentExceptionReason.MistypedParameter);
        }

@@ -219,18 +230,19 @@
        public void encodeData(AsnOutputStream aos) throws CAPException {

                if (this.aChBillingChargingCharacteristics == null)
- throw new CAPException("Error while encoding " + _PrimitiveName + ": aChBillingChargingCharacteristics must not be null");
+                       throw new CAPException("Error while encoding " + 
_PrimitiveName
+                                       + ": aChBillingChargingCharacteristics must 
not be null");

                try {
                        if (this.aChBillingChargingCharacteristics != null)
- ((CAMELAChBillingChargingCharacteristicsImpl) this.aChBillingChargingCharacteristics).encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC,
-                                               
_ID_aChBillingChargingCharacteristics);
+ ((CAMELAChBillingChargingCharacteristicsImpl) this.aChBillingChargingCharacteristics).encodeAll(aos,
+                                               Tag.CLASS_CONTEXT_SPECIFIC, 
_ID_aChBillingChargingCharacteristics);
                        if (this.partyToCharge != null) {
                                aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, 
_ID_partyToCharge);
                                int pos = aos.StartContentDefiniteLength();
                                ((SendingSideIDImpl) 
this.partyToCharge).encodeAll(aos);
                                aos.FinalizeContent(pos);
-                       }
+                       }
                        if (this.extensions != null)
((CAPExtensionsImpl) this.extensions).encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, _ID_extensions);
                        if (this.aChChargingAddress != null) {
@@ -270,5 +282,49 @@

                return sb.toString();
        }
+
+       /**
+        * XML Serialization/Deserialization
+        */
+ protected static final XMLFormat<ApplyChargingRequestImpl> APPLY_CHARGING_REQUEST_XML = new XMLFormat<ApplyChargingRequestImpl>(
+                       ApplyChargingRequestImpl.class) {
+
+               @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml, ApplyChargingRequestImpl applyChargingRequest)
+                               throws XMLStreamException {
+
+ applyChargingRequest.aChBillingChargingCharacteristics = xml.get(A_CH_BILLING_CHARGING_CHARACTERISTICS,
+                                       
CAMELAChBillingChargingCharacteristicsImpl.class);
+ applyChargingRequest.partyToCharge = xml.get(PARTY_TO_CHARGE, SendingSideIDImpl.class);
+
+                       // TODO AChChargingAddressImpl is not implemented yet
+                       // oAnswerSpecificInfo.aChChargingAddress =
+                       // xml.get(A_CH_CHARGING_ADDRESS, 
AChChargingAddressImpl.class);
+
+ applyChargingRequest.extensions = xml.get(EXTENSIONS, CAPExtensionsImpl.class);
+               }
+
+               @Override
+ public void write(ApplyChargingRequestImpl applyChargingRequest, javolution.xml.XMLFormat.OutputElement xml)
+                               throws XMLStreamException {
+
+ xml.add((CAMELAChBillingChargingCharacteristicsImpl) applyChargingRequest.aChBillingChargingCharacteristics, + A_CH_BILLING_CHARGING_CHARACTERISTICS, CAMELAChBillingChargingCharacteristicsImpl.class);
+
+ xml.add((SendingSideIDImpl) applyChargingRequest.partyToCharge, PARTY_TO_CHARGE, SendingSideIDImpl.class);
+
+                       if (applyChargingRequest.aChChargingAddress != null) {
+                               // TODO AChChargingAddressImpl is not 
implemented yet
+                               // xml.add((AChChargingAddressImpl)
+                               // oAnswerSpecificInfo.aChChargingAddress,
+                               // A_CH_CHARGING_ADDRESS,
+                               // AChChargingAddressImpl.class);
+                       }
+
+                       if (applyChargingRequest.extensions != null) {
+ xml.add((CAPExtensionsImpl) applyChargingRequest.extensions, EXTENSIONS, CAPExtensionsImpl.class);
+                       }
+
+               }
+       };
 }
-
=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/primitive/CAMELAChBillingChargingCharacteristicsImpl.java Mon Aug 6 06:08:42 2012 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/primitive/CAMELAChBillingChargingCharacteristicsImpl.java Fri Jan 25 00:43:43 2013
@@ -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,9 @@

 import java.io.IOException;

+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
 import org.mobicents.protocols.asn.AsnException;
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
@@ -41,9 +44,17 @@
 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
-public class CAMELAChBillingChargingCharacteristicsImpl implements CAMELAChBillingChargingCharacteristics, CAPAsnPrimitive { +public class CAMELAChBillingChargingCharacteristicsImpl implements CAMELAChBillingChargingCharacteristics,
+               CAPAsnPrimitive {
+
+ private static final String MAX_CALL_PERIOD_DURATION = "maxCallPeriodDuration"; + private static final String RELEASED_IF_DURATION_EXCEEDED = "releaseIfdurationExceeded"; + private static final String TARIFF_SWITCH_INTERVAL = "tariffSwitchInterval";
+       private static final String AUDIBLE_INDICATOR = "audibleIndicator";
+       private static final String EXTENSIONS = "extensions";

        public static final int _ID_timeDurationCharging = 0;

@@ -65,16 +76,16 @@

        private boolean isCAPVersion3orLater;

-
        public CAMELAChBillingChargingCharacteristicsImpl() {
        }
-
+
        public CAMELAChBillingChargingCharacteristicsImpl(byte[] data) {
                this.data = data;
        }

- public CAMELAChBillingChargingCharacteristicsImpl(long maxCallPeriodDuration, boolean releaseIfdurationExceeded, Long tariffSwitchInterval, - AudibleIndicator audibleIndicator, CAPExtensions extensions, boolean isCAPVersion3orLater) { + public CAMELAChBillingChargingCharacteristicsImpl(long maxCallPeriodDuration, boolean releaseIfdurationExceeded, + Long tariffSwitchInterval, AudibleIndicator audibleIndicator, CAPExtensions extensions,
+                       boolean isCAPVersion3orLater) {
                this.maxCallPeriodDuration = maxCallPeriodDuration;
                this.releaseIfdurationExceeded = releaseIfdurationExceeded;
                this.tariffSwitchInterval = tariffSwitchInterval;
@@ -83,7 +94,6 @@
                this.isCAPVersion3orLater = isCAPVersion3orLater;
        }

-
        @Override
        public byte[] getData() {
                return data;
@@ -113,9 +123,7 @@
        public CAPExtensions getExtensions() {
                return extensions;
        }
-
-
-
+
        @Override
        public int getTag() throws CAPException {
                return Tag.STRING_OCTET;
@@ -138,14 +146,14 @@
                        int length = ansIS.readLength();
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (MAPParsingComponentException e) {
- throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + + ": " + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

@@ -155,18 +163,19 @@
                try {
                        this._decode(ansIS, length);
                } catch (IOException e) {
- throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (AsnException e) {
- throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                } catch (MAPParsingComponentException e) {
- throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
-                                       
CAPParsingComponentExceptionReason.MistypedParameter);
+ throw new CAPParsingComponentException("MAPParsingComponentException when decoding " + _PrimitiveName + + ": " + e.getMessage(), e, CAPParsingComponentExceptionReason.MistypedParameter);
                }
        }

- private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, MAPParsingComponentException, IOException, AsnException { + private void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException,
+                       MAPParsingComponentException, IOException, AsnException 
{

                this.data = null;
                this.maxCallPeriodDuration = -1;
@@ -174,15 +183,16 @@
                this.tariffSwitchInterval = null;
                this.audibleIndicator = null; // TODO: DEFAULT tone: FALSE
                this.extensions = null;
-
+
                this.data = ansIS.readOctetStringData(length);

                AsnInputStream aiss = new AsnInputStream(this.data);
                int tag = aiss.readTag();
- if (tag != _ID_timeDurationCharging || aiss.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || aiss.isTagPrimitive()) + if (tag != _ID_timeDurationCharging || aiss.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC
+                               || aiss.isTagPrimitive())
throw new CAPParsingComponentException("Error when decoding " + _PrimitiveName - + ": CAMEL-AChBillingChargingCharacteristics choice has bad tag oe tagClass or is primitive, tag=" + tag + ", tagClass=" - + aiss.getTagClass(), CAPParsingComponentExceptionReason.MistypedParameter); + + ": CAMEL-AChBillingChargingCharacteristics choice has bad tag oe tagClass or is primitive, tag=" + + tag + ", tagClass=" + aiss.getTagClass(), CAPParsingComponentExceptionReason.MistypedParameter);

                AsnInputStream ais = aiss.readSequenceStream();
                while (true) {
@@ -217,7 +227,8 @@
                                                                        parsed 
= true;
                                                                }
                                                        }
- if (ais2.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC && tag2 == _ID_extensions_In_ReleaseIfDurationExceeded) {
+                                                       if (ais2.getTagClass() 
== Tag.CLASS_CONTEXT_SPECIFIC
+                                                                       && tag2 
== _ID_extensions_In_ReleaseIfDurationExceeded) {
                                                                this.extensions 
= new CAPExtensionsImpl();
                                                                
((CAPExtensionsImpl) this.extensions).decodeAll(ais2);
                                                                parsed = true;
@@ -250,7 +261,8 @@
                }

                if (this.maxCallPeriodDuration == -1)
- throw new CAPParsingComponentException("Error while decoding " + _PrimitiveName + ": maxCallPeriodDuration is mandatory but not found", + throw new CAPParsingComponentException("Error while decoding " + _PrimitiveName
+                                       + ": maxCallPeriodDuration is mandatory but 
not found",
                                        
CAPParsingComponentExceptionReason.MistypedParameter);
        }

@@ -261,7 +273,7 @@

        @Override
public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws CAPException {
-
+
                try {
                        asnOs.writeTag(tagClass, this.getIsPrimitive(), tag);
                        int pos = asnOs.StartContentDefiniteLength();
@@ -274,13 +286,16 @@

        @Override
        public void encodeData(AsnOutputStream asnOs) throws CAPException {
-
+
                if (this.data == null) {
                        // encoding internal octet string
if (this.maxCallPeriodDuration < 1 || this.maxCallPeriodDuration > 864000) - throw new CAPException("Error while encoding " + _PrimitiveName + ": maxCallPeriodDuration must be from 1 to 864000"); - if (this.tariffSwitchInterval != null && (this.tariffSwitchInterval < 1 || this.tariffSwitchInterval > 86400)) - throw new CAPException("Error while encoding " + _PrimitiveName + ": tariffSwitchInterval must be from 1 to 86400");
+                               throw new CAPException("Error while encoding " 
+ _PrimitiveName
+                                               + ": maxCallPeriodDuration must be 
from 1 to 864000");
+                       if (this.tariffSwitchInterval != null
+ && (this.tariffSwitchInterval < 1 || this.tariffSwitchInterval > 86400))
+                               throw new CAPException("Error while encoding " 
+ _PrimitiveName
+                                               + ": tariffSwitchInterval must be 
from 1 to 86400");

                        try {
                                AsnOutputStream aos = new AsnOutputStream();
@@ -298,7 +313,8 @@
                                                int pos2 = 
aos.StartContentDefiniteLength();
                                                aos.writeBoolean(true);
                                                if (this.extensions != null) {
- ((CAPExtensionsImpl) this.extensions).encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, _ID_extensions_In_ReleaseIfDurationExceeded); + ((CAPExtensionsImpl) this.extensions).encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC,
+                                                                       
_ID_extensions_In_ReleaseIfDurationExceeded);
                                                }
                                                aos.FinalizeContent(pos2);
                                        }
@@ -313,7 +329,7 @@

                                if (this.extensions != null && 
this.isCAPVersion3orLater)
((CAPExtensionsImpl) this.extensions).encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, _ID_extensions);
-
+
                                aos.FinalizeContent(pos);
                                this.data = aos.toByteArray();
                        } catch (IOException e) {
@@ -355,4 +371,42 @@

                return sb.toString();
        }
+
+       /**
+        * XML Serialization/Deserialization
+        */
+ protected static final XMLFormat<CAMELAChBillingChargingCharacteristicsImpl> CAMEL_ACH_BILLING_CHARGING_CHARACTERISTIC_XML = new XMLFormat<CAMELAChBillingChargingCharacteristicsImpl>(
+                       CAMELAChBillingChargingCharacteristicsImpl.class) {
+
+               @Override
+               public void read(javolution.xml.XMLFormat.InputElement xml,
+ CAMELAChBillingChargingCharacteristicsImpl camelAChBillingChargingCharacteristics) throws XMLStreamException { + camelAChBillingChargingCharacteristics.maxCallPeriodDuration = xml.get(MAX_CALL_PERIOD_DURATION, Long.class); + camelAChBillingChargingCharacteristics.releaseIfdurationExceeded = xml.get(RELEASED_IF_DURATION_EXCEEDED, Boolean.class); + camelAChBillingChargingCharacteristics.tariffSwitchInterval = xml.get(TARIFF_SWITCH_INTERVAL, Long.class);
+                       // TODO AudibleIndicatorImpl is not yet implemented
+                       // oAnswerSpecificInfo.audibleIndicator = 
xml.get(AUDIBLE_INDICATOR,
+                       // AudibleIndicatorImpl.class);
+
+               }
+
+               @Override
+ public void write(CAMELAChBillingChargingCharacteristicsImpl camelAChBillingChargingCharacteristics,
+                               javolution.xml.XMLFormat.OutputElement xml) 
throws XMLStreamException {
+
+ xml.add(camelAChBillingChargingCharacteristics.maxCallPeriodDuration, MAX_CALL_PERIOD_DURATION, Long.class); + xml.add(camelAChBillingChargingCharacteristics.releaseIfdurationExceeded, RELEASED_IF_DURATION_EXCEEDED, Boolean.class);
+
+ if (camelAChBillingChargingCharacteristics.tariffSwitchInterval != null) { + xml.add(camelAChBillingChargingCharacteristics.tariffSwitchInterval, TARIFF_SWITCH_INTERVAL, Long.class);
+                       }
+
+                       // TODO AudibleIndicatorImpl is not yet implemented
+                       // if(oAnswerSpecificInfo.audibleIndicator != null){
+                       // 
xml.add(((AudibleIndicatorImpl)oAnswerSpecificInfo.audibleIndicator),
+                       // AUDIBLE_INDICATOR, AudibleIndicatorImpl.class);
+                       // }
+
+               }
+       };
 }
=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/CAMELAChBillingChargingCharacteristicsTest.java Mon Aug 6 06:08:42 2012 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/CAMELAChBillingChargingCharacteristicsTest.java Fri Jan 25 00:43:43 2013
@@ -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.
  *
@@ -22,38 +22,49 @@

 package org.mobicents.protocols.ss7.cap.primitives;

-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;

+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Arrays;

+import javolution.xml.XMLObjectReader;
+import javolution.xml.XMLObjectWriter;
+
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
 import org.mobicents.protocols.asn.Tag;
import org.mobicents.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAMELAChBillingChargingCharacteristicsImpl;
-import org.testng.*;import org.testng.annotations.*;
+import org.testng.annotations.Test;

 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
 public class CAMELAChBillingChargingCharacteristicsTest {

        public byte[] getData1() {
- return new byte[] { (byte) 128, 11, (byte) 160, 9, (byte) 128, 2, 46, (byte) 224, (byte) 161, 3, 1, 1, (byte) 255 }; + return new byte[] { (byte) 128, 11, (byte) 160, 9, (byte) 128, 2, 46, (byte) 224, (byte) 161, 3, 1, 1,
+                               (byte) 255 };
        }

        public byte[] getData2() {
- return new byte[] { (byte) 128, 35, (byte) 160, 33, (byte) 128, 2, 39, 16, (byte) 161, 23, 1, 1, (byte) 255, (byte) 170, 18, 48, 5, 2, 1, 2, - (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1, (byte) 129, 1, (byte) 255, (byte) 130, 2, 3, (byte) 232 }; + return new byte[] { (byte) 128, 35, (byte) 160, 33, (byte) 128, 2, 39, 16, (byte) 161, 23, 1, 1, (byte) 255, + (byte) 170, 18, 48, 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1, (byte) 129, 1, (byte) 255,
+                               (byte) 130, 2, 3, (byte) 232 };
        }

        public byte[] getData3() {
- return new byte[] { (byte) 128, 33, (byte) 160, 31, (byte) 128, 2, 39, 16, (byte) 129, 1, (byte) 255, (byte) 130, 2, 3, (byte) 232, (byte) 164, 18, 48, - 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1, (byte) 129, 1, (byte) 255 }; + return new byte[] { (byte) 128, 33, (byte) 160, 31, (byte) 128, 2, 39, 16, (byte) 129, 1, (byte) 255, + (byte) 130, 2, 3, (byte) 232, (byte) 164, 18, 48, 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1,
+                               (byte) 129, 1, (byte) 255 };
        }

-       @Test(groups = { "functional.decode","primitives"})
+       @Test(groups = { "functional.decode", "primitives" })
        public void testDecode() throws Exception {

                byte[] data = this.getData1();
@@ -88,25 +99,28 @@
                assertEquals((int) (long) elem.getTariffSwitchInterval(), 1000);
                assertNull(elem.getAudibleIndicator());
assertTrue(CAPExtensionsTest.checkTestCAPExtensions(elem.getExtensions()));
-
+
                // TODO: implement unimplemented parameters:
                // audibleIndicator
        }

-       @Test(groups = { "functional.encode","primitives"})
+       @Test(groups = { "functional.encode", "primitives" })
        public void testEncode() throws Exception {

- CAMELAChBillingChargingCharacteristicsImpl elem = new CAMELAChBillingChargingCharacteristicsImpl(12000, true, null, null, null, false); + CAMELAChBillingChargingCharacteristicsImpl elem = new CAMELAChBillingChargingCharacteristicsImpl(12000, true,
+                               null, null, null, false);
                AsnOutputStream aos = new AsnOutputStream();
                elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData1()));

- elem = new CAMELAChBillingChargingCharacteristicsImpl(10000, true, 1000L, null, CAPExtensionsTest.createTestCAPExtensions(), false); + elem = new CAMELAChBillingChargingCharacteristicsImpl(10000, true, 1000L, null,
+                               CAPExtensionsTest.createTestCAPExtensions(), 
false);
                aos = new AsnOutputStream();
                elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData2()));

- elem = new CAMELAChBillingChargingCharacteristicsImpl(10000, true, 1000L, null, CAPExtensionsTest.createTestCAPExtensions(), true); + elem = new CAMELAChBillingChargingCharacteristicsImpl(10000, true, 1000L, null,
+                               CAPExtensionsTest.createTestCAPExtensions(), 
true);
                aos = new AsnOutputStream();
                elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData3()));
@@ -114,7 +128,37 @@
                // TODO: implement unimplemented parameters:
                // audibleIndicator

- //long maxCallPeriodDuration, boolean releaseIfdurationExceeded, Long tariffSwitchInterval,AudibleIndicator audibleIndicator, CAPExtensions extensions, boolean isCAPVersion3orLater
+               // long maxCallPeriodDuration, boolean 
releaseIfdurationExceeded, Long
+               // tariffSwitchInterval,AudibleIndicator audibleIndicator, 
CAPExtensions
+               // extensions, boolean isCAPVersion3orLater
+       }
+
+       @Test(groups = { "functional.xml.serialize", "primitives" })
+       public void testXMLSerializaion() throws Exception {
+ CAMELAChBillingChargingCharacteristicsImpl original = new CAMELAChBillingChargingCharacteristicsImpl(12000,
+                               true, null, null, null, false);
+
+               // Writes the area to a file.
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               XMLObjectWriter writer = XMLObjectWriter.newInstance(baos);
+               // writer.setBinding(binding); // Optional.
+               writer.setIndentation("\t"); // Optional (use tabulation for
+                                                                               
// indentation).
+               writer.write(original, "camelAChBillingChargingCharacteristics",
+                               
CAMELAChBillingChargingCharacteristicsImpl.class);
+               writer.close();
+
+               byte[] rawData = baos.toByteArray();
+               String serializedEvent = new String(rawData);
+
+               System.out.println(serializedEvent);
+
+               ByteArrayInputStream bais = new ByteArrayInputStream(rawData);
+               XMLObjectReader reader = XMLObjectReader.newInstance(bais);
+ CAMELAChBillingChargingCharacteristicsImpl copy = reader.read("camelAChBillingChargingCharacteristics",
+                               
CAMELAChBillingChargingCharacteristicsImpl.class);
+
+ assertEquals(copy.getMaxCallPeriodDuration(), original.getMaxCallPeriodDuration()); + assertEquals(copy.getReleaseIfdurationExceeded(), original.getReleaseIfdurationExceeded());
        }
 }
-
=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDTest.java Mon Apr 23 10:53:14 2012 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/primitives/SendingSideIDTest.java Fri Jan 25 00:43:43 2013
@@ -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.
  *
@@ -22,19 +22,26 @@

 package org.mobicents.protocols.ss7.cap.primitives;

-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;

+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Arrays;

+import javolution.xml.XMLObjectReader;
+import javolution.xml.XMLObjectWriter;
+
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
 import org.mobicents.protocols.asn.Tag;
 import org.mobicents.protocols.ss7.inap.api.primitives.LegType;
-import org.testng.*;import org.testng.annotations.*;
+import org.testng.annotations.Test;

 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
 public class SendingSideIDTest {
@@ -43,18 +50,18 @@
                return new byte[] { (byte) 128, 1, 1 };
        }

-       @Test(groups = { "functional.decode","primitives"})
+       @Test(groups = { "functional.decode", "primitives" })
        public void testDecode() throws Exception {

-                byte[] data = this.getData1();
-                AsnInputStream ais = new AsnInputStream(data);
-                SendingSideIDImpl elem = new SendingSideIDImpl();
-                int tag = ais.readTag();
-                elem.decodeAll(ais);
-                assertEquals(elem.getSendingSideID(), LegType.leg1);
+               byte[] data = this.getData1();
+               AsnInputStream ais = new AsnInputStream(data);
+               SendingSideIDImpl elem = new SendingSideIDImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               assertEquals(elem.getSendingSideID(), LegType.leg1);
        }

-       @Test(groups = { "functional.encode","primitives"})
+       @Test(groups = { "functional.encode", "primitives" })
        public void testEncode() throws Exception {

                SendingSideIDImpl elem = new SendingSideIDImpl(LegType.leg1);
@@ -62,4 +69,29 @@
                elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData1()));
        }
+
+       @Test(groups = { "functional.xml.serialize", "circuitSwitchedCall" })
+       public void testXMLSerializaion() throws Exception {
+               SendingSideIDImpl original = new 
SendingSideIDImpl(LegType.leg1);
+
+               // Writes the area to a file.
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               XMLObjectWriter writer = XMLObjectWriter.newInstance(baos);
+               // writer.setBinding(binding); // Optional.
+               writer.setIndentation("\t"); // Optional (use tabulation for
+                                                                               
// indentation).
+               writer.write(original, "sendingSideID", 
SendingSideIDImpl.class);
+               writer.close();
+
+               byte[] rawData = baos.toByteArray();
+               String serializedEvent = new String(rawData);
+
+               System.out.println(serializedEvent);
+
+               ByteArrayInputStream bais = new ByteArrayInputStream(rawData);
+               XMLObjectReader reader = XMLObjectReader.newInstance(bais);
+ SendingSideIDImpl copy = reader.read("sendingSideID", SendingSideIDImpl.class);
+
+               assertEquals(copy.getSendingSideID(), 
original.getSendingSideID());
+       }
 }
=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestTest.java Mon Aug 6 06:08:42 2012 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/ApplyChargingRequestTest.java Fri Jan 25 00:43:43 2013
@@ -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.
  *
@@ -22,35 +22,46 @@

 package org.mobicents.protocols.ss7.cap.service.circuitSwitchedCall;

-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;

+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Arrays;

+import javolution.xml.XMLObjectReader;
+import javolution.xml.XMLObjectWriter;
+
 import org.mobicents.protocols.asn.AsnInputStream;
 import org.mobicents.protocols.asn.AsnOutputStream;
 import org.mobicents.protocols.ss7.cap.primitives.CAPExtensionsTest;
 import org.mobicents.protocols.ss7.cap.primitives.SendingSideIDImpl;
import org.mobicents.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAMELAChBillingChargingCharacteristicsImpl;
 import org.mobicents.protocols.ss7.inap.api.primitives.LegType;
-import org.testng.*;import org.testng.annotations.*;
+import org.testng.annotations.Test;

 /**
  *
  * @author sergey vetyutnev
+ * @author Amit Bhayani
  *
  */
 public class ApplyChargingRequestTest {

        public byte[] getData1() {
- return new byte[] { 48, 14, (byte) 128, 7, (byte) 160, 5, (byte) 128, 3, 0, (byte) 140, (byte) 160, (byte) 162, 3, (byte) 128, 1, 1 }; + return new byte[] { 48, 14, (byte) 128, 7, (byte) 160, 5, (byte) 128, 3, 0, (byte) 140, (byte) 160, (byte) 162,
+                               3, (byte) 128, 1, 1 };
        }

        public byte[] getData2() {
- return new byte[] { 48, 34, (byte) 128, 7, (byte) 160, 5, (byte) 128, 3, 0, (byte) 140, (byte) 160, (byte) 162, 3, (byte) 128, 1, 1, (byte) 163, 18, - 48, 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1, (byte) 129, 1, (byte) 255 }; + return new byte[] { 48, 34, (byte) 128, 7, (byte) 160, 5, (byte) 128, 3, 0, (byte) 140, (byte) 160, (byte) 162, + 3, (byte) 128, 1, 1, (byte) 163, 18, 48, 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1,
+                               (byte) 129, 1, (byte) 255 };
        }

-       @Test(groups = { "functional.decode","circuitSwitchedCall"})
+       @Test(groups = { "functional.decode", "circuitSwitchedCall" })
        public void testDecode() throws Exception {

                byte[] data = this.getData1();
@@ -58,13 +69,13 @@
                ApplyChargingRequestImpl elem = new ApplyChargingRequestImpl();
                int tag = ais.readTag();
                elem.decodeAll(ais);
-
- assertEquals((long)elem.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration(), 36000);
+
+ assertEquals((long) elem.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration(), 36000); assertNull(elem.getAChBillingChargingCharacteristics().getAudibleIndicator());
                
assertNull(elem.getAChBillingChargingCharacteristics().getExtensions());
assertFalse(elem.getAChBillingChargingCharacteristics().getReleaseIfdurationExceeded()); assertNull(elem.getAChBillingChargingCharacteristics().getTariffSwitchInterval());
-               assertEquals(elem.getPartyToCharge().getSendingSideID(), 
LegType.leg1 );
+               assertEquals(elem.getPartyToCharge().getSendingSideID(), 
LegType.leg1);
                assertNull(elem.getExtensions());
                assertNull(elem.getAChChargingAddress());

@@ -73,37 +84,75 @@
                elem = new ApplyChargingRequestImpl();
                tag = ais.readTag();
                elem.decodeAll(ais);
-
- assertEquals((long)elem.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration(), 36000);
+
+ assertEquals((long) elem.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration(), 36000); assertNull(elem.getAChBillingChargingCharacteristics().getAudibleIndicator());
                
assertNull(elem.getAChBillingChargingCharacteristics().getExtensions());
assertFalse(elem.getAChBillingChargingCharacteristics().getReleaseIfdurationExceeded()); assertNull(elem.getAChBillingChargingCharacteristics().getTariffSwitchInterval());
-               assertEquals(elem.getPartyToCharge().getSendingSideID(), 
LegType.leg1 );
+               assertEquals(elem.getPartyToCharge().getSendingSideID(), 
LegType.leg1);
assertTrue(CAPExtensionsTest.checkTestCAPExtensions(elem.getExtensions()));
                assertNull(elem.getAChChargingAddress());
        }

-       @Test(groups = { "functional.encode","circuitSwitchedCall"})
+       @Test(groups = { "functional.encode", "circuitSwitchedCall" })
        public void testEncode() throws Exception {

- CAMELAChBillingChargingCharacteristicsImpl aChBillingChargingCharacteristics = new CAMELAChBillingChargingCharacteristicsImpl(36000, false, null,
-                               null, null, false);
-// long maxCallPeriodDuration, boolean releaseIfdurationExceeded, Long tariffSwitchInterval, -// AudibleIndicator audibleIndicator, CAPExtensions extensions, boolean isCAPVersion3orLater + CAMELAChBillingChargingCharacteristicsImpl aChBillingChargingCharacteristics = new CAMELAChBillingChargingCharacteristicsImpl(
+                               36000, false, null, null, null, false);
+               // long maxCallPeriodDuration, boolean 
releaseIfdurationExceeded, Long
+               // tariffSwitchInterval,
+               // AudibleIndicator audibleIndicator, CAPExtensions extensions, 
boolean
+               // isCAPVersion3orLater
                SendingSideIDImpl partyToCharge = new 
SendingSideIDImpl(LegType.leg1);
-
- ApplyChargingRequestImpl elem = new ApplyChargingRequestImpl(aChBillingChargingCharacteristics, partyToCharge, null, null);
+
+ ApplyChargingRequestImpl elem = new ApplyChargingRequestImpl(aChBillingChargingCharacteristics, partyToCharge,
+                               null, null);
                AsnOutputStream aos = new AsnOutputStream();
                elem.encodeAll(aos);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData1()));
-// CAMELAChBillingChargingCharacteristics aChBillingChargingCharacteristics, SendingSideID partyToCharge,
-//             CAPExtensions extensions, AChChargingAddress aChChargingAddress
-
- elem = new ApplyChargingRequestImpl(aChBillingChargingCharacteristics, partyToCharge, CAPExtensionsTest.createTestCAPExtensions(), null);
+               // CAMELAChBillingChargingCharacteristics
+               // aChBillingChargingCharacteristics, SendingSideID 
partyToCharge,
+               // CAPExtensions extensions, AChChargingAddress 
aChChargingAddress
+
+ elem = new ApplyChargingRequestImpl(aChBillingChargingCharacteristics, partyToCharge,
+                               CAPExtensionsTest.createTestCAPExtensions(), 
null);
                aos = new AsnOutputStream();
                elem.encodeAll(aos);
                assertTrue(Arrays.equals(aos.toByteArray(), this.getData2()));
        }
+
+       @Test(groups = { "functional.xml.serialize", "circuitSwitchedCall" })
+       public void testXMLSerializaion() throws Exception {
+ CAMELAChBillingChargingCharacteristicsImpl aChBillingChargingCharacteristics = new CAMELAChBillingChargingCharacteristicsImpl(
+                               36000, false, null, null, null, false);
+               SendingSideIDImpl partyToCharge = new 
SendingSideIDImpl(LegType.leg1);
+ ApplyChargingRequestImpl original = new ApplyChargingRequestImpl(aChBillingChargingCharacteristics,
+                               partyToCharge, null, null);
+
+               // Writes the area to a file.
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               XMLObjectWriter writer = XMLObjectWriter.newInstance(baos);
+               // writer.setBinding(binding); // Optional.
+               writer.setIndentation("\t"); // Optional (use tabulation for
+                                                                               
// indentation).
+ writer.write(original, "applyChargingRequest", ApplyChargingRequestImpl.class);
+               writer.close();
+
+               byte[] rawData = baos.toByteArray();
+               String serializedEvent = new String(rawData);
+
+               System.out.println(serializedEvent);
+
+               ByteArrayInputStream bais = new ByteArrayInputStream(rawData);
+               XMLObjectReader reader = XMLObjectReader.newInstance(bais);
+ ApplyChargingRequestImpl copy = reader.read("applyChargingRequest", ApplyChargingRequestImpl.class);
+
+ assertEquals(copy.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration(), original
+                               
.getAChBillingChargingCharacteristics().getMaxCallPeriodDuration());
+ assertEquals(copy.getAChBillingChargingCharacteristics().getReleaseIfdurationExceeded(), original + .getAChBillingChargingCharacteristics().getReleaseIfdurationExceeded()); + assertEquals(copy.getPartyToCharge().getSendingSideID(), original.getPartyToCharge().getSendingSideID());
+
+       }
 }
-

--



Reply via email to