You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by tm...@apache.org on 2021/05/06 11:54:22 UTC

[sling-org-apache-sling-distribution-core] branch SLING-9873-2 created (now e4f9f7d)

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

tmaret pushed a change to branch SLING-9873-2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-core.git.


      at e4f9f7d  SLING-9873 - Use the characters :: as path delimiter

This branch includes the following new commits:

     new e4f9f7d  SLING-9873 - Use the characters :: as path delimiter

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[sling-org-apache-sling-distribution-core] 01/01: SLING-9873 - Use the characters :: as path delimiter

Posted by tm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tmaret pushed a commit to branch SLING-9873-2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-core.git

commit e4f9f7de6f589d0a43ab638b9dd07a864695f339
Author: tmaret <tm...@adobe.com>
AuthorDate: Thu May 6 13:53:45 2021 +0200

    SLING-9873 - Use the characters :: as path delimiter
---
 .../packaging/impl/SimpleDistributionPackage.java  |  2 +-
 .../impl/SimpleDistributionPackageTest.java        | 51 ++++++----------------
 2 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/src/main/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackage.java b/src/main/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackage.java
index 8aec301..88f2a4a 100644
--- a/src/main/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackage.java
+++ b/src/main/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackage.java
@@ -41,7 +41,7 @@ public class SimpleDistributionPackage extends AbstractDistributionPackage imple
     private final static String PACKAGE_START = "DSTRPCK::";
     private final static String PACKAGE_START_OLD = "DSTRPCK:";
     private final static String DELIM = "|";
-    private final static String PATH_DELIM = ":";
+    private final static String PATH_DELIM = "::";
     private final static String PATH_DELIM_OLD = ",";
     private final long size;
 
diff --git a/src/test/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackageTest.java b/src/test/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackageTest.java
index 76d1dc1..9009d54 100644
--- a/src/test/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackageTest.java
+++ b/src/test/java/org/apache/sling/distribution/packaging/impl/SimpleDistributionPackageTest.java
@@ -32,7 +32,6 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 import static org.apache.commons.io.IOUtils.toInputStream;
-import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -49,9 +48,6 @@ public class SimpleDistributionPackageTest {
 
     private static final String TYPE = "testPackageType";
 
-    private static final String DSTRPCK_DELETE = "DSTRPCK::DELETE|/abc:/c";
-    private static final String DSTRPCK_ITEM_WITH_COMMA_DELETE = "DSTRPCK::DELETE|/ab,c:/c";
-
     @Test
     public void testInvalid() {
         String id = "invalid";
@@ -83,49 +79,20 @@ public class SimpleDistributionPackageTest {
 
     @Test
     public void testPackageWithNamespaceInPath() {
-        DistributionRequest req = new SimpleDistributionRequest(DistributionRequestType.ADD, "/a/jcr:content", "/b");
-        SimpleDistributionPackage pkgOut = new SimpleDistributionPackage(req, TYPE);
-        SimpleDistributionPackage pkgIn = SimpleDistributionPackage.fromStream(toInputStream(pkgOut.toString(), Charset.defaultCharset()), TYPE);
-        assertNotNull(pkgIn);
-        assertArrayEquals(pkgOut.getInfo().getPaths(), pkgIn.getInfo().getPaths());
+        DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/a/jcr:content", "/b");
+        testPackageSerDeser(request);
     }
 
     @Test
     public void testCreatedAndReadPackagesEqualityWithCommaInName() throws Exception {
         DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.DELETE, "/ab,c", "/c");
-        SimpleDistributionPackage createdPackage = new SimpleDistributionPackage(request, "VOID");
-        assertThat(createdPackage.toString(), equalTo(DSTRPCK_ITEM_WITH_COMMA_DELETE));
-        // Just to run the code
-        createdPackage.acquire();
-        createdPackage.release();
-        createdPackage.close();
-        createdPackage.delete();
-
-        SimpleDistributionPackage readPackage = SimpleDistributionPackage.fromStream(new ByteArrayInputStream(DSTRPCK_ITEM_WITH_COMMA_DELETE.getBytes()), "VOID");
-        assertNotNull(readPackage);
-        assertEquals(Arrays.toString(createdPackage.getInfo().getPaths()), Arrays.toString(readPackage.getInfo().getPaths()));
+        testPackageSerDeser(request);
     }
     
     @Test
     public void testCreatedAndReadPackagesEquality() throws Exception {
         DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.DELETE, "/abc", "/c");
-        SimpleDistributionPackage createdPackage = new SimpleDistributionPackage(request, "VOID");
-        assertThat(createdPackage.toString(), equalTo(DSTRPCK_DELETE));
-        // Just to run the code
-        createdPackage.acquire();
-        createdPackage.release();
-        createdPackage.close();
-        createdPackage.delete();
-        
-        SimpleDistributionPackage readPackage = SimpleDistributionPackage.fromStream(new ByteArrayInputStream(DSTRPCK_DELETE.getBytes()), "VOID");
-        assertNotNull(readPackage);
-        assertEquals(DSTRPCK_DELETE.length(), readPackage.getSize());
-        assertEquals(createdPackage.getType(), readPackage.getType());
-        assertEquals(createdPackage.getInfo().getRequestType(), readPackage.getInfo().getRequestType());
-        assertEquals(Arrays.toString(createdPackage.getInfo().getPaths()), Arrays.toString(readPackage.getInfo().getPaths()));
-        assertEquals(createdPackage.getId(), readPackage.getId());
-        assertTrue(IOUtils.contentEquals(createdPackage.createInputStream(), readPackage.createInputStream()));
-        
+        testPackageSerDeser(request);
     }
 
     @Test
@@ -140,4 +107,14 @@ public class SimpleDistributionPackageTest {
         assertEquals(createdPackage.getId(), readPackage.getId());
         assertTrue(IOUtils.contentEquals(createdPackage.createInputStream(), readPackage.createInputStream()));
     }
+
+    private void testPackageSerDeser(DistributionRequest request) {
+        SimpleDistributionPackage pkgOut = new SimpleDistributionPackage(request, TYPE);
+        SimpleDistributionPackage pkgIn = SimpleDistributionPackage.fromStream(toInputStream(pkgOut.toString(), Charset.defaultCharset()), TYPE);
+        assertNotNull(pkgIn);
+        assertArrayEquals(pkgOut.getInfo().getPaths(), pkgIn.getInfo().getPaths());
+        assertEquals(pkgOut.getType(), pkgIn.getType());
+        assertEquals(pkgOut.getId(), pkgIn.getId());
+        assertEquals(pkgOut.getInfo().getRequestType(), pkgIn.getInfo().getRequestType());
+    }
 }