You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ro...@apache.org on 2020/12/17 22:52:29 UTC

[jackrabbit-filevault] 01/03: JCRVLT-488 - PlatformNameFormat incorrectly sets repository names for nodes with double colons

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch issue/JCRVLT-488
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit 8758f9526e149f5c02f07117646d3a331fd78acc
Author: Robert Munteanu <ro...@rombert.corp.adobe.com>
AuthorDate: Thu Dec 17 23:41:16 2020 +0100

    JCRVLT-488 - PlatformNameFormat incorrectly sets repository names for nodes with double colons
    
    Convert PlatformNameTest to Junit 4
---
 .../jackrabbit/vault/util/PlatformNameTest.java    | 74 ++++++++++++----------
 1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/util/PlatformNameTest.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/util/PlatformNameTest.java
index fb5d547..94a9f60 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/util/PlatformNameTest.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/util/PlatformNameTest.java
@@ -17,48 +17,54 @@
 
 package org.apache.jackrabbit.vault.util;
 
-import java.util.HashMap;
-import java.util.Map;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.TestCase;
+import java.util.Arrays;
+import java.util.Collection;
 
-/**
- * {@code PlatformNameTest}...
- *
- */
-public class PlatformNameTest extends TestCase {
-
-    private Map<String, String> names = new HashMap<String, String>();
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(Parameterized.class)
+public class PlatformNameTest {
+    
+    @Parameters(name = "platform: {0}, repo: {1}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {     
+             { "test.jpg", "test.jpg" },
+             {"cq:content", "_cq_content"},
+             {"cq:test_image.jpg", "_cq_test_image.jpg"},
+             {"test_image.jpg", "test_image.jpg"},
+             {"_testimage.jpg", "_testimage.jpg"},
+             {"_test_image.jpg", "__test_image.jpg"},
+             {"cq:test:image.jpg", "_cq_test%3aimage.jpg"},
+             {"_cq_:test.jpg", "__cq_%3atest.jpg"},
+             {"_cq:test.jpg", "_cq%3atest.jpg"},
+             {"cq_:test.jpg", "cq_%3atest.jpg"},
+             {"_", "_"},
+             {":", "%3a"},
+             {":test", "%3atest"}
+       });
+    }
 
-    protected void setUp() throws Exception {
-        names.put("test.jpg", "test.jpg");
-        names.put("cq:content", "_cq_content");
-        names.put("cq:test_image.jpg", "_cq_test_image.jpg");
-        names.put("test_image.jpg", "test_image.jpg");
-        names.put("_testimage.jpg", "_testimage.jpg");
-        names.put("_test_image.jpg", "__test_image.jpg");
-        names.put("cq:test:image.jpg", "_cq_test%3aimage.jpg");
-        names.put("_cq_:test.jpg", "__cq_%3atest.jpg");
-        names.put("_cq:test.jpg", "_cq%3atest.jpg");
-        names.put("cq_:test.jpg", "cq_%3atest.jpg");
-        names.put("_", "_");
-        names.put(":", "%3a");
-        names.put(":test", "%3atest");
+    private final String repoName;
+    private final String platformName;
+    
+    public PlatformNameTest(String repoName, String platformName) {
+        this.repoName = repoName;
+        this.platformName = platformName;
     }
 
-    public void testToPlatform() {
-        for (String repName: names.keySet()) {
-            String pfName = names.get(repName);
-            assertEquals("Repo("+repName+")->Platform", pfName, PlatformNameFormat.getPlatformName(repName));
-        }
+    @Test
+    public void toPlatform() {
+        assertEquals(platformName, PlatformNameFormat.getPlatformName(repoName));
     }
 
-    public void testToRepo() {
-        for (String repName: names.keySet()) {
-            String pfName = names.get(repName);
-            assertEquals("Platform("+pfName+")->Repo", repName, PlatformNameFormat.getRepositoryName(pfName));
-        }
+    @Test
+    public void toRepo() {
+        assertEquals(repoName, PlatformNameFormat.getRepositoryName(platformName));
     }
 
 }
\ No newline at end of file