[jboss-cvs] JBossAS SVN: r98935 - in projects/kernel/trunk: dependency/src/test/java/org/jboss/test/dependency/controller/test and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 25 08:43:48 EST 2009
Author: kabir.khan at jboss.com
Date: 2009-12-25 08:43:47 -0500 (Fri, 25 Dec 2009)
New Revision: 98935
Added:
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/ControllerStateBean.java
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValue.java
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValueBean.java
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfTestCase.java
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfXMLTestCase.java
projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForControllerState.xml
projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForCustomValue.xml
Modified:
projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/spi/ControllerState.java
projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/test/ControllerStateTestCase.java
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ConfigTestSuite.java
Log:
[JBKERNEL-73] Test property values created by ValueConverter using static valueOf(Object) method
Modified: projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/spi/ControllerState.java
===================================================================
--- projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/spi/ControllerState.java 2009-12-25 13:06:24 UTC (rev 98934)
+++ projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/spi/ControllerState.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -129,6 +129,11 @@
return getOrCreateState(stateString, true);
}
+ public static ControllerState valueOf(String stateString)
+ {
+ return getInstance(stateString);
+ }
+
/**
* Get the state string
*
Modified: projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/test/ControllerStateTestCase.java
===================================================================
--- projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/test/ControllerStateTestCase.java 2009-12-25 13:06:24 UTC (rev 98934)
+++ projects/kernel/trunk/dependency/src/test/java/org/jboss/test/dependency/controller/test/ControllerStateTestCase.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -23,9 +23,6 @@
import junit.framework.Test;
-import org.jboss.dependency.plugins.AbstractControllerStateModel;
-import org.jboss.dependency.plugins.ListControllerStateModel;
-import org.jboss.dependency.plugins.MapControllerStateModel;
import org.jboss.dependency.spi.ControllerState;
/**
Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/ControllerStateBean.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/ControllerStateBean.java (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/ControllerStateBean.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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 org.jboss.dependency.spi.ControllerState;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ControllerStateBean
+{
+ ControllerState state;
+
+ public ControllerState getState()
+ {
+ return state;
+ }
+
+ public void setState(ControllerState state)
+ {
+ this.state = state;
+ }
+
+
+}
Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValue.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValue.java (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValue.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CustomValue
+{
+ String value;
+
+ CustomValue(String value)
+ {
+ this.value = value;
+ }
+
+ public static CustomValue valueOf(String value)
+ {
+ return new CustomValue(value);
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+}
Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValueBean.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValueBean.java (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/support/CustomValueBean.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CustomValueBean
+{
+ CustomValue value;
+
+ public CustomValue getValue()
+ {
+ return value;
+ }
+
+ public void setValue(CustomValue value)
+ {
+ this.value = value;
+ }
+}
Modified: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ConfigTestSuite.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2009-12-25 13:06:24 UTC (rev 98934)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -84,6 +84,8 @@
suite.addTest(ValueFactoryTestCase.suite());
suite.addTest(ValueFactoryXMLTestCase.suite());
suite.addTest(ValueFactoryAnnotationTestCase.suite());
+ suite.addTest(ValueConverterValueOfTestCase.suite());
+ suite.addTest(ValueConverterValueOfXMLTestCase.suite());
suite.addTest(ValueTrimTestCase.suite());
suite.addTest(ValueTrimXMLTestCase.suite());
suite.addTest(ValueTrimAnnotationTestCase.suite());
Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfTestCase.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfTestCase.java (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfTestCase.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.util.HashSet;
+
+import junit.framework.Test;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.test.kernel.config.support.ControllerStateBean;
+import org.jboss.test.kernel.config.support.CustomValueBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ValueConverterValueOfTestCase extends AbstractKernelConfigTest
+{
+ public ValueConverterValueOfTestCase(String name)
+ {
+ super(name);
+ }
+
+ public ValueConverterValueOfTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(ValueConverterValueOfTestCase.class);
+ }
+
+ public void testValueOfForCustomValue() throws Throwable
+ {
+ CustomValueBean bean = valueOfForCustomValue();
+ assertNotNull(bean);
+ assertNotNull(bean.getValue());
+ assertEquals("Custom", bean.getValue().getValue());
+ }
+
+ public void testValueOfForControllerState() throws Throwable
+ {
+ ControllerStateBean bean = valueOfForControllerState();
+ assertNotNull(bean);
+ assertNotNull(bean.getState());
+ assertEquals(ControllerState.CONFIGURED, bean.getState());
+ }
+
+ protected CustomValueBean valueOfForCustomValue() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelConfigurator configurator = kernel.getConfigurator();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(CustomValueBean.class.getName());
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ AbstractPropertyMetaData pmd = new AbstractPropertyMetaData("value", new StringValueMetaData("Custom"));
+ properties.add(pmd);
+
+ return (CustomValueBean) instantiateAndConfigure(configurator, bmd);
+ }
+
+ protected ControllerStateBean valueOfForControllerState() throws Throwable
+ {
+ Kernel kernel = bootstrap();
+ KernelConfigurator configurator = kernel.getConfigurator();
+
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(ControllerStateBean.class.getName());
+ HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+ bmd.setProperties(properties);
+
+ AbstractPropertyMetaData pmd = new AbstractPropertyMetaData("state", new StringValueMetaData("Configured"));
+ properties.add(pmd);
+
+ return (ControllerStateBean) instantiateAndConfigure(configurator, bmd);
+ }
+}
Added: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfXMLTestCase.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfXMLTestCase.java (rev 0)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/ValueConverterValueOfXMLTestCase.java 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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 junit.framework.Test;
+
+import org.jboss.test.kernel.config.support.ControllerStateBean;
+import org.jboss.test.kernel.config.support.CustomValueBean;
+import org.jboss.test.kernel.config.support.XMLUtil;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ValueConverterValueOfXMLTestCase extends ValueConverterValueOfTestCase
+{
+ public ValueConverterValueOfXMLTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(ValueConverterValueOfXMLTestCase.class);
+ }
+
+ protected CustomValueBean valueOfForCustomValue() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (CustomValueBean) util.getBean("CustomValueBean");
+ }
+
+ protected ControllerStateBean valueOfForControllerState() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ return (ControllerStateBean) util.getBean("ControllerStateBean");
+ }
+}
Added: projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForControllerState.xml
===================================================================
--- projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForControllerState.xml (rev 0)
+++ projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForControllerState.xml 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="ControllerStateBean" class="org.jboss.test.kernel.config.support.ControllerStateBean">
+ <property name="state">Configured</property>
+ </bean>
+</deployment>
Added: projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForCustomValue.xml
===================================================================
--- projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForCustomValue.xml (rev 0)
+++ projects/kernel/trunk/kernel/src/test/resources/xml-test/org/jboss/test/kernel/config/test/testValueOfForCustomValue.xml 2009-12-25 13:43:47 UTC (rev 98935)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="CustomValueBean" class="org.jboss.test.kernel.config.support.CustomValueBean">
+ <property name="value">Custom</property>
+ </bean>
+</deployment>
More information about the jboss-cvs-commits
mailing list