[jboss-cvs] JBossAS SVN: r64363 - in projects/microcontainer/trunk/kernel/src: tests/org/jboss/test/kernel/config/support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 31 06:11:27 EDT 2007


Author: alesj
Date: 2007-07-31 06:11:26 -0400 (Tue, 31 Jul 2007)
New Revision: 64363

Added:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromObjectSimpleBean.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectAnnotationTestCase.java
Modified:
   projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testConfigure.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectXMLTestCase.java
Log:
Added from object @annotation tests.
Fixed XML test, which was never actually executed from file.

Modified: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testConfigure.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testConfigure.xml	2007-07-31 09:17:31 UTC (rev 64362)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/config/test/testConfigure.xml	2007-07-31 10:11:26 UTC (rev 64363)
@@ -1,12 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
-            xmlns="urn:jboss:bean-deployer">
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
    <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.SimpleBean">
       <property name="AString">StringValue</property>
       <property name="AByte">12</property>
       <property name="ABoolean">true</property>
+      <property name="ACharacter">a</property>
       <property name="AShort">123</property>
       <property name="anInt">1234</property>
       <property name="ALong">12345</property>
@@ -17,6 +18,7 @@
       <property name="ABigInteger">123456</property>
       <property name="abyte">12</property>
       <property name="aboolean">true</property>
