Commits

Anonymous committed 079ca37

All unit tests now pass. Modified build.xml to copy over the hibernate mapping files. Add hibernate unit tests fixed two issues with the HibernatePropertySet: update supportsType() to return false for DATA, OBJECT, PROPERTIES and XML; corrected exists() to only return true if an item was found.

git-svn-id: http://svn.opensymphony.com/svn/propertyset/trunk@142bf3cbcdd-1c1a-0410-9a68-d6f521e3fa7b

  • Participants
  • Parent commits 506eb32

Comments (0)

Files changed (4)

         <include name="**/*.properties"/>
         <include name="**/*.sql"/>
       </fileset>
+        <fileset dir="${src.java}">
+            <include name="**/*.xml"/>
+        </fileset>
     </copy>
     <mkdir dir="${dist}/docs/junit"/>
     <junit printsummary="withOutAndErr" haltonfailure="no" haltonerror="no" fork="yes">

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySet.java

 
 import com.opensymphony.module.propertyset.AbstractPropertySet;
 import com.opensymphony.module.propertyset.PropertyException;
+import com.opensymphony.module.propertyset.PropertySet;
 
 import com.opensymphony.util.ClassLoaderUtil;
 
 
     public boolean exists(String key) throws PropertyException {
         try {
-            findByKey(key);
+            if (findByKey(key) != null) {
+                return true;
+            }
 
-            return true;
+            return false;
         } catch (PropertyException e) {
             return false;
         }
     private PropertySetItem findByKey(String key) throws PropertyException {
         return configProvider.getPropertySetDAO().findByKey(entityName, entityId, key);
     }
+
+    public boolean supportsType(int type) {
+        switch(type) {
+            case PropertySet.DATA:
+            case PropertySet.OBJECT:
+            case PropertySet.PROPERTIES:
+            case PropertySet.XML:
+                return false;
+        }
+        return true;
+    }
+
 }

src/test/com/opensymphony/module/propertyset/AbstractPropertySetTest.java

         }
     }
 
+    public void testGetStringNotInPropertySet() {
+        assertNull(ps.getString("test555"));
+    }
+
     public void testGetTypeForBoolean() {
         if (ps.supportsType(PropertySet.BOOLEAN)) {
             ps.setBoolean("testBoolean", true);

src/test/com/opensymphony/module/propertyset/hibernate/HibernatePropertySetTest.java

  */
 package com.opensymphony.module.propertyset.hibernate;
 
-import com.opensymphony.module.propertyset.BasePropertySetTest;
+import com.opensymphony.module.propertyset.AbstractPropertySetTest;
 import com.opensymphony.module.propertyset.DatabaseHelper;
-
+import com.opensymphony.module.propertyset.PropertySetManager;
 import net.sf.hibernate.cfg.Configuration;
 
+import java.util.HashMap;
 
 /**
  * This test case tests a propertyset backed by Hibernate
  *
  * @author Eric Pugh (epugh@upstate.com)
  */
-public class HibernatePropertySetTest extends BasePropertySetTest {
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public HibernatePropertySetTest(String s) {
-        super(s);
-    }
+public class HibernatePropertySetTest extends AbstractPropertySetTest {
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public String getType() {
-        return "hibernate";
-    }
-
     public void setUp() throws Exception {
-        //DatabaseHelper.exportSchemaForJDBC();
+        super.setUp();
         DatabaseHelper.createDatabase("");
 
         Configuration config = DatabaseHelper.createHibernateConfiguration();
         configurationProvider.setConfiguration(config);
         configurationProvider.setSessionFactory(config.buildSessionFactory());
 
+        HashMap args = new HashMap();
         args.put("entityName", "testHibernate");
         args.put("entityId", new Long(3));
-
-        //args.put("sessionFactory",DatabaseHelper.getSessionFactory());
         args.put("configurationProvider", configurationProvider);
-        super.setUp();
+        ps = PropertySetManager.getInstance("hibernate", args);
     }
 }