[jboss-svn-commits] JBL Code SVN: r13387 - in labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions: naming and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 12 01:15:40 EDT 2007


Author: tcunning
Date: 2007-07-12 01:15:38 -0400 (Thu, 12 Jul 2007)
New Revision: 13387

Added:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/AddTimestampNamingStrategyUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/ChangeSuffixNamingStrategyUnitTest.java
Log:
bug:JBESB-563
Test the naming strategy classes.


Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/AddTimestampNamingStrategyUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/AddTimestampNamingStrategyUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/AddTimestampNamingStrategyUnitTest.java	2007-07-12 05:15:38 UTC (rev 13387)
@@ -0,0 +1,65 @@
+/*
+ * 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.actions.naming.strategy;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the timestamp naming strategy.
+ * 
+ * @author <a href="mailto:tcunning at redhat.com">tcunning at redhat.com</a>
+ */
+public class AddTimestampNamingStrategyUnitTest extends TestCase {
+	private static String FILENAME = "word";
+	private static String SUFFIX = "doc";
+
+	private static Logger logger = Logger.getLogger(AddTimestampNamingStrategyUnitTest.class);
+	
+	public void testProcess() {
+		AddTimestampNamingStrategy atns = new AddTimestampNamingStrategy();
+		Message msg1 = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		msg1.getBody().add("foo", "bar");
+		try {
+			msg1.getHeader().getCall().setTo(new HTTPEpr("http://foo.bar"));
+			msg1.getHeader().getCall().setMessageID(new URI("urn:1234"));
+		} catch (URISyntaxException e1) {
+			e1.printStackTrace();
+			fail(e1.getMessage());
+		}
+		
+		String filename = atns.process(FILENAME + "."  + SUFFIX, msg1);
+		logger.debug("Filename: [" + filename + "]");
+		
+		if (! filename.matches(FILENAME + "-[0-9]+." + SUFFIX)) {
+			fail("Filename does not match filename-timestamp.suffix.");
+		}
+	}
+}

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/ChangeSuffixNamingStrategyUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/ChangeSuffixNamingStrategyUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/naming/strategy/ChangeSuffixNamingStrategyUnitTest.java	2007-07-12 05:15:38 UTC (rev 13387)
@@ -0,0 +1,65 @@
+/*
+ * 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.actions.naming.strategy;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the suffix changing naming strategy.
+ * 
+ * @author <a href="mailto:tcunning at redhat.com">tcunning at redhat.com</a>
+ */
+public class ChangeSuffixNamingStrategyUnitTest extends TestCase {
+	private static String FILENAME = "word";
+	private static String SUFFIX = "doc";
+	private static String NEWSUFFIX = "txt";
+	
+	private static Logger logger = Logger.getLogger(AddTimestampNamingStrategyUnitTest.class);
+
+	
+	public void testProcess() {
+		ChangeSuffixNamingStrategy csns = new ChangeSuffixNamingStrategy();
+		Message msg1 = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		msg1.getBody().add("foo", "bar");
+		try {
+			msg1.getHeader().getCall().setTo(new HTTPEpr("http://foo.bar"));
+			msg1.getHeader().getCall().setMessageID(new URI("urn:1234"));
+		} catch (URISyntaxException e1) {
+			e1.printStackTrace();
+			fail(e1.getMessage());
+		}
+		csns.setNewSuffix(NEWSUFFIX);
+		String newFileName = csns.process(FILENAME + "." + SUFFIX, msg1);
+		logger.debug("Filename: [" + newFileName + "]");
+		assertEquals(newFileName, FILENAME + "." + NEWSUFFIX);
+		assertEquals(NEWSUFFIX, csns.getNewSuffix());
+	}
+}




More information about the jboss-svn-commits mailing list