[jboss-cvs] JBossAS SVN: r59079 - in projects/microcontainer/trunk/spring-int/src: resources/xml-test/org/jboss/test/spring/test tests/org/jboss/test/spring/support tests/org/jboss/test/spring/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 18 09:57:54 EST 2006
Author: alesj
Date: 2006-12-18 09:57:41 -0500 (Mon, 18 Dec 2006)
New Revision: 59079
Added:
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixedTestCase.xml
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/OldBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixed2TestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixedTestCase.java
Modified:
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SimpleBean.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DescribeSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java
projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java
Log:
Added mixed test - injection of Spring beans into MC's, and vice versa.
Added: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml 2006-12-18 14:57:41 UTC (rev 59079)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="urn:jboss:spring-beans:2.0">
+
+ <bean id="testBean" class="org.jboss.test.spring.support.SimpleBean">
+ <property name="refBean"><ref bean="oldBean"/></property>
+ </bean>
+
+ <bean xmlns="urn:jboss:bean-deployer:2.0" name="oldBean" class="org.jboss.test.spring.support.OldBean">
+ <property name="javaBeanString">JavaBean</property>
+ </bean>
+
+</beans>
\ No newline at end of file
Added: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixedTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixedTestCase.xml 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixedTestCase.xml 2006-12-18 14:57:41 UTC (rev 59079)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="oldBean" class="org.jboss.test.spring.support.OldBean">
+ <property name="testBean">
+ <inject/>
+ </property>
+ </bean>
+
+ <bean xmlns="urn:jboss:spring-beans:2.0" id="testBean" class="org.jboss.test.spring.support.SimpleBean">
+ <property name="mylist">
+ <list value-type="java.lang.String">
+ <value>onel</value>
+ <value>twol</value>
+ <value>threel</value>
+ </list>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
Modified: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml 2006-12-18 14:57:41 UTC (rev 59079)
@@ -12,20 +12,20 @@
<constructor-arg index="1">
<value>3.14159</value>
</constructor-arg>
- <property name="mylist">
- <list value-type="java.lang.String">
- <value>onel</value>
- <value>twol</value>
- <value>threel</value>
- </list>
- </property>
- <property name="myset">
- <set value-type="java.lang.String">
- <value>ones</value>
- <value>twos</value>
- <value>ones</value>
- </set>
- </property>
+ <property name="mylist">
+ <list value-type="java.lang.String">
+ <value>onel</value>
+ <value>twol</value>
+ <value>threel</value>
+ </list>
+ </property>
+ <property name="myset">
+ <set value-type="java.lang.String">
+ <value>ones</value>
+ <value>twos</value>
+ <value>ones</value>
+ </set>
+ </property>
<!--
<property name="map">
<entry>
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/OldBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/OldBean.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/OldBean.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -0,0 +1,53 @@
+/*
+* 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.test.spring.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OldBean
+{
+
+ private SimpleBean testBean;
+ private String javaBeanString;
+
+ public SimpleBean getTestBean()
+ {
+ return testBean;
+ }
+
+ public void setTestBean(SimpleBean testBean)
+ {
+ this.testBean = testBean;
+ }
+
+ public String getJavaBeanString()
+ {
+ return javaBeanString;
+ }
+
+ public void setJavaBeanString(String javaBeanString)
+ {
+ this.javaBeanString = javaBeanString;
+ }
+
+}
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SimpleBean.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SimpleBean.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/support/SimpleBean.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -37,6 +37,7 @@
private List mylist;
private Set myset;
private Map mymap;
+ private OldBean refBean;
public SimpleBean()
{
@@ -94,6 +95,16 @@
this.mymap = mymap;
}
+ public OldBean getRefBean()
+ {
+ return refBean;
+ }
+
+ public void setRefBean(OldBean refBean)
+ {
+ this.refBean = refBean;
+ }
+
public String toString()
{
StringBuilder builder = new StringBuilder();
@@ -103,6 +114,7 @@
builder.append(mylist).append(",");
builder.append(myset).append(",");
builder.append(mymap);
+ builder.append(refBean);
return builder.toString();
}
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DescribeSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DescribeSpringTestCase.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/DescribeSpringTestCase.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -47,16 +47,9 @@
public void testDescribe() throws Exception
{
- try
- {
- BeanMetaData simpleBeanMD = unmarshal("TestDescribe.xml", BeanMetaData.class);
- // todo - test descriptions
- System.out.println("simpleBean = " + simpleBeanMD);
- }
- catch (Exception e)
- {
- System.out.println("not yet fully implemented = " + e);
- }
+ BeanMetaData simpleBeanMD = unmarshal("TestDescribe.xml", BeanMetaData.class);
+ // todo - test descriptions
+ System.out.println("simpleBean = " + simpleBeanMD);
}
}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixed2TestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixed2TestCase.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixed2TestCase.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -0,0 +1,62 @@
+/*
+* 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.test.spring.test;
+
+import junit.framework.Test;
+import org.jboss.test.spring.support.OldBean;
+import org.jboss.test.spring.support.SimpleBean;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * Testing how MC beans can be mixed (injected, ...) with Spring beans.
+ *
+ * @see InstantiateMixedTestCase
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstantiateMixed2TestCase extends TempSpringMicrocontainerTest
+{
+
+ public InstantiateMixed2TestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(InstantiateMixed2TestCase.class);
+ }
+
+ public void testInjection() throws Exception
+ {
+ SimpleBean simpleBean = (SimpleBean) getBean("testBean", ControllerState.INSTANTIATED);
+ assertNotNull(simpleBean);
+ OldBean oldBean = simpleBean.getRefBean();
+ assertNotNull(oldBean);
+ assertEquals(oldBean.getJavaBeanString(), "JavaBean");
+ }
+
+}
Added: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixedTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixedTestCase.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateMixedTestCase.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -0,0 +1,62 @@
+/*
+* 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.test.spring.test;
+
+import junit.framework.Test;
+import org.jboss.test.spring.support.OldBean;
+import org.jboss.test.spring.support.SimpleBean;
+
+/**
+ * Testing how Spring beans can be mixed (injected, ...) with MC beans.
+ *
+ * @see InstantiateMixed2TestCase
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstantiateMixedTestCase extends TempSpringMicrocontainerTest
+{
+
+ public InstantiateMixedTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(InstantiateMixedTestCase.class);
+ }
+
+ public void testInjection() throws Exception
+ {
+ OldBean oldBean = (OldBean) getBean("oldBean");
+ assertNotNull(oldBean);
+ SimpleBean testBean = oldBean.getTestBean();
+ assertNotNull(testBean);
+ assertFalse(testBean.getMylist().isEmpty());
+ assertEquals(testBean.getMylist().size(), 3);
+ }
+
+}
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/InstantiateSpringTestCase.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -49,6 +49,7 @@
public void testDescribe() throws Exception
{
SimpleBean testBean = (SimpleBean) getBean("testBean", ControllerState.INSTANTIATED);
+ assertNotNull(testBean);
assertEquals(testBean.getX(), 1);
assertEquals(testBean.getY(), 3.14159);
assertEquals(testBean.getS(), "SpringBean");
Modified: projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java 2006-12-18 14:10:38 UTC (rev 59078)
+++ projects/microcontainer/trunk/spring-int/src/tests/org/jboss/test/spring/test/SpringTestSuite.java 2006-12-18 14:57:41 UTC (rev 59079)
@@ -42,6 +42,8 @@
suite.addTest(DescribeSpringTestCase.suite());
suite.addTest(InstantiateSpringTestCase.suite());
+ suite.addTest(InstantiateMixedTestCase.suite());
+ suite.addTest(InstantiateMixed2TestCase.suite());
return suite;
}
More information about the jboss-cvs-commits
mailing list