[jboss-svn-commits] JBL Code SVN: r6369 - labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 22 11:19:05 EDT 2006


Author: estebanschifman
Date: 2006-09-22 11:19:03 -0400 (Fri, 22 Sep 2006)
New Revision: 6369

Added:
   labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessageAttachmentSerializeTest.java
Modified:
   labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessagePropertiesSerializeTest.java
Log:
Tests for message Properties and Attachment

Added: labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessageAttachmentSerializeTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessageAttachmentSerializeTest.java	2006-09-22 15:17:42 UTC (rev 6368)
+++ labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessageAttachmentSerializeTest.java	2006-09-22 15:19:03 UTC (rev 6369)
@@ -0,0 +1,112 @@
+/*
+ * 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.rosetta.qa;
+
+import junit.framework.TestCase;
+
+import java.io.*;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.soa.esb.message.Attachment;
+import org.w3c.dom.*;
+
+/**
+ * QA tests for the Message interface and implementations.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class MessageAttachmentSerializeTest extends TestCase 
+{
+
+	protected void setUp() throws Exception 
+	{
+	}
+
+	public void runTest() throws Exception 
+	{
+		testJavaSerializable();
+		testXml();
+	}
+
+	private static final File TESTFILE = new File("msgAttachment.test");
+	protected void tearDown() throws Exception 
+	{
+		TESTFILE.delete();
+	}
+	
+	private void testJavaSerializable() throws Exception
+	{
+		org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+		old = new  org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl();
+		populateAttachment(old);
+		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
+		out.writeObject(old);
+		out.close();
+
+		ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
+		org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+		oNew = (org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl)
+			inp.readObject();
+		inp.close();
+
+		assertEquals(old,oNew);
+	}
+
+	private void testXml() throws Exception
+	{
+		DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();	
+		Document oDoc = oDB.newDocument();
+		Element  oRoot = oDoc.createElement("root");
+		oDoc.appendChild(oRoot);
+		
+		org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
+		old = new  org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
+		populateAttachment(old);
+		old.toXML(oRoot);
+		
+		org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
+		oNew = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();		
+		oNew.fromXML(oRoot);
+
+		assertEquals(old,oNew);
+		
+		Document oD2 = oDB.newDocument();
+		Element  oR2 = oD2.createElement("root");
+		oD2.appendChild(oR2);
+		oNew.toXML(oR2);
+
+		String s1 = Util.toString(oRoot);
+		String s2 = Util.toString(oR2);
+		assertEquals(s1,s2);
+
+	}
+	
+	private void populateAttachment(Attachment att)
+	{
+		att.addItem("unnamed att 1");
+		att.put("name 2","N2N2N2N2N2N2N2N2");
+		att.addItem("unn 2");
+		att.put("name 1","named att 111111111111111");
+	}
+}

Modified: labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessagePropertiesSerializeTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessagePropertiesSerializeTest.java	2006-09-22 15:17:42 UTC (rev 6368)
+++ labs/jbossesb/workspace/rearchitecture/qa/junit/src/org/jboss/soa/esb/rosetta/qa/MessagePropertiesSerializeTest.java	2006-09-22 15:19:03 UTC (rev 6369)
@@ -23,7 +23,6 @@
 package org.jboss.soa.esb.rosetta.qa;
 
 import junit.framework.TestCase;
-import junit.framework.TestResult;
 
 import java.io.*;
 
@@ -49,7 +48,7 @@
 		testXml();
 	}
 
-	private static final File TESTFILE = new File("serialize.test");
+	private static final File TESTFILE = new File("msgProperties.test");
 	protected void tearDown() throws Exception 
 	{
 		TESTFILE.delete();




More information about the jboss-svn-commits mailing list