[jboss-cvs] JBossAS SVN: r60104 - projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 29 12:24:22 EST 2007


Author: alesj
Date: 2007-01-29 12:24:22 -0500 (Mon, 29 Jan 2007)
New Revision: 60104

Added:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceXMLTestCase.java
Removed:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyXMLTestCase.java
Modified:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
Log:
Renaming the test classes - adding Replace; since testing diff xml elements for replacement

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-01-29 14:50:23 UTC (rev 60103)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java	2007-01-29 17:24:22 UTC (rev 60104)
@@ -65,8 +65,8 @@
       suite.addTest(ProgressionTestCase.suite());
       suite.addTest(ProgressionXMLTestCase.suite());
       suite.addTest(BeanMetaDataBuilderTestCase.suite());
-      suite.addTest(PropertyTestCase.suite());
-      suite.addTest(PropertyXMLTestCase.suite());
+      suite.addTest(PropertyReplaceTestCase.suite());
+      suite.addTest(PropertyReplaceXMLTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceTestCase.java	2007-01-29 17:24:22 UTC (rev 60104)
@@ -0,0 +1,120 @@
+/*
+* 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.util.Collections;
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+
+/**
+ * Property replace test cases: ${x} - looking for System property named x.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyReplaceTestCase extends AbstractKernelConfigTest
+{
+   public PropertyReplaceTestCase(String name)
+   {
+      super(name);
+   }
+
+   public PropertyReplaceTestCase(String name, boolean xmltest)
+   {
+      super(name, xmltest);
+   }
+
+   public static Test suite()
+   {
+      return suite(PropertyReplaceTestCase.class);
+   }
+
+   private List<ObjectCreator> singlePropertyCreator(final boolean replace)
+   {
+      PropertyReplaceTestCase.ObjectCreator oc = new PropertyReplaceTestCase.ObjectCreator()
+      {
+         public Object createObject() throws Throwable
+         {
+            return instantiateReplacePropertyValue(replace);
+         }
+      };
+      return Collections.singletonList(oc);
+   }
+
+   public void testPropertyWithPropertyValue() throws Throwable
+   {
+      doTestProperty(true, singlePropertyCreator(true));
+   }
+
+   public void testPropertyWithIgnoreReplace() throws Throwable
+   {
+      doTestProperty(false, createCreators());
+   }
+
+   protected List<PropertyReplaceTestCase.ObjectCreator> createCreators()
+   {
+      return singlePropertyCreator(false);
+   }
+
+   private void doTestProperty(boolean replace, List<PropertyReplaceTestCase.ObjectCreator> ocs) throws Throwable
+   {
+      SecurityManager sm = suspendSecurity();
+      try
+      {
+         // set property to be replaced
+         String PROP_NAME = "test.property.value";
+         String CONST = "PropertyReplaceTestCase";
+         System.setProperty(PROP_NAME, CONST);
+         for(PropertyReplaceTestCase.ObjectCreator oc : ocs)
+         {
+            // get property
+            Object value = oc.createObject();
+            assertNotNull(value);
+            assertEquals(String.class, value.getClass());
+            String checkValue = replace ? CONST : "${" + PROP_NAME + "}";
+            assertEquals(checkValue, value);
+         }
+      }
+      finally
+      {
+         resumeSecurity(sm);
+      }
+   }
+
+   protected Object instantiateReplacePropertyValue(boolean replace) throws Throwable
+   {
+      PropertyMetaData property = new AbstractPropertyMetaData("key", "${test.property.value}", String.class.getName());
+      StringValueMetaData svmd = assertInstanceOf(property.getValue(), StringValueMetaData.class, false);
+      svmd.setReplace(replace);
+      svmd.setConfigurator(bootstrap().getConfigurator());
+      return svmd.getValue(null, Thread.currentThread().getContextClassLoader());
+   }
+
+   protected interface ObjectCreator
+   {
+      Object createObject() throws Throwable;
+   }
+
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceXMLTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyReplaceXMLTestCase.java	2007-01-29 17:24:22 UTC (rev 60104)
@@ -0,0 +1,103 @@
+/*
+* 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.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.config.support.MyObject;
+import org.jboss.test.kernel.config.support.XMLUtil;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyReplaceXMLTestCase extends PropertyReplaceTestCase
+{
+   public PropertyReplaceXMLTestCase(String name)
+   {
+      super(name);
+   }
+
+   public PropertyReplaceXMLTestCase(String name, boolean xmltest)
+   {
+      super(name, xmltest);
+   }
+
+   public static Test suite()
+   {
+      return suite(PropertyReplaceXMLTestCase.class);
+   }
+
+   protected Object instantiateValue(String type) throws Throwable
+   {
+      XMLUtil util = bootstrapXML(true);
+      MyObject mybean = (MyObject)util.getBean("MyBean" + type);
+      return mybean.getKey();
+   }
+
+   protected Object instantiateProperty() throws Throwable
+   {
+      return instantiateValue("Property");
+   }
+
+   protected Object instantiateConstructorParameter() throws Throwable
+   {
+      return instantiateValue("Parameter");
+   }
+
+   protected Object instantiatePlainValue() throws Throwable
+   {
+      return instantiateValue("PlainValue");
+   }
+
+   protected List<ObjectCreator> createCreators()
+   {
+      List<ObjectCreator> result = new ArrayList<ObjectCreator>();
+      ObjectCreator property = new ObjectCreator()
+      {
+         public Object createObject() throws Throwable
+         {
+            return instantiateProperty();
+         }
+      };
+      result.add(property);
+      ObjectCreator parameter = new ObjectCreator()
+      {
+         public Object createObject() throws Throwable
+         {
+            return instantiateConstructorParameter();
+         }
+      };
+      result.add(parameter);
+      ObjectCreator plainValue = new ObjectCreator()
+      {
+         public Object createObject() throws Throwable
+         {
+            return instantiatePlainValue();
+         }
+      };
+      result.add(plainValue);
+      return result;
+   }
+
+}

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyTestCase.java	2007-01-29 14:50:23 UTC (rev 60103)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyTestCase.java	2007-01-29 17:24:22 UTC (rev 60104)
@@ -1,118 +0,0 @@
-/*
-* 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.util.Collections;
-import java.util.List;
-
-import junit.framework.Test;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-import org.jboss.beans.metadata.plugins.StringValueMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class PropertyTestCase extends AbstractKernelConfigTest
-{
-   public PropertyTestCase(String name)
-   {
-      super(name);
-   }
-
-   public PropertyTestCase(String name, boolean xmltest)
-   {
-      super(name, xmltest);
-   }
-
-   public static Test suite()
-   {
-      return suite(PropertyTestCase.class);
-   }
-
-   private List<ObjectCreator> singlePropertyCreator(final boolean replace)
-   {
-      ObjectCreator oc = new ObjectCreator()
-      {
-         public Object createObject() throws Throwable
-         {
-            return instantiateReplacePropertyValue(replace);
-         }
-      };
-      return Collections.singletonList(oc);
-   }
-
-   public void testPropertyWithPropertyValue() throws Throwable
-   {
-      doTestProperty(true, singlePropertyCreator(true));
-   }
-
-   public void testPropertyWithIgnoreReplace() throws Throwable
-   {
-      doTestProperty(false, createCreators());
-   }
-
-   protected List<ObjectCreator> createCreators()
-   {
-      return singlePropertyCreator(false);
-   }
-
-   private void doTestProperty(boolean replace, List<ObjectCreator> ocs) throws Throwable
-   {
-      SecurityManager sm = suspendSecurity();
-      try
-      {
-         // set property to be replaced
-         String PROP_NAME = "test.property.value";
-         String CONST = "PropertyReplaceTestCase";
-         System.setProperty(PROP_NAME, CONST);
-         for(ObjectCreator oc : ocs)
-         {
-            // get property
-            Object value = oc.createObject();
-            assertNotNull(value);
-            assertEquals(String.class, value.getClass());
-            String checkValue = replace ? CONST : "${" + PROP_NAME + "}";
-            assertEquals(checkValue, value);
-         }
-      }
-      finally
-      {
-         resumeSecurity(sm);
-      }
-   }
-
-   protected Object instantiateReplacePropertyValue(boolean replace) throws Throwable
-   {
-      PropertyMetaData property = new AbstractPropertyMetaData("key", "${test.property.value}", String.class.getName());
-      StringValueMetaData svmd = assertInstanceOf(property.getValue(), StringValueMetaData.class, false);
-      svmd.setReplace(replace);
-      svmd.setConfigurator(bootstrap().getConfigurator());
-      return svmd.getValue(null, Thread.currentThread().getContextClassLoader());
-   }
-
-   protected interface ObjectCreator
-   {
-      Object createObject() throws Throwable;
-   }
-
-}

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyXMLTestCase.java	2007-01-29 14:50:23 UTC (rev 60103)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/PropertyXMLTestCase.java	2007-01-29 17:24:22 UTC (rev 60104)
@@ -1,103 +0,0 @@
-/*
-* 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.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import org.jboss.test.kernel.config.support.MyObject;
-import org.jboss.test.kernel.config.support.XMLUtil;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class PropertyXMLTestCase extends PropertyTestCase
-{
-   public PropertyXMLTestCase(String name)
-   {
-      super(name);
-   }
-
-   public PropertyXMLTestCase(String name, boolean xmltest)
-   {
-      super(name, xmltest);
-   }
-
-   public static Test suite()
-   {
-      return suite(PropertyXMLTestCase.class);
-   }
-
-   protected Object instantiateValue(String type) throws Throwable
-   {
-      XMLUtil util = bootstrapXML(true);
-      MyObject mybean = (MyObject)util.getBean("MyBean" + type);
-      return mybean.getKey();
-   }
-
-   protected Object instantiateProperty() throws Throwable
-   {
-      return instantiateValue("Property");
-   }
-
-   protected Object instantiateConstructorParameter() throws Throwable
-   {
-      return instantiateValue("Parameter");
-   }
-
-   protected Object instantiatePlainValue() throws Throwable
-   {
-      return instantiateValue("PlainValue");
-   }
-
-   protected List<ObjectCreator> createCreators()
-   {
-      List<ObjectCreator> result = new ArrayList<ObjectCreator>();
-      ObjectCreator property = new ObjectCreator()
-      {
-         public Object createObject() throws Throwable
-         {
-            return instantiateProperty();
-         }
-      };
-      result.add(property);
-      ObjectCreator parameter = new ObjectCreator()
-      {
-         public Object createObject() throws Throwable
-         {
-            return instantiateConstructorParameter();
-         }
-      };
-      result.add(parameter);
-      ObjectCreator plainValue = new ObjectCreator()
-      {
-         public Object createObject() throws Throwable
-         {
-            return instantiatePlainValue();
-         }
-      };
-      result.add(plainValue);
-      return result;
-   }
-
-}




More information about the jboss-cvs-commits mailing list