[jboss-svn-commits] JBL Code SVN: r14410 - in labs/jbossesb/workspace/rearch2/core/src: main/java/org/jboss/internal/soa/esb/api/local and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 21 04:54:01 EDT 2007
Author: mark.little at jboss.com
Date: 2007-08-21 04:54:01 -0400 (Tue, 21 Aug 2007)
New Revision: 14410
Added:
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/MessageFactory.java
Removed:
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/XMLMessagePlugin.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
Modified:
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/HeaderHelper.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/TwoWaySenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/BodyImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/HeaderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/MessageImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpClient.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpService.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpClient.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpService.java
Log:
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/HeaderHelper.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/HeaderHelper.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/HeaderHelper.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -25,10 +25,11 @@
import java.net.URISyntaxException;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.message.normalized.xml.HeaderImpl;
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.XMLUtil;
+import org.jboss.soa.esb.message.Header;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -37,7 +38,7 @@
public abstract class HeaderHelper
{
- public static Element toXML(Call call, Document doc, Element header)
+ public static Element toXML(Header call, Document doc, Element header)
throws MarshalException
{
AssertArgument.isNotNull(call, "call");
@@ -115,11 +116,10 @@
return header;
}
- public static Call fromXML(Element header) throws UnmarshalException
+ public static void fromXML(Header call, Element header) throws UnmarshalException
{
AssertArgument.isNotNull(header, "header");
- Call call = new Call();
NodeList nl = header.getChildNodes();
for (int i = 0; i < nl.getLength(); i++)
@@ -189,8 +189,6 @@
}
}
}
-
- return call;
}
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -55,7 +55,7 @@
try
{
- String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+ String locatorUri = msg.getHeader().getTo().getAddr().getAddress();
if (msg instanceof MessageImpl)
locatorUri = locatorUri + DATA_TYPE;
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -55,7 +55,7 @@
try
{
- String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+ String locatorUri = msg.getHeader().getTo().getAddr().getAddress();
if (msg instanceof MessageImpl)
locatorUri = locatorUri + DATA_TYPE;
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/TwoWaySenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/TwoWaySenderImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/TwoWaySenderImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -55,7 +55,7 @@
try
{
- String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+ String locatorUri = msg.getHeader().getTo().getAddr().getAddress();
if (msg instanceof MessageImpl)
locatorUri = locatorUri + DATA_TYPE;
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/BodyImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/BodyImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -43,8 +43,6 @@
{
public static final String BODY_TAG = "Body";
- public static final String BYTES_TAG = "Bytes";
-
public static final String CONTENT_TAG = "Content";
public static final String KEY_TAG = "Key";
@@ -53,7 +51,6 @@
public BodyImpl()
{
- _content = null;
_objects = new Hashtable<String, Object>();
}
@@ -105,16 +102,6 @@
envelope.appendChild(bodyElement);
- if (_content != null)
- {
- Element byteElement = doc.createElement(BYTES_TAG);
-
- byteElement.appendChild(doc.createCDATASection(Base64
- .encodeBytes(_content)));
-
- bodyElement.appendChild(byteElement);
- }
-
/*
* This would normally be handled by an external adapter.
*/
@@ -175,110 +162,55 @@
Element node = (Element) xxx;
- if (node.getNodeName().equals(BYTES_TAG))
+ if (node.getNodeName().equals(CONTENT_TAG))
{
- CDATASection cdata = (CDATASection) node
- .getFirstChild();
+ final NodeList childList = node.getChildNodes();
- // support empty byte (null files etc.)
+ String key = null;
+ Object value = null;
- if (cdata != null)
- _content = Base64.decode(cdata.getWholeText());
- else
- _content = new byte[0];
- }
- else
- {
- if (node.getNodeName().equals(CONTENT_TAG))
+ for (int k = 0; k < childList.getLength(); k++)
{
- final NodeList childList = node.getChildNodes();
+ if (childList.item(k).getNodeName().equals(
+ VALUE_TAG))
+ value = MarshalUnmarshalManager.getInstance()
+ .unmarshal((Element) childList.item(k));
- String key = null;
- Object value = null;
-
- for (int k = 0; k < childList.getLength(); k++)
+ if (childList.item(k).getNodeName().equals(KEY_TAG))
{
- if (childList.item(k).getNodeName().equals(
- VALUE_TAG))
- value = MarshalUnmarshalManager
- .getInstance()
- .unmarshal(
- (Element) childList.item(k));
+ CDATASection cdata = (CDATASection) childList
+ .item(k).getFirstChild();
- if (childList.item(k).getNodeName().equals(
- KEY_TAG))
- {
- CDATASection cdata = (CDATASection) childList.item(k).getFirstChild();
-
- key = new String(Base64.decode(cdata
- .getWholeText()));
- }
+ key = new String(Base64.decode(cdata
+ .getWholeText()));
}
-
- if (value == null)
- throw new UnmarshalException(
- "Cannot unpack object "
- + node.getNodeName());
- else
- _objects.put(key, value);
}
+
+ if (value == null)
+ throw new UnmarshalException(
+ "Cannot unpack object "
+ + node.getNodeName());
+ else
+ _objects.put(key, value);
}
}
}
}
}
- public void addBytes(byte[] content)
- {
- _content = content;
- }
-
- public byte[] getBytes()
- {
- return _content;
- }
-
public void replace(Body b)
{
if (b == null)
throw new IllegalArgumentException();
- addBytes(b.getBytes());
-
_objects = ((BodyImpl) b)._objects;
}
public void merge(Body b)
{
- if (b == null)
- throw new IllegalArgumentException();
-
- byte[] toAdd = b.getBytes();
-
- if ((toAdd != null) && (toAdd.length > 0))
- {
- if ((_content == null) || (_content.length == 0))
- {
- _content = toAdd;
- }
- else
- {
- int newSize = _content.length + toAdd.length;
- byte[] buffer = new byte[newSize];
-
- System.arraycopy(_content, 0, buffer, 0, _content.length);
- System.arraycopy(toAdd, 0, buffer, _content.length,
- toAdd.length);
-
- _content = buffer;
- }
- }
-
_objects.putAll(((BodyImpl) b)._objects);
}
- private byte[] _content;
-
private Hashtable<String, Object> _objects;
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/HeaderImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/HeaderImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -21,10 +21,13 @@
* @author mark.little at jboss.com
*/
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.jboss.internal.soa.esb.addressing.helpers.HeaderHelper;
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
-import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Header;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -41,24 +44,202 @@
public HeaderImpl ()
{
- _call = new Call();
}
- // TODO add other setters/getters for artibitrary attributes
+ /**
+ * Set the To field. Must not be null.
+ *
+ * @param epr the To field value.
+ */
- public Call getCall ()
+ public void setTo (EPR epr)
{
- return _call;
+ if (epr == null)
+ throw new IllegalArgumentException();
+
+ _to = epr;
}
- public void setCall (Call call)
+ /**
+ * @return the To field.
+ */
+
+ public EPR getTo ()
{
- if (call == null)
- throw new IllegalArgumentException();
+ return _to;
+ }
+
+ /**
+ * Set the From field. May be null.
+ *
+ * @param from the value of the field.
+ */
+
+ public void setFrom (EPR from)
+ {
+ _from = from;
+ }
+
+ /**
+ * @return the From field.
+ * @throws URISyntaxException thrown if the address is invalid.
+ */
+
+ public EPR getFrom ()
+ {
+ return _from;
+ }
+
+ /**
+ * Set the ReplyTo field. May be null.
+ *
+ * @param replyTo the value of the field.
+ */
+
+ public void setReplyTo (EPR replyTo)
+ {
+ _replyTo = replyTo;
+ }
+
+ /**
+ * @return the ReplyTo field.
+ * @throws URISyntaxException thrown if the address is invalid.
+ */
+
+ public EPR getReplyTo ()
+ {
+ return _replyTo;
+ }
+
+ /**
+ * Set the FaultTo field. May be null.
+ *
+ * @param uri the value of the field.
+ */
+
+ public void setFaultTo (EPR uri)
+ {
+ _faultTo = uri;
+ }
+
+ /**
+ * @return the FaultTo field.
+ */
+
+ public EPR getFaultTo ()
+ {
+ return _faultTo;
+ }
+
+ /**
+ * Set the RelatesTo field.
+ *
+ * @param uri the value to set.
+ */
+
+ public void setRelatesTo (URI uri)
+ {
+ _relatesTo = uri;
+ }
+
+ /**
+ * @return the RelatesTo field.
+ */
+
+ public URI getRelatesTo ()
+ {
+ return _relatesTo;
+ }
+
+ /**
+ * Set the Action field.
+ * @param uri the value to set.
+ */
+
+ public void setAction (URI uri)
+ {
+ _action = uri;
+ }
+
+ /**
+ * @return the Action field.
+ */
+ public URI getAction ()
+ {
+ return _action;
+ }
+
+ /**
+ * Set the MessageId for this instance.
+ *
+ * @param uri the value to use.
+ */
+
+ public void setMessageID (URI uri)
+ {
+ _messageID = uri;
+ }
+
+ /**
+ * @return the MessageID field.
+ */
+
+ public URI getMessageID ()
+ {
+ return _messageID;
+ }
+
+ public final boolean empty ()
+ {
+ if ((_to == null) && (_from == null) && (_replyTo == null))
+ {
+ if ((_relatesTo == null) && (_faultTo == null) && (_action == null) && (_messageID == null))
+ return true;
+ }
- _call = call;
+ return false;
}
+ /**
+ * Copy the instance specified.
+ *
+ * @param from the instance to copy.
+ */
+
+ public void copy (Header fromImpl)
+ {
+ _to = fromImpl.getTo();
+ _from = fromImpl.getFrom();
+ _replyTo = fromImpl.getReplyTo();
+ _relatesTo = fromImpl.getRelatesTo();
+ _faultTo = fromImpl.getFaultTo();
+ _action = fromImpl.getAction();
+ _messageID = fromImpl.getMessageID();
+ }
+
+// public void setMetaData (MetaData md);
+// public MetaData getMetaData ();
+// public void addReferenceParameter (...);
+
+ public String toString ()
+ {
+ return "To: "+_to+" From: "+_from+" ReplyTo: "+_replyTo+" FaultTo: "+_faultTo+" Action: "+_action+" MessagdID: "+_messageID;
+ }
+
+ /**
+ * This instance is valid if all mandatory elements are set.
+ *
+ * @return <code>true</code> if all mandatory elements are set, <code>false</code> otherwise.
+ */
+
+ public boolean valid ()
+ {
+ if ((_to != null) && (_action != null))
+ return true;
+ else
+ return false;
+ }
+
public Element toXML (Element envelope) throws MarshalException
{
Document doc = envelope.getOwnerDocument();
@@ -69,16 +250,11 @@
envelope.appendChild(headerElement);
- if (_call != null)
- return HeaderHelper.toXML(_call, doc, headerElement);
- else
- return headerElement;
+ return HeaderHelper.toXML(this, doc, headerElement);
}
public void fromXML (Element envelope) throws UnmarshalException
{
- _call = new Call();
-
NodeList nl = envelope.getChildNodes();
Element headerElement = null;
@@ -96,8 +272,15 @@
// TODO error handling!!
if (headerElement != null)
- _call = HeaderHelper.fromXML(headerElement);
+ HeaderHelper.fromXML(this, headerElement);
}
- private Call _call;
+ private EPR _to = null;
+ private EPR _from = null;
+ private EPR _faultTo = null;
+ private EPR _replyTo = null;
+ private URI _relatesTo = null;
+ private URI _action = null;
+ private URI _messageID = null;
+
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/MessageImpl.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/MessageImpl.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -21,7 +21,6 @@
package org.jboss.internal.soa.esb.message.normalized.xml;
import java.io.Serializable;
-import java.net.URI;
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
@@ -30,7 +29,6 @@
import org.jboss.soa.esb.message.Fault;
import org.jboss.soa.esb.message.Header;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -104,15 +102,6 @@
return _theFault;
}
- /**
- * @return the type of this message format.
- */
-
- public URI getType ()
- {
- return ExternalizationType.JBOSS_XML;
- }
-
// to/from XML here, rather than on individual elements
public Document toXML (Document doc) throws MarshalException
Deleted: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/XMLMessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/XMLMessagePlugin.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/normalized/xml/XMLMessagePlugin.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -1,48 +0,0 @@
-package org.jboss.internal.soa.esb.message.normalized.xml;
-
-import java.net.URI;
-
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationPlugin;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Used to plug in new message formats dynamically.
- *
- * @author Mark Little
- *
- */
-
-public class XMLMessagePlugin implements ExternalizationPlugin
-{
- public Message getMessage ()
- {
- return new MessageImpl();
- }
-
- public URI getType ()
- {
- return ExternalizationType.JBOSS_XML;
- }
-}
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -28,7 +28,6 @@
* A fault consists of a unique code (MANDATORY) and a reason string (OPTIONAL).
*/
-
// TODO make class
public interface Fault
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.XMLUtil;
@@ -35,7 +34,7 @@
* The message header. Contains such things as routing information.
*/
-public class Header
+public abstract class Header
{
/**
* Populate the header.
@@ -55,62 +54,50 @@
if (keys != null)
{
Iterator<String> iter = keys.iterator();
- Call theCall = null;
- if (theCall == null)
- theCall = new Call();
-
while (iter.hasNext())
{
String value = iter.next();
- boolean found = false;
if (value.equals(XMLUtil.ACTION_TAG))
{
- theCall.setAction((URI) contents.get(value));
- found = true;
+ setAction((URI) contents.get(value));
}
else
{
if (value.equals(XMLUtil.FAULT_TO_TAG))
{
- theCall.setFaultTo((EPR) contents.get(value));
- found = true;
+ setFaultTo((EPR) contents.get(value));
}
else
{
if (value.equals(XMLUtil.TO_TAG))
{
- theCall.setTo((EPR) contents.get(value));
- found = true;
+ setTo((EPR) contents.get(value));
}
else
{
if (value.equals(XMLUtil.REPLY_TO_TAG))
{
- theCall.setReplyTo((EPR) contents.get(value));
- found = true;
+ setReplyTo((EPR) contents.get(value));
}
else
{
if (value.equals(XMLUtil.FROM_TAG))
{
- theCall.setFrom((EPR) contents.get(value));
- found = true;
+ setFrom((EPR) contents.get(value));
}
else
{
if (value.equals(XMLUtil.MESSAGE_IDENTIFIER_TAG))
{
- theCall.setMessageID((URI) contents.get(value));
- found = true;
+ setMessageID((URI) contents.get(value));
}
else
{
if (value.equals(XMLUtil.RELATES_TO_TAG))
{
- theCall.setRelatesTo((URI) contents.get(value));
- found = true;
+ setRelatesTo((URI) contents.get(value));
}
}
}
@@ -118,10 +105,6 @@
}
}
}
-
-
- if (found)
- setCall(theCall);
}
}
}
@@ -137,22 +120,13 @@
* @param epr the To field value.
*/
- public void setTo (EPR epr)
- {
- if (epr == null)
- throw new IllegalArgumentException();
-
- _to = epr;
- }
+ public abstract void setTo (EPR epr);
/**
* @return the To field.
*/
- public EPR getTo ()
- {
- return _to;
- }
+ public abstract EPR getTo ();
/**
* Set the From field. May be null.
@@ -160,20 +134,14 @@
* @param from the value of the field.
*/
- public void setFrom (EPR from)
- {
- _from = from;
- }
+ public abstract void setFrom (EPR from);
/**
* @return the From field.
* @throws URISyntaxException thrown if the address is invalid.
*/
- public EPR getFrom ()
- {
- return _from;
- }
+ public abstract EPR getFrom ();
/**
* Set the ReplyTo field. May be null.
@@ -181,20 +149,14 @@
* @param replyTo the value of the field.
*/
- public void setReplyTo (EPR replyTo)
- {
- _replyTo = replyTo;
- }
+ public abstract void setReplyTo (EPR replyTo);
/**
* @return the ReplyTo field.
* @throws URISyntaxException thrown if the address is invalid.
*/
- public EPR getReplyTo ()
- {
- return _replyTo;
- }
+ public abstract EPR getReplyTo ();
/**
* Set the FaultTo field. May be null.
@@ -202,19 +164,13 @@
* @param uri the value of the field.
*/
- public void setFaultTo (EPR uri)
- {
- _faultTo = uri;
- }
+ public abstract void setFaultTo (EPR uri);
/**
* @return the FaultTo field.
*/
- public EPR getFaultTo ()
- {
- return _faultTo;
- }
+ public abstract EPR getFaultTo ();
/**
* Set the RelatesTo field.
@@ -222,37 +178,25 @@
* @param uri the value to set.
*/
- public void setRelatesTo (URI uri)
- {
- _relatesTo = uri;
- }
+ public abstract void setRelatesTo (URI uri);
/**
* @return the RelatesTo field.
*/
- public URI getRelatesTo ()
- {
- return _relatesTo;
- }
+ public abstract URI getRelatesTo ();
/**
* Set the Action field.
* @param uri the value to set.
*/
- public void setAction (URI uri)
- {
- _action = uri;
- }
+ public abstract void setAction (URI uri);
/**
* @return the Action field.
*/
- public URI getAction ()
- {
- return _action;
- }
+ public abstract URI getAction ();
/**
* Set the MessageId for this instance.
@@ -260,77 +204,28 @@
* @param uri the value to use.
*/
- public void setMessageID (URI uri)
- {
- _messageID = uri;
- }
+ public abstract void setMessageID (URI uri);
/**
* @return the MessageID field.
*/
- public URI getMessageID ()
- {
- return _messageID;
- }
+ public abstract URI getMessageID ();
- public final boolean empty ()
- {
- if ((_to == null) && (_from == null) && (_replyTo == null))
- {
- if ((_relatesTo == null) && (_faultTo == null) && (_action == null) && (_messageID == null))
- return true;
- }
-
- return false;
- }
-
/**
* Copy the instance specified.
*
* @param from the instance to copy.
*/
- public void copy (Header fromImpl)
- {
- _to = fromImpl._to;
- _from = fromImpl._from;
- _replyTo = fromImpl._replyTo;
- _relatesTo = fromImpl._relatesTo;
- _faultTo = fromImpl._faultTo;
- _action = fromImpl._action;
- _messageID = fromImpl._messageID;
- }
+ public abstract void copy (Header fromImpl);
-// public void setMetaData (MetaData md);
-// public MetaData getMetaData ();
-// public void addReferenceParameter (...);
-
- public String toString ()
- {
- return "To: "+_to+" From: "+_from+" ReplyTo: "+_replyTo+" FaultTo: "+_faultTo+" Action: "+_action+" MessagdID: "+_messageID;
- }
-
/**
* This instance is valid if all mandatory elements are set.
*
* @return <code>true</code> if all mandatory elements are set, <code>false</code> otherwise.
*/
- public boolean valid ()
- {
- if ((_to != null) && (_action != null))
- return true;
- else
- return false;
- }
+ public abstract boolean valid ();
- private EPR _to = null;
- private EPR _from = null;
- private EPR _faultTo = null;
- private EPR _replyTo = null;
- private URI _relatesTo = null;
- private URI _action = null;
- private URI _messageID = null;
-
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -71,10 +71,4 @@
public Fault getFault ();
- /**
- * @return the type of this message.
- */
-
- public URI getType ();
-
}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/MessageFactory.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/MessageFactory.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/MessageFactory.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -0,0 +1,49 @@
+package org.jboss.soa.esb.message;
+
+import org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl;
+import org.jboss.soa.esb.message.Message;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * You get a message of a specific type when you need it. Obviously that type may not be
+ * suitable for the service (hopefully you've got that contractual information a priori, but
+ * maybe not) and in which case some translation/transformation may be necessary.
+ *
+ * @author Mark Little
+ *
+ */
+
+public class MessageFactory
+{
+ /**
+ * @return some default implementation.
+ */
+
+ public static final Message getMessage ()
+ {
+ // TODO handle issues such as pooling, particularly in the case of large messages.
+
+ return new MessageImpl();
+ }
+
+}
Deleted: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -1,195 +0,0 @@
-/*
- * 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.addressing.tests;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.addressing.EPR;
-
-/**
- * Unit tests for the Class class.
- *
- * @author Mark Little
- */
-
-public class CallUnitTest extends TestCase
-{
- public void testConstructor ()
- {
- Call call = new Call();
-
- try
- {
- assertEquals((call.getTo() == null), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testEPRConstructor ()
- {
- try
- {
- EPR epr = new EPR(new URI("http://localhost"));
- Call call = new Call(epr);
-
- assertEquals(call.getTo().equals(epr), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetTo ()
- {
- Call call = new Call();
-
- try
- {
- EPR epr = new EPR(new URI("http://localhost"));
-
- call.setTo(epr);
-
- assertEquals(call.getTo().equals(epr), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetFrom ()
- {
- Call call = new Call();
-
- try
- {
- EPR epr = new EPR(new URI("http://localhost"));
-
- call.setFrom(epr);
-
- assertEquals(call.getFrom().equals(epr), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetReplyTo ()
- {
- Call call = new Call();
-
- try
- {
- EPR epr = new EPR(new URI("http://localhost"));
-
- call.setReplyTo(epr);
-
- assertEquals(call.getReplyTo().equals(epr), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetFaultTo ()
- {
- Call call = new Call();
-
- try
- {
- EPR epr = new EPR(new URI("http://localhost"));
-
- call.setFaultTo(epr);
-
- assertEquals(call.getFaultTo().equals(epr), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetRelatesTo ()
- {
- Call call = new Call();
-
- try
- {
- URI uri = new URI("urn:1234");
-
- call.setRelatesTo(uri);
-
- assertEquals(call.getRelatesTo().equals(uri), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetAction ()
- {
- Call call = new Call();
-
- try
- {
- URI uri = new URI("urn:1234");
-
- call.setAction(uri);
-
- assertEquals(call.getAction().equals(uri), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSetGetMessageID ()
- {
- Call call = new Call();
-
- try
- {
- URI uri = new URI("urn:1234");
-
- call.setMessageID(uri);
-
- assertEquals(call.getMessageID().equals(uri), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
-}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -33,7 +33,7 @@
import org.jboss.soa.esb.infrastructure.NullReceiverDispatcherPlugin;
import org.jboss.soa.esb.infrastructure.NullSenderDispatcherPlugin;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
+import org.jboss.soa.esb.message.MessageFactory;
/**
* Unit tests for the Dispatchers.
@@ -112,7 +112,7 @@
Dispatcher root = DispatcherFactory.getFactory().getDispatcherHierarchy(theContract.getRootContract());
- Message msg = ExternalizationFactory.getInstance().getMessage();
+ Message msg = MessageFactory.getMessage();
msg.getBody().add("foo", "bar");
Deleted: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -1,207 +0,0 @@
-/*
- * 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 javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
-import org.jboss.soa.esb.message.Attachment;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
-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 AttachmentUnitTest extends TestCase
-{
-
- public void testSerializeAttachment()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- Attachment at = msg.getAttachment();
-
- assertEquals((msg != null), true);
-
- at.addItem(new ExampleObject(0)); // un-named
- at.addItemAt(0, new ExampleObject(0)); // un-named;
-
- try
- {
- at.addItem(new Object());
-
- fail();
- }
- catch (IllegalArgumentException ex)
- {
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
-
- assertEquals(at.getUnnamedCount(), 2);
-
- assertEquals(at.get("foo"), null);
-
- at.put("foobar", new ExampleObject(1));
-
- assertEquals(at.getNamedCount(), 1);
-
- at.addItem(new ExampleObject(1));
- at.addItem(new ExampleObject(2));
-
- assertEquals((at.getNames() != null), true);
-
- assertEquals((at.removeItemAt(0) != null), true);
-
- at.replaceItemAt(0, new ExampleObject(2));
-
- int count = at.getUnnamedCount();
-
- 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.getAttachment().getUnnamedCount(), count);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testXMLAttachment()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
-
- assertEquals((msg != null), true);
-
- Attachment at = msg.getAttachment();
-
- assertEquals((msg != null), true);
-
- at.addItem(new ExampleObject(0)); // un-named
- at.addItemAt(0, new ExampleObject(0)); // un-named;
-
- try
- {
- at.addItem(new Object());
-
- fail();
- }
- catch (IllegalArgumentException ex)
- {
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
-
- assertEquals(at.getUnnamedCount(), 2);
-
- assertEquals(at.get("foo"), null);
-
- at.put("foobar", new ExampleObject(1));
-
- assertEquals(at.getNamedCount(), 1);
-
- at.addItem(new ExampleObject(1));
- at.addItem(new ExampleObject(2));
-
- assertEquals((at.getNames() != null), true);
-
- assertEquals((at.removeItemAt(0) != null), true);
-
- at.replaceItemAt(0, new ExampleObject(2));
-
- int count = at.getUnnamedCount();
-
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.normalized.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.normalized.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl();
-
- nImpl.fromXML(doc);
-
- assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
-}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -35,8 +35,7 @@
import org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
+import org.jboss.soa.esb.message.MessageFactory;
import org.w3c.dom.Document;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
@@ -55,8 +54,7 @@
{
// get XML message
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertEquals((msg != null), true);
@@ -108,8 +106,7 @@
{
// get XML message
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertEquals((msg != null), true);
@@ -154,74 +151,4 @@
}
}
- public void testSerializedAddString ()
- {
- // get XML message
-
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- try
- {
- msg.getBody().add("foo", "bar");
-
- assertEquals(msg.getBody().get("foo"), "bar");
-
- 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);
-
- org.jboss.internal.soa.esb.message.format.serialized.MessageImpl nImpl = (org.jboss.internal.soa.esb.message.format.serialized.MessageImpl) io.readObject();
-
- o.close();
-
- assertEquals(nImpl.getBody().get("foo"), "bar");
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testSerializedAddBoolean ()
- {
- // get XML message
-
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- try
- {
- msg.getBody().add("foo", new Boolean(true));
-
- assertEquals(msg.getBody().get("foo"), new Boolean(true));
-
- 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);
-
- org.jboss.internal.soa.esb.message.format.serialized.MessageImpl nImpl = (org.jboss.internal.soa.esb.message.format.serialized.MessageImpl) io.readObject();
-
- assertEquals(nImpl.getBody().get("foo"), new Boolean(true));
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -34,10 +34,8 @@
import junit.framework.TestCase;
-import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
+import org.jboss.soa.esb.message.MessageFactory;
import org.w3c.dom.Document;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
@@ -52,48 +50,9 @@
public class FaultUnitTest extends TestCase
{
- public void testSerializeFault ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.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 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertEquals((msg != null), true);
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -25,8 +25,7 @@
import junit.framework.TestCase;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
+import org.jboss.soa.esb.message.MessageFactory;
/**
* Unit tests for the Class class.
@@ -39,38 +38,22 @@
public void testDefaultMessageFields ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage();
+ Message msg = MessageFactory.getMessage();
assertEquals((msg.getBody() != null), true);
assertEquals((msg.getHeader() != null), true);
assertEquals((msg.getContext() != null), true);
- assertEquals((msg.getAttachment() != null), true);
assertEquals((msg.getFault() != null), true);
- assertEquals((msg.getProperties() != null), true);
}
public void testXMLMessageFields ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertEquals((msg.getBody() != null), true);
assertEquals((msg.getHeader() != null), true);
assertEquals((msg.getContext() != null), true);
- assertEquals((msg.getAttachment() != null), true);
assertEquals((msg.getFault() != null), true);
- assertEquals((msg.getProperties() != null), true);
}
- public void testSerializedMessageFields ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg.getBody() != null), true);
- assertEquals((msg.getHeader() != null), true);
- assertEquals((msg.getContext() != null), true);
- assertEquals((msg.getAttachment() != null), true);
- assertEquals((msg.getFault() != null), true);
- assertEquals((msg.getProperties() != null), true);
- }
-
}
Deleted: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -1,161 +0,0 @@
-/*
- * 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 javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
-import org.w3c.dom.Document;
-
-/**
- * Unit tests for the Class class.
- *
- * @author Mark Little
- */
-
-public class PropertiesUnitTest extends TestCase
-{
-
- public void testSerializeProperties()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.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 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.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.normalized.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl) msg;
-
- doc = theImpl.toXML(doc);
-
- org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl();
-
- nImpl.fromXML(doc);
-
- assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
-
- assertEquals(msg.getProperties().remove("foo"), "bar");
- }
-
-}
Deleted: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -1,667 +0,0 @@
-/*
- * 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.net.URI;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.EmailEpr;
-import org.jboss.soa.esb.addressing.eprs.FTPEpr;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
-import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
-
-/**
- * Unit tests for the Class class.
- *
- * @author Mark Little
- */
-
-public class SerializedMessageUnitTest extends TestCase
-{
-
- public void testSerialize()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- try
- {
- ByteArrayOutputStream s = new ByteArrayOutputStream();
- ObjectOutputStream o = new ObjectOutputStream(s);
-
- o.writeObject(msg);
- o.close();
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
-
- }
-
- public void testDeserialize()
- {
- // get XML message
-
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- 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);
-
- @SuppressWarnings("unused")
- MessageImpl nImpl = (MessageImpl) io.readObject();
-
- o.close();
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testHeader ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- Call call = new Call();
-
- msg.getHeader().setCall(call);
-
- call = msg.getHeader().getCall();
-
- assertEquals((call != null), true);
-
- try
- {
- msg.getHeader().setCall(null);
-
- fail();
- }
- catch (IllegalArgumentException ex)
- {
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testInvalidAdd ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- try
- {
- msg.getBody().add(null, null);
-
- fail();
- }
- catch (IllegalArgumentException ex)
- {
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testAddBytes ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- String testString = "test";
-
- msg.getBody().addBytes(testString.getBytes());
-
- 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();
-
- o.close();
-
- String val = new String(nImpl.getBody().getBytes());
-
- assertEquals(val, testString);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testReplace ()
- {
- Message msg1 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg1 != null), true);
-
- String foo = "foo";
-
- Message msg2 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg2 != null), true);
-
- String bar = "bar";
-
- msg1.getBody().addBytes(foo.getBytes());
- msg2.getBody().addBytes(bar.getBytes());
-
- msg1.getBody().replace(msg2.getBody());
-
- String foobar = new String(msg1.getBody().getBytes());
-
- assertEquals(foobar.equals("bar"), true);
- }
-
- public void testMerge ()
- {
- Message msg1 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg1 != null), true);
-
- String foo = "foo";
-
- Message msg2 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg2 != null), true);
-
- String bar = "bar";
-
- msg1.getBody().addBytes(foo.getBytes());
- msg2.getBody().addBytes(bar.getBytes());
-
- msg1.getBody().merge(msg2.getBody());
-
- String foobar = new String(msg1.getBody().getBytes());
-
- assertEquals(foobar, "foobar");
- }
-
- public void testAddObjects ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- ExampleObject value = new ExampleObject(1234);
-
- msg.getBody().add("foo", value);
-
- 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();
-
- o.close();
-
- ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
-
- assertEquals((foo.getValue() == value.getValue()), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testGetNames ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- ExampleObject value = new ExampleObject(1234);
-
- msg.getBody().add("foo", value);
- msg.getBody().add("bar", value);
-
- String[] names = msg.getBody().getNames();
-
- assertNotNull(names);
-
- assertEquals(names.length, 2);
-
- /*
- * The array comes back ordered alphabetically.
- */
-
- assertEquals(names[0], "bar");
- assertEquals(names[1], "foo");
-
- 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();
-
- o.close();
-
- ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
-
- assertEquals((foo.getValue() == value.getValue()), true);
-
- names = nImpl.getBody().getNames();
-
- assertNotNull(names);
-
- assertEquals(names.length, 2);
- assertEquals(names[0], "foo");
- assertEquals(names[1], "bar");
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testAddInvalidObject ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- try
- {
- msg.getBody().add("foo", new Object());
-
- fail();
- }
- catch (IllegalArgumentException ex)
- {
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testRemoveObjects ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JAVA_SERIALIZED);
-
- assertEquals((msg != null), true);
-
- ExampleObject value = new ExampleObject(1234);
-
- msg.getBody().add("bar", value);
-
- msg.getBody().remove("bar");
-
- 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();
-
- o.close();
-
- ExampleObject foo = (ExampleObject) nImpl.getBody().get("bar");
-
- assertEquals((foo == null), true);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
- public void testJmsEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
- JMSEpr epr = new JMSEpr(JMSEpr.TOPIC_TYPE, "foo", "bar");
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof JMSEpr, true);
-
- assertEquals(((JMSEpr) theEpr).getConnectionFactory(), "bar");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testHttpEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- HTTPEpr epr = new HTTPEpr("http://www.foo.bar");
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof HTTPEpr, true);
-
- assertEquals(((HTTPEpr) theEpr).getURI().toString(), "http://www.foo.bar");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testEmailEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- EmailEpr epr = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foo.bar", "25", "me", "password");
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof EmailEpr, true);
-
- assertEquals(((EmailEpr) theEpr).getPassword(), "password");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testFtpEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- FTPEpr epr = new FTPEpr("http://www.foo.bar");
-
- epr.setPassive(true);
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof FTPEpr, true);
-
- assertEquals(((FTPEpr) theEpr).getPassive(), true);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testJdbcEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- JDBCEpr epr = new JDBCEpr("http://www.foo.bar", "SOME FAKE SQL");
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof JDBCEpr, true);
-
- assertEquals(((JDBCEpr) theEpr).getSQL(), "SOME FAKE SQL");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testFileEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- FileEpr epr = new FileEpr("file://tmp/bar.txt");
-
- epr.setErrorDelete(true);
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof FileEpr, true);
-
- assertEquals(((FileEpr) theEpr).getErrorDelete(), true);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
- public void testSFtpEPRType ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JAVA_SERIALIZED);
-
- try
- {
- SFTPEpr epr = new SFTPEpr(new URI("http://www.foo.bar"), new URI("http://www.bar.foo"));
-
- assertEquals(epr.getCertificateURI().toString(), "http://www.bar.foo");
-
- msg.getHeader().getCall().setTo(epr);
-
- 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();
-
- o.close();
-
- EPR theEpr = nImpl.getHeader().getCall().getTo();
-
- assertEquals(theEpr instanceof SFTPEpr, true);
-
- assertEquals(((SFTPEpr) theEpr).getCertificateURI().toString(), "http://www.bar.foo");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- fail(ex.toString());
- }
- }
-
-}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -32,7 +32,6 @@
import junit.framework.TestCase;
import org.jboss.internal.soa.esb.message.normalized.xml.MessageImpl;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.eprs.EmailEpr;
import org.jboss.soa.esb.addressing.eprs.FTPEpr;
@@ -41,9 +40,9 @@
import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.jboss.soa.esb.message.Header;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
-import org.jboss.soa.esb.message.externalization.ExternalizationType;
+import org.jboss.soa.esb.message.MessageFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -63,8 +62,7 @@
{
// get XML message
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
@@ -84,8 +82,7 @@
{
// get XML message
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
@@ -103,22 +100,17 @@
public void testHeader ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
-
- Call call = new Call();
-
- msg.getHeader().setCall(call);
- call = msg.getHeader().getCall();
+ Header call = msg.getHeader();
assertNotNull("message call", call);
try
{
- msg.getHeader().setCall(null);
+ msg.getHeader().setTo(null);
fail();
}
@@ -133,8 +125,7 @@
public void testInvalidAdd ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
@@ -153,91 +144,57 @@
}
}
- public void testAddBytes ()
- {
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
-
- assertNotNull("created message", msg);
-
- String testString = "test";
-
- msg.getBody().addBytes(testString.getBytes());
-
- try
- {
- final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
- System.err.println("Document is "+xmlRepresentation);
-
- final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
-
- String val = new String(nImpl.getBody().getBytes());
-
- assertEquals(val, testString);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
- }
-
public void testReplace ()
{
- Message msg1 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg1 = MessageFactory.getMessage();
assertNotNull("created message", msg1);
String foo = "foo";
- Message msg2 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg2 = MessageFactory.getMessage();
assertNotNull("second created message", msg2);
String bar = "bar";
- msg1.getBody().addBytes(foo.getBytes());
- msg2.getBody().addBytes(bar.getBytes());
+ msg1.getBody().add("foo", foo);
+ msg2.getBody().add("bar", bar);
msg1.getBody().replace(msg2.getBody());
- String foobar = new String(msg1.getBody().getBytes());
+ String foobar = (String) msg1.getBody().get("bar");
assertEquals(foobar, "bar");
}
public void testMerge ()
{
- Message msg1 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg1 = MessageFactory.getMessage();
assertNotNull("created message", msg1);
String foo = "foo";
- Message msg2 = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg2 = MessageFactory.getMessage();
assertNotNull("second created message", msg2);
String bar = "bar";
- msg1.getBody().addBytes(foo.getBytes());
- msg2.getBody().addBytes(bar.getBytes());
+ msg1.getBody().add("foo", foo);
+ msg2.getBody().add("bar", bar);
msg1.getBody().merge(msg2.getBody());
- String foobar = new String(msg1.getBody().getBytes());
-
- assertEquals(foobar, "foobar");
+ assertEquals((String) msg1.getBody().get("foo"), "foo");
+ assertEquals((String) msg1.getBody().get("bar"), "bar");
}
public void testAddObjects ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
-
+ Message msg = MessageFactory.getMessage();
+
assertNotNull("created message", msg);
ExampleObject value = new ExampleObject(1234);
@@ -267,8 +224,7 @@
public void testGetNames ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
@@ -324,8 +280,7 @@
public void testRemoveObjects ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(
- ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
assertNotNull("created message", msg);
@@ -354,10 +309,10 @@
public void testJmsEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
JMSEpr epr = new JMSEpr(JMSEpr.TOPIC_TYPE, "foo", "bar");
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
try
{
@@ -366,7 +321,7 @@
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof JMSEpr, true);
@@ -380,20 +335,20 @@
public void testHttpEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
-
+ Message msg = MessageFactory.getMessage();
+
try
{
HTTPEpr epr = new HTTPEpr("http://www.foo.bar");
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof HTTPEpr, true);
@@ -407,20 +362,20 @@
public void testEmailEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
try
{
EmailEpr epr = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foo.bar", "25", "me", "password");
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof EmailEpr, true);
@@ -434,22 +389,22 @@
public void testFtpEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
-
+ Message msg = MessageFactory.getMessage();
+
try
{
FTPEpr epr = new FTPEpr("http://www.foo.bar");
epr.setPassive(true);
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof FTPEpr, true);
@@ -463,20 +418,20 @@
public void testJdbcEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
try
{
JDBCEpr epr = new JDBCEpr("http://www.foo.bar", "SOME FAKE SQL");
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof JDBCEpr, true);
@@ -490,7 +445,7 @@
public void testFileEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
try
{
@@ -498,14 +453,14 @@
epr.setErrorDelete(true);
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof FileEpr, true);
@@ -519,7 +474,7 @@
public void testSFtpEPRType ()
{
- Message msg = ExternalizationFactory.getInstance().getMessage(ExternalizationType.JBOSS_XML);
+ Message msg = MessageFactory.getMessage();
try
{
@@ -527,14 +482,14 @@
assertEquals(epr.getCertificateURI().toString(), "http://www.bar.foo");
- msg.getHeader().getCall().setTo(epr);
+ msg.getHeader().setTo(epr);
final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
System.err.println("Document is "+xmlRepresentation);
final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
- EPR theEpr = nImpl.getHeader().getCall().getTo();
+ EPR theEpr = nImpl.getHeader().getTo();
assertEquals(theEpr instanceof SFTPEpr, true);
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpClient.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpClient.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpClient.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -5,13 +5,12 @@
import javax.xml.parsers.DocumentBuilderFactory;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.api.Sender;
import org.jboss.soa.esb.api.SenderFactory;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
+import org.jboss.soa.esb.message.MessageFactory;
import org.jboss.soa.esb.spi.Receiver;
import org.jboss.soa.esb.spi.ReceiverFactory;
import org.jboss.soa.esb.spi.Service;
@@ -127,15 +126,15 @@
* Create the message payload.
*/
- Message msg = ExternalizationFactory.getInstance().getMessage();
+ Message msg = MessageFactory.getMessage();
Body payload = msg.getBody();
String message = "Hello World";
- payload.addBytes(message.getBytes());
+ payload.add("message", message);
- msg.getHeader().setCall(new Call(epr));
- msg.getHeader().getCall().setReplyTo(new EPR(response));
+ msg.getHeader().setTo(epr);
+ msg.getHeader().setReplyTo(new EPR(response));
/*
* Send the message payload.
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpService.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpService.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/oneway/TcpService.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -5,13 +5,12 @@
import javax.xml.parsers.DocumentBuilderFactory;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.api.Sender;
import org.jboss.soa.esb.api.SenderFactory;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
+import org.jboss.soa.esb.message.MessageFactory;
import org.jboss.soa.esb.spi.Receiver;
import org.jboss.soa.esb.spi.ReceiverFactory;
import org.jboss.soa.esb.spi.Service;
@@ -70,20 +69,20 @@
try
{
- Sender tcpClientPlugin = SenderFactory.getInstance().getSender(msg.getHeader().getCall().getReplyTo());
+ Sender tcpClientPlugin = SenderFactory.getInstance().getSender(msg.getHeader().getReplyTo());
- Message response = ExternalizationFactory.getInstance().getMessage();
- response.getHeader().setCall(new Call(msg.getHeader().getCall().getReplyTo()));
+ Message response = MessageFactory.getMessage();
+ response.getHeader().setTo(msg.getHeader().getReplyTo());
Body payload = response.getBody();
String message = "Echo echo echo echo";
- payload.addBytes(message.getBytes());
+ payload.add("message", message);
tcpClientPlugin.send(response);
- System.err.println("Sent response to "+response.getHeader().getCall().getTo());
+ System.err.println("Sent response to "+response.getHeader().getTo());
}
catch (Exception ex)
{
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpClient.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpClient.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpClient.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -5,13 +5,12 @@
import javax.xml.parsers.DocumentBuilderFactory;
-import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.api.SenderFactory;
import org.jboss.soa.esb.api.TwoWaySender;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
+import org.jboss.soa.esb.message.MessageFactory;
import org.w3c.dom.Document;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
@@ -94,14 +93,14 @@
* Create the message payload.
*/
- Message msg = ExternalizationFactory.getInstance().getMessage();
+ Message msg = MessageFactory.getMessage();
Body payload = msg.getBody();
String message = "Hello World";
- payload.addBytes(message.getBytes());
+ payload.add("message", message);
- msg.getHeader().setCall(new Call(epr));
+ msg.getHeader().setTo(epr);
/*
* Send the message payload.
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpService.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpService.java 2007-08-21 06:49:14 UTC (rev 14409)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/twoway/TcpService.java 2007-08-21 08:54:01 UTC (rev 14410)
@@ -8,7 +8,7 @@
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.externalization.ExternalizationFactory;
+import org.jboss.soa.esb.message.MessageFactory;
import org.jboss.soa.esb.spi.Receiver;
import org.jboss.soa.esb.spi.ReceiverFactory;
import org.jboss.soa.esb.spi.Service;
@@ -69,12 +69,12 @@
* How do we get the implicit ReplyTo address?
*/
- Message response = ExternalizationFactory.getInstance().getMessage();
+ Message response = MessageFactory.getMessage();
Body payload = response.getBody();
String message = "Echo echo echo echo";
- payload.addBytes(message.getBytes());
+ payload.add("message", message);
return response;
}
More information about the jboss-svn-commits
mailing list