sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1615918 - in /sling/trunk/contrib/extensions/replication: core/src/main/java/org/apache/sling/replication/agent/impl/ core/src/main/java/org/apache/sling/replication/rule/impl/ core/src/main/java/org/apache/sling/replication/serialization/...
Date Tue, 05 Aug 2014 12:25:01 GMT
Author: tommaso
Date: Tue Aug  5 12:25:00 2014
New Revision: 1615918

URL: http://svn.apache.org/r1615918
Log:
SLING-3820 - fixed possible NPE in SimpleReplicationAgent, fixed RP impl toString, adjusted
ITs

Modified:
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/rule/impl/ScheduleReplicateReplicationRule.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackage.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java
    sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java
    sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java
    sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactory.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactory.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactory.java
Tue Aug  5 12:25:00 2014
@@ -94,8 +94,8 @@ public class ReplicationAgentServiceFact
     @Reference(name = "ReplicationPackageExporter", target = "(name=vlt)", policy = ReferencePolicy.DYNAMIC)
     private ReplicationPackageExporter packageExporter;
 
-    @Property(label = "Target ReplicationPackageImporter", name = "ReplicationPackageImporter.target",
value = "(name=default)")
-    @Reference(name = "ReplicationPackageImporter", target = "(name=default)", policy = ReferencePolicy.DYNAMIC)
+    @Property(label = "Target ReplicationPackageImporter", name = "ReplicationPackageImporter.target",
value = "(name=local)")
+    @Reference(name = "ReplicationPackageImporter", target = "(name=local)", policy = ReferencePolicy.DYNAMIC)
     private ReplicationPackageImporter packageImporter;
 
     @Property(label = "Target ReplicationQueueProvider", name = QUEUEPROVIDER, value = DEFAULT_QUEUEPROVIDER)

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/rule/impl/ScheduleReplicateReplicationRule.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/rule/impl/ScheduleReplicateReplicationRule.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/rule/impl/ScheduleReplicateReplicationRule.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/rule/impl/ScheduleReplicateReplicationRule.java
Tue Aug  5 12:25:00 2014
@@ -92,6 +92,9 @@ public class ScheduleReplicateReplicatio
 
         public void run() {
             try {
+                if (log.isDebugEnabled()) {
+                    log.debug("agent {}: scheduling {} replication of {}", new Object[]{agent,
action, path});
+                }
                 agent.send(new ReplicationRequest(System.currentTimeMillis(), action, path));
             } catch (AgentReplicationException e) {
                 if (log.isErrorEnabled()) {

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackage.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackage.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackage.java
Tue Aug  5 12:25:00 2014
@@ -117,4 +117,14 @@ public class VoidReplicationPackage impl
     public void delete() {
 
     }
+
+    @Override
+    public String toString() {
+        return "VoidReplicationPackage{" +
+                "type='" + type + '\'' +
+                ", paths=" + Arrays.toString(paths) +
+                ", id='" + id + '\'' +
+                ", action='" + action + '\'' +
+                '}';
+    }
 }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java
Tue Aug  5 12:25:00 2014
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
@@ -95,4 +96,13 @@ public class FileVaultReplicationPackage
         }
     }
 
