[jboss-svn-commits] JBL Code SVN: r12307 - in labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions: spring and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jun 3 15:26:36 EDT 2007


Author: james.williams at jboss.com
Date: 2007-06-03 15:26:36 -0400 (Sun, 03 Jun 2007)
New Revision: 12307

Added:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/AbstractSpringActionUnitTest.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MockSpringAction.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MyInterceptor.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/SaySomething.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-1.xml
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-2.xml
Log:
initial commit of spring proxy integration unit tests for jira ticket:

http://jira.jboss.com/jira/browse/JBESB-592

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/AbstractSpringActionUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/AbstractSpringActionUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/AbstractSpringActionUnitTest.java	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,90 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.spring;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+
+/**
+ * Unit tests for org.jboss.soa.esb.actions.AbstractSpringAction
+ * 
+ * @author <a href="mailto:james.williams at redhat.com">james.williams at redhat.com</a>
+ */
+public class AbstractSpringActionUnitTest extends TestCase
+{
+
+   public void test_bean_factory_load_single() throws Exception
+   {
+      ConfigTree config = new ConfigTree("<config/>");
+
+      String pathToConfigFile = new StringBuilder().append(
+            TestEnvironmentUtil.getUserDir("product")).append(
+            "org/jboss/soa/esb/actions/spring/").append("spring-context-1.xml")
+            .toString();
+
+      config.setAttribute("springContextXml", pathToConfigFile);
+
+      MockSpringAction mockAction = new MockSpringAction(config);
+      assertEquals("hello from Spring", mockAction.sayHelloSpring());
+      assertEquals(false, mockAction.isBeanFactoryNull());
+   }
+
+   public void test_bean_factory_load_multiple() throws Exception
+   {
+      ConfigTree config = new ConfigTree("<config/>");
+
+      String pathToConfigFile = new StringBuilder().append(
+            TestEnvironmentUtil.getUserDir("product")).append(
+            "org/jboss/soa/esb/actions/spring/").toString();
+      String configPath1 = pathToConfigFile + "spring-context-1.xml";
+      String configPath2 = pathToConfigFile + "spring-context-2.xml";
+
+      config.setAttribute("springContextXml", configPath1 + "," + configPath2);
+
+      MockSpringAction mockAction = new MockSpringAction(config);
+      assertEquals("hello from Spring", mockAction.sayHelloSpring());
+      assertEquals("goodbye from Spring", mockAction.sayGoodbyeSpring());
+      assertEquals(false, mockAction.isBeanFactoryNull());
+   }
+
+   public void test_spring_aop() throws Exception
+   {
+      ConfigTree config = new ConfigTree("<config/>");
+
+      String pathToConfigFile = new StringBuilder().append(
+            TestEnvironmentUtil.getUserDir("product")).append(
+            "org/jboss/soa/esb/actions/spring/").append("spring-context-1.xml")
+            .toString();
+
+      config.setAttribute("springContextXml", pathToConfigFile);
+
+      MockSpringAction mockAction = new MockSpringAction(config);
+      assertEquals("Greeting Changed", mockAction.sayHelloAopStyle());
+      assertEquals(false, mockAction.isBeanFactoryNull());
+   }
+}

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MockSpringAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MockSpringAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MockSpringAction.java	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,68 @@
+/*
+ * 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 JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.spring;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.AbstractSpringAction;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Used to test Spring integration.
+ * 
+ * @author James Williams(james.williams at redhat.com)
+ * 
+ */
+public class MockSpringAction extends AbstractSpringAction
+{
+
+   public MockSpringAction(ConfigTree config) throws Exception
+   {
+      configTree = config;
+      initialise();
+   }
+
+   public String sayHelloSpring() throws Exception
+   {
+      SaySomething hello = (SaySomething) getBeanFactory().getBean(
+            "helloObject");
+
+      return hello.getGreeting();
+   }
+
+   public String sayGoodbyeSpring() throws Exception
+   {
+      SaySomething goodbye = (SaySomething) getBeanFactory().getBean(
+            "goodbyeObject");
+      return goodbye.getGreeting();
+   }
+
+   public String sayHelloAopStyle() throws Exception
+   {
+      SaySomething hello = (SaySomething) getBeanFactory().getBean(
+            "helloObject");
+      hello.setGreeting("trying to trigger interceptor");
+
+      return hello.getGreeting();
+   }
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MyInterceptor.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MyInterceptor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/MyInterceptor.java	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,20 @@
+package org.jboss.soa.esb.actions.spring;
+
+import java.lang.reflect.Method;
+import org.springframework.aop.AfterReturningAdvice;
+
+/**
+ * Spring interceptor implementation used to test Spring AOP integration.
+ * 
+ * @author James Williams(james.williams at redhat.com)
+ * 
+ */
+public class MyInterceptor implements AfterReturningAdvice
+{
+   public void afterReturning(Object returnValue, Method m, Object[] args,
+         Object target) throws Exception
+   {
+      SaySomething something = (SaySomething) target;
+      something.setGreeting("Greeting Changed");
+   }
+}

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/SaySomething.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/SaySomething.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/SaySomething.java	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,22 @@
+package org.jboss.soa.esb.actions.spring;
+
+/**
+ * Simple pojo used to test Spring AOP integration.
+ * 
+ * @author James Williams(james.williams at redhat.com)
+ * 
+ */
+public class SaySomething
+{
+   private String greeting;
+
+   public String getGreeting()
+   {
+      return greeting;
+   }
+
+   public void setGreeting(String greeting)
+   {
+      this.greeting = greeting;
+   }
+}

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-1.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-1.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-1.xml	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Spring AOP and simple spring beans definitions to test AbstractSpringAction -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
+
+	<!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->
+
+	<bean id="helloObject" class="org.jboss.soa.esb.actions.spring.SaySomething">
+		<property name="greeting" value="hello from Spring"/>
+	</bean>
+	
+	<aop:config proxy-target-class="true">
+		<aop:advisor pointcut="execution(* setGreeting*(..))" advice-ref="myInterceptor" />
+	</aop:config>
+
+	<bean id="myInterceptor"
+		class="org.jboss.soa.esb.actions.spring.MyInterceptor"/>
+	
+
+</beans>

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-2.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-2.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/spring/spring-context-2.xml	2007-06-03 19:26:36 UTC (rev 12307)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Second spring context to test loading multiple spring contexts using AbstractSpringAction -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+	     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+	<!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->
+
+	<bean id="goodbyeObject" class="org.jboss.soa.esb.actions.spring.SaySomething">
+		<property name="greeting" value="goodbye from Spring"/>
+	</bean>
+	
+
+</beans>




More information about the jboss-svn-commits mailing list