[jboss-svn-commits] JBL Code SVN: r6348 - in labs/jbossesb/workspace/rearchitecture/product/core/rosetta: src/org/jboss/internal/soa/esb/addressing src/org/jboss/internal/soa/esb/message/format src/org/jboss/internal/soa/esb/message/format/serialized src/org/jboss/internal/soa/esb/message/format/xml src/org/jboss/soa/esb/message tests/src/org/jboss/soa/esb/message/format/tests tests/src/org/jboss/soa/esb/message/tests
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 21 18:28:28 EDT 2006
Author: mark.little at jboss.com
Date: 2006-09-21 18:28:07 -0400 (Thu, 21 Sep 2006)
New Revision: 6348
Added:
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
Modified:
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/PortReferenceHelper.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Context.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Fault.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
Log:
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/PortReferenceHelper.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/PortReferenceHelper.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/PortReferenceHelper.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -41,7 +41,6 @@
import org.jboss.soa.esb.addressing.PortReference;
import org.jboss.soa.esb.addressing.XMLUtil;
-import org.jboss.soa.esb.addressing.PortReference.Extension;
import org.jboss.soa.esb.exceptions.MarshalException;
/*
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -10,7 +10,7 @@
import org.jboss.internal.soa.esb.message.format.xml.XMLMessagePlugin;
import java.net.URI;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
@@ -113,7 +113,7 @@
public Message getMessage(URI type) // returns a message of a specific type.
{
if (type == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
MessagePlugin plugin = messageFormats.get(type);
@@ -128,7 +128,7 @@
// another.
{
if ((msg == null) || (type == null))
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
return null;
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -1,7 +1,7 @@
package org.jboss.internal.soa.esb.message.format.serialized;
import java.io.Serializable;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import java.util.Hashtable;
import org.jboss.soa.esb.message.Body;
@@ -54,7 +54,7 @@
public void add (String name, Object value)
{
if ((name == null) || (value == null))
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
if (value instanceof Serializable)
{
@@ -64,7 +64,7 @@
}
}
else
- throw new InvalidParameterException("Object must be Serializable.");
+ throw new IllegalArgumentException("Object must be Serializable.");
}
public Object get (String name)
@@ -86,7 +86,7 @@
public void replace (Body b)
{
if (b == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
setContents(b.getContents());
@@ -96,7 +96,7 @@
public void merge (Body b)
{
if (b == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
byte[] toAdd = b.getContents();
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -1,5 +1,7 @@
package org.jboss.internal.soa.esb.message.format.serialized;
+import java.net.URI;
+
import org.jboss.soa.esb.message.Fault;
/*
@@ -26,4 +28,28 @@
public class FaultImpl implements Fault, java.io.Serializable
{
private static final long serialVersionUID = 0x0;
+
+ public URI getCode ()
+ {
+ return _code;
+ }
+
+ public void setCode (URI code)
+ {
+ _code = code;
+ }
+
+ public String getReason ()
+ {
+ return _reason;
+ }
+
+ public void setReason (String reason)
+ {
+ _reason = reason;
+ }
+
+ private URI _code = null;
+ private String _reason = null;
+
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -22,7 +22,7 @@
*/
import java.io.Serializable;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import org.jboss.soa.esb.message.Header;
import org.jboss.soa.esb.addressing.Call;
@@ -50,7 +50,7 @@
public void setCall (Call call)
{
if (call == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
_call = call;
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -25,22 +25,25 @@
import java.util.Hashtable;
import java.io.Serializable;
-public class PropertiesImpl implements Properties
+public class PropertiesImpl implements Properties, Serializable
{
+ private static final long serialVersionUID = 0x0;
- public Object getProperty(String name) {
+ public Object getProperty(String name)
+ {
return _table.get(name);
}
- public Object getProperty(String name, Object defaultVal) {
+ public Object getProperty(String name, Object defaultVal)
+ {
Object oRet = getProperty(name);
- return (null==oRet) ? defaultVal : oRet;
+ return (null == oRet) ? defaultVal : oRet;
}
- public Object setProperty(String name, Object value)
+ public Object setProperty(String name, Object value)
{
if (value instanceof Serializable)
- return _table.put(name,(Serializable)value);
+ return _table.put(name, (Serializable) value);
else
throw new IllegalArgumentException("Value must be serializable");
}
@@ -50,11 +53,15 @@
return _table.remove(name);
}
- public String[] getNames() {
+ public String[] getNames()
+ {
return _table.keySet().toArray(new String[_table.size()]);
}
- public String toString() { return _table.toString(); }
+ public String toString()
+ {
+ return _table.toString();
+ }
- Hashtable<String,Serializable> _table = new Hashtable<String,Serializable>();
+ Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -43,6 +43,11 @@
public class AttachmentImpl implements Attachment, java.io.Serializable
{
+ public static final String ATTACHMENT_TAG = "Attachment";
+ public static final String NAME_ATTR = "name";
+ public static final String NAMED_TAG = "Named";
+ public static final String UNNAMED_TAG = "UnNamed";
+
private static final long serialVersionUID = 0x0;
public Object get(String name)
@@ -50,169 +55,179 @@
return _table.get(name);
}
- public Object put(String name, Object value)
+ public Object put(String name, Object value)
{
if (value instanceof Serializable)
- return _table.put(name,(Serializable)value);
+ return _table.put(name, (Serializable) value);
throw new IllegalArgumentException("value must be Serializable");
}
- public Object remove(String name)
+ public Object remove(String name)
{
return _table.remove(name);
}
- public String[] getNames()
+ public String[] getNames()
{
return _table.keySet().toArray(new String[_table.size()]);
}
- public Object itemAt(int index) throws IndexOutOfBoundsException
+ public Object itemAt(int index) throws IndexOutOfBoundsException
{
return _list.get(index);
}
- public Object removeItemAt(int index) throws IndexOutOfBoundsException
+ public Object removeItemAt(int index) throws IndexOutOfBoundsException
{
return _list.remove(index);
}
- public Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException
+ public Object replaceItemAt(int index, Object value)
+ throws IndexOutOfBoundsException
{
if (value instanceof Serializable)
- return _list.set(index,(Serializable)value);
+ return _list.set(index, (Serializable) value);
throw new IllegalArgumentException("value must be Serializable");
}
- public void addItem(Object value)
+ public void addItem(Object value)
{
if (value instanceof Serializable)
- _list.add((Serializable)value);
+ _list.add((Serializable) value);
else
throw new IllegalArgumentException("value must be Serializable");
}
- public void addItemAt(int index, Object value) throws IndexOutOfBoundsException
+ public void addItemAt(int index, Object value)
+ throws IndexOutOfBoundsException
{
if (value instanceof Serializable)
- _list.add(index,(Serializable)value);
+ _list.add(index, (Serializable) value);
else
throw new IllegalArgumentException("value must be Serializable");
}
- public int getNamedCount()
+ public int getNamedCount()
{
return _table.size();
}
- public int getUnnamedCount()
+
+ public int getUnnamedCount()
{
return _list.size();
}
-
- public String toString()
- { return new StringBuilder()
- .append("Attachment - Named:").append(_table.toString())
- .append(" Unnamed:").append(_list.toString())
- .toString();
+
+ public String toString()
+ {
+ return new StringBuilder().append("Attachment - Named:").append(
+ _table.toString()).append(" Unnamed:").append(_list.toString())
+ .toString();
}
/**
- * toXML(elem) - Will build a child element with appropriate values and append it
- * to arg0
- * @param elem Element - where to add 'this' as a child node
- * @return Element - 'this' as the added Element, or <null> if no properties in table
- * and nothing was appended to arg0
+ * toXML(elem) - Will build a child element with appropriate values and
+ * append it to arg0
+ *
+ * @param elem
+ * Element - where to add 'this' as a child node
+ * @return Element - 'this' as the added Element, or <null> if no
+ * properties in table and nothing was appended to arg0
* @see XMLUtil.ATTACHMENT_TAG
*/
- public Element toXML(Element elem)
+ public Element toXML(Element elem)
{
- if (_table.size()<1 && _list.size()<1)
+ if (_table.size() < 1 && _list.size() < 1)
return null;
Document doc = elem.getOwnerDocument();
- Element thisElement = doc.createElement(XMLUtil.ATTACHMENT_TAG);
+ Element thisElement = doc.createElement(ATTACHMENT_TAG);
- listToXml (doc, thisElement);
- tableToXml (doc, thisElement);
+ listToXml(doc, thisElement);
+ tableToXml(doc, thisElement);
elem.appendChild(thisElement);
return thisElement;
}
-
- private void tableToXml (Document doc, Element elem)
+
+ private void tableToXml(Document doc, Element elem)
{
- for (Map.Entry<String,Serializable> oCurr: _table.entrySet())
- {
- Element named = doc.createElement(XMLUtil.NAMED_TAG);
- named.setAttribute("name",oCurr.getKey());
- named.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr.getValue())));
+ for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+ {
+ Element named = doc.createElement(NAMED_TAG);
+ named.setAttribute(NAME_ATTR, oCurr.getKey());
+ named.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr
+ .getValue())));
elem.appendChild(named);
}
}
- private void listToXml (Document doc, Element elem)
+
+ private void listToXml(Document doc, Element elem)
{
- for (Serializable oCurr: _list)
- {
- Element anonymous = doc.createElement(XMLUtil.UNNAMED_TAG);
- anonymous.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr)));
+ for (Serializable oCurr : _list)
+ {
+ Element anonymous = doc.createElement(UNNAMED_TAG);
+ anonymous.appendChild(doc.createCDATASection(Base64
+ .encodeObject(oCurr)));
elem.appendChild(anonymous);
}
}
-/**
- * fromXml(elem) - Populate properties found in appropriate child element
- * @see XMLUtil.ATTACHMENT_TAG
- * @param elem - Element where to look for child nodes
- */
- public void fromXML(Element elem)
+
+ /**
+ * fromXml(elem) - Populate properties found in appropriate child element
+ *
+ * @see XMLUtil.ATTACHMENT_TAG
+ * @param elem -
+ * Element where to look for child nodes
+ */
+ public void fromXML(Element elem)
{
_table.clear();
_list.clear();
- NodeList NL = elem.getElementsByTagName(XMLUtil.ATTACHMENT_TAG);
- for (int i1=0; i1<NL.getLength(); i1++)
- {
+ NodeList NL = elem.getElementsByTagName(ATTACHMENT_TAG);
+ for (int i1 = 0; i1 < NL.getLength(); i1++)
+ {
Node oCurr = NL.item(i1);
if ((oCurr instanceof Element))
{
- listFromXml ((Element)oCurr);
- tableFromXml((Element)oCurr);
+ listFromXml((Element) oCurr);
+ tableFromXml((Element) oCurr);
}
}
}
-
+
private void listFromXml(Element elem)
{
- NodeList anonymous = elem.getElementsByTagName(XMLUtil.UNNAMED_TAG);
- for (int i1=0; i1<anonymous.getLength(); i1++)
+ NodeList anonymous = elem.getElementsByTagName(UNNAMED_TAG);
+ for (int i1 = 0; i1 < anonymous.getLength(); i1++)
{
Node oCurr = anonymous.item(i1);
if (oCurr instanceof Element)
{
CDATASection cdata = (CDATASection) oCurr.getFirstChild();
- Object value = Base64.decodeToObject(cdata.getWholeText());
- _list.add((Serializable)value);
+ Object value = Base64.decodeToObject(cdata.getWholeText());
+ _list.add((Serializable) value);
}
}
}
-
+
private void tableFromXml(Element elem)
{
- NodeList named = elem.getElementsByTagName(XMLUtil.NAMED_TAG);
- for (int i1=0; i1<named.getLength(); i1++)
+ NodeList named = elem.getElementsByTagName(NAMED_TAG);
+ for (int i1 = 0; i1 < named.getLength(); i1++)
{
Node oCurr = named.item(i1);
if (oCurr instanceof Element)
{
CDATASection cdata = (CDATASection) oCurr.getFirstChild();
- String name = ((Element)oCurr).getAttribute("name");
- Object value = Base64.decodeToObject(cdata.getWholeText());
- _table.put(name,(Serializable)value);
+ String name = ((Element) oCurr).getAttribute(NAME_ATTR);
+ Object value = Base64.decodeToObject(cdata.getWholeText());
+ _table.put(name, (Serializable) value);
}
}
}
-
-
ArrayList<Serializable> _list = new ArrayList<Serializable>();
- Hashtable<String,Serializable> _table = new Hashtable<String,Serializable>();
+
+ Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -1,7 +1,7 @@
package org.jboss.internal.soa.esb.message.format.xml;
import java.io.Serializable;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import org.jboss.soa.esb.message.Body;
@@ -42,7 +42,8 @@
public class BodyImpl implements Body
{
- private static final String BYTES_TAG = "Bytes";
+ public static final String BODY_TAG = "Body";
+ public static final String BYTES_TAG = "Bytes";
public BodyImpl ()
{
@@ -53,7 +54,7 @@
public void add (String name, Object value)
{
if ((name == null) || (value == null))
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
if (value instanceof Serializable)
{
@@ -63,7 +64,7 @@
}
}
else
- throw new InvalidParameterException("Object must be Serializable in this release.");
+ throw new IllegalArgumentException("Object must be Serializable in this release.");
}
public Object get (String name)
@@ -85,7 +86,7 @@
public Element toXML (Element envelope)
{
Document doc = envelope.getOwnerDocument();
- Element bodyElement = doc.createElement(XMLUtil.BODY_TAG);
+ Element bodyElement = doc.createElement(BODY_TAG);
envelope.appendChild(bodyElement);
@@ -128,7 +129,14 @@
for (int i = 0; i < nl.getLength(); i++)
{
- if (nl.item(i).getNodeName().equals(XMLUtil.BODY_TAG))
+ /*
+ * TODO
+ *
+ * In the past, bugs in certain Dom implementations mean that getElementsByName
+ * did not always work. Still the case? Plus this way is quicker.
+ */
+
+ if (nl.item(i).getNodeName().equals(BODY_TAG))
{
NodeList children = nl.item(i).getChildNodes();
@@ -167,7 +175,7 @@
public void replace (Body b)
{
if (b == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
setContents(b.getContents());
@@ -177,7 +185,7 @@
public void merge (Body b)
{
if (b == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
byte[] toAdd = b.getContents();
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -28,10 +28,12 @@
public class ContextImpl implements Context
{
+ public static final String CONTEXT_TAG = "Context";
+
public Element toXML (Element envelope)
{
Document doc = envelope.getOwnerDocument();
- Element contextElement = doc.createElement(XMLUtil.CONTEXT_TAG);
+ Element contextElement = doc.createElement(CONTEXT_TAG);
envelope.appendChild(contextElement);
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -1,9 +1,16 @@
package org.jboss.internal.soa.esb.message.format.xml;
+import java.net.URI;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
import org.jboss.soa.esb.message.Fault;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
/*
* JBoss, Home of Professional Open Source
@@ -28,17 +35,108 @@
public class FaultImpl implements Fault
{
- public Element toXML (Element envelope)
+ public static final String FAULT_TAG = "Fault";
+
+ public static final String CODE_TAG = "Code";
+
+ public static final String REASON_TAG = "Reason";
+
+ public URI getCode()
{
+ return _code;
+ }
+
+ public void setCode(URI code)
+ {
+ _code = code;
+ }
+
+ public String getReason()
+ {
+ return _reason;
+ }
+
+ public void setReason(String reason)
+ {
+ _reason = reason;
+ }
+
+ public Element toXML(Element envelope)
+ {
Document doc = envelope.getOwnerDocument();
- Element faultElement = doc.createElement(XMLUtil.FAULT_TAG);
-
+ Element faultElement = doc.createElement(FAULT_TAG);
+
envelope.appendChild(faultElement);
-
+
+ if (_code != null)
+ {
+ //Attr codeElement = doc.createAttribute(CODE_TAG);
+
+ Element codeElement = doc.createElement(CODE_TAG);
+ Text content = doc.createTextNode(_code.toString());
+
+ codeElement.appendChild(content);
+
+ faultElement.appendChild(codeElement);
+
+ //faultElement.setAttributeNode(codeElement);
+ }
+
+ if (_reason != null)
+ {
+ //Attr reasonElement = doc.createAttribute(REASON_TAG);
+
+ Element reasonElement = doc.createElement(REASON_TAG);
+ Text content = doc.createTextNode(_reason);
+
+ reasonElement.appendChild(content);
+
+ faultElement.appendChild(reasonElement);
+
+ //faultElement.setAttributeNode(reasonElement);
+ }
+
return faultElement;
}
-
+
public void fromXML (Element envelope)
{
+ NodeList nl = envelope.getChildNodes();
+
+ _code = null;
+ _reason = null;
+
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ if (nl.item(i).getNodeName().equals(FAULT_TAG))
+ {
+ NodeList children = nl.item(i).getChildNodes();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Element child = (Element) children.item(j);
+
+ if (child.getNodeName().equals(CODE_TAG))
+ {
+ try
+ {
+ _code = new URI(child.getFirstChild().getNodeValue());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ if (child.getNodeName().equals(REASON_TAG))
+ _reason = child.getFirstChild().getNodeValue();
+ }
+ }
+ }
}
+
+ private URI _code = null;
+
+ private String _reason = null;
+
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -21,7 +21,7 @@
* @author mark.little at jboss.com
*/
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import org.jboss.internal.soa.esb.addressing.CallHelper;
import org.jboss.soa.esb.message.Header;
@@ -38,6 +38,8 @@
public class HeaderImpl implements Header
{
+ public static final String HEADER_TAG = "Header";
+
public HeaderImpl ()
{
_call = null;
@@ -53,7 +55,7 @@
public void setCall (Call call)
{
if (call == null)
- throw new InvalidParameterException();
+ throw new IllegalArgumentException();
_call = call;
}
@@ -63,7 +65,7 @@
Document doc = envelope.getOwnerDocument();
// TODO remove MAGIC strings!!
- Element headerElement = doc.createElement(XMLUtil.HEADER_TAG);
+ Element headerElement = doc.createElement(HEADER_TAG);
envelope.appendChild(headerElement);
@@ -81,7 +83,7 @@
{
Node n = nl.item(i);
- if (n.getNodeName().equals(XMLUtil.HEADER_TAG))
+ if (n.getNodeName().equals(HEADER_TAG))
{
headerElement = (Element) n;
break;
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -60,6 +60,8 @@
public class MessageImpl implements Message // also implement XmlSerializable ?
{
+ public static final String ENVELOPE_TAG = "Envelope";
+
/**
* @return get the header component of the message.
*/
@@ -131,7 +133,7 @@
{
// TODO remove magic strings!
- Element envelope = doc.createElement(XMLUtil.ENVELOPE_TAG);
+ Element envelope = doc.createElement(ENVELOPE_TAG);
doc.appendChild(envelope);
@@ -165,7 +167,7 @@
{
Node n = nl.item(i);
- if (n.getNodeName().equals(XMLUtil.ENVELOPE_TAG))
+ if (n.getNodeName().equals(ENVELOPE_TAG))
{
envelope = (Element) n;
break;
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -30,20 +30,23 @@
public class PropertiesImpl implements Properties
{
+ public static final String PROPERTIES_TAG = "Properties";
- public Object getProperty(String name) {
+ public Object getProperty(String name)
+ {
return _table.get(name);
}
- public Object getProperty(String name, Object defaultVal) {
+ public Object getProperty(String name, Object defaultVal)
+ {
Object oRet = getProperty(name);
- return (null==oRet) ? defaultVal : oRet;
+ return (null == oRet) ? defaultVal : oRet;
}
- public Object setProperty(String name, Object value)
+ public Object setProperty(String name, Object value)
{
if (value instanceof Serializable)
- return _table.put(name,(Serializable)value);
+ return _table.put(name, (Serializable) value);
else
throw new IllegalArgumentException("value must be XmlSerializable");
}
@@ -53,71 +56,82 @@
return _table.remove(name);
}
- public String[] getNames() {
+ public String[] getNames()
+ {
return _table.keySet().toArray(new String[_table.size()]);
}
/**
- * toXML(elem) - Will build a child element with appropriate values and append it
- * to arg0
- * @param elem Element - where to add 'this' as a child node
- * @return Element - 'this' as the added Element, or <null> if no properties in table
- * and nothing was appended to arg0
+ * toXML(elem) - Will build a child element with appropriate values and
+ * append it to arg0
+ *
+ * @param elem
+ * Element - where to add 'this' as a child node
+ * @return Element - 'this' as the added Element, or <null> if no
+ * properties in table and nothing was appended to arg0
*/
- public Element toXML(Element elem)
+ public Element toXML(Element elem)
{
- if (_table.size()<1)
+ if (_table.size() < 1)
return null;
Document doc = elem.getOwnerDocument();
- Element thisElement = doc.createElement(XMLUtil.PROPERTIES_TAG);
+ Element thisElement = doc.createElement(PROPERTIES_TAG);
boolean bAdd = false;
- for (Map.Entry<String,Serializable> oCurr: _table.entrySet())
- {
+ for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+ {
Element oProp = doc.createElement(oCurr.getKey());
- oProp.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr.getValue())));
+ oProp.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr
+ .getValue())));
thisElement.appendChild(oProp);
bAdd = true;
}
if (bAdd)
- { elem.appendChild(thisElement);
+ {
+ elem.appendChild(thisElement);
return thisElement;
}
else
return null;
}
-/**
- * fromXml(elem) - Populate properties found in appropriate child element
- * @see XMLUtil.PROPERTIES_TAG
- * @param elem - Element where to look for child nodes
- */
- public void fromXML(Element elem)
+
+ /**
+ * fromXml(elem) - Populate properties found in appropriate child element
+ *
+ * @see XMLUtil.PROPERTIES_TAG
+ * @param elem -
+ * Element where to look for child nodes
+ */
+ public void fromXML(Element elem)
{
_table.clear();
-
- NodeList NL = elem.getElementsByTagName(XMLUtil.PROPERTIES_TAG);
- for (int i1=0; i1<NL.getLength(); i1++)
- {
+
+ NodeList NL = elem.getElementsByTagName(PROPERTIES_TAG);
+ for (int i1 = 0; i1 < NL.getLength(); i1++)
+ {
Node oCurr = NL.item(i1);
- if (! (oCurr instanceof Element))
+ if (!(oCurr instanceof Element))
continue;
NodeList props = oCurr.getChildNodes();
- for (int i2=0; i2<props.getLength(); i2++)
+ for (int i2 = 0; i2 < props.getLength(); i2++)
{
Node oProp = props.item(i2);
if (oProp instanceof Element)
{
CDATASection cdata = (CDATASection) oProp.getFirstChild();
- Object value = Base64.decodeToObject(cdata.getWholeText());
- _table.put(oProp.getNodeName(),(Serializable)value);
+ Object value = Base64.decodeToObject(cdata.getWholeText());
+ _table.put(oProp.getNodeName(), (Serializable) value);
}
}
}
}
-
- public String toString() { return _table.toString(); }
- Hashtable<String,Serializable> _table = new Hashtable<String,Serializable>();
+ public String toString()
+ {
+ return _table.toString();
+ }
+ Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -31,15 +31,4 @@
{
public static final String ESB_PREFIX = "jbesb";
public static final String ESB_NAMESPACE_URI = "http://www.jboss.org/ws/2006/09/esb";
-
- public static final String ATTACHMENT_TAG = "Attachment";
- public static final String BODY_TAG = "Body";
- public static final String CONTEXT_TAG = "Context";
- public static final String FAULT_TAG = "Fault";
- public static final String HEADER_TAG = "Header";
- public static final String ENVELOPE_TAG = "Envelope";
- public static final String PROPERTIES_TAG = "Properties";
-
- public static final String NAMED_TAG = "Named";
- public static final String UNNAMED_TAG = "UnNamed";
}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Context.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Context.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Context.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -23,5 +23,5 @@
public interface Context
{
- // TODO
+ // TODO add some methods!
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Fault.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Fault.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/Fault.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -1,5 +1,7 @@
package org.jboss.soa.esb.message;
+import java.net.URI;
+
/*
* JBoss, Home of Professional Open Source
* Copyright 2006, JBoss Inc., and others contributors as indicated
@@ -23,5 +25,9 @@
public interface Fault
{
- // TODO
+ public URI getCode ();
+ public void setCode (URI code);
+
+ public String getReason ();
+ public void setReason (String reason);
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -23,7 +23,7 @@
package org.jboss.soa.esb.message.format.tests;
import java.net.URI;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import junit.framework.TestCase;
@@ -81,7 +81,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
// success
}
@@ -99,7 +99,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
// success
}
@@ -119,9 +119,7 @@
{
URI uri = new URI(ExampleMessagePlugin.URN);
Message msg = MessageFactory.getInstance().getMessage(uri);
-
- System.err.println("**got "+msg);
-
+
assertEquals(msg.getType().equals(uri), true);
}
catch (Exception ex)
Added: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringWriter;
+import java.lang.IllegalArgumentException;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the Class class.
+ *
+ * @author Mark Little
+ */
+
+public class FaultUnitTest extends TestCase
+{
+
+ public void testSerializeFault ()
+ {
+ Message msg = MessageFactory.getInstance().getMessage(
+ MessageType.JAVA_SERIALIZED);
+
+ assertEquals((msg != null), true);
+
+ try
+ {
+ URI code = new URI("urn:code");
+
+ msg.getFault().setCode(code);
+ msg.getFault().setReason("because");
+
+ assertEquals(msg.getFault().getCode(), code);
+ assertEquals(msg.getFault().getReason(), "because");
+
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ ObjectOutputStream o = new ObjectOutputStream(s);
+
+ o.writeObject(msg);
+ o.close();
+
+ ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+ ObjectInputStream io = new ObjectInputStream(is);
+
+ MessageImpl nImpl = (MessageImpl) io.readObject();
+
+ assertEquals(nImpl.getFault().getReason(), "because");
+
+ o.close();
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+ }
+
+ public void testXMLFault ()
+ {
+ Message msg = MessageFactory.getInstance().getMessage(
+ MessageType.JBOSS_XML);
+
+ assertEquals((msg != null), true);
+
+ try
+ {
+ URI code = new URI("urn:code");
+
+ msg.getFault().setCode(code);
+ msg.getFault().setReason("because");
+
+ assertEquals(msg.getFault().getCode(), code);
+ assertEquals(msg.getFault().getReason(), "because");
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.newDocument();
+ org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+
+ doc = theImpl.toXML(doc);
+
+ StringWriter sWriter = new StringWriter();
+ OutputFormat format = new OutputFormat();
+ format.setIndenting(true);
+
+ XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+ xmlS.asDOMSerializer();
+ xmlS.serialize(doc);
+
+ String documentAsString = sWriter.toString();
+
+ System.err.println("Message looks like: " + documentAsString);
+
+ org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
+
+ nImpl.fromXML(doc);
+
+ assertEquals(nImpl.getFault().getReason(), "because");
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+ }
+
+}
Added: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.IllegalArgumentException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.w3c.dom.Document;
+
+/**
+ * Unit tests for the Class class.
+ *
+ * @author Mark Little
+ */
+
+public class PropertiesUnitTest extends TestCase
+{
+
+ public void testSerializeProperties()
+ {
+ Message msg = MessageFactory.getInstance().getMessage(
+ MessageType.JAVA_SERIALIZED);
+
+ assertEquals((msg != null), true);
+
+ msg.getProperties().setProperty("foo", "bar");
+
+ assertEquals(msg.getProperties().getProperty("foo"), "bar");
+ assertEquals((msg.getProperties().getProperty("foobar") == null), true);
+
+ assertEquals(msg.getProperties().getProperty("foobar", "barfoo"),
+ "barfoo");
+
+ try
+ {
+ msg.getProperties().setProperty("1234", new Object());
+
+ fail();
+ }
+ catch (IllegalArgumentException ex)
+ {
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+
+ msg.getProperties().getNames();
+
+ try
+ {
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ ObjectOutputStream o = new ObjectOutputStream(s);
+
+ o.writeObject(msg);
+ o.close();
+
+ ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+ ObjectInputStream io = new ObjectInputStream(is);
+
+ MessageImpl nImpl = (MessageImpl) io.readObject();
+
+ assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
+
+ o.close();
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+
+ assertEquals(msg.getProperties().remove("foo"), "bar");
+ }
+
+ public void testXMLProperties()
+ {
+ Message msg = MessageFactory.getInstance().getMessage(
+ MessageType.JBOSS_XML);
+
+ assertEquals((msg != null), true);
+
+ msg.getProperties().setProperty("foo", "bar");
+
+ assertEquals(msg.getProperties().getProperty("foo"), "bar");
+ assertEquals((msg.getProperties().getProperty("foobar") == null), true);
+
+ assertEquals(msg.getProperties().getProperty("foobar", "barfoo"),
+ "barfoo");
+
+ try
+ {
+ msg.getProperties().setProperty("1234", new Object());
+
+ fail();
+ }
+ catch (IllegalArgumentException ex)
+ {
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+
+ msg.getProperties().getNames();
+
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.newDocument();
+ org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+
+ doc = theImpl.toXML(doc);
+
+ org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
+
+ nImpl.fromXML(doc);
+
+ assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
+
+ assertEquals(msg.getProperties().remove("foo"), "bar");
+ }
+
+}
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -24,14 +24,10 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.StringWriter;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
-import javax.transaction.xa.XAResource;
-
import junit.framework.TestCase;
import org.jboss.soa.esb.addressing.Call;
@@ -123,7 +119,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
}
catch (Exception ex)
@@ -145,7 +141,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
}
catch (Exception ex)
@@ -291,7 +287,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
}
catch (Exception ex)
Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java 2006-09-21 21:55:19 UTC (rev 6347)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java 2006-09-21 22:28:07 UTC (rev 6348)
@@ -23,7 +23,7 @@
package org.jboss.soa.esb.message.tests;
import java.io.StringWriter;
-import java.security.InvalidParameterException;
+import java.lang.IllegalArgumentException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -139,7 +139,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
}
catch (Exception ex)
@@ -161,7 +161,7 @@
fail();
}
- catch (InvalidParameterException ex)
+ catch (IllegalArgumentException ex)
{
}
catch (Exception ex)
More information about the jboss-svn-commits
mailing list