Documentation
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 11 Nov 2007 00:09:10 +0000 (00:09 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 11 Nov 2007 00:09:10 +0000 (00:09 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@699 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc/src/main/java/org/argeo/slc/diff/package.html [new file with mode: 0644]
org.argeo.slc/src/main/java/org/argeo/slc/unit/DbModel.java
org.argeo.slc/src/main/java/org/argeo/slc/unit/IndependentDbTestCase.java
org.argeo.slc/src/main/java/org/argeo/slc/unit/SpringBasedTestCase.java
org.argeo.slc/src/main/java/org/argeo/slc/unit/package.html [new file with mode: 0644]

diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/diff/package.html b/org.argeo.slc/src/main/java/org/argeo/slc/diff/package.html
new file mode 100644 (file)
index 0000000..a58e685
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Abstraction of diff comparison with structured results.\r
+</body>\r
+</html>
\ No newline at end of file
index 742d13ead97aff1b1aca0231d600fe12073654bc..dacb80369fcf9a75b760800d19c2ee7d8ce86047 100644 (file)
@@ -8,6 +8,11 @@ import org.hibernate.cfg.Configuration;
 import org.hibernate.cfg.Environment;\r
 import org.hibernate.tool.hbm2ddl.SchemaExport;\r
 \r
+/**\r
+ * Creates a relational data model from Hibernate mapping files. The benefit of\r
+ * this class is to be able to use Hibernate to have test data which are\r
+ * independent from the type of database used.\r
+ */\r
 public class DbModel {\r
        private String dialect;\r
        private List<String> mappings;\r
index cbebeffb2723dd741f32cd214d9d4a5cc0f95bb0..baf611ef6c69399df4d39af730f2a3cd5d8ece03 100644 (file)
@@ -19,9 +19,14 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
 \r
 import org.argeo.slc.core.SlcException;\r
 \r
+/**\r
+ * Helper to make db vendor independent tests using DbUnit data sets. Based on\r
+ * {@link DbModel}.\r
+ */\r
 public class IndependentDbTestCase extends SpringBasedTestCase {\r
        private IDatabaseTester databaseTester;\r
 \r
+       /** Creates the DDL of the data model and loads the data. */\r
        @Override\r
        protected void setUp() throws Exception {\r
                super.setUp();\r
@@ -53,15 +58,27 @@ public class IndependentDbTestCase extends SpringBasedTestCase {
                super.tearDown();\r
        }\r
 \r
+       /**\r
+        * The data source to use. The default implementation returns a bean named\r
+        * {@link #getDataSourceBeanName}\r
+        */\r
        protected DataSource getDataSource() {\r
-               return (DataSource) getApplicationContext().getBean(\r
-                               getDataSourceBeanName());\r
+               return (DataSource) getContext().getBean(getDataSourceBeanName());\r
        }\r
 \r
+       /**\r
+        * The name of the data source bean to use. The default implementation\r
+        * returns <i>dataSource</i>.\r
+        */\r
        protected String getDataSourceBeanName() {\r
                return "dataSource";\r
        }\r
 \r
+       /**\r
+        * Creates the data set to use. The default implementation creates a\r
+        * <code>FlatXmlDataSet</code> load from the resource defined in\r
+        * {@link #getDataSetResource()}\r
+        */\r
        protected IDataSet createDataSet() {\r
                try {\r
                        InputStream in = getDataSetResource().getInputStream();\r
@@ -73,18 +90,35 @@ public class IndependentDbTestCase extends SpringBasedTestCase {
                }\r
        }\r
 \r
+       /**\r
+        * The resource of the data set to load. The default implementation loads a\r
+        * <code>ClassPathResource</code> located at\r
+        * {@link #getDataSetResourceLocation()}.\r
+        */\r
        protected Resource getDataSetResource() {\r
                return new ClassPathResource(getDataSetResourceLocation());\r
        }\r
 \r
+       /**\r
+        * The location of the data set to load. The default implementation loads\r
+        * <i>dataSet.xml</i> found in the same package as the test.\r
+        */\r
        protected String getDataSetResourceLocation() {\r
                return inPackage("dataSet.xml");\r
        }\r
 \r
+       /**\r
+        * The DB model to us to create the DDL of the testes database. The default\r
+        * implementation loads a bean named after {@link #getDbModelBeanName()}.\r
+        */\r
        protected DbModel getDbModel() {\r
-               return (DbModel) getApplicationContext().getBean(getDbModelBeanName());\r
+               return (DbModel) getContext().getBean(getDbModelBeanName());\r
        }\r
 \r
+       /**\r
+        * The name of the bean to load. The default implementation returns\r
+        * <i>dbModel</i>.\r
+        */\r
        protected String getDbModelBeanName() {\r
                return "dbModel";\r
        }\r
index f5ec0e17c2b13d908203671b0b7d17d86f54115e..b607825f0d1da23e9fa34d74b7cb1422b8327524 100644 (file)
@@ -5,6 +5,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
 \r
 import junit.framework.TestCase;\r
 \r
+/** Helper for tests using a Spring application co,text. */\r
 public class SpringBasedTestCase extends TestCase {\r
        private ApplicationContext context;\r
 \r
@@ -13,7 +14,7 @@ public class SpringBasedTestCase extends TestCase {
         * implementation uses a class path xml application context and calls\r
         * {@link #getApplicationContextLocation()}.\r
         */\r
-       protected ApplicationContext getApplicationContext() {\r
+       protected ApplicationContext getContext() {\r
                if (context == null) {\r
                        context = new ClassPathXmlApplicationContext(\r
                                        getApplicationContextLocation());\r
@@ -22,15 +23,20 @@ public class SpringBasedTestCase extends TestCase {
        }\r
 \r
        /**\r
-        * Get the application context location used by the default implementation\r
-        * of {@link #getApplicationContext()}.\r
+        * Th location of the application to load. The default implementation\r
+        * returns <i>applicationContext.xml</i> found in the same package as the\r
+        * test.\r
         */\r
        protected String getApplicationContextLocation() {\r
                return inPackage("applicationContext.xml");\r
        }\r
-       \r
-       protected String inPackage(String suffix){\r
+\r
+       /**\r
+        * Prefixes the package of the class after converting the '.' to '/' in\r
+        * order to have a resource path.\r
+        */\r
+       protected String inPackage(String suffix) {\r
                String prefix = getClass().getPackage().getName().replace('.', '/');\r
-               return prefix+'/'+suffix;\r
+               return prefix + '/' + suffix;\r
        }\r
 }\r
diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/unit/package.html b/org.argeo.slc/src/main/java/org/argeo/slc/unit/package.html
new file mode 100644 (file)
index 0000000..907430d
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Helpers for unit tests.\r
+</body>\r
+</html>
\ No newline at end of file