Change default separator
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 18 Nov 2007 08:27:50 +0000 (08:27 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 18 Nov 2007 08:27:50 +0000 (08:27 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@715 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc/src/main/java/org/argeo/slc/core/structure/tree/TreeSPath.java
org.argeo.slc/src/test/java/org/argeo/slc/example/junit/TestAntBuild.java
org.argeo.slc/src/test/java/org/argeo/slc/hibernate/structure/tree/TreeSPathDaoHibernateTest.java
org.argeo.slc/src/test/java/org/argeo/slc/hibernate/structure/tree/TreeSRegistryDaoHibernateTest.java
org.argeo.slc/src/test/java/org/argeo/slc/hibernate/test/tree/TreeTestResultDaoHibernateTest.java

index 014e12c0b52967acedbedc82e501f90b9f89f1c8..f28c843cfc76d189688e510275b95ae6cd06505d 100644 (file)
@@ -12,8 +12,8 @@ import org.argeo.slc.core.structure.StructureRegistry;
  * Path for tree based <code>StructureRegistry</code> implementations.\r
  */\r
 public class TreeSPath implements StructurePath, Comparable<StructurePath> {\r
-       /** Default character to use a separator: #. */\r
-       public static Character DEFAULT_SEPARATOR = '#';\r
+       /** Default character to use a separator: /. */\r
+       public static Character DEFAULT_SEPARATOR = '/';\r
 \r
        private TreeSPath parent;\r
        private String name;\r
@@ -68,6 +68,10 @@ public class TreeSPath implements StructurePath, Comparable<StructurePath> {
                path.name = name;\r
                return path;\r
        }\r
+       /** Parses a string to a path. */\r
+       public static TreeSPath parseToCreatePath(String path) {\r
+               return parseToCreatePath(path, DEFAULT_SEPARATOR);\r
+       }\r
 \r
        /** Parses a string to a path. */\r
        public static TreeSPath parseToCreatePath(String path, Character separator) {\r
index b4d097483ee2cf79a808ea14db2ef09ce6f7c0cb..a3ca0e5303bb1891c27a701ecf35c875a005f9ac 100644 (file)
@@ -47,12 +47,12 @@ public class TestAntBuild extends TestCase {
                // assertPart(testResult1, "", 0, TestStatus.PASSED, "");\r
                assertPart(\r
                                testResult1,\r
-                               "#root#Category1#SubCategory2#testComplex#slc.test0#0",\r
+                               "/root/Category1/SubCategory2/testComplex/slc.test0/0",\r
                                0,\r
                                TestStatus.PASSED,\r
-                               "Sub task with path #root#Category1#SubCategory2#testComplex#slc.test0#0 executed");\r
+                               "Sub task with path /root/Category1/SubCategory2/testComplex/slc.test0/0 executed");\r
                assertPart(testResult1,\r
-                               "#root#Category1#SubCategory2#testSimple#slc.test0", 1,\r
+                               "/root/Category1/SubCategory2/testSimple/slc.test0", 1,\r
                                TestStatus.FAILED,\r
                                "Compare nato-expected.txt with nato-reached.txt");\r
 \r
@@ -60,11 +60,11 @@ public class TestAntBuild extends TestCase {
                TreeTestResult testResult2 = (TreeTestResult) testResultDao\r
                                .getTestResult(numericTRId);\r
                assertPart(testResult2,\r
-                               "#root#Category1#SubCategory2#testSimple#slc.test2", 1,\r
+                               "/root/Category1/SubCategory2/testSimple/slc.test2", 1,\r
                                TestStatus.PASSED,\r
                                "Compare eu-reform-expected.txt with eu-reform-reached.txt");\r
                assertPart(testResult2,\r
-                               "#root#Category1#SubCategory2#testSimple#slc.test3", 1,\r
+                               "/root/Category1/SubCategory2/testSimple/slc.test3", 1,\r
                                TestStatus.FAILED,\r
                                "Compare eu-reform-expected.txt with eu-reform-reached.txt");\r
 \r
@@ -76,7 +76,7 @@ public class TestAntBuild extends TestCase {
 \r
        private void assertPart(TreeTestResult testResult, String pathStr,\r
                        int index, Integer status, String message) {\r
-               TreeSPath path = TreeSPath.parseToCreatePath(pathStr, '#');\r
+               TreeSPath path = TreeSPath.parseToCreatePath(pathStr);\r
                PartSubList list = testResult.getResultParts().get(path);\r
                SimpleResultPart part = (SimpleResultPart) list.getParts().get(index);\r
                assertEquals(status, part.getStatus());\r
index 66447030d12e8cbe7c9af5b55f3944164f1e4e0a..3b9a32ddfd10a9f326357b3ec9e899dbab13b132 100644 (file)
@@ -10,9 +10,9 @@ public class TreeSPathDaoHibernateTest extends SpringBasedTestCase {
                TreeSPathDao treeSPathDao = (TreeSPathDao) getContext().getBean(\r
                                "treeSPathDao");\r
                \r
-               String pathParentStr = "#root#testParent";\r
-               String pathStr = pathParentStr+"#test";\r
-               TreeSPath path = TreeSPath.parseToCreatePath(pathStr, '#');\r
+               String pathParentStr = "/root/testParent";\r
+               String pathStr = pathParentStr+"/test";\r
+               TreeSPath path = TreeSPath.parseToCreatePath(pathStr);\r
                treeSPathDao.create(path);\r
                \r
                TreeSPath pathChild = treeSPathDao.getTreeSPath(pathStr);\r
index 7ed2684582ed69da74f266e78fb7e1947b450b5e..b5b626b3ef6dd1f485973fc01717b02a206e31ce 100644 (file)
@@ -16,7 +16,7 @@ public class TreeSRegistryDaoHibernateTest extends SpringBasedTestCase {
                TreeSPathDao treeSPathDao = (TreeSPathDao) getContext().getBean(\r
                "treeSPathDao");\r
 \r
-               TreeSPath root = TreeSPath.parseToCreatePath("#root", '#');\r
+               TreeSPath root = TreeSPath.parseToCreatePath("/root");\r
                TreeSPath path = root.createChild("test");\r
                \r
                treeSPathDao.create(root);\r
index f983a89fece599c58bbf6b3f6b2506b709838195..1e7fcf716a9625da1b2eed63143a1cd5367bfe80 100644 (file)
@@ -19,9 +19,9 @@ public class TreeTestResultDaoHibernateTest extends SpringBasedTestCase {
                TestResultDao testResultDao = (TestResultDao) getContext().getBean(\r
                                "testResultDao");\r
 \r
-               String pathParentStr = "#root#testParent";\r
-               String pathStr = pathParentStr + "#test";\r
-               TreeSPath path = TreeSPath.parseToCreatePath(pathStr, '#');\r
+               String pathParentStr = "/root/testParent";\r
+               String pathStr = pathParentStr + "/test";\r
+               TreeSPath path = TreeSPath.parseToCreatePath(pathStr);\r
                treeSPathDao.create(path);\r
 \r
                TreeTestResult treeTestResult = new TreeTestResult();\r