+    @Override
+    public String toString() {
+        return "FileVaultReplicationPackage{" +
+                "id='" + id + '\'' +
+                ", paths=" + Arrays.toString(paths) +
+                ", pkg=" + pkg +
+                ", action='" + action + '\'' +
+                '}';
+    }
 }

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java
Tue Aug  5 12:25:00 2014
@@ -28,7 +28,7 @@ public class ForwardReplicationTest exte
 
     @Test
     public void testAddContent() throws Exception {
-        String nodePath = createRandomNode(authorClient, "/content");
+        String nodePath = createRandomNode(authorClient, "/content/forward_add_" + System.nanoTime());
         assertExists(authorClient, nodePath);
         replicate(author, "publish", ReplicationActionType.ADD, nodePath);
         assertExists(publishClient, nodePath);
@@ -37,11 +37,8 @@ public class ForwardReplicationTest exte
 
     @Test
     public void testDeleteContent() throws Exception {
-        String nodePath = createRandomNode(publishClient, "/content");
-
+        String nodePath = createRandomNode(publishClient, "/content/forward_del_" + System.nanoTime());
         assertExists(publishClient, nodePath);
-
-
         replicate(author, "publish", ReplicationActionType.DELETE, nodePath);
         assertNotExits(publishClient, nodePath);
     }

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java
(original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java
Tue Aug  5 12:25:00 2014
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.UUID;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -88,9 +89,9 @@ public class ReplicationUtils {
         ).getContent().replaceAll("\n", "").trim();
 
 
-        for (int i = 0; i < parameters.length; i++) {
-            assertTrue(parameters[i] + " is not contained in " + content,
-                    content.contains(parameters[i])
+        for (String parameter : parameters) {
+            assertTrue(parameter + " is not contained in " + content,
+                    content.contains(parameter)
             );
         }
     }
@@ -99,7 +100,6 @@ public class ReplicationUtils {
     public static void replicate(SlingInstance slingInstance, String agentName, ReplicationActionType
action, String... paths) throws IOException {
         String agentResource = agentUrl(agentName);
 
-
         List<String> args = new ArrayList<String>();
         args.add(ReplicationHeader.ACTION.toString());
         args.add(action.toString());
@@ -116,35 +116,32 @@ public class ReplicationUtils {
 
     public static void deleteNode(SlingInstance slingInstance, String path) throws IOException
{
         assertPostResourceWithParameters(slingInstance, 200, path, ":operation", "delete");
-
     }
 
     public static void assertExists(SlingClient slingClient, String path) throws Exception
{
-
-        int retries = 100;
+        int retries = 10;
         while(!slingClient.exists(path) && retries-- > 0) {
             Thread.sleep(1000);
         }
-
-        assertTrue(retries > 0);
+        assertTrue(slingClient.exists(path));
     }
 
     public static void assertNotExits(SlingClient slingClient, String path) throws Exception
{
-
-        int retries = 100;
+        int retries = 10;
         while(slingClient.exists(path) && retries-- > 0) {
             Thread.sleep(1000);
         }
-
-        assertTrue(retries > 0);
+        assertFalse(slingClient.exists(path));
     }
 
     public static String createRandomNode(SlingClient slingClient, String parentPath) throws
Exception {
-        String nodePath = parentPath + "/" + UUID.randomUUID();
-        return slingClient.createNode(nodePath, "propName", "propValue");
+        if (!slingClient.exists(parentPath)) {
+            slingClient.createNode(parentPath, "jcr:primaryType", "nt:unstructured");
+        }
+        return slingClient.createNode(parentPath + "/" + UUID.randomUUID(), "jcr:primaryType",
"nt:unstructured",
+                "propName", "propValue");
     }
 
-
     public static String agentRootUrl() {
         return REPLICATION_ROOT_PATH + "/agents";
     }

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java?rev=1615918&r1=1615917&r2=1615918&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java
Tue Aug  5 12:25:00 2014
@@ -9,20 +9,18 @@ import static org.apache.sling.replicati
 public class ReverseReplicationTest extends ReplicationIntegrationTestBase {
     @Test
     public void testAddContent() throws Exception {
-        String nodePath = createRandomNode(publishClient, "/content");
+        String nodePath = createRandomNode(publishClient, "/content/reverse_add_" + System.nanoTime());
         assertExists(publishClient, nodePath);
         replicate(publish, "reverse", ReplicationActionType.ADD, nodePath);
-
         assertExists(authorClient, nodePath);
     }
 
 
     @Test
     public void testDeleteContent() throws Exception {
-        String nodePath = createRandomNode(authorClient, "/content");
+        String nodePath = createRandomNode(authorClient, "/content/reverse_del_" + System.nanoTime());
         assertExists(authorClient, nodePath);
         replicate(publish, "reverse", ReplicationActionType.DELETE, nodePath);
-
         assertNotExits(authorClient, nodePath);
     }
 }



Mime
View raw message