[jboss-svn-commits] JBL Code SVN: r6304 - 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/format tests/src/org/jboss/soa/esb tests/src/org/jboss/soa/esb/addressing tests/src/org/jboss/soa/esb/addressing/tests tests/src/org/jboss/soa/esb/message tests/src/org/jboss/soa/esb/message/format 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
Tue Sep 19 17:12:34 EDT 2006


Author: mark.little at jboss.com
Date: 2006-09-19 17:12:15 -0400 (Tue, 19 Sep 2006)
New Revision: 6304

Added:
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.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/
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/MessageUnitTest.java
Removed:
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java
Modified:
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/CallHelper.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/MessageImpl.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/soa/esb/message/format/MessageFactory.java
Log:
added unit tests for EPR and Message.

Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/CallHelper.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/CallHelper.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/CallHelper.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -60,7 +60,7 @@
 			header.appendChild(replyToElement);
 			
 			Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG);
-			PortReferenceHelper.toXML(header, doc, relatesToElement, call.getRelatesTo().getAddr(), false);
+			relatesToElement.setNodeValue(call.getRelatesTo().toString());
 			header.appendChild(relatesToElement);
 			
 			Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG);
@@ -139,7 +139,7 @@
 				{
 					try
 					{
-						call.setRelatesTo(new EPR(PortReferenceHelper.fromXML((Element) n, false)));
+						call.setRelatesTo(new URI(n.getNodeValue()));
 					}
 					catch (Exception ex)
 					{

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-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -6,6 +6,7 @@
 
 import org.jboss.soa.esb.message.format.MessagePlugin;
 
+import org.jboss.internal.soa.esb.message.format.serialized.SerializedMessagePlugin;
 import org.jboss.internal.soa.esb.message.format.xml.XMLMessagePlugin;
 
 import java.net.URI;
@@ -47,6 +48,13 @@
 
 	public MessageFactoryImpl ()
 	{
+		reset();
+	}
+
+	public void reset ()
+	{
+		messageFormats.clear();
+		
 		/*
 		 * Go through the properties loaded from the property file. Anything
 		 * starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be a plugin
@@ -62,7 +70,7 @@
 			while (names.hasMoreElements())
 			{
 				String attrName = (String) names.nextElement();
-
+				
 				if (attrName.startsWith(MessagePlugin.MESSAGE_PLUGIN))
 				{
 					try
@@ -70,7 +78,7 @@
 						String pluginName = properties.getProperty(attrName);
 						Class c = Class.forName(pluginName);
 						MessagePlugin thePlugin = (MessagePlugin) c.newInstance();
-						
+
 						messageFormats.put(thePlugin.getType(), thePlugin);
 					}
 					catch (ClassNotFoundException ex)
@@ -94,8 +102,9 @@
 		 */
 		
 		messageFormats.put(MessageType.JBOSS_XML, new XMLMessagePlugin());
+		messageFormats.put(MessageType.JAVA_SERIALIZED, new SerializedMessagePlugin());
 	}
-
+	
 	public Message getMessage() // returns some default implementation.
 	{
 		return ((MessagePlugin) messageFormats.get(MessageType.DEFAULT_TYPE)).getMessage();
@@ -106,7 +115,12 @@
 		if (type == null)
 			throw new InvalidParameterException();
 
-		return ((MessagePlugin) messageFormats.get(type)).getMessage();
+		MessagePlugin plugin = messageFormats.get(type);
+
+		if (plugin != null)
+			return plugin.getMessage();
+		else
+			return null;
 	}
 
 	public Message getMessage(Message msg, URI type) // convert a message

Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -1,6 +1,11 @@
 package org.jboss.internal.soa.esb.message.format.serialized;
 
-import org.jboss.soa.esb.message.*;
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+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.format.MessageType;
 
 import java.net.URI;

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-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -1,6 +1,11 @@
 package org.jboss.internal.soa.esb.message.format.xml;
 
-import org.jboss.soa.esb.message.*;
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+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.format.MessageType;
 
 import org.w3c.dom.Document;

Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -59,6 +59,14 @@
 	
 	public abstract Message getMessage (Message msg, URI type);
 	
+	/**
+	 * Reload the plugins.
+	 */
+	
+	public abstract void reset ();
+	
+	// TODO setters/getters for the plugin programmatically too.
+	
 	public static MessageFactory getInstance ()
 	{
 		return theFactory;

Deleted: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -1,194 +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;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.addressing.Call;
-
-/**
- * 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());
-		}
-	}
-	
-}

Deleted: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -1,115 +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;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.PortReference;
-
-import java.net.URI;
-
-/**
- * Unit tests for the EPR class.
- * 
- * @author Mark Little
- */
-
-public class EPRUnitTest extends TestCase
-{
-
-	public void testConstructor ()
-	{
-		EPR epr = new EPR();
-		
-		System.err.println("Default EPR: "+epr);
-	}
-	
-	public void testPortReferenceConstructor ()
-	{
-		EPR epr = new EPR(new PortReference("http://localhost:8080"));
-		
-		assertEquals(epr.toString(), "EPR: PortReference < http://localhost:8080 >");
-	}
-	
-	public void testURIConstructor ()
-	{
-		try
-		{
-			EPR epr = new EPR(new URI("urn:foo:bar"));
-			
-			assertEquals(epr.toString(), "EPR: PortReference < urn:foo:bar >");
-		}
-		catch (Exception ex)
-		{
-			fail(ex.toString());
-		}
-	}
-	
-	public void testGetAddr ()
-	{
-		try
-		{
-			EPR epr = new EPR(new URI("urn:foo:bar"));
-		
-			assertEquals(epr.getAddr().getAddress(), "urn:foo:bar");
-		}
-		catch (Exception ex)
-		{
-			fail(ex.toString());
-		}
-	}
-	
-	public void testSetAddr ()
-	{
-		EPR epr = new EPR();
-		
-		epr.setAddr(new PortReference("http://localhost"));
-
-		try
-		{
-			assertEquals(epr.getAddr().getAddress(), "http://localhost");
-		}
-		catch (Exception ex)
-		{
-			fail(ex.toString());
-		}
-	}
-	
-	public void testEquals ()
-	{
-		try
-		{
-			EPR epr1 = new EPR(new URI("http://localhost"));
-			EPR epr2 = new EPR(new URI("http://localhost"));
-			EPR epr3 = new EPR(new URI("http://localhost:8080"));
-			
-			assertEquals(epr1.equals(epr2), true);
-			assertEquals(epr1.equals(epr3), false);
-		}
-		catch (Exception ex)
-		{
-			fail(ex.toString());
-		}
-	}
-}

Copied: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java (from rev 6301, labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java)
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/CallUnitTest.java	2006-09-19 16:16:31 UTC (rev 6301)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,195 @@
+/*
+ * 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());
+		}
+	}
+	
+}

Copied: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java (from rev 6301, labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java)
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/EPRUnitTest.java	2006-09-19 16:16:31 UTC (rev 6301)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,115 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+
+import java.net.URI;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class EPRUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		EPR epr = new EPR();
+		
+		System.err.println("Default EPR: "+epr);
+	}
+	
+	public void testPortReferenceConstructor ()
+	{
+		EPR epr = new EPR(new PortReference("http://localhost:8080"));
+		
+		assertEquals(epr.toString(), "EPR: PortReference < http://localhost:8080 >");
+	}
+	
+	public void testURIConstructor ()
+	{
+		try
+		{
+			EPR epr = new EPR(new URI("urn:foo:bar"));
+			
+			assertEquals(epr.toString(), "EPR: PortReference < urn:foo:bar >");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testGetAddr ()
+	{
+		try
+		{
+			EPR epr = new EPR(new URI("urn:foo:bar"));
+		
+			assertEquals(epr.getAddr().getAddress(), "urn:foo:bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetAddr ()
+	{
+		EPR epr = new EPR();
+		
+		epr.setAddr(new PortReference("http://localhost"));
+
+		try
+		{
+			assertEquals(epr.getAddr().getAddress(), "http://localhost");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testEquals ()
+	{
+		try
+		{
+			EPR epr1 = new EPR(new URI("http://localhost"));
+			EPR epr2 = new EPR(new URI("http://localhost"));
+			EPR epr3 = new EPR(new URI("http://localhost:8080"));
+			
+			assertEquals(epr1.equals(epr2), true);
+			assertEquals(epr1.equals(epr3), false);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,109 @@
+package org.jboss.soa.esb.message.format.tests;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+import org.jboss.soa.esb.message.Fault;
+import org.jboss.soa.esb.message.Header;
+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
+ */
+
+/**
+ * Used to plug in new message formats dynamically. Each plugin is responsible for
+ * returning a message implementation that knows how to serialize its state in a
+ * specific manner, e.g., XML or ASN.1.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class ExampleMessageImpl implements Message
+{
+	
+	/**
+	 * @return get the header component of the message.
+	 */
+	
+	public Header getHeader ()
+	{
+		return null;
+	}
+
+	/**
+	 * @return get the context component of the message.
+	 */
+	
+	public Context getContext ()
+	{
+		return null;
+	}
+	
+	/**
+	 * @return get the body component of the message.
+	 */
+	
+	public Body getBody ()
+	{
+		return null;
+	}
+
+	/**
+	 * @return get any faults associated with the message. These should not
+	 * be application level faults, but comms level.
+	 */
+	
+	public Fault getFault ()
+	{
+		return null;
+	}
+	
+	/**
+	 * @return get any message attachments.
+	 */
+	
+	public Attachment getAttachment ()
+	{
+		return null;
+	}
+	
+	/**
+	 * @return the type of this message.
+	 */
+	
+	public URI getType ()
+	{
+		try
+		{
+			return new URI(ExampleMessagePlugin.URN);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+	
+}

Added: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,69 @@
+package org.jboss.soa.esb.message.format.tests;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+
+import java.net.URI;
+
+/*
+ * 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. Each plugin is responsible for
+ * returning a message implementation that knows how to serialize its state in a
+ * specific manner, e.g., XML or ASN.1.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class ExampleMessagePlugin implements MessagePlugin
+{
+	
+	public static final String URN = "foobar";
+	
+	/**
+	 * @return the message instance.
+	 */
+	
+	public Message getMessage ()
+	{
+		return new ExampleMessageImpl();
+	}
+	
+	/**
+	 * @return the unique identifier for this message plugin.
+	 */
+	
+	public URI getType ()
+	{
+		try
+		{
+			return new URI(URN);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+}

Added: 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-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,114 @@
+/*
+ * 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.format.tests;
+
+import java.net.URI;
+import java.security.InvalidParameterException;
+
+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.MessagePlugin;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class MessageFactoryUnitTest extends TestCase
+{
+	public void testDefaultMessage ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage();
+		
+		assertEquals((msg != null), true);
+	}
+	
+	public void testURIMessage ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
+		Message msg2 = MessageFactory.getInstance().getMessage();
+		
+		assertEquals(msg1.getType().equals(msg2.getType()), true);
+		
+		Message msg3 = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		
+		assertEquals(msg1.getType().equals(msg3.getType()), false);
+	}
+	
+	public void testInvalidURIMessage ()
+	{
+		try
+		{
+			Message msg = MessageFactory.getInstance().getMessage(new URI("urn:foo"));
+			
+			assertEquals((msg == null), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testNullURIMessage ()
+	{
+		try
+		{
+			Message msg = MessageFactory.getInstance().getMessage(null);
+			
+			fail();
+		}
+		catch (InvalidParameterException ex)
+		{
+			// success
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testPlugin ()
+	{
+		System.setProperty(MessagePlugin.MESSAGE_PLUGIN+"1", ExampleMessagePlugin.class.getName());
+		
+		MessageFactory.getInstance().reset();
+		
+		try
+		{
+			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)
+		{
+			fail(ex.toString());
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/MessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/MessageUnitTest.java	2006-09-19 17:26:13 UTC (rev 6303)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/MessageUnitTest.java	2006-09-19 21:12:15 UTC (rev 6304)
@@ -0,0 +1,50 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class MessageUnitTest extends TestCase
+{
+	
+	public void testFields ()
+	{
+		Message msg = MessageFactory.getInstance().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);
+	}
+	
+}




More information about the jboss-svn-commits mailing list