[jboss-svn-commits] JBL Code SVN: r35332 - labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 28 07:16:57 EDT 2010
Author: mageshbk at jboss.com
Date: 2010-09-28 07:16:56 -0400 (Tue, 28 Sep 2010)
New Revision: 35332
Added:
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryUnitTest.java
Removed:
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryTest.java
Log:
[JBESB-3495] - Renamed HttpMethodFactoryTest to HttpMethodFactoryUnitTest
Deleted: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryTest.java 2010-09-28 10:40:44 UTC (rev 35331)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryTest.java 2010-09-28 11:16:56 UTC (rev 35332)
@@ -1,164 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, 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.
- */
-
-package org.jboss.soa.esb.actions.routing.http;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.net.URL;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpMethodRetryHandler;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.jboss.soa.esb.Configurable;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.junit.Test;
-
-public class HttpMethodFactoryTest
-{
- @Test
- public void testDefaultRetryHandlerPOST()
- throws Exception
- {
- testDefaultRetryHandler("POST") ;
- }
-
- @Test
- public void testDefaultRetryHandlerGET()
- throws Exception
- {
- testDefaultRetryHandler("GET") ;
- }
-
- private void testDefaultRetryHandler(final String method)
- throws Exception
- {
- final HttpMethodBase httpMethodBase = executeTest(method, null) ;
- final HttpMethodParams params = httpMethodBase.getParams() ;
- final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
- assertNotNull("retry handler", handler) ;
- assertEquals("handler class", AbstractHttpMethodFactory.HttpMethodRetryHandlerWrapper.class, handler.getClass()) ;
- }
-
- @Test
- public void testRetryHandlerPOST()
- throws Exception
- {
- testRetryHandler("POST") ;
- }
-
- @Test
- public void testRetryHandlerGET()
- throws Exception
- {
- testRetryHandler("GET") ;
- }
-
- private void testRetryHandler(final String method)
- throws Exception
- {
- final Class<?> handlerClass = RetryHandler.class ;
- final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
- final HttpMethodParams params = httpMethodBase.getParams() ;
- final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
- assertNotNull("retry handler", handler) ;
- assertEquals("handler class", handlerClass, handler.getClass()) ;
- }
-
- @Test
- public void testConfigurableRetryHandlerPOST()
- throws Exception
- {
- testConfigurableRetryHandler("POST") ;
- }
-
- @Test
- public void testConfigurableRetryHandlerGET()
- throws Exception
- {
- testConfigurableRetryHandler("GET") ;
- }
-
- private void testConfigurableRetryHandler(final String method)
- throws Exception
- {
- final Class<ConfigurableRetryHandler> handlerClass = ConfigurableRetryHandler.class ;
- final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
- final HttpMethodParams params = httpMethodBase.getParams() ;
- final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
- assertNotNull("retry handler", handler) ;
- assertEquals("handler class", handlerClass, handler.getClass()) ;
- final ConfigurableRetryHandler configurableRetryHandler = handlerClass.cast(handler) ;
- assertNotNull("config", configurableRetryHandler.getConfig()) ;
- }
-
- private HttpMethodBase executeTest(final String method, final String handlerName)
- throws Exception
- {
- final Message message = MessageFactory.getInstance().getMessage() ;
- message.getBody().add("test") ;
- final ConfigTree config = new ConfigTree("test") ;
- if (handlerName != null)
- {
- config.setAttribute(AbstractHttpMethodFactory.RETRY_HANDLER, handlerName) ;
- }
- final HttpMethodFactory factory = HttpMethodFactory.Factory.getInstance(method, config, new URL("http://dummy")) ;
- return factory.getInstance(message) ;
- }
-
- public static final class RetryHandler implements HttpMethodRetryHandler
- {
- public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount)
- {
- return false;
- }
- }
-
- public static final class ConfigurableRetryHandler implements HttpMethodRetryHandler, Configurable
- {
- private ConfigTree config ;
-
- public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount)
- {
- return false;
- }
-
- public void setConfiguration(final ConfigTree config)
- throws ConfigurationException
- {
- this.config = config ;
- }
-
- public ConfigTree getConfig()
- {
- return config ;
- }
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(HttpMethodFactoryTest.class);
- }
-}
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactoryUnitTest.java 2010-09-28 11:16:56 UTC (rev 35332)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, 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.
+ */
+
+package org.jboss.soa.esb.actions.routing.http;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpMethodRetryHandler;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.jboss.soa.esb.Configurable;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.junit.Test;
+
+public class HttpMethodFactoryUnitTest
+{
+ @Test
+ public void testDefaultRetryHandlerPOST()
+ throws Exception
+ {
+ testDefaultRetryHandler("POST") ;
+ }
+
+ @Test
+ public void testDefaultRetryHandlerGET()
+ throws Exception
+ {
+ testDefaultRetryHandler("GET") ;
+ }
+
+ private void testDefaultRetryHandler(final String method)
+ throws Exception
+ {
+ final HttpMethodBase httpMethodBase = executeTest(method, null) ;
+ final HttpMethodParams params = httpMethodBase.getParams() ;
+ final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
+ assertNotNull("retry handler", handler) ;
+ assertEquals("handler class", AbstractHttpMethodFactory.HttpMethodRetryHandlerWrapper.class, handler.getClass()) ;
+ }
+
+ @Test
+ public void testRetryHandlerPOST()
+ throws Exception
+ {
+ testRetryHandler("POST") ;
+ }
+
+ @Test
+ public void testRetryHandlerGET()
+ throws Exception
+ {
+ testRetryHandler("GET") ;
+ }
+
+ private void testRetryHandler(final String method)
+ throws Exception
+ {
+ final Class<?> handlerClass = RetryHandler.class ;
+ final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
+ final HttpMethodParams params = httpMethodBase.getParams() ;
+ final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
+ assertNotNull("retry handler", handler) ;
+ assertEquals("handler class", handlerClass, handler.getClass()) ;
+ }
+
+ @Test
+ public void testConfigurableRetryHandlerPOST()
+ throws Exception
+ {
+ testConfigurableRetryHandler("POST") ;
+ }
+
+ @Test
+ public void testConfigurableRetryHandlerGET()
+ throws Exception
+ {
+ testConfigurableRetryHandler("GET") ;
+ }
+
+ private void testConfigurableRetryHandler(final String method)
+ throws Exception
+ {
+ final Class<ConfigurableRetryHandler> handlerClass = ConfigurableRetryHandler.class ;
+ final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
+ final HttpMethodParams params = httpMethodBase.getParams() ;
+ final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
+ assertNotNull("retry handler", handler) ;
+ assertEquals("handler class", handlerClass, handler.getClass()) ;
+ final ConfigurableRetryHandler configurableRetryHandler = handlerClass.cast(handler) ;
+ assertNotNull("config", configurableRetryHandler.getConfig()) ;
+ }
+
+ private HttpMethodBase executeTest(final String method, final String handlerName)
+ throws Exception
+ {
+ final Message message = MessageFactory.getInstance().getMessage() ;
+ message.getBody().add("test") ;
+ final ConfigTree config = new ConfigTree("test") ;
+ if (handlerName != null)
+ {
+ config.setAttribute(AbstractHttpMethodFactory.RETRY_HANDLER, handlerName) ;
+ }
+ final HttpMethodFactory factory = HttpMethodFactory.Factory.getInstance(method, config, new URL("http://dummy")) ;
+ return factory.getInstance(message) ;
+ }
+
+ public static final class RetryHandler implements HttpMethodRetryHandler
+ {
+ public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount)
+ {
+ return false;
+ }
+ }
+
+ public static final class ConfigurableRetryHandler implements HttpMethodRetryHandler, Configurable
+ {
+ private ConfigTree config ;
+
+ public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount)
+ {
+ return false;
+ }
+
+ public void setConfiguration(final ConfigTree config)
+ throws ConfigurationException
+ {
+ this.config = config ;
+ }
+
+ public ConfigTree getConfig()
+ {
+ return config ;
+ }
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(HttpMethodFactoryUnitTest.class);
+ }
+}
More information about the jboss-svn-commits
mailing list