3 new revisions:
Revision: 9cdb19f58d33
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:18:58 2013
Log: CAP primitives serializing 25012013
http://code.google.com/p/jss7/source/detail?r=9cdb19f58d33
Revision: b0e46f88be1c
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:32:19 2013
Log: Merge remote-tracking branch 'origin/cap1'
http://code.google.com/p/jss7/source/detail?r=b0e46f88be1c
Revision: b1fefbf65be9
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:33:14 2013
Log: Merge remote-tracking branch 'origin/cap1'
http://code.google.com/p/jss7/source/detail?r=b1fefbf65be9
==============================================================================
Revision: 9cdb19f58d33
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:18:58 2013
Log: CAP primitives serializing 25012013
http://code.google.com/p/jss7/source/detail?r=9cdb19f58d33
Modified:
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/BearerCapImpl.java
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapImpl.java
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapImpl.java
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/BearerCapTest.java
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapTest.java
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapTest.java
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
=======================================
---
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/BearerCapImpl.java
Mon Apr 23 10:53:14 2012
+++
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/BearerCapImpl.java
Thu Jan 24 22:18:58 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,10 @@
import java.io.IOException;
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
@@ -47,6 +51,10 @@
public static final String _PrimitiveName = "BearerCap";
+ private static final String USER_SERVICE_INFORMATION_XML
= "userServiceInformation";
+
+ protected static final Logger loger =
Logger.getLogger(BearerCapImpl.class);
+
private byte[] data;
public BearerCapImpl() {
@@ -57,6 +65,10 @@
}
public BearerCapImpl(UserServiceInformation userServiceInformation)
throws CAPException {
+ setUserServiceInformation(userServiceInformation);
+ }
+
+ public void setUserServiceInformation(UserServiceInformation
userServiceInformation) throws CAPException {
if (userServiceInformation == null)
throw new CAPException("The userServiceInformation parameter must not
be null");
try {
@@ -205,5 +217,29 @@
return sb.toString();
}
+
+ /**
+ * XML Serialization/Deserialization
+ */
+ protected static final XMLFormat<BearerCapImpl> BEARER_CAP_XML = new
XMLFormat<BearerCapImpl>(BearerCapImpl.class) {
+
+ @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml,
BearerCapImpl bearerCap) throws XMLStreamException {
+ try {
+
bearerCap.setUserServiceInformation(xml.get(USER_SERVICE_INFORMATION_XML,
UserServiceInformationImpl.class));
+ } catch (CAPException e) {
+ loger.error("Error while deserialzing
UserServiceInformation.", e);
+ }
+ }
+
+ @Override
+ public void write(BearerCapImpl bearerCap,
javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
+ try {
+ xml.add(((UserServiceInformationImpl)
bearerCap.getUserServiceInformation()), USER_SERVICE_INFORMATION_XML,
UserServiceInformationImpl.class);
+ } catch (CAPException e) {
+ loger.error("Error while serialzing
UserServiceInformation.", e);
+ }
+ }
+ };
}
=======================================
---
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapImpl.java
Fri Jan 18 01:03:29 2013
+++
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapImpl.java
Thu Jan 24 22:18:58 2013
@@ -221,7 +221,7 @@
/**
* XML Serialization/Deserialization
*/
- protected static final XMLFormat<CalledPartyNumberCapImpl>
CALLED_PARTY_NUMBER_XML = new
XMLFormat<CalledPartyNumberCapImpl>(CalledPartyNumberCapImpl.class) {
+ protected static final XMLFormat<CalledPartyNumberCapImpl>
CALLED_PARTY_NUMBER_CAP_XML = new
XMLFormat<CalledPartyNumberCapImpl>(CalledPartyNumberCapImpl.class) {
@Override
public void read(javolution.xml.XMLFormat.InputElement xml,
CalledPartyNumberCapImpl calledPartyNumber) throws XMLStreamException {
=======================================
---
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapImpl.java
Mon Apr 23 10:53:14 2012
+++
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapImpl.java
Thu Jan 24 22:18:58 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,10 @@
import java.io.IOException;
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
@@ -47,6 +51,10 @@
public static final String _PrimitiveName = "CallingPartyNumberCap";
+ private static final String ISUP_CALLING_PARTY_NUMBER_XML
= "isupCallingPartyNumber";
+
+ protected static final Logger loger =
Logger.getLogger(CallingPartyNumberCapImpl.class);
+
private byte[] data;
public CallingPartyNumberCapImpl() {
@@ -57,6 +65,10 @@
}
public CallingPartyNumberCapImpl(CallingPartyNumber callingPartyNumber)
throws CAPException {
+ setCallingPartyNumber(callingPartyNumber);
+ }
+
+ public void setCallingPartyNumber(CallingPartyNumber callingPartyNumber)
throws CAPException {
if (callingPartyNumber == null)
throw new CAPException("The callingPartyNumber parameter must not be
null");
try {
@@ -205,4 +217,28 @@
return sb.toString();
}
+
+ /**
+ * XML Serialization/Deserialization
+ */
+ protected static final XMLFormat<CallingPartyNumberCapImpl>
CALLING_PARTY_NUMBER_CAP_XML = new
XMLFormat<CallingPartyNumberCapImpl>(CallingPartyNumberCapImpl.class) {
+
+ @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml,
CallingPartyNumberCapImpl callingPartyNumber) throws XMLStreamException {
+ try {
+
callingPartyNumber.setCallingPartyNumber(xml.get(ISUP_CALLING_PARTY_NUMBER_XML,
CallingPartyNumberImpl.class));
+ } catch (CAPException e) {
+ loger.error("Error while deserialzing
CallingPartyNumberCapImpl.", e);
+ }
+ }
+
+ @Override
+ public void write(CallingPartyNumberCapImpl callingPartyNumber,
javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
+ try {
+ xml.add(((CallingPartyNumberImpl)
callingPartyNumber.getCallingPartyNumber()), ISUP_CALLING_PARTY_NUMBER_XML,
CallingPartyNumberImpl.class);
+ } catch (CAPException e) {
+ loger.error("Error while serialzing
CallingPartyNumberCapImpl.", e);
+ }
+ }
+ };
}
=======================================
---
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
Fri Jan 18 01:03:29 2013
+++
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
Thu Jan 24 22:18:58 2013
@@ -24,6 +24,10 @@
import java.io.IOException;
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
@@ -47,6 +51,10 @@
public static final String _PrimitiveName = "CauseCap";
+ private static final String ISUP_CAUSE_INDICATORS_XML
= "isupCauseIndicators";
+
+ protected static final Logger loger =
Logger.getLogger(CauseCapImpl.class);
+
private byte[] data;
@@ -58,6 +66,10 @@
}
public CauseCapImpl(CauseIndicators causeIndicators) throws
CAPException {
+ setCauseIndicators(causeIndicators);
+ }
+
+ public void setCauseIndicators(CauseIndicators causeIndicators) throws
CAPException {
if (causeIndicators == null)
throw new CAPException("The causeIndicators parameter must not be
null");
try {
@@ -206,4 +218,28 @@
return sb.toString();
}
+
+ /**
+ * XML Serialization/Deserialization
+ */
+ protected static final XMLFormat<CauseCapImpl> CAUSE_CAP_XML = new
XMLFormat<CauseCapImpl>(CauseCapImpl.class) {
+
+ @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml, CauseCapImpl
causeCap) throws XMLStreamException {
+ try {
+ causeCap.setCauseIndicators(xml.get(ISUP_CAUSE_INDICATORS_XML,
CauseIndicatorsImpl.class));
+ } catch (CAPException e) {
+ loger.error("Error while deserialzing
CauseIndicators.", e);
+ }
+ }
+
+ @Override
+ public void write(CauseCapImpl causeCap,
javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
+ try {
+ xml.add(((CauseIndicatorsImpl) causeCap.getCauseIndicators()),
ISUP_CAUSE_INDICATORS_XML, CauseIndicatorsImpl.class);
+ } catch (CAPException e) {
+ loger.error("Error while serialzing
CauseIndicators.", e);
+ }
+ }
+ };
}
=======================================
---
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/BearerCapTest.java
Mon Apr 23 10:53:14 2012
+++
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/BearerCapTest.java
Thu Jan 24 22:18:58 2013
@@ -24,11 +24,19 @@
import static org.testng.Assert.*;
+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.isup.impl.message.parameter.CalledPartyNumberImpl;
+import
org.mobicents.protocols.ss7.isup.impl.message.parameter.UserServiceInformationImpl;
+import
org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber;
import
org.mobicents.protocols.ss7.isup.message.parameter.UserServiceInformation;
import org.testng.*;import org.testng.annotations.*;
@@ -79,5 +87,40 @@
// elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
// assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
}
+
+ @Test(groups = { "functional.xml.serialize", "isup" })
+ public void testXMLSerialize() throws Exception {
+
+ UserServiceInformationImpl original0 = new
UserServiceInformationImpl();
+
original0.setCodingStandart(UserServiceInformation._CS_INTERNATIONAL);
+
original0.setInformationTransferCapability(UserServiceInformation._ITS_VIDEO);
+ original0.setTransferMode(UserServiceInformation._TM_PACKET);
+
original0.setInformationTransferRate(UserServiceInformation._ITR_64x2);
+
+ BearerCapImpl original = new BearerCapImpl(original0);
+
+ // 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, "bearerCap", BearerCapImpl.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);
+ BearerCapImpl copy = reader.read("bearerCap",
BearerCapImpl.class);
+
+ assertEquals(copy.getUserServiceInformation().getCodingStandart(),
original.getUserServiceInformation().getCodingStandart());
+
assertEquals(copy.getUserServiceInformation().getInformationTransferCapability(),
original.getUserServiceInformation().getInformationTransferCapability());
+ assertEquals(copy.getUserServiceInformation().getTransferMode(),
original.getUserServiceInformation().getTransferMode());
+
assertEquals(copy.getUserServiceInformation().getInformationTransferRate(),
original.getUserServiceInformation().getInformationTransferRate());
+
+ }
}
=======================================
---
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapTest.java
Fri Jan 18 01:03:29 2013
+++
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapTest.java
Thu Jan 24 22:18:58 2013
@@ -96,7 +96,7 @@
// int natureOfAddresIndicator, String address, int
numberingPlanIndicator, int internalNetworkNumberIndicator
}
- @Test(groups = { "functional.xml.serialize", "service.ussd" })
+ @Test(groups = { "functional.xml.serialize", "isup" })
public void testXMLSerialize() throws Exception {
CalledPartyNumberCapImpl original = new CalledPartyNumberCapImpl(new
CalledPartyNumberImpl(CalledPartyNumber._NAI_INTERNATIONAL_NUMBER, "664422",
=======================================
---
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapTest.java
Fri Jan 18 03:01:51 2013
+++
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapTest.java
Thu Jan 24 22:18:58 2013
@@ -24,13 +24,21 @@
import static org.testng.Assert.*;
+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.isup.impl.message.parameter.CalledPartyNumberImpl;
import
org.mobicents.protocols.ss7.isup.impl.message.parameter.CallingPartyNumberImpl;
+import
org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber;
import
org.mobicents.protocols.ss7.isup.message.parameter.CallingPartyNumber;
+import org.mobicents.protocols.ss7.isup.message.parameter.NAINumber;
import org.testng.annotations.*;
/**
@@ -84,6 +92,39 @@
// int natureOfAddresIndicator, String address, int
numberingPlanIndicator, int numberIncompleteIndicator, int
addressRepresentationREstrictedIndicator,
// int screeningIndicator
}
+
+ @Test(groups = { "functional.xml.serialize", "isup" })
+ public void testXMLSerialize() throws Exception {
+
+ CallingPartyNumberCapImpl original = new
CallingPartyNumberCapImpl(
+ new CallingPartyNumberImpl(NAINumber._NAI_NATIONAL_SN, "12345",
CallingPartyNumber._NPI_TELEX, CallingPartyNumber._NI_INCOMPLETE,
+ CallingPartyNumber._APRI_ALLOWED,
CallingPartyNumber._SI_USER_PROVIDED_FAILED));
+
+ // 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, "callingPartyNumberCap",
CallingPartyNumberCapImpl.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);
+ CallingPartyNumberCapImpl copy = reader.read("callingPartyNumberCap",
CallingPartyNumberCapImpl.class);
+
+ assertEquals(copy.getCallingPartyNumber().getNatureOfAddressIndicator(),
original.getCallingPartyNumber().getNatureOfAddressIndicator());
+ assertEquals(copy.getCallingPartyNumber().getAddress(),
original.getCallingPartyNumber().getAddress());
+ assertEquals(copy.getCallingPartyNumber().getNumberingPlanIndicator(),
original.getCallingPartyNumber().getNumberingPlanIndicator());
+
assertEquals(copy.getCallingPartyNumber().getNumberIncompleteIndicator(),
original.getCallingPartyNumber().getNumberIncompleteIndicator());
+
assertEquals(copy.getCallingPartyNumber().getAddressRepresentationRestrictedIndicator(),
original.getCallingPartyNumber().getAddressRepresentationRestrictedIndicator());
+ assertEquals(copy.getCallingPartyNumber().getScreeningIndicator(),
original.getCallingPartyNumber().getScreeningIndicator());
+
+ }
}
=======================================
---
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
Fri Jan 18 03:01:51 2013
+++
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
Thu Jan 24 22:18:58 2013
@@ -24,8 +24,13 @@
import static org.testng.Assert.*;
+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;
@@ -78,4 +83,35 @@
elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
}
+
+ @Test(groups = { "functional.xml.serialize", "isup" })
+ public void testXMLSerialize() throws Exception {
+
+ CauseIndicatorsImpl original0 = new
CauseIndicatorsImpl(CauseIndicators._CODING_STANDARD_NATIONAL,
CauseIndicators._LOCATION_PRIVATE_NSRU, 1,
+ CauseIndicators._CV_CALL_REJECTED, null);
+
+ CauseCapImpl original = new CauseCapImpl(original0);
+
+ // 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, "causeCap", CauseCapImpl.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);
+ CauseCapImpl copy = reader.read("causeCap", CauseCapImpl.class);
+
+ assertEquals(copy.getCauseIndicators().getCodingStandard(),
original.getCauseIndicators().getCodingStandard());
+ assertEquals(copy.getCauseIndicators().getLocation(),
original.getCauseIndicators().getLocation());
+ assertEquals(copy.getCauseIndicators().getRecommendation(),
original.getCauseIndicators().getRecommendation());
+ assertEquals(copy.getCauseIndicators().getCauseValue(),
original.getCauseIndicators().getCauseValue());
+ }
}
==============================================================================
Revision: b0e46f88be1c
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:32:19 2013
Log: Merge remote-tracking branch 'origin/cap1'
http://code.google.com/p/jss7/source/detail?r=b0e46f88be1c
Modified:
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
=======================================
---
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
Thu Jan 24 06:41:41 2013
+++
/cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/isup/CauseCapImpl.java
Thu Jan 24 22:32:19 2013
@@ -27,6 +27,7 @@
import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;
+import org.apache.log4j.Logger;
import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
@@ -52,6 +53,10 @@
public static final String _PrimitiveName = "CauseCap";
+ private static final String ISUP_CAUSE_INDICATORS_XML
= "isupCauseIndicators";
+
+ protected static final Logger loger =
Logger.getLogger(CauseCapImpl.class);
+
private byte[] data;
public CauseCapImpl() {
@@ -62,6 +67,10 @@
}
public CauseCapImpl(CauseIndicators causeIndicators) throws
CAPException {
+ setCauseIndicators(causeIndicators);
+ }
+
+ public void setCauseIndicators(CauseIndicators causeIndicators) throws
CAPException {
if (causeIndicators == null)
throw new CAPException("The causeIndicators parameter must not be
null");
try {
@@ -215,15 +224,13 @@
/**
* XML Serialization/Deserialization
*/
- protected static final XMLFormat<CauseCapImpl> ISUP_CAUSE_INDICATORS_XML
= new XMLFormat<CauseCapImpl>(
- CauseCapImpl.class) {
+ protected static final XMLFormat<CauseCapImpl> CAUSE_CAP_XML = new
XMLFormat<CauseCapImpl>(CauseCapImpl.class) {
@Override
public void read(javolution.xml.XMLFormat.InputElement xml, CauseCapImpl
causeCap) throws XMLStreamException {
- CauseIndicatorsImpl causeIndicatorsImpl = xml.get(CAUSE_INDICATORS,
CauseIndicatorsImpl.class);
try {
- causeCap.data = causeIndicatorsImpl.encode();
- } catch (ParameterException e) {
+ causeCap.setCauseIndicators(xml.get(ISUP_CAUSE_INDICATORS_XML,
CauseIndicatorsImpl.class));
+ } catch (CAPException e) {
throw new XMLStreamException(e);
}
}
@@ -231,12 +238,10 @@
@Override
public void write(CauseCapImpl causeCap,
javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
try {
- xml.add(((CauseIndicatorsImpl) causeCap.getCauseIndicators()),
CAUSE_INDICATORS,
- CauseIndicatorsImpl.class);
+ xml.add(((CauseIndicatorsImpl) causeCap.getCauseIndicators()),
ISUP_CAUSE_INDICATORS_XML, CauseIndicatorsImpl.class);
} catch (CAPException e) {
throw new XMLStreamException(e);
}
-
}
};
}
=======================================
---
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
Thu Jan 24 06:41:41 2013
+++
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CauseCapTest.java
Thu Jan 24 22:32:19 2013
@@ -34,6 +34,7 @@
import javolution.xml.XMLObjectWriter;
import org.mobicents.protocols.asn.AsnInputStream;
+import
org.mobicents.protocols.ss7.isup.impl.message.parameter.CauseIndicatorsImpl;
import org.mobicents.protocols.ss7.isup.message.parameter.CauseIndicators;
import org.testng.annotations.Test;
@@ -100,4 +101,35 @@
public void testEncode() throws Exception {
}
+
+ @Test(groups = { "functional.xml.serialize", "isup" })
+ public void testXMLSerialize() throws Exception {
+
+ CauseIndicatorsImpl original0 = new
CauseIndicatorsImpl(CauseIndicators._CODING_STANDARD_NATIONAL,
CauseIndicators._LOCATION_PRIVATE_NSRU, 1,
+ CauseIndicators._CV_CALL_REJECTED, null);
+
+ CauseCapImpl original = new CauseCapImpl(original0);
+
+ // 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, "causeCap", CauseCapImpl.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);
+ CauseCapImpl copy = reader.read("causeCap", CauseCapImpl.class);
+
+ assertEquals(copy.getCauseIndicators().getCodingStandard(),
original.getCauseIndicators().getCodingStandard());
+ assertEquals(copy.getCauseIndicators().getLocation(),
original.getCauseIndicators().getLocation());
+ assertEquals(copy.getCauseIndicators().getRecommendation(),
original.getCauseIndicators().getRecommendation());
+ assertEquals(copy.getCauseIndicators().getCauseValue(),
original.getCauseIndicators().getCauseValue());
+ }
}
==============================================================================
Revision: b1fefbf65be9
Author: Sergey Vetyutnev <[email protected]>
Date: Thu Jan 24 22:33:14 2013
Log: Merge remote-tracking branch 'origin/cap1'
http://code.google.com/p/jss7/source/detail?r=b1fefbf65be9
--