+      <property name="achar">a</property>
       <property name="ashort">123</property>
       <property name="anint">1234</property>
       <property name="along">12345</property>

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromObjectSimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromObjectSimpleBean.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromObjectSimpleBean.java	2007-07-31 10:11:26 UTC (rev 64363)
@@ -0,0 +1,181 @@
+/*
+* 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.kernel.config.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FromObjectSimpleBean extends SimpleBean
+{
+   public FromObjectSimpleBean()
+   {
+      super();
+   }
+
+   // Public --------------------------------------------------------
+
+   @StringValue("Z")
+   public void setEnumProperty(Alphabet enumProperty)
+   {
+      super.setEnumProperty(enumProperty);
+   }
+
+   @StringValue("StringValue")
+   public void setOverloadedProperty(String overloadedProperty)
+   {
+      super.setOverloadedProperty(overloadedProperty);
+   }
+
+   @StringValue("StringValue")
+   public void setAString(String string)
+   {
+      super.setAString(string);
+   }
+
+   @StringValue("123")
+   public void setAShort(Short short1)
+   {
+      super.setAShort(short1);
+   }
+
+   @StringValue("123")
+   public void setAshort(short ashort)
+   {
+      super.setAshort(ashort);
+   }
+
+   @StringValue("1234")
+   public void setAnInt(Integer anInt)
+   {
+      super.setAnInt(anInt);
+   }
+
+   @StringValue("1234")
+   public void setAnint(int anint)
+   {
+      super.setAnint(anint);
+   }
+
+   @StringValue("12345")
+   public void setALong(Long long1)
+   {
+      super.setALong(long1);
+   }
+
+   @StringValue("12345")
+   public void setAlong(long along)
+   {
+      super.setAlong(along);
+   }
+
+   @StringValue("3.14")
+   public void setAFloat(Float float1)
+   {
+      super.setAFloat(float1);
+   }
+
+   @StringValue("3.14")
+   public void setAfloat(float afloat)
+   {
+      super.setAfloat(afloat);
+   }
+
+   @StringValue("3.14e12")
+   public void setADouble(Double double1)
+   {
+      super.setADouble(double1);
+   }
+
+   @StringValue("3.14e12")
+   public void setAdouble(double adouble)
+   {
+      super.setAdouble(adouble);
+   }
+
+   @StringValue("Mon Jan 01 00:00:00 CET 2001")
+   public void setADate(Date date)
+   {
+      super.setADate(date);
+   }
+
+   @StringValue("a")
+   public void setACharacter(Character character)
+   {
+      super.setACharacter(character);
+   }
+
+   @StringValue("a")
+   public void setAchar(char achar)
+   {
+      super.setAchar(achar);
+   }
+
+   @StringValue("12")
+   public void setAByte(Byte byte1)
+   {
+      super.setAByte(byte1);
+   }
+
+   @StringValue("12")
+   public void setAbyte(byte abyte)
+   {
+      super.setAbyte(abyte);
+   }
+
+   @StringValue(value="12345", type="java.lang.Long")
+   public void setANumber(Number number)
+   {
+      super.setANumber(number);
+   }
+
+   @StringValue("true")
+   public void setABoolean(Boolean boolean1)
+   {
+      super.setABoolean(boolean1);
+   }
+
+   @StringValue("true")
+   public void setAboolean(boolean aboolean)
+   {
+      super.setAboolean(aboolean);
+   }
+
+   @StringValue("123456")
+   public void setABigInteger(BigInteger bigInteger)
+   {
+      super.setABigInteger(bigInteger);
+   }
+
+   @StringValue("12e4")
+   public void setABigDecimal(BigDecimal bigDecimal)
+   {
+      super.setABigDecimal(bigDecimal);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java	2007-07-31 09:17:31 UTC (rev 64362)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java	2007-07-31 10:11:26 UTC (rev 64363)
@@ -52,6 +52,7 @@
       suite.addTest(ConfigureAttributeFromStringTestCase.suite());
       suite.addTest(ConfigureFromObjectTestCase.suite());
       suite.addTest(ConfigureFromObjectXMLTestCase.suite());
+      suite.addTest(ConfigureFromObjectAnnotationTestCase.suite());
       suite.addTest(ConfigureFromStringTestCase.suite());
       suite.addTest(ConfigureFromStringXMLTestCase.suite());
       suite.addTest(CollectionTestCase.suite());

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectAnnotationTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectAnnotationTestCase.java	2007-07-31 10:11:26 UTC (rev 64363)
@@ -0,0 +1,71 @@
+/*
+* 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.kernel.config.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.test.kernel.config.support.FromObjectSimpleBean;
+import org.jboss.test.kernel.config.support.SimpleBean;
+
+/**
+ * Configuration from object Test Case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ConfigureFromObjectAnnotationTestCase extends ConfigureFromObjectTestCase
+{
+   public static Test suite()
+   {
+      return suite(ConfigureFromObjectAnnotationTestCase.class);
+   }
+
+   public ConfigureFromObjectAnnotationTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected SimpleBean createSimpleBean(
+         String stringValue,
+         Byte byteValue,
+         Boolean booleanValue,
+         Character characterValue,
+         Short shortValue,
+         Integer integerValue,
+         Long longValue,
+         Float floatValue,
+         Double doubleValue,
+         Date dateValue,
+         BigDecimal bigDecimalValue,
+         BigInteger bigIntegerValue,
+         SimpleBean.Alphabet enumValue
+   )
+         throws Throwable
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromObjectSimpleBean.class.getName());
+      return (SimpleBean)instantiate(builder.getBeanMetaData());
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectTestCase.java	2007-07-31 09:17:31 UTC (rev 64362)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectTestCase.java	2007-07-31 10:11:26 UTC (rev 64363)
@@ -27,8 +27,6 @@
 import java.util.HashSet;
 
 import junit.framework.Test;
-
-import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
 import org.jboss.beans.metadata.spi.PropertyMetaData;
@@ -55,12 +53,17 @@
       super(name);
    }
 
+   public ConfigureFromObjectTestCase(String name, boolean xmltest)
+   {
+      super(name, xmltest);
+   }
+
    public void testConfigure() throws Throwable
    {
-      String stringValue =  new String("StringValue");
+      String stringValue =  "StringValue";
       Byte byteValue = new Byte("12");
       Boolean booleanValue = Boolean.TRUE;
-      Character characterValue = new Character('a');
+      Character characterValue = 'a';
       Short shortValue = new Short("123");
       Integer integerValue = new Integer("1234");
       Long longValue = new Long("12345");
@@ -71,40 +74,22 @@
       BigInteger bigIntegerValue = new BigInteger("123456");
       Alphabet enumValue = Alphabet.Z;
 
-      Kernel kernel = bootstrap();
-      KernelConfigurator configurator = kernel.getConfigurator();
-      BeanInfo info = configurator.getBeanInfo(SimpleBean.class);
-      SimpleBean bean = (SimpleBean) instantiate(configurator, info);
+      SimpleBean bean = createSimpleBean(
+            stringValue,
+            byteValue,
+            booleanValue,
+            characterValue,
+            shortValue,
+            integerValue,
+            longValue,
+            floatValue,
+            doubleValue,
+            dateValue,
+            bigDecimalValue,
+            bigIntegerValue,
+            enumValue
+      );
 
-      AbstractBeanMetaData metaData = new AbstractBeanMetaData();
-      HashSet<PropertyMetaData> attributes = new HashSet<PropertyMetaData>();
-      attributes.add(new AbstractPropertyMetaData("AString", stringValue));
-      attributes.add(new AbstractPropertyMetaData("AByte", byteValue));
-      attributes.add(new AbstractPropertyMetaData("ABoolean", booleanValue));
-      attributes.add(new AbstractPropertyMetaData("ACharacter", characterValue));
-      attributes.add(new AbstractPropertyMetaData("AShort", shortValue));
-      attributes.add(new AbstractPropertyMetaData("anInt", integerValue));
-      attributes.add(new AbstractPropertyMetaData("ALong", longValue));
-      attributes.add(new AbstractPropertyMetaData("AFloat", floatValue));
-      attributes.add(new AbstractPropertyMetaData("ADouble", doubleValue));
-      attributes.add(new AbstractPropertyMetaData("ADate", dateValue));
-      attributes.add(new AbstractPropertyMetaData("ABigDecimal", bigDecimalValue));
-      attributes.add(new AbstractPropertyMetaData("ABigInteger", bigIntegerValue));
-      attributes.add(new AbstractPropertyMetaData("abyte", byteValue));
-      attributes.add(new AbstractPropertyMetaData("aboolean", booleanValue));
-      attributes.add(new AbstractPropertyMetaData("achar", characterValue));
-      attributes.add(new AbstractPropertyMetaData("ashort", shortValue));
-      attributes.add(new AbstractPropertyMetaData("anint", integerValue));
-      attributes.add(new AbstractPropertyMetaData("along", longValue));
-      attributes.add(new AbstractPropertyMetaData("afloat", floatValue));
-      attributes.add(new AbstractPropertyMetaData("adouble", doubleValue));
-      attributes.add(new AbstractPropertyMetaData("ANumber", longValue));
-      attributes.add(new AbstractPropertyMetaData("overloadedProperty", stringValue));
-      attributes.add(new AbstractPropertyMetaData("enumProperty", enumValue));
-      metaData.setProperties(attributes);
-      
-      configure(configurator, bean, info, metaData);
-      
       assertEquals(stringValue, bean.getAString());
       assertEquals(byteValue, bean.getAByte());
       assertEquals(booleanValue, bean.getABoolean());
@@ -134,4 +119,54 @@
       Alphabet anenum = bean.getEnumProperty();
       assertEquals(enumValue, anenum);
    }
+
+   protected SimpleBean createSimpleBean(
+         String stringValue,
+         Byte byteValue,
+         Boolean booleanValue,
+         Character characterValue,
+         Short shortValue,
+         Integer integerValue,
+         Long longValue,
+         Float floatValue,
+         Double doubleValue,
+         Date dateValue,
+         BigDecimal bigDecimalValue,
+         BigInteger bigIntegerValue,
+         Alphabet enumValue
+   )
+         throws Throwable
+   {
+      HashSet<PropertyMetaData> attributes = new HashSet<PropertyMetaData>();
+      attributes.add(new AbstractPropertyMetaData("AString", stringValue));
+      attributes.add(new AbstractPropertyMetaData("AByte", byteValue));
+      attributes.add(new AbstractPropertyMetaData("ABoolean", booleanValue));
+      attributes.add(new AbstractPropertyMetaData("ACharacter", characterValue));
+      attributes.add(new AbstractPropertyMetaData("AShort", shortValue));
+      attributes.add(new AbstractPropertyMetaData("anInt", integerValue));
+      attributes.add(new AbstractPropertyMetaData("ALong", longValue));
+      attributes.add(new AbstractPropertyMetaData("AFloat", floatValue));
+      attributes.add(new AbstractPropertyMetaData("ADouble", doubleValue));
+      attributes.add(new AbstractPropertyMetaData("ADate", dateValue));
+      attributes.add(new AbstractPropertyMetaData("ABigDecimal", bigDecimalValue));
+      attributes.add(new AbstractPropertyMetaData("ABigInteger", bigIntegerValue));
+      attributes.add(new AbstractPropertyMetaData("abyte", byteValue));
+      attributes.add(new AbstractPropertyMetaData("aboolean", booleanValue));
+      attributes.add(new AbstractPropertyMetaData("achar", characterValue));
+      attributes.add(new AbstractPropertyMetaData("ashort", shortValue));
+      attributes.add(new AbstractPropertyMetaData("anint", integerValue));
+      attributes.add(new AbstractPropertyMetaData("along", longValue));
+      attributes.add(new AbstractPropertyMetaData("afloat", floatValue));
+      attributes.add(new AbstractPropertyMetaData("adouble", doubleValue));
+      attributes.add(new AbstractPropertyMetaData("ANumber", longValue));
+      attributes.add(new AbstractPropertyMetaData("overloadedProperty", stringValue));
+      attributes.add(new AbstractPropertyMetaData("enumProperty", enumValue));
+
+      AbstractBeanMetaData metaData = new AbstractBeanMetaData(SimpleBean.class.getName());
+      metaData.setProperties(attributes);
+
+      Kernel kernel = bootstrap();
+      KernelConfigurator configurator = kernel.getConfigurator();
+      return (SimpleBean) instantiateAndConfigure(configurator, metaData);
+   }
 }

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectXMLTestCase.java	2007-07-31 09:17:31 UTC (rev 64362)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigureFromObjectXMLTestCase.java	2007-07-31 10:11:26 UTC (rev 64363)
@@ -21,7 +21,13 @@
 */
 package org.jboss.test.kernel.config.test;
 
+import java.util.Date;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
 import junit.framework.Test;
+import org.jboss.test.kernel.config.support.SimpleBean;
+import org.jboss.test.kernel.config.support.XMLUtil;
 
 /**
  * Configuration from object Test Case.
@@ -38,6 +44,27 @@
 
    public ConfigureFromObjectXMLTestCase(String name)
    {
-      super(name);
+      super(name, true);
    }
+
+   protected SimpleBean createSimpleBean(
+         String stringValue,
+         Byte byteValue,
+         Boolean booleanValue,
+         Character characterValue,
+         Short shortValue,
+         Integer integerValue,
+         Long longValue,
+         Float floatValue,
+         Double doubleValue,
+         Date dateValue,
+         BigDecimal bigDecimalValue,
+         BigInteger bigIntegerValue,
+         SimpleBean.Alphabet enumValue
+   )
+         throws Throwable
+   {
+      XMLUtil util = bootstrapXML(true);
+      return (SimpleBean) util.getBean("SimpleBean");
